org.pentaho.ui.xul.containers.XulDialog Java Examples

The following examples show how to use org.pentaho.ui.xul.containers.XulDialog. 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: XulDatabaseDialog.java    From pentaho-reporting with GNU Lesser General Public License v2.1 6 votes vote down vote up
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 File: ConnectionControllerTest.java    From pentaho-aggdesigner with GNU General Public License v2.0 6 votes vote down vote up
@Test
public void testApply_Success() throws XulException, AggDesignerException {
  setupSchemaProviderDefaults();

  context.checking(new Expectations() {
    {
      //using dialog stub here instead of a mock so we get thread blocking which is needed to have this test run sucessfully
      final XulDialog waitDialog = new XulDialogStub();
      allowing(doc).getElementById(ConnectionController.ANON_WAIT_DIALOG);
      will(returnValue(waitDialog));

      one(model).setCubeNames(cubeNames);
      one(model).setSelectedSchemaModel(providerModel);
    }
  });

  controller.apply();
}
 
Example #3
Source File: ConnectionControllerTest.java    From pentaho-aggdesigner with GNU General Public License v2.0 6 votes vote down vote up
@Test
public void testLoadDatabaseDialog() {
  final XulDialog dialog = context.mock(XulDialog.class);
  context.checking(new Expectations() {
    {
      one(doc).getElementById(ConnectionController.GENERAL_DATASOURCE_WINDOW);
      will(returnValue(dialog));
      one(dialog).show();
      allowing(dataHandler).setData(with(any(DatabaseMeta.class)));
      allowing(dataHandler).getData();
      will(returnValue(new DatabaseMeta()));
      allowing(model).getDatabaseMeta();
      will(returnValue(new DatabaseMeta()));
      one(model).setDatabaseMeta(with(any(DatabaseMeta.class)));
    }
  });
  controller.loadDatabaseDialog();
}
 
Example #4
Source File: ExportHandlerTest.java    From pentaho-aggdesigner with GNU General Public License v2.0 6 votes vote down vote up
@Test
public void testStartExecuteDdl() {
  final XulDialog diag = context.mock(XulDialog.class);
  context.checking(new Expectations() {
    {
      // get progress dialog
      one(doc).getElementById(with(any(String.class)));
      will(returnValue(diag));
      one(executor).execute(with(any(new String[0].getClass())), with(any(ExecutorCallback.class)));
      one(diag).show();
    }
  });
  controller.startExecuteDdl();

  // WG: The reason this test case was failing has to do with the Thread in startExecuteDdl.  
  // This test passes if given enough time to call execute() within the thread. as a temporary
  // solution, I added a one second sleep at the end of this test to give the thread time to run.

  // see this article for ideas on how to resolve this:
  // http://www.jmock.org/threads.html

  try {
    Thread.sleep(1000);
  } catch (Exception e) {
  }
}
 
Example #5
Source File: XulStepFieldsDialog.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
public void open( boolean isAcceptButtonHidden ) {
  try {
    KettleXulLoader theLoader = new KettleXulLoader();
    theLoader.setOuterContext( this.shell );
    theLoader.setSettingsManager( XulSpoonSettingsManager.getInstance() );
    this.container = theLoader.loadXul( XUL );

    this.controller =
      new XulStepFieldsController( this.shell, this.databaseMeta, this.schemaTableCombo, this.rowMeta );
    this.controller.setShowAcceptButton( isAcceptButtonHidden );
    this.container.addEventHandler( this.controller );

    this.runner = new SwtXulRunner();
    this.runner.addContainer( this.container );
    this.runner.initialize();

    XulDialog thePreviewDialog =
      (XulDialog) this.container.getDocumentRoot().getElementById( "stepFieldsDialog" );
    thePreviewDialog.show();
    ( (SwtDialog) thePreviewDialog ).dispose();
  } catch ( Exception e ) {
    logger.info( e );
  }
}
 
Example #6
Source File: XulPreviewRowsDialog.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
public void open() {
  try {
    KettleXulLoader theLoader = new KettleXulLoader();
    theLoader.setSettingsManager( XulSpoonSettingsManager.getInstance() );
    theLoader.setOuterContext( this.shell );
    this.container = theLoader.loadXul( XUL );

    this.controller =
      new XulPreviewRowsController( this.shell, this.databaseMeta, this.schema, this.table, this.limit );
    this.container.addEventHandler( this.controller );

    this.runner = new SwtXulRunner();
    this.runner.addContainer( this.container );
    this.runner.initialize();

    XulDialog thePreviewDialog =
      (XulDialog) this.container.getDocumentRoot().getElementById( "previewRowsDialog" );
    thePreviewDialog.show();

  } catch ( Exception e ) {
    logger.info( e );
  }
}
 
Example #7
Source File: BaseStepGenericXulDialog.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
protected void initializeXul( XulLoader loader, BindingFactory bindingFactory, XulRunner runner, Object parent ) throws XulException {
  bf = bindingFactory;
  this.runner = runner;
  loader.registerClassLoader( getClass().getClassLoader() );
  loader.setSettingsManager( getSettingsManager() );
  loader.setOuterContext( parent );
  container = loader.loadXul( xulFile, getResourceBundle() );
  bf.setDocument( container.getDocumentRoot() );

  for ( XulEventHandler h : getEventHandlers() ) {
    container.addEventHandler( h );
  }

  this.runner.addContainer( container );

  // try and get the dialog
  xulDialog = (XulDialog) container.getDocumentRoot().getRootElement();
  runner.initialize();
}
 
Example #8
Source File: AbstractPreviewRowsXulDialog.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
protected void initializeXul( XulLoader loader, BindingFactory bindingFactory, XulRunner runner, Object parent ) throws XulException {

    bf = bindingFactory;
    this.runner = runner;

    loader.registerClassLoader( getClass().getClassLoader() );
    loader.setSettingsManager( getSettingsManager() );
    loader.setOuterContext( parent );

    container = loader.loadXul( xulFile, getResourceBundle() );

    bf.setDocument( container.getDocumentRoot() );

    for ( XulEventHandler h : getEventHandlers() ) {
      container.addEventHandler( h );
    }

    this.runner.addContainer( container );

    // try and get the dialog
    xulDialog = (XulDialog) container.getDocumentRoot().getRootElement();
    runner.initialize();
  }
 
Example #9
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 #10
Source File: ConnectionController.java    From pentaho-aggdesigner with GNU General Public License v2.0 5 votes vote down vote up
@RequestHandler
public void loadDatabaseDialog() {
  dataHandler.setData(connectionModel.getDatabaseMeta());

  XulDialog dialog = (XulDialog) document.getElementById(GENERAL_DATASOURCE_WINDOW);
  dialog.show();

  DatabaseMeta databaseMeta = (DatabaseMeta) dataHandler.getData();

  if (databaseMeta != null) {
    connectionModel.setDatabaseMeta(databaseMeta);
  }
}
 
Example #11
Source File: ConnectionController.java    From pentaho-aggdesigner with GNU General Public License v2.0 5 votes vote down vote up
@RequestHandler
public void connectErrorDialogDismiss() {
  XulDialog connectErrorDialog = (XulDialog) document.getElementById(CONNECT_ERROR_DIALOG);
  Assert.notNull(connectErrorDialog, "missing element from document");
  if (!connectErrorDialog.isHidden()) {
    connectErrorDialog.hide();
  }
}
 
Example #12
Source File: ExportHandler.java    From pentaho-aggdesigner with GNU General Public License v2.0 5 votes vote down vote up
public void startExecuteDml() {
  if (logger.isDebugEnabled()) {
    logger.debug("enter startExecuteDdlDml");
  }

  XulDialog dialog = (XulDialog) document.getElementById(ELEM_ID_EXEC_PROGRESS_DIALOG);
  Assert.notNull(dialog, "could not find element with id '" + ELEM_ID_EXEC_PROGRESS_DIALOG + "'");

  final ExecutorCallback cb = new ExecutorCallback() {
    public void executionComplete(Exception e) {
      ExportHandler.this.done(e);
    }
  };

  new Thread() {

    @Override
    public void run() {
      if (logger.isDebugEnabled()) {
        logger.debug("enter run");
      }

      List<String> sqls = ExportHandler.this.getOutput(false, true);

      ExportHandler.this.ddlDmlExecutor.execute(sqls.toArray(new String[0]), cb);

      if (logger.isDebugEnabled()) {
        logger.debug("exit run");
      }

    }

  }.start();

  dialog.show();
  if (logger.isDebugEnabled()) {
    logger.debug("exit startExecuteDdlDml");
  }
}
 
Example #13
Source File: ExportHandler.java    From pentaho-aggdesigner with GNU General Public License v2.0 5 votes vote down vote up
public void openDialog() throws Exception {
  if (getEnabledAggs().size() == 0) {
    XulMessageBox msgBox = (XulMessageBox) document.createElement(ELEM_ID_MESSAGEBOX);
    msgBox.setMessage(Messages.getString("ExportHandler.NoAggsDefinedOrEnabled")); //$NON-NLS-1$
    msgBox.open();

    logger.info("Exiting showRelationalPreview as there are no Aggs defined");
    return;
  }
  XulDialog dialog = (XulDialog) document.getElementById(ELEM_ID_EXPORT_DIALOG);
  dialog.show();
}
 
Example #14
Source File: ExportHandlerTest.java    From pentaho-aggdesigner with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void testOpenDialogWithAggs() throws Exception {
  final XulDialog diag = context.mock(XulDialog.class);
  context.checking(new Expectations() {
    {
      // show export dialog
      one(doc).getElementById(with(any(String.class)));
      will(returnValue(diag));
      one(diag).show();
    }
  });
  aggList.addAgg(new UIAggregateImpl());
  controller.openDialog();
}
 
Example #15
Source File: ExportHandlerTest.java    From pentaho-aggdesigner with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void testShowPreviewWithAggs() throws Exception {
  final XulDialog diag = context.mock(XulDialog.class);
  final XulTextbox textbox = context.mock(XulTextbox.class);
  final XulComponent ignored = context.mock(XulComponent.class);
  context.checking(new Expectations() {
    {
      // get preview dialog
      one(doc).getElementById(with(any(String.class)));
      will(returnValue(diag));
      // get ddl field
      one(doc).getElementById(with(any(String.class)));
      will(returnValue(textbox));
      one(outputService).getFullArtifact(with(any(List.class)), with(equal(CreateScriptGenerator.class)));
      one(textbox).setValue(with(any(String.class)));
      // get dml field
      one(doc).getElementById(with(any(String.class)));
      will(returnValue(textbox));
      // get dml tab (if exists)
      one(doc).getElementById(with(any(String.class)));
      // returnValue doesn't matter as long as not null
      will(returnValue(ignored));
      one(outputService).getFullArtifact(with(any(List.class)), with(equal(PopulateScriptGenerator.class)));
      one(textbox).setValue(with(any(String.class)));
      // get olap field
      one(doc).getElementById(with(any(String.class)));
      will(returnValue(textbox));
      one(outputService).getFullArtifact(with(any(List.class)), with(equal(SchemaGenerator.class)));
      one(textbox).setValue(with(any(String.class)));
      one(diag).show();
    }
  });
  aggList.addAgg(new UIAggregateImpl());
  controller.showPreview();
}
 
Example #16
Source File: RepositoryConfigController.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
private void createBindings() {
  repositoryConfigDialog = (XulDialog) document.getElementById( "repository-config-dialog" );//$NON-NLS-1$
  url = (XulTextbox) document.getElementById( "repository-url" );//$NON-NLS-1$
  name = (XulTextbox) document.getElementById( "repository-name" );//$NON-NLS-1$
  id = (XulTextbox) document.getElementById( "repository-id" );//$NON-NLS-1$
  modificationComments = (XulCheckbox) document.getElementById( "repository-modification-comments" );//$NON-NLS-1$
  okButton = (XulButton) document.getElementById( "repository-config-dialog_accept" ); //$NON-NLS-1$
  bf.setBindingType( Type.BI_DIRECTIONAL );
  bf.createBinding( model, "url", url, "value" );//$NON-NLS-1$ //$NON-NLS-2$
  bf.createBinding( model, "name", name, "value" );//$NON-NLS-1$ //$NON-NLS-2$
  bf.createBinding( model, "id", id, "value" );//$NON-NLS-1$ //$NON-NLS-2$
  bf.createBinding( model, "modificationComments", modificationComments, "checked" );//$NON-NLS-1$ //$NON-NLS-2$
  bf.setBindingType( Type.ONE_WAY );
  bf.createBinding( model, "valid", okButton, "!disabled" );//$NON-NLS-1$ //$NON-NLS-2$
}
 
Example #17
Source File: DataHandler.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
private void close() {
  XulComponent window = document.getElementById( "general-datasource-window" );

  if ( window == null ) { // window must be root
    window = document.getRootElement();
  }
  if ( window instanceof XulDialog ) {
    ( (XulDialog) window ).hide();
  } else if ( window instanceof XulWindow ) {
    ( (XulWindow) window ).close();
  }
}
 
Example #18
Source File: XulDatabaseExplorerDialog.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
public boolean open() {
  try {

    KettleXulLoader theLoader = new KettleXulLoader();
    theLoader.setSettingsManager( XulSpoonSettingsManager.getInstance() );
    theLoader.setSettingsManager( new DefaultSettingsManager( new File( Const.getKettleDirectory()
      + Const.FILE_SEPARATOR + "xulSettings.properties" ) ) );
    theLoader.setOuterContext( this.shell );

    this.container = theLoader.loadXul( XUL, new XulDatabaseExplorerResourceBundle() );

    XulDialog theExplorerDialog =
      (XulDialog) this.container.getDocumentRoot().getElementById( "databaseExplorerDialog" );

    SpoonPluginManager.getInstance().applyPluginsForContainer( "database_dialog", container );

    this.controller =
      new XulDatabaseExplorerController(
        this.shell, this.databaseMeta, this.databases, look );

    this.container.addEventHandler( this.controller );

    this.runner = new SwtXulRunner();
    this.runner.addContainer( this.container );

    this.runner.initialize();

    this.controller.setSelectedSchemaAndTable( schemaName, selectedTable );

    // show dialog if connection is success only.
    if ( controller.getActionStatus() == UiPostActionStatus.OK ) {
      theExplorerDialog.show();
    }

  } catch ( Exception e ) {
    LogChannel.GENERAL.logError( "Error exploring database", e );
  }
  return this.controller.getSelectedTable() != null;
}
 
Example #19
Source File: DataSourceAndQueryStep.java    From pentaho-reporting with GNU Lesser General Public License v2.1 5 votes vote down vote up
public void createDataFactory() {
  final XulDialog datasourceType = (XulDialog) getDocument().getElementById( DATASOURCE_TYPE_DIALOG_ID );
  datasourceType.setVisible( true );
  final XulListbox box = (XulListbox) getDocument().getElementById( DATASOURCE_SELECTIONS_BOX_ID );
  final XulEditorDataFactoryMetaData myEditData = (XulEditorDataFactoryMetaData) box.getSelectedItem();
  if ( myEditData != null ) {
    editOrCreateDataFactory( myEditData.getMetadata() );
  }
  box.setSelectedIndices( new int[ 0 ] );  // clear the selection for next time.
}
 
Example #20
Source File: XulStepFieldsController.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
public void editOriginStep() {
  StepFieldNode theSelectedStep = (StepFieldNode) this.stepFieldsTree.getSelectedItem();
  if ( theSelectedStep != null ) {
    XulDialog theStepsDialog = (XulDialog) document.getElementById( "stepFieldsDialog" );
    theStepsDialog.hide();
  }
}
 
Example #21
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 #22
Source File: ExportHandlerTest.java    From pentaho-aggdesigner with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void testSaveDdl() throws Exception {
  final XulFileDialog fileBox = context.mock(XulFileDialog.class);
  final XulDialog diag = context.mock(XulDialog.class);
  final File tmpFile = File.createTempFile("whatever", ".sql");
  // save path so that it can be deleted after test
  tmpFilePath = tmpFile.getAbsolutePath();
  context.checking(new Expectations() {
    {
      // show error messagebox stating no aggs
      one(doc).createElement(with(equal("filedialog")));
      will(returnValue(fileBox));
      ignoring(doc).getElementById(with(any(String.class)));
      will(returnValue(diag));
      ignoring(diag).getRootObject();
      will(returnValue(null));
      one(fileBox).setModalParent(with(any(Object.class)));
      one(fileBox).showSaveDialog();
      will(returnValue(RETURN_CODE.OK));
      one(fileBox).getFile();
      will(returnValue(tmpFile));
    }
  });
  UIAggregate agg = new UIAggregateImpl();
  agg.setEnabled(false);
  aggList.addAgg(agg);
  controller.saveDdl();
  System.out.println(FileUtils.readFileToString(new File(tmpFilePath)));
}
 
Example #23
Source File: ExportHandlerTest.java    From pentaho-aggdesigner with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void testSaveDml() throws Exception {
  final XulFileDialog fileBox = context.mock(XulFileDialog.class);
  final XulDialog diag = context.mock(XulDialog.class);
  final File tmpFile = File.createTempFile("whatever", ".sql");
  // save path so that it can be deleted after test
  tmpFilePath = tmpFile.getAbsolutePath();
  context.checking(new Expectations() {
    {
      // show error messagebox stating no aggs
      one(doc).createElement(with(equal("filedialog")));
      will(returnValue(fileBox));
      ignoring(doc).getElementById(with(any(String.class)));
      will(returnValue(diag));
      ignoring(diag).getRootObject();
      will(returnValue(null));
      one(fileBox).setModalParent(with(any(Object.class)));
      one(fileBox).showSaveDialog();
      will(returnValue(RETURN_CODE.OK));
      one(fileBox).getFile();
      will(returnValue(tmpFile));
    }
  });
  UIAggregate agg = new UIAggregateImpl();
  agg.setEnabled(false);
  aggList.addAgg(agg);
  controller.saveDml();
  System.out.println(FileUtils.readFileToString(new File(tmpFilePath)));
}
 
Example #24
Source File: ExportHandlerTest.java    From pentaho-aggdesigner with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void testStartExecuteDml() {
  final XulDialog diag = context.mock(XulDialog.class);
  context.checking(new Expectations() {
    {
      // get progress dialog
      exactly(1).of(doc).getElementById(with(any(String.class)));
      will(returnValue(diag));
      String[] sql = new String[0];
      System.err.println(sql.getClass());
      System.err.println(String.class);
      System.err.println(new String[1].getClass());
      exactly(1).of(executor).execute(with(any(new String[0].getClass())), with(any(ExecutorCallback.class)));
      one(diag).show();
    }
  });
  controller.startExecuteDml();

  // WG: The reason this test case was failing has to do with the Thread in startExecuteDml.  
  // This test passes if given enough time to call execute() within the thread. as a temporary
  // solution, I added a one second sleep at the end of this test to give the thread time to run.

  // see this article for ideas on how to resolve this:
  // http://www.jmock.org/threads.html

  try {
    Thread.sleep(1000);
  } catch (Exception e) {
  }

}
 
Example #25
Source File: ExportHandlerTest.java    From pentaho-aggdesigner with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void testSaveOlap() throws Exception {
  final XulFileDialog fileBox = context.mock(XulFileDialog.class);
  final XulDialog diag = context.mock(XulDialog.class);
  final ConnectionModel connModel = context.mock(ConnectionModel.class);
  final MondrianFileSchemaModel schemaModel = context.mock(MondrianFileSchemaModel.class);
  final File tmpFile = File.createTempFile("whatever", ".sql");
  // save path so that it can be deleted after test
  tmpFilePath = tmpFile.getAbsolutePath();
  controller.setConnectionModel(connModel);
  context.checking(new Expectations() {
    {
      // show error messagebox stating no aggs
      one(doc).createElement(with(equal("filedialog")));
      will(returnValue(fileBox));
      ignoring(doc).getElementById(with(any(String.class)));
      will(returnValue(diag));
      ignoring(diag).getRootObject();
      will(returnValue(null));
      one(fileBox).setModalParent(with(any(Object.class)));
      one(fileBox).showSaveDialog(with(any(File.class)));
      will(returnValue(RETURN_CODE.OK));
      one(fileBox).getFile();
      will(returnValue(tmpFile));
      exactly(2).of(connModel).getSelectedSchemaModel();
      will(returnValue(schemaModel));
      one(schemaModel).getMondrianSchemaFilename();
      will(returnValue(tmpFile.getAbsolutePath()));
      one(outputService).getFullArtifact(with(any(List.class)), with(equal(SchemaGenerator.class)));
      one(schemaModel).setMondrianSchemaFilename(with(any(String.class)));
      one(connModel).setSchemaUpToDate(true);
    }
  });
  UIAggregate agg = new UIAggregateImpl();
  agg.setEnabled(false);
  aggList.addAgg(agg);
  controller.saveOlap();
  System.out.println(FileUtils.readFileToString(new File(tmpFilePath)));
}
 
Example #26
Source File: ConnectionControllerTest.java    From pentaho-aggdesigner with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void testConnect_Success() throws AggDesignerException {
  setupSchemaProviderDefaults();
  controller.setSelectedSchemaProvider(); //mimics the apply having been pressed

  //now call connect
  context.checking(new Expectations() {
    {
      //using dialog stub here instead of a mock so we get thread blocking which is needed to have this test run sucessfully
      final XulDialog waitDialog = new XulDialogStub();
      allowing(doc).getElementById(ConnectionController.ANON_WAIT_DIALOG);
      will(returnValue(waitDialog));

      final XulDialog connDialog = context.mock(XulDialog.class);
      allowing(doc).getElementById(ConnectionController.CONNECTION_DIALOG);
      will(returnValue(connDialog));
      one(connDialog).hide();

      final Schema schema = context.mock(Schema.class);
      one(aSchemaProvider).loadSchema("testCube");
      will(returnValue(schema));

      one(model).getCubeName();
      will(returnValue("testCube"));
      one(model).setSchema(schema);
      ignoring(model).setSchemaUpToDate(with(any(Boolean.class)));

      ignoring(outputService);
    }
  });

  controller.connect();
  //make sure the all the aggdesigner functionality is enabled after a successful connection
  assertTrue(workspace.isApplicationUnlocked());
}
 
Example #27
Source File: ConnectionControllerTest.java    From pentaho-aggdesigner with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void testConnectErrorDialogDismiss_Visible() {
  context.checking(new Expectations() {
    {
      final XulDialog dialog = context.mock(XulDialog.class);
      allowing(doc).getElementById(ConnectionController.CONNECT_ERROR_DIALOG);
      will(returnValue(dialog));
      allowing(dialog).isHidden();
      will(returnValue(false));
      one(dialog).hide();
    }
  });
  controller.connectErrorDialogDismiss();
}
 
Example #28
Source File: ConnectionControllerTest.java    From pentaho-aggdesigner with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void testHideConnectionDialog() {
  context.checking(new Expectations() {
    {
      final XulDialog dialog = context.mock(XulDialog.class);
      allowing(doc).getElementById(ConnectionController.CONNECTION_DIALOG);
      will(returnValue(dialog));
      one(dialog).hide();
    }
  });

  controller.hideConnectionDialog();
}
 
Example #29
Source File: ConnectionControllerTest.java    From pentaho-aggdesigner with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void testShowConnectionDialog() {
  context.checking(new Expectations() {
    {
      final XulDialog dialog = context.mock(XulDialog.class);
      allowing(doc).getElementById(ConnectionController.CONNECTION_DIALOG);
      will(returnValue(dialog));
      one(dialog).show();
    }
  });

  controller.showConnectionDialog();
}
 
Example #30
Source File: ConnectionControllerTest.java    From pentaho-aggdesigner with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void testConnectErrorDialogDismiss_NotVisible() {
  context.checking(new Expectations() {
    {
      final XulDialog dialog = context.mock(XulDialog.class);
      allowing(doc).getElementById(ConnectionController.CONNECT_ERROR_DIALOG);
      will(returnValue(dialog));
      allowing(dialog).isHidden();
      will(returnValue(true));
      never(dialog).hide();
    }
  });
  controller.connectErrorDialogDismiss();
}