org.pentaho.ui.xul.XulDomContainer Java Examples

The following examples show how to use org.pentaho.ui.xul.XulDomContainer. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TransGridDelegate.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
private void addToolBar() {

    try {
      XulLoader loader = new KettleXulLoader();
      loader.setSettingsManager( XulSpoonSettingsManager.getInstance() );
      ResourceBundle bundle = GlobalMessages.getBundle( "org/pentaho/di/ui/spoon/messages/messages" );
      XulDomContainer xulDomContainer = loader.loadXul( XUL_FILE_TRANS_GRID_TOOLBAR, bundle );
      xulDomContainer.addEventHandler( this );
      toolbar = (XulToolbar) xulDomContainer.getDocumentRoot().getElementById( "nav-toolbar" );

      ToolBar swtToolBar = (ToolBar) toolbar.getManagedObject();
      spoon.props.setLook( swtToolBar, Props.WIDGET_STYLE_TOOLBAR );
      swtToolBar.layout( true, true );
    } catch ( Throwable t ) {
      log.logError( toString(), Const.getStackTracker( t ) );
      new ErrorDialog( transGridComposite.getShell(),
        BaseMessages.getString( PKG, "Spoon.Exception.ErrorReadingXULFile.Title" ),
        BaseMessages.getString( PKG, "Spoon.Exception.ErrorReadingXULFile.Message", XUL_FILE_TRANS_GRID_TOOLBAR ),
        new Exception( t ) );
    }
  }
 
Example #2
Source File: ImportRulesDialog.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
private void addToolBar() {

    try {
      XulLoader loader = new KettleXulLoader();
      loader.setSettingsManager( XulSpoonSettingsManager.getInstance() );
      ResourceBundle bundle = new XulSpoonResourceBundle( Spoon.class );
      XulDomContainer xulDomContainer = loader.loadXul( XUL_FILE_TOOLBAR, bundle );
      xulDomContainer.addEventHandler( this );
      toolbar = (XulToolbar) xulDomContainer.getDocumentRoot().getElementById( "import-rules-toolbar" );

      ToolBar swtToolbar = (ToolBar) toolbar.getManagedObject();
      swtToolbar.layout( true, true );
    } catch ( Throwable t ) {
      LogChannel.GENERAL.logError( Const.getStackTracker( t ) );
      new ErrorDialog( shell,
        BaseMessages.getString( PKG, "ImportRulesDialog.Exception.ErrorReadingXULFile.Title" ),
        BaseMessages.getString( PKG, "ImportRulesDialog.Exception.ErrorReadingXULFile.Message", XUL_FILE_TOOLBAR ),
        new Exception( t ) );
    }
  }
 
Example #3
Source File: FragmentHandler.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
protected void loadDatabaseOptionsFragment( String fragmentUri ) throws XulException {

    XulComponent groupElement = document.getElementById( "database-options-box" );
    XulComponent parentElement = groupElement.getParent();

    XulDomContainer fragmentContainer;

    try {

      // Get new group box fragment ...
      // This will effectively set up the SWT parent child relationship...

      fragmentContainer = this.xulDomContainer.loadFragment( fragmentUri, Messages.getBundle() );
      XulComponent newGroup = fragmentContainer.getDocumentRoot().getFirstChild();
      parentElement.replaceChild( groupElement, newGroup );

    } catch ( XulException e ) {
      e.printStackTrace();
      throw e;
    }
  }
 
Example #4
Source File: AbstractWizardStep.java    From pentaho-reporting with GNU Lesser General Public License v2.1 6 votes vote down vote up
/**
 * @throws XulException
 */
public void createPresentationComponent( final XulDomContainer mainWizardContainer ) throws XulException {
  final XulVbox stepContainer = (XulVbox) mainWizardContainer.getDocumentRoot().getElementById( STEP_CONTAINER );

  XulHbox row = (XulHbox) mainWizardContainer.getDocumentRoot().createElement( XUL_HBOX_TYPE );

  // Create and add the activeImage to the row (goes in the first column)
  stepImage = (XulImage) mainWizardContainer.getDocumentRoot().createElement( XUL_IMAGE_TYPE );
  stepImage.setSrc( STEP_IMAGE_SRC );
  stepImage.setId( this.getStepName() );
  stepImage.setVisible( false );
  row.addChild( stepImage );

  // Create and add the text label to the row (goes in the second column)
  stepLabel = (XulLabel) mainWizardContainer.getDocumentRoot().createElement( XUL_LABEL_TYPE );
  stepLabel.setValue( this.getStepName() );
  stepLabel.setFlex( 1 );
  stepLabel.setDisabled( true );
  row.addChild( stepLabel );

  stepContainer.addChild( row );
}
 
Example #5
Source File: FileOverwriteDialogController.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
public static FileOverwriteDialogController getInstance( Shell shell, List<UIRepositoryObject> objects ) {
  try {
    KettleXulLoader swtLoader = new KettleXulLoader();
    swtLoader.setOuterContext( shell );
    swtLoader.setSettingsManager( XulSpoonSettingsManager.getInstance() );
    XulDomContainer container =
      swtLoader.loadXul(
        "org/pentaho/di/ui/repository/repositoryexplorer/xul/file-overwrite-dialog.xul", resourceBundle );
    final XulRunner runner = new SwtXulRunner();
    runner.addContainer( container );

    FileOverwriteDialogController dialogController = new FileOverwriteDialogController( container, objects );

    container.addEventHandler( dialogController );

    runner.initialize();

    return dialogController;
  } catch ( Exception e ) {
    return null;
  }
}
 
Example #6
Source File: JobLogDelegate.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
private void addToolBar() {

    try {
      XulLoader loader = new KettleXulLoader();
      loader.setSettingsManager( XulSpoonSettingsManager.getInstance() );
      ResourceBundle bundle = new XulSpoonResourceBundle( Spoon.class );
      XulDomContainer xulDomContainer = loader.loadXul( XUL_FILE_TRANS_LOG_TOOLBAR, bundle );
      xulDomContainer.addEventHandler( this );
      toolbar = (XulToolbar) xulDomContainer.getDocumentRoot().getElementById( "nav-toolbar" );

      ToolBar swtToolbar = (ToolBar) toolbar.getManagedObject();
      spoon.props.setLook( swtToolbar, Props.WIDGET_STYLE_TOOLBAR );
      swtToolbar.layout( true, true );
    } catch ( Throwable t ) {
      log.logError( Const.getStackTracker( t ) );
      new ErrorDialog( jobLogComposite.getShell(),
        BaseMessages.getString( PKG, "Spoon.Exception.ErrorReadingXULFile.Title" ),
        BaseMessages.getString( PKG, "Spoon.Exception.ErrorReadingXULFile.Message", XUL_FILE_TRANS_LOG_TOOLBAR ),
        new Exception( t ) );
    }
  }
 
Example #7
Source File: TransLogDelegate.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
private void addToolBar() {

    try {
      XulLoader loader = new KettleXulLoader();
      loader.setSettingsManager( XulSpoonSettingsManager.getInstance() );
      ResourceBundle bundle = new XulSpoonResourceBundle( Spoon.class );
      XulDomContainer xulDomContainer = loader.loadXul( XUL_FILE_TRANS_LOG_TOOLBAR, bundle );
      xulDomContainer.addEventHandler( this );
      toolbar = (XulToolbar) xulDomContainer.getDocumentRoot().getElementById( "nav-toolbar" );

      ToolBar swtToolBar = (ToolBar) toolbar.getManagedObject();
      spoon.props.setLook( swtToolBar, Props.WIDGET_STYLE_TOOLBAR );
      swtToolBar.layout( true, true );
    } catch ( Throwable t ) {
      log.logError( Const.getStackTracker( t ) );
      new ErrorDialog( transLogComposite.getShell(),
        BaseMessages.getString( PKG, "Spoon.Exception.ErrorReadingXULFile.Title" ),
        BaseMessages.getString( PKG, "Spoon.Exception.ErrorReadingXULFile.Message", XUL_FILE_TRANS_LOG_TOOLBAR ),
        new Exception( t ) );
    }
  }
 
Example #8
Source File: TransHistoryDelegate.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
private void addToolBar() {
  try {
    KettleXulLoader loader = new KettleXulLoader();
    loader.setIconsSize( 16, 16 );
    loader.setSettingsManager( XulSpoonSettingsManager.getInstance() );
    ResourceBundle bundle = new XulSpoonResourceBundle( Spoon.class );
    XulDomContainer xulDomContainer = loader.loadXul( XUL_FILE_TRANS_GRID_TOOLBAR, bundle );
    xulDomContainer.addEventHandler( this );
    toolbar = (XulToolbar) xulDomContainer.getDocumentRoot().getElementById( "nav-toolbar" );

    refreshButton = (XulToolbarbutton) xulDomContainer.getDocumentRoot().getElementById( "refresh-history" );
    fetchNextBatchButton =
      (XulToolbarbutton) xulDomContainer.getDocumentRoot().getElementById( "fetch-next-batch-history" );
    fetchAllButton = (XulToolbarbutton) xulDomContainer.getDocumentRoot().getElementById( "fetch-all-history" );

    ToolBar swtToolBar = (ToolBar) toolbar.getManagedObject();
    spoon.props.setLook( swtToolBar, Props.WIDGET_STYLE_TOOLBAR );
    swtToolBar.layout( true, true );
  } catch ( Throwable t ) {
    log.logError( Const.getStackTracker( t ) );
    new ErrorDialog( transHistoryComposite.getShell(),
      BaseMessages.getString( PKG, "Spoon.Exception.ErrorReadingXULFile.Title" ),
      BaseMessages.getString( PKG, "Spoon.Exception.ErrorReadingXULFile.Message", XUL_FILE_TRANS_GRID_TOOLBAR ),
      new Exception( t ) );
  }
}
 
Example #9
Source File: JobHistoryDelegate.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
private void addToolBar() {
  try {
    XulLoader loader = new KettleXulLoader();
    loader.setSettingsManager( XulSpoonSettingsManager.getInstance() );
    ResourceBundle bundle = new XulSpoonResourceBundle( Spoon.class );
    XulDomContainer xulDomContainer = loader.loadXul( XUL_FILE_TRANS_GRID_TOOLBAR, bundle );
    xulDomContainer.addEventHandler( this );
    toolbar = (XulToolbar) xulDomContainer.getDocumentRoot().getElementById( "nav-toolbar" );

    refreshButton = (XulToolbarbutton) xulDomContainer.getDocumentRoot().getElementById( "refresh-history" );
    fetchNextBatchButton =
      (XulToolbarbutton) xulDomContainer.getDocumentRoot().getElementById( "fetch-next-batch-history" );
    fetchAllButton = (XulToolbarbutton) xulDomContainer.getDocumentRoot().getElementById( "fetch-all-history" );

    ToolBar swtToolBar = (ToolBar) toolbar.getManagedObject();
    spoon.props.setLook( swtToolBar, Props.WIDGET_STYLE_TOOLBAR );
    swtToolBar.layout( true, true );
  } catch ( Throwable t ) {
    log.logError( Const.getStackTracker( t ) );
    new ErrorDialog( jobHistoryComposite.getShell(),
      BaseMessages.getString( PKG, "Spoon.Exception.ErrorReadingXULFile.Title" ),
      BaseMessages.getString( PKG, "Spoon.Exception.ErrorReadingXULFile.Message", XUL_FILE_TRANS_GRID_TOOLBAR ),
      new Exception( t ) );
  }
}
 
Example #10
Source File: BeamSpoonPlugin.java    From kettle-beam with Apache License 2.0 5 votes vote down vote up
@Override
public void applyToContainer( String category, XulDomContainer container ) throws XulException {
  container.registerClassLoader( getClass().getClassLoader() );
  if ( category.equals( "spoon" ) ) {
    container.loadOverlay( "beam_spoon_overlays.xul", resourceBundle );
    container.addEventHandler( BeamHelper.getInstance() );
  }
  if ( category.equals( "trans-graph" ) ) {
    container.loadOverlay( "beam_transgraph_overlays.xul", resourceBundle );
    container.addEventHandler( BeamHelper.getInstance() );
  }
}
 
Example #11
Source File: SparkTuningPopupMenu.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
@Override public void applyToContainer( String category, XulDomContainer container ) throws XulException {
  if ( category.equals( "trans-graph" ) ) {
    container.registerClassLoader( getClass().getClassLoader() );
    container.loadOverlay( "org/pentaho/di/engine/configuration/impl/spark/spark-tuning-menu.xul", resourceBundle );
    container.addEventHandler( this.handler );
  }
}
 
Example #12
Source File: XulDatabaseDialog.java    From pentaho-reporting with GNU Lesser General Public License v2.1 5 votes vote down vote up
public XulDatabaseDialog( final Window parent ) throws XulException {
  final SwingXulLoader loader = new SwingXulLoader();

  if ( parent != null ) {
    loader.setOuterContext( parent );
  }
  final XulDomContainer container = loader.loadXul( DIALOG_DEFINITION_FILE, Messages.getBundle() );
  container.getDocumentRoot().addOverlay( OVERLAY_DEFINITION_FILE );
  container.initialize();

  handler = new XulDatabaseHandler();
  container.addEventHandler( handler );   //$NON-NLS-1$

  final Document documentRoot = container.getDocumentRoot();
  final XulComponent root = documentRoot.getRootElement();

  if ( root instanceof XulDialog ) {
    dialog = (XulDialog) root;
    dialog.setResizable( Boolean.TRUE );
  } else {
    throw new XulException( "Error getting Xul Database Dialog root, element of type: " + root );
  }

  final ObjectFactory objectFactory = ClassicEngineBoot.getInstance().getObjectFactory();
  final IDatabaseDialectService dialectService = objectFactory.get( IDatabaseDialectService.class );
  this.databaseTypeHelper = new DatabaseTypeHelper( dialectService.getDatabaseTypes() );

}
 
Example #13
Source File: StandaloneWizard.java    From pentaho-reporting with GNU Lesser General Public License v2.1 5 votes vote down vote up
public StandaloneWizard() {
  wizardController = new LinearWizardController( new WizardEditorModel(), new DefaultBindingFactory() );
  wizardController.addPropertyChangeListener( new CloseListener() );

  final DataSourceAndQueryStep dataSourceAndQueryStep = new DataSourceAndQueryStep();

  // add the steps ..
  wizardController.addStep( new LookAndFeelStep() );
  wizardController.addStep( dataSourceAndQueryStep );
  wizardController.addStep( new LayoutStep() );
  wizardController.addStep( new FormatStep() );


  try {
    final XulDomContainer mainWizardContainer = new SwingXulLoader().loadXul( MAIN_WIZARD_PANEL );
    new WizardContentPanel( wizardController ).addContent( mainWizardContainer );

    wizardController.registerMainXULContainer( mainWizardContainer );

    final Document documentRoot = mainWizardContainer.getDocumentRoot();
    final XulDialog root = (XulDialog) documentRoot.getRootElement();
    final Window window = (Window) root.getRootObject();
    final DesignTimeContext designTimeContext =
      new DefaultWizardDesignTimeContext( wizardController.getEditorModel(), window );
    dataSourceAndQueryStep.setDesignTimeContext( designTimeContext );
    wizardController.setDesignTimeContext( designTimeContext );

    final XulRunner runner = new SwingXulRunner();
    runner.addContainer( mainWizardContainer );

    runner.initialize();
    runner.start();

  } catch ( Exception e ) {
    ExceptionDialog.showExceptionDialog( null, "Error", e.getMessage(), e );
  }

}
 
Example #14
Source File: LookAndFeelStep.java    From pentaho-reporting with GNU Lesser General Public License v2.1 5 votes vote down vote up
public void createPresentationComponent( final XulDomContainer mainWizardContainer ) throws XulException {
  super.createPresentationComponent( mainWizardContainer );

  // Add the overlay
  mainWizardContainer.loadOverlay( LOOK_AND_FEEL_STEP_OVERLAY );

  // Add event handlers
  mainWizardContainer.addEventHandler( new SelectTemplateStepHandler() );
}
 
Example #15
Source File: FragmentHandlerTest.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
@Test
public void testLoadDatabaseOptionsFragment() throws Exception {
  XulComponent component = mock( XulComponent.class );
  XulComponent parent = mock( XulComponent.class );
  when( component.getParent() ).thenReturn( parent );
  when( document.getElementById( "database-options-box" ) ).thenReturn( component );
  XulDomContainer fragmentContainer = mock( XulDomContainer.class );
  Document mockDoc = mock( Document.class );
  XulComponent firstChild = mock( XulComponent.class );
  when( mockDoc.getFirstChild() ).thenReturn( firstChild );
  when( fragmentContainer.getDocumentRoot() ).thenReturn( mockDoc );
  when( xulDomContainer.loadFragment( anyString(), any( Object.class ) ) ).thenReturn( fragmentContainer );
  fragmentHandler.loadDatabaseOptionsFragment( null );
}
 
Example #16
Source File: FragmentHandlerTest.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
@Test
public void testRefreshOptions() throws Exception {
  XulListbox connectionBox = mock( XulListbox.class );
  when( document.getElementById( "connection-type-list" ) ).thenReturn( connectionBox );
  when( connectionBox.getSelectedItem() ).thenReturn( "myDb" );
  XulListbox accessBox = mock( XulListbox.class );
  when( document.getElementById( "access-type-list" ) ).thenReturn( accessBox );
  when( accessBox.getSelectedItem() ).thenReturn( "Native" );
  DataHandler dataHandler = mock( DataHandler.class );
  when( xulDomContainer.getEventHandler( "dataHandler" ) ).thenReturn( dataHandler );
  DatabaseInterface dbInterface = mock( DatabaseInterface.class );
  when( dbInterface.getDefaultDatabasePort() ).thenReturn( 5309 );
  DataHandler.connectionMap.put( "myDb", dbInterface );

  XulComponent component = mock( XulComponent.class );
  XulComponent parent = mock( XulComponent.class );
  when( component.getParent() ).thenReturn( parent );
  when( document.getElementById( "database-options-box" ) ).thenReturn( component );
  XulDomContainer fragmentContainer = mock( XulDomContainer.class );
  Document mockDoc = mock( Document.class );
  XulComponent firstChild = mock( XulComponent.class );
  when( mockDoc.getFirstChild() ).thenReturn( firstChild );
  when( fragmentContainer.getDocumentRoot() ).thenReturn( mockDoc );
  when( xulDomContainer.loadFragment( anyString(), any( Object.class ) ) ).thenReturn( fragmentContainer );

  XulTextbox portBox = mock( XulTextbox.class );
  when( document.getElementById( "port-number-text" ) ).thenReturn( portBox );

  fragmentHandler.refreshOptions();

  // Iterate through the other database access types
  when( accessBox.getSelectedItem() ).thenReturn( "JNDI" );
  fragmentHandler.refreshOptions();
  when( accessBox.getSelectedItem() ).thenReturn( "ODBC" );
  fragmentHandler.refreshOptions();
  when( accessBox.getSelectedItem() ).thenReturn( "OCI" );
  fragmentHandler.refreshOptions();
  when( accessBox.getSelectedItem() ).thenReturn( "Plugin" );
  fragmentHandler.refreshOptions();
}
 
Example #17
Source File: FormatStep.java    From pentaho-reporting with GNU Lesser General Public License v2.1 5 votes vote down vote up
public void createPresentationComponent( final XulDomContainer mainWizardContainer ) throws XulException {
  super.createPresentationComponent( mainWizardContainer );

  mainWizardContainer.loadOverlay( FORMAT_STEP_OVERLAY );

  // Add event handlers
  mainWizardContainer.addEventHandler( formatStepHandler );
}
 
Example #18
Source File: UIMain.java    From pentaho-aggdesigner with GNU General Public License v2.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
public void start(ApplicationContext context) throws XulException {
  XulDomContainer container;

  //check to see if they've specified an alternate resource bundle
  String bundleStr = configuration.getResourceBundle();
  ResourceBundle bundle = null;
  if(bundleStr != null){
    try{
      bundle = ResourceBundle.getBundle(bundleStr);
    } catch (MissingResourceException e){
      logger.error("Could not load Resource Bundle: "+bundleStr); //$NON-NLS-1$
    }
  }

  //Set the look and feel based on configuration
  setLAF();

  if(bundle != null){
    container = xulLoader.loadXul("org/pentaho/aggdes/ui/resources/mainFrame.xul", bundle); //$NON-NLS-1$
  } else {
    container = xulLoader.loadXul("org/pentaho/aggdes/ui/resources/mainFrame.xul"); //$NON-NLS-1$
  }

  //generically register all Spring-initialized XulEventHandlers
  Map handlerMap = context.getBeansOfType(XulEventHandler.class);
  for(Object handler : handlerMap.values()) {
    container.addEventHandler((XulEventHandler)handler);
  }

  xulRunner.addContainer(container);
  xulRunner.initialize();
  xulRunner.start();
}
 
Example #19
Source File: RepositorySpoonPlugin.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
@Override
public void applyToContainer( String category, XulDomContainer container ) throws XulException {
  if ( category.equals( SPOON_CATEGORY ) ) {
    XulToolbar toolbar = (XulToolbar) container.getDocumentRoot().getElementById( "main-toolbar" );
    RepositoryConnectMenu repoConnectMenu =
      new RepositoryConnectMenu( Spoon.getInstance(), (ToolBar) toolbar.getManagedObject(),
        repositoryConnectController );
    repoConnectMenu.render();
  }
}
 
Example #20
Source File: XulDrillDownParameterTable.java    From pentaho-reporting with GNU Lesser General Public License v2.1 5 votes vote down vote up
public XulDrillDownParameterTable( final Element self,
                                   final XulComponent parent,
                                   final XulDomContainer domContainer,
                                   final String tagName ) {
  super( tagName );
  this.table = new DrillDownParameterTable();
  setManagedObject( table );

  table.addPropertyChangeListener( DrillDownParameterTable.DRILL_DOWN_PARAMETER_PROPERTY,
    new ForwardChangeEventsHandler() );
  table.addPropertyChangeListener( DrillDownParameterTable.HIDE_PARAMETER_UI_PARAMETER_PROPERTY,
    new ForwardChangeEventsHandler() );
}
 
Example #21
Source File: SpoonPluginManagerTest.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
@Override public void applyToContainer( String category, XulDomContainer container ) throws XulException {
  if ( applies.get( this ) == null ) {
    applies.put( this, 1 );
  } else {
    applies.put( this, applies.get( this ) + 1 );
  }
}
 
Example #22
Source File: BrowseControllerTest.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
@Before
public void setUp() throws Exception {
  DocumentFactory.registerElementClass( ElementDom4J.class );

  controller = spy( new BrowseController() );

  controller.setRepositoryDirectory( mock( UIRepositoryDirectory.class ) );

  directoryMap = new HashMap<>( 8 );
  controller.setDirMap( directoryMap );

  document = mock( Document.class );
  XulDomContainer xulDomContainer = mock( XulDomContainer.class );
  when( xulDomContainer.getDocumentRoot() ).thenReturn( document );
  controller.setXulDomContainer( xulDomContainer );

  UIRepositoryDirectory someDirectory = mock( UIRepositoryDirectory.class );
  selectedFolder = mock( UIRepositoryDirectory.class );
  when( selectedFolder.createFolder( FOLDER_NAME ) ).thenReturn( someDirectory );

  XulTree folderTree = mock( XulTree.class );
  when( folderTree.getSelectedItems() ).thenReturn( Collections.<Object>singleton( selectedFolder ) );
  controller.setFolderTree( folderTree );

  directoryBinding = mock( Binding.class );
  controller.setDirectoryBinding( directoryBinding );

  selectedItemsBinding = mock( Binding.class );
  controller.setSelectedItemsBinding( selectedItemsBinding );
}
 
Example #23
Source File: ExtTextbox.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
public ExtTextbox( Element self, XulComponent parent, XulDomContainer container, String tagName ) {
  super( self, parent, container, tagName );
  String typeAttribute = self.getAttributeValue( "type" );
  if ( typeAttribute != null ) {
    this.type = TextType.valueOf( typeAttribute.toUpperCase() );
  }
  createNewExtText( parent );
}
 
Example #24
Source File: TransPreviewDelegate.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
private void addToolBar() {

    try {
      XulLoader loader = new KettleXulLoader();
      loader.setSettingsManager( XulSpoonSettingsManager.getInstance() );
      ResourceBundle bundle = GlobalMessages.getBundle( "org/pentaho/di/ui/spoon/messages/messages" );
      XulDomContainer xulDomContainer = loader.loadXul( XUL_FILE_TRANS_PREVIEW_TOOLBAR, bundle );
      xulDomContainer.addEventHandler( this );
      toolbar = (XulToolbar) xulDomContainer.getDocumentRoot().getElementById( "nav-toolbar" );
      ToolBar swtToolBar = (ToolBar) toolbar.getManagedObject();
      spoon.props.setLook( swtToolBar, Props.WIDGET_STYLE_TOOLBAR );
      swtToolBar.layout( true, true );
      swtToolBar.pack();

      firstRadio = (SwtRadio) xulDomContainer.getDocumentRoot().getElementById( "preview-first" );
      lastRadio = (SwtRadio) xulDomContainer.getDocumentRoot().getElementById( "preview-last" );
      offRadio = (SwtRadio) xulDomContainer.getDocumentRoot().getElementById( "preview-off" );

      PropsUI.getInstance().setLook( (Control) firstRadio.getManagedObject(), Props.WIDGET_STYLE_TOOLBAR );
      PropsUI.getInstance().setLook( (Control) lastRadio.getManagedObject(), Props.WIDGET_STYLE_TOOLBAR );
      PropsUI.getInstance().setLook( (Control) offRadio.getManagedObject(), Props.WIDGET_STYLE_TOOLBAR );

    } catch ( Throwable t ) {
      log.logError( toString(), Const.getStackTracker( t ) );
      new ErrorDialog( transPreviewComposite.getShell(),
        BaseMessages.getString( PKG, "Spoon.Exception.ErrorReadingXULFile.Title" ),
        BaseMessages.getString( PKG, "Spoon.Exception.ErrorReadingXULFile.Message", XUL_FILE_TRANS_PREVIEW_TOOLBAR ),
        new Exception( t ) );
    }
  }
 
Example #25
Source File: AbstractRepositoryExplorerUISupport.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
public void apply( XulDomContainer container ) throws XulException {
  this.container = container;
  container.registerClassLoader( getClass().getClassLoader() );
  for ( XulEventHandler handler : handlers ) {
    container.addEventHandler( handler );
  }
  for ( XulOverlay overlay : overlays ) {
    if ( overlay instanceof RepositoryExplorerDefaultXulOverlay ) {
      container.loadOverlay( overlay.getOverlayUri(), new XulSpoonResourceBundle(
        ( (RepositoryExplorerDefaultXulOverlay) overlay ).getPackageClass() ) );
    } else {
      container.loadOverlay( overlay.getOverlayUri(), overlay.getResourceBundleUri() );
    }
  }
}
 
Example #26
Source File: SpoonBrowser.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
protected void addToolBar() {

    try {
      XulLoader loader = new KettleXulLoader();
      loader.setSettingsManager( XulSpoonSettingsManager.getInstance() );
      ResourceBundle bundle = GlobalMessages.getBundle( "org/pentaho/di/ui/spoon/messages/messages" );
      XulDomContainer xulDomContainer = loader.loadXul( XUL_FILE_BROWSER_TOOLBAR, bundle );
      xulDomContainer.addEventHandler( this );
      toolbar = (XulToolbar) xulDomContainer.getDocumentRoot().getElementById( "nav-toolbar" );

      @SuppressWarnings( "unused" )
      ToolBar swtToolBar = (ToolBar) toolbar.getManagedObject();
      spoon.props.setLook( swtToolBar, Props.WIDGET_STYLE_TOOLBAR );

      // Add a URL

      back = (XulToolbarbutton) toolbar.getElementById( "browse-back" );
      back.setDisabled( true );
      forward = (XulToolbarbutton) toolbar.getElementById( "browse-forward" );
      forward.setLabel( BaseMessages.getString( PKG, "SpoonBrowser.Dialog.Forward" ) );
      forward.setDisabled( false );
      location = (XulTextbox) toolbar.getElementById( "browser-address" );
      Control toolbarControl = (Control) toolbar.getManagedObject();
      toolbarControl.setLayoutData( new FormData() );
      toolbarControl.setParent( composite );
    } catch ( Exception e ) {
      e.printStackTrace();
      new ErrorDialog(
        shell, BaseMessages.getString( PKG, "Spoon.Exception.ErrorReadingXULFile.Title" ), BaseMessages
          .getString( PKG, "Spoon.Exception.ErrorReadingXULFile.Message", XUL_FILE_BROWSER_TOOLBAR ), e );
    }
  }
 
Example #27
Source File: ExportHandlerTest.java    From pentaho-aggdesigner with GNU General Public License v2.0 5 votes vote down vote up
@Before
public void setUp() throws Exception {
  controller = new ExportHandler();
  context = new JUnit4Mockery() {
    {
      // only here to mock types that are not interfaces
      setImposteriser(ClassImposteriser.INSTANCE);
    }
  };
  doc = context.mock(Document.class);
  container = context.mock(XulDomContainer.class);
  outputService = context.mock(OutputService.class);
  executor = context.mock(SqlExecutor.class);

  aggList = new AggListImpl();

  controller.setOutputService(outputService);
  controller.setAggList(aggList);
  controller.setDdlDmlExecutor(executor);

  // need some expectations here as setXulDomContainer calls getDocumentRoot on the container
  context.checking(new Expectations() {
    {
      one(container).getDocumentRoot();
      will(returnValue(doc));
    }
  });

  controller.setXulDomContainer(container);

}
 
Example #28
Source File: StarModelerSpoonPlugin.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
public void applyToContainer(String category, XulDomContainer container) throws XulException {
  container.registerClassLoader(getClass().getClassLoader());
  if(category.equals("spoon")){
    container.loadOverlay("org/pentaho/di/starmodeler/xul/spoon_overlays.xul");
    container.addEventHandler(ModelerHelper.getInstance());
  }
}
 
Example #29
Source File: ConnectionControllerTest.java    From pentaho-aggdesigner with GNU General Public License v2.0 5 votes vote down vote up
@Before
public void setUp() throws Exception {
  controller = new ConnectionController();
  context = new JUnit4Mockery();
  doc = context.mock(Document.class);
  container = context.mock(XulDomContainer.class);
  dataHandler = context.mock(XulEventHandler.class);
  model = context.mock(ConnectionModel.class);
  controller.setConnectionModel(model);
  workspace = new Workspace();
  controller.setWorkspace(workspace);
  outputService = context.mock(OutputService.class);
  controller.setOutputService(outputService);
  aSchemaProvider = context.mock(SchemaProviderUiExtension.class);
  cubeNames = Arrays.asList("testCube1", "testCube2");
  providerModel = context.mock(SchemaModel.class);

  // need some expectations here as setXulDomContainer calls getDocumentRoot on the container
  context.checking(new Expectations() {
    {
      one(container).getDocumentRoot();
      will(returnValue(doc));
      allowing(doc).invokeLater(with(any(Runnable.class))); //don't care if the controller uses invokeLater or not
    }
  });

  controller.setXulDomContainer(container);
  controller.setDataHandler(dataHandler);
}
 
Example #30
Source File: SpoonPluginManager.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
public void applyPluginsForContainer( final String category, final XulDomContainer container ) throws XulException {
  List<SpoonPluginInterface> plugins = pluginCategoryMap.get( category );
  if ( plugins != null ) {
    for ( SpoonPluginInterface sp : plugins ) {
      sp.applyToContainer( category, container );
    }
  }
}