Java Code Examples for org.pentaho.ui.xul.dom.Document

The following examples show how to use org.pentaho.ui.xul.dom.Document. These examples are extracted from open source projects. 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
public XulDatabaseDialog( final Window parent,
                          final DesignTimeContext designTimeContext ) throws XulException {
  this.designTimeContext = designTimeContext;
  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 );
  }
}
 
Example 2
Source Project: pentaho-kettle   Source File: SpoonPerspectiveManager.java    License: Apache License 2.0 6 votes vote down vote up
public void removePerspective( SpoonPerspective per ) {
  perspectives.remove( per );
  orderedPerspectives.remove( per );
  Document document = domContainer.getDocumentRoot();

  XulComponent comp = document.getElementById( "perspective-" + per.getId() );
  comp.getParent().removeChild( comp );

  comp = document.getElementById( "perspective-btn-" + per.getId() );
  comp.getParent().removeChild( comp );
  XulToolbar mainToolbar = (XulToolbar) domContainer.getDocumentRoot().getElementById( "main-toolbar" );
  ( (Composite) mainToolbar.getManagedObject() ).layout( true, true );

  deck.setSelectedIndex( 0 );

}
 
Example 3
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 4
protected void configureDisableTableOnEmptyFile() {
  final Document doc = getXulDomContainer().getDocumentRoot();
  final XulComponent paramTableElement = doc.getElementById( "parameter-table" ); // NON-NLS
  if ( paramTableElement instanceof XulDrillDownParameterTable == false ) {
    return;
  }

  pentahoPathWrapper.addPropertyChangeListener( PentahoPathModel.LOCAL_PATH_PROPERTY, new CheckEmptyPathHandler(
      paramTableElement ) );
}
 
Example 5
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 6
protected void configureDisableTableOnEmptyFile() {
  final Document doc = getXulDomContainer().getDocumentRoot();
  final XulComponent paramTableElement = doc.getElementById( "parameter-table" );//NON-NLS
  if ( paramTableElement instanceof XulDrillDownParameterTable == false ) {
    return;
  }

  getWrapper().getModel().addPropertyChangeListener
    ( DrillDownModel.DRILL_DOWN_PATH_PROPERTY, new CheckEmptyPathHandler( paramTableElement ) );

}
 
Example 7
public JobGraphJobEntryMenuExtension( XulDomContainer xulDomContainer, Document doc, JobMeta jobMeta,
  JobEntryCopy jobEntry, JobGraph jobGraph ) {
  this.xulDomContainer = xulDomContainer;
  this.doc = doc;
  this.jobMeta = jobMeta;
  this.jobEntry = jobEntry;
  this.jobGraph = jobGraph;
}
 
Example 8
Source Project: pentaho-kettle   Source File: BrowseControllerTest.java    License: 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 9
Source Project: pentaho-kettle   Source File: TransGraphTest.java    License: Apache License 2.0 5 votes vote down vote up
@SuppressWarnings( "unchecked" )
@Test
public void testInitializeXulMenu() throws KettleException {
  StepMeta stepMeta = mock( StepMeta.class );
  TransGraph transGraph = mock( TransGraph.class );
  TransMeta transMeta = mock( TransMeta.class );
  Document document = mock( Document.class );
  XulMenuitem xulItem = mock( XulMenuitem.class );
  XulMenu xulMenu = mock( XulMenu.class );
  StepErrorMeta stepErrorMeta = mock( StepErrorMeta.class );
  Spoon spoon = mock( Spoon.class );
  List<StepMeta> selection = Arrays.asList( new StepMeta(), stepMeta, new StepMeta() );

  doCallRealMethod().when( transGraph ).setTransMeta( any( TransMeta.class ) );
  doCallRealMethod().when( transGraph ).setSpoon( any( Spoon.class ) );
  transGraph.setTransMeta( transMeta );
  transGraph.setSpoon( spoon );

  when( stepMeta.getStepErrorMeta() ).thenReturn( stepErrorMeta );
  when( stepMeta.isDrawn() ).thenReturn( true );
  when( document.getElementById( any( String.class ) ) ).thenReturn( xulItem );
  when( document.getElementById( TransGraph.TRANS_GRAPH_ENTRY_AGAIN ) ).thenReturn( xulMenu );
  when( document.getElementById( TransGraph.TRANS_GRAPH_ENTRY_SNIFF ) ).thenReturn( xulMenu );

  doCallRealMethod().when( transGraph ).initializeXulMenu( any( Document.class ),
    any( List.class ), any( StepMeta.class ) );

  transGraph.initializeXulMenu( document, selection, stepMeta );
  verify( transMeta ).isAnySelectedStepUsedInTransHops();
}
 
Example 10
Source Project: pentaho-kettle   Source File: FragmentHandlerTest.java    License: Apache License 2.0 5 votes vote down vote up
@Before
public void setUp() throws Exception {
  fragmentHandler = new FragmentHandler();

  xulDomContainer = mock( XulDomContainer.class );

  document = mock( Document.class );
  when( xulDomContainer.getDocumentRoot() ).thenReturn( document );
  fragmentHandler.setXulDomContainer( xulDomContainer );
}
 
Example 11
Source Project: pentaho-kettle   Source File: FragmentHandlerTest.java    License: 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 12
Source Project: pentaho-kettle   Source File: FragmentHandlerTest.java    License: 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 13
Source Project: pentaho-kettle   Source File: SpoonMenuLockController.java    License: Apache License 2.0 5 votes vote down vote up
public void updateMenu( Document doc ) {
  try {
    Spoon spoon = Spoon.getInstance();

    // If we are working with an Enterprise Repository
    if ( ( spoon != null ) && ( spoon.getRepository() != null ) && ( spoon.getRepository() instanceof PurRepository ) ) {
      ILockService service = getService( spoon.getRepository() );

      EngineMetaInterface meta = spoon.getActiveMeta();

      // If (meta is not null) and (meta is either a Transformation or Job)
      if ( ( meta != null ) && ( meta instanceof ILockable ) ) {

        RepositoryLock repoLock = null;
        if ( service != null && meta.getObjectId() != null ) {
          if ( meta instanceof EEJobMeta ) {
            repoLock = service.getJobLock( meta.getObjectId() );
          } else {
            repoLock = service.getTransformationLock( meta.getObjectId() );
          }
        }
        // If (there is a lock on this item) and (the UserInfo does not have permission to unlock this file)
        if ( repoLock != null ) {
          if ( !service.canUnlockFileById( meta.getObjectId() ) ) {
            // User does not have modify permissions on this file
            ( (XulToolbarbutton) doc.getElementById( "toolbar-file-save" ) ).setDisabled( true ); //$NON-NLS-1$
            ( (XulMenuitem) doc.getElementById( "file-save" ) ).setDisabled( true ); //$NON-NLS-1$  
          }
        }
      }
    }
  } catch ( Exception e ) {
    throw new RuntimeException( e );
  }
}
 
Example 14
Source Project: pentaho-kettle   Source File: EESpoonPlugin.java    License: Apache License 2.0 5 votes vote down vote up
private Document getDocumentRoot() {
  initMainSpoonContainer();
  if ( spoonXulContainer != null ) {
    return spoonXulContainer.getDocumentRoot();
  } else {
    return null;
  }

}
 
Example 15
@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 16
@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 17
@Before
public void setUp() throws Exception {
  controller = new AggListController();
  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);
  workspace = context.mock(Workspace.class);
  connModel = context.mock(ConnectionModel.class);
  schema = context.mock(Schema.class);
  uiExt = context.mock(AlgorithmUiExtension.class);
  algo = context.mock(Algorithm.class);
  aggregateSummaryModel = context.mock(AggregateSummaryModel.class);

  aggList = new AggListImpl();

  controller.setOutputService(outputService);
  controller.setAggList(aggList);
  controller.setAlgorithmUiExtension(uiExt);
  controller.setAlgorithm(algo);

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

  controller.setXulDomContainer(container);
  controller.setWorkspace(workspace);
  controller.setConnectionModel(connModel);
  controller.setAggregateSummaryModel(aggregateSummaryModel);
  
}
 
Example 18
Source Project: kettle-beam   Source File: BeamMenuController.java    License: Apache License 2.0 4 votes vote down vote up
@Override public void updateMenu( Document document ) {
  // TODO
}
 
Example 19
public void updateMenu( Document doc ) {
  // Nothing so far.
}
 
Example 20
@Override public void updateMenu( Document document ) {
  // TODO
}
 
Example 21
Source Project: pentaho-pdi-dataset   Source File: DataSetHelper.java    License: Apache License 2.0 4 votes vote down vote up
public void updateMenu( Document doc ) {
  // Nothing so far.
}
 
Example 22
public AbstractReportDefinition run( final AbstractReportDefinition original ) throws ReportProcessingException {
  // Set the report if we have one otherwise create a new one
  if ( original != null ) {
    wizardController.getEditorModel().setReportDefinition( original, true );
  } else {
    final MasterReport report = new MasterReport();
    report.setDataFactory( new CompoundDataFactory() );
    report.setQuery( null );
    report.setAutoSort( Boolean.TRUE );
    wizardController.getEditorModel().setReportDefinition( report, false );
  }

  // Create the gui
  try {
    final SwingXulLoader loader = new SwingXulLoader();
    loader.setOuterContext( owner );

    final XulDomContainer mainWizardContainer = new SwingXulLoader().loadXul( MAIN_WIZARD_PANEL );
    new WizardContentPanel( wizardController ).addContent( mainWizardContainer );
    mainWizardContainer.setOuterContext( this.owner );
    wizardController.registerMainXULContainer( mainWizardContainer );
    wizardController.onLoad();

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

    if ( !( root instanceof XulDialog ) ) {
      throw new XulException(
        Messages.getInstance().getString( "EMBEDDED_WIZARD.Root_Error" ) + " " + root ); //$NON-NLS-1$ //$NON-NLS-2$
    }

    dialog = (XulDialog) root;
    // This is a hack to get the JDialog (this wizard) to become the parent window of windows/dialogs
    // that the wizard creates.
    final DesignTimeContext context = new DefaultWizardDesignTimeContext
      ( wizardController.getEditorModel(), (Window) dialog.getRootObject(), designTimeContext );
    dataSourceAndQueryStep.setDesignTimeContext( context );
    wizardController.setDesignTimeContext( context );

    // if we're doing an edit drop into the layout step
    if ( wizardController.getEditorModel().isEditing() ) {
      if ( wizardController.getStep( 0 ).isValid() ) {
        wizardController.setActiveStep( 1 ); // initializes the data
        if ( wizardController.getStep( 1 ).isValid() ) {
          wizardController.setActiveStep( 2 );
        }
      }
    }

    dialog.show();

  } catch ( Exception e ) {
    DebugLog.log( "Failed to initialize the wizard", e );
    return null;
  }

  // -----------------------------------
  if ( !wizardController.isFinished() ) {
    return null;
  }
  final AbstractReportDefinition reportDefinition = wizardController.getEditorModel().getReportDefinition();
  try {
    final WizardSpecification spec = wizardController.getEditorModel().getReportSpec();
    WizardProcessorUtil.applyWizardSpec( reportDefinition, spec );
    WizardProcessorUtil.ensureWizardProcessorIsAdded( reportDefinition, null );
  } catch ( Exception ex ) {
    throw new IllegalStateException();
  }

  if ( reportDefinition instanceof MasterReport ) {
    return WizardProcessorUtil.materialize( (MasterReport) reportDefinition, new WizardProcessor() );
  } else if ( reportDefinition instanceof SubReport ) {
    return WizardProcessorUtil.materialize( (SubReport) reportDefinition, new WizardProcessor() );
  } else {
    throw new IllegalStateException();
  }
}
 
Example 23
public Document getDocument() {
  return document;
}
 
Example 24
public void setDocument( final Document document ) {
  this.document = document;
}
 
Example 25
public void init( final ReportDesignerContext reportDesignerContext,
                  final DrillDownModel model,
                  final String[] fields ) {
  if ( model == null ) {
    throw new NullPointerException();
  }
  if ( reportDesignerContext == null ) {
    throw new NullPointerException();
  }
  if ( fields == null ) {
    throw new NullPointerException();
  }

  this.reportDesignerContext = reportDesignerContext;

  final Document doc = this.xulDomContainer.getDocumentRoot();
  final DefaultBindingFactory bindingFactory = new DefaultBindingFactory();
  bindingFactory.setDocument( doc );
  bindingFactory.setBindingType( Binding.Type.BI_DIRECTIONAL );
  wrapper = new DrillDownModelWrapper( model );
  final XulComponent pathElement = doc.getElementById( "path" ); //NON-NLS
  if ( pathElement != null ) {
    bindingFactory.createBinding( wrapper, DrillDownModel.DRILL_DOWN_PATH_PROPERTY, "path", "value" ); //NON-NLS
  }
  final XulComponent configElement = doc.getElementById( "config" ); //NON-NLS
  if ( configElement != null ) {
    bindingFactory.createBinding( wrapper, DrillDownModel.DRILL_DOWN_CONFIG_PROPERTY, "config", "value" ); //NON-NLS
  }
  final XulComponent linkTargetElement = doc.getElementById( "link-target" ); //NON-NLS
  if ( linkTargetElement != null ) {
    bindingFactory.createBinding( wrapper, DrillDownModel.TARGET_FORMULA_PROPERTY, "link-target", "value" ); //NON-NLS
  }
  final XulComponent linkTooltipElement = doc.getElementById( "link-tooltip" ); //NON-NLS
  if ( linkTooltipElement != null ) {
    bindingFactory
      .createBinding( wrapper, DrillDownModel.TOOLTIP_FORMULA_PROPERTY, "link-tooltip", "value" ); //NON-NLS
  }
  final XulComponent previewElement = doc.getElementById( "preview" ); //NON-NLS
  if ( previewElement != null ) {
    final BindingFactory singleSourceBinding = new DefaultBindingFactory();
    singleSourceBinding.setBindingType( Binding.Type.ONE_WAY );
    singleSourceBinding.setDocument( doc );
    singleSourceBinding.createBinding( wrapper, "preview", "preview", "value" ); //NON-NLS
  }

  // we manage the binding between the table and the outside world manually
  wrapper.refresh();
  final XulComponent paramTableElement = doc.getElementById( "parameter-table" ); //NON-NLS
  if ( paramTableElement instanceof XulDrillDownParameterTable ) {
    final XulDrillDownParameterTable parameterTable = (XulDrillDownParameterTable) paramTableElement;
    table = parameterTable.getTable();
    table.setExtraFields( fields );
    table.setReportDesignerContext( reportDesignerContext );
    table.setDrillDownParameter( model.getDrillDownParameter() );
    table.setHideParameterUi( model.getDrillDownConfig().endsWith( "-no-parameter" ) );
    table.addPropertyChangeListener( DrillDownParameterTable.DRILL_DOWN_PARAMETER_PROPERTY, new TableModelBinding() );
  }

  if ( model.isLimitedEditor() ) {
    final XulComponent tooltipAndTargetElement = doc.getElementById( "tooltip-and-target-panel" ); //NON-NLS
    if ( tooltipAndTargetElement != null ) {
      tooltipAndTargetElement.setVisible( false );
    }
  }

  SwingUtilities.invokeLater( new RefreshParameterTask() );
}
 
Example 26
Source Project: pentaho-kettle   Source File: DataHandlerTest.java    License: Apache License 2.0 4 votes vote down vote up
@Before
public void setUp() throws Exception {
  dataHandler = new DataHandler();
  xulDomContainer = mock( XulDomContainer.class );

  document = mock( Document.class );
  XulComponent rootElement = mock( XulComponent.class );
  when( document.getRootElement() ).thenReturn( rootElement );

  // Mock the UI components

  accessBox = mock( XulListbox.class );
  when( document.getElementById( "access-type-list" ) ).thenReturn( accessBox );
  connectionBox = mock( XulListbox.class );
  when( document.getElementById( "connection-type-list" ) ).thenReturn( connectionBox );
  connectionNameBox = mock( XulTextbox.class );
  when( document.getElementById( "connection-name-text" ) ).thenReturn( connectionNameBox );
  dialogDeck = mock( XulDeck.class );
  when( document.getElementById( "dialog-panel-deck" ) ).thenReturn( dialogDeck );
  deckOptionsBox = mock( XulListbox.class );
  when( document.getElementById( "deck-options-list" ) ).thenReturn( deckOptionsBox );
  hostNameBox = mock( XulTextbox.class );
  when( document.getElementById( "server-host-name-text" ) ).thenReturn( hostNameBox );
  databaseNameBox = mock( XulTextbox.class );
  when( document.getElementById( "database-name-text" ) ).thenReturn( databaseNameBox );
  portNumberBox = mock( XulTextbox.class );
  when( document.getElementById( "port-number-text" ) ).thenReturn( portNumberBox );
  userNameBox = mock( XulTextbox.class );
  when( document.getElementById( "username-text" ) ).thenReturn( userNameBox );
  passwordBox = mock( XulTextbox.class );
  when( document.getElementById( "password-text" ) ).thenReturn( passwordBox );
  serverInstanceBox = mock( XulTextbox.class );
  when( document.getElementById( "instance-text" ) ).thenReturn( serverInstanceBox );
  when( serverInstanceBox.getValue() ).thenReturn( "instance" );
  when( serverInstanceBox.getAttributeValue( "shouldDisablePortIfPopulated" ) ).thenReturn( "true" );
  webappName = mock( XulTextbox.class );
  when( document.getElementById( "web-application-name-text" ) ).thenReturn( webappName );
  when( webappName.getValue() ).thenReturn( "webappName" );

  messageBox = mock( XulMessageBox.class );
  when( document.createElement( "messagebox" ) ).thenReturn( messageBox );
  when( xulDomContainer.getDocumentRoot() ).thenReturn( document );

  generalDatasourceWindow = mock( XulRoot.class );
  when( generalDatasourceWindow.getRootObject() ).thenReturn( mock( XulComponent.class ) );
  when( document.getElementById( "general-datasource-window" ) ).thenReturn( generalDatasourceWindow );
  dataHandler.setXulDomContainer( xulDomContainer );
}
 
Example 27
Source Project: pentaho-kettle   Source File: EESpoonPlugin.java    License: Apache License 2.0 4 votes vote down vote up
/**
 * Change the menu-item states based on Execute and Create permissions.
 * @param createPermitted
 *          - if true, we enable menu-items requiring creation permissions
 * @param executePermitted
 *          - if true, we enable menu-items requiring execute permissions
 */
void updateMenuState( boolean createPermitted, boolean executePermitted ) {
  Document doc = getDocumentRoot();
  if ( doc != null ) {
    // Main spoon menu
    ( (XulMenuitem) doc.getElementById( "process-run" ) ).setDisabled( !executePermitted ); //$NON-NLS-1$

    XulToolbarbutton transRunButton = ( (XulToolbarbutton) doc.getElementById( "trans-run" ) ); //$NON-NLS-1$
    if ( transRunButton != null ) {
      transRunButton.setDisabled( !executePermitted );
    }

    ( (XulMenuitem) doc.getElementById( "trans-preview" ) ).setDisabled( !executePermitted ); //$NON-NLS-1$
    ( (XulMenuitem) doc.getElementById( "trans-debug" ) ).setDisabled( !executePermitted ); //$NON-NLS-1$
    ( (XulMenuitem) doc.getElementById( "trans-replay" ) ).setDisabled( !executePermitted ); //$NON-NLS-1$
    ( (XulMenuitem) doc.getElementById( "trans-verify" ) ).setDisabled( !executePermitted ); //$NON-NLS-1$
    ( (XulMenuitem) doc.getElementById( "trans-impact" ) ).setDisabled( !executePermitted ); //$NON-NLS-1$
    ( (XulMenuitem) doc.getElementById( "trans-get-sql" ) ).setDisabled( !executePermitted ); //$NON-NLS-1$

    // Disable Show Last menu under the Action menu.
    ( (XulMenu) doc.getElementById( "trans-last" ) ).setDisabled( !executePermitted ); //$NON-NLS-1$

    // Schedule is a plugin
    if ( doc.getElementById( "trans-schedule" ) != null ) {
      ( (XulMenuitem) doc.getElementById( "trans-schedule" ) ).setDisabled( !executePermitted ); //$NON-NLS-1$
    }

    // Main spoon toolbar
    ( (XulToolbarbutton) doc.getElementById( "toolbar-file-new" ) ).setDisabled( !createPermitted ); //$NON-NLS-1$
    ( (XulToolbarbutton) doc.getElementById( "toolbar-file-save" ) ).setDisabled( !createPermitted ); //$NON-NLS-1$
    ( (XulToolbarbutton) doc.getElementById( "toolbar-file-save-as" ) ).setDisabled( !createPermitted ); //$NON-NLS-1$

    // Popup menus
    ( (XulMenuitem) doc.getElementById( "trans-class-new" ) ).setDisabled( !createPermitted ); //$NON-NLS-1$
    ( (XulMenuitem) doc.getElementById( "job-class-new" ) ).setDisabled( !createPermitted ); //$NON-NLS-1$

    // Main spoon menu
    ( (XulMenu) doc.getElementById( "file-new" ) ).setDisabled( !createPermitted ); //$NON-NLS-1$
    ( (XulMenuitem) doc.getElementById( "file-save" ) ).setDisabled( !createPermitted ); //$NON-NLS-1$
    ( (XulMenuitem) doc.getElementById( "file-save-as" ) ).setDisabled( !createPermitted ); //$NON-NLS-1$
    ( (XulMenuitem) doc.getElementById( "file-close" ) ).setDisabled( !createPermitted ); //$NON-NLS-1$

    boolean exportAllowed = createPermitted && executePermitted;
    ( (XulMenu) doc.getElementById( "file-export" ) ).setDisabled( !exportAllowed ); //$NON-NLS-1$
    ( (XulMenuitem) doc.getElementById( "repository-export-all" ) ).setDisabled( !exportAllowed ); //$NON-NLS-1$
    ( (XulMenuitem) doc.getElementById( "file-save-as-vfs" ) ).setDisabled( !exportAllowed ); //$NON-NLS-1$
    ( (XulMenuitem) doc.getElementById( "edit-cut-steps" ) ).setDisabled( !exportAllowed ); //$NON-NLS-1$
    ( (XulMenuitem) doc.getElementById( "edit-copy-steps" ) ).setDisabled( !exportAllowed ); //$NON-NLS-1$
    ( (XulMenuitem) doc.getElementById( "edit.copy-file" ) ).setDisabled( !exportAllowed ); //$NON-NLS-1$
    ( (XulMenuitem) doc.getElementById( "edit-paste-steps" ) ).setDisabled( !exportAllowed ); //$NON-NLS-1$

    XulMenuitem transCopyContextMenu = ( (XulMenuitem) doc.getElementById( "trans-graph-entry-copy" ) ); //$NON-NLS-1$
    if ( transCopyContextMenu != null ) {
      transCopyContextMenu.setDisabled( !exportAllowed );
    }
  }
}
 
Example 28
Source Project: pentaho-kettle   Source File: ModelerHelper.java    License: Apache License 2.0 4 votes vote down vote up
public void updateMenu(Document doc) {
  // Nothing so far.
}
 
Example 29
@Before
public void setUp() throws Exception {
  /*
   * In this integration test, we want to mock only the XUL framework, all other components
   * we want to be the "real" ones.  This will allow us to test application behavior without
   * dependency on a UI.
   */
  context = new JUnit4Mockery();
  doc = context.mock(Document.class);
  container = context.mock(XulDomContainer.class);

  // need some expectations here as setXulDomContainer calls getDocumentRoot on the container
  context.checking(new Expectations() {
    {
      allowing(container).getDocumentRoot();
      will(returnValue(doc));
      allowing(container).addEventHandler(with(any(XulEventHandler.class)));
      allowing(doc).addOverlay(with(any(String.class)));
      ignoring(container);
      allowing(doc).getElementById(with(aNonNull(String.class)));
      will(returnValue(context.mock(XulComponent.class, Long.toString(System.currentTimeMillis()))));
      allowing(doc).addInitializedBinding(with(any(Binding.class)));
      allowing(doc).invokeLater(with(any(Runnable.class))); //don't care if the controller uses invokeLater or not, this is UI stuff
    }
  });

  schemaProvider.setXulDomContainer(container);


  //In order to really make this an integration test, there needs to be a BindingFactory that is injected into the controller
  //so we can mock or stub it out and allow the object->object bindings to actually be bound while the xulcomponent bindings
  //are consumed.  Here we are proxying the BindingFactory to acheive this.
  bindingFactory.setDocument(doc);
  //setup the proxy binding factory that will ignore all XUL stuff
  XulSupressingBindingFactoryProxy proxy = new XulSupressingBindingFactoryProxy();
  proxy.setProxiedBindingFactory(bindingFactory);
  schemaProvider.setBindingFactory(proxy);

  schemaProvider.onLoad();

  eventRecorder = new EventRecorder();
  eventRecorder.setLogging(true);
  eventRecorder.record(schemaProvider);
}
 
Example 30
public void setDocument(Document document) {
  //do nothing, we are ignoring all xul-specific behavior
}