Java Code Examples for org.pentaho.ui.xul.XulException

The following examples show how to use org.pentaho.ui.xul.XulException. 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
Source Project: kettle-beam   Source File: BeamPerspective.java    License: Apache License 2.0 6 votes vote down vote up
public XulTabAndPanel createTab() {

    try {
      XulTab tab = (XulTab) document.createElement( "tab" );
      XulTabpanel panel = (XulTabpanel) document.createElement( "tabpanel" );
      panel.setSpacing( 0 );
      panel.setPadding( 0 );

      tabs.addChild( tab );
      panels.addChild( panel );
      tabbox.setSelectedIndex( panels.getChildNodes().indexOf( panel ) );


      tab.addPropertyChangeListener( new PropertyChangeListener() {
        @Override public void propertyChange( PropertyChangeEvent evt ) {
          LogChannel.GENERAL.logBasic( "Property changed: " + evt.getPropertyName() + ", " + evt.toString() );
        }
      } );

      return new XulTabAndPanel( tab, panel );
    } catch ( XulException e ) {
      e.printStackTrace();
    }
    return null;
  }
 
Example 2
Source Project: pentaho-kettle   Source File: StarModelerPerspective.java    License: Apache License 2.0 6 votes vote down vote up
public boolean onFileClose() {

int idx = tabbox.getSelectedIndex();
if (idx == -1 || idx >= tabbox.getTabs().getChildNodes().size()) {
	return false;
}

try {
	if (onTabClose(idx)) {
		
		XulComponent panel = panels.getChildNodes().get(idx);
		XulComponent tab = tabs.getChildNodes().get(idx);

		panels.removeChild(panel);	
		tabs.removeChild(tab);
									    								
		return true;
	}
} catch (XulException e) {
	e.printStackTrace();
}

return false;
}
 
Example 3
public XulTabAndPanel createTab() {

    try {
      XulTab tab = (XulTab) document.createElement( "tab" );
      XulTabpanel panel = (XulTabpanel) document.createElement( "tabpanel" );
      panel.setSpacing( 0 );
      panel.setPadding( 0 );

      tabs.addChild( tab );
      panels.addChild( panel );
      tabbox.setSelectedIndex( panels.getChildNodes().indexOf( panel ) );


      tab.addPropertyChangeListener( new PropertyChangeListener() {
        @Override public void propertyChange( PropertyChangeEvent evt ) {
          LogChannel.GENERAL.logBasic( "Property changed: " + evt.getPropertyName() + ", " + evt.toString() );
        }
      } );

      return new XulTabAndPanel( tab, panel );
    } catch ( XulException e ) {
      e.printStackTrace();
    }
    return null;
  }
 
Example 4
public void actionPerformed( final ActionEvent e ) {
  try {
    final Window parentWindow = LibSwingUtil.getWindowAncestor( ConnectionEditorPanel.this );
    final XulDatabaseDialog connectionDialog = new XulDatabaseDialog( parentWindow );
    final IDatabaseConnection connectionDefinition = connectionDialog.open( null );

    if ( connectionDefinition != null &&
      !StringUtils.isEmpty( connectionDefinition.getName() ) ) {
      // A new JNDI source was created
      dialogModel.createDatasource( connectionDefinition );
      dataSourceModel.addElement( connectionDefinition );
      dataSourceList.setSelectedValue( connectionDefinition, true );
    }
  } catch ( XulException e1 ) {
    UncaughtExceptionsModel.getInstance().addException( e1 );
  }
}
 
Example 5
public void actionPerformed(final ActionEvent e)
{
  final DesignTimeContext designTimeContext = getDesignTimeContext();
  try
  {
    final Window parentWindow = LibSwingUtil.getWindowAncestor(ConnectionPanel.this);
    final XulDatabaseDialog connectionDialog = new XulDatabaseDialog(parentWindow, designTimeContext);
    final JdbcConnectionDefinition connectionDefinition = connectionDialog.open(null);

    if (connectionDefinition != null &&
        !StringUtils.isEmpty(connectionDefinition.getName()))
    {
      // A new JNDI source was created
      if (getDialogModel().getConnectionDefinitionManager().updateSourceList(connectionDefinition) == false)
      {
        getDialogModel().addConnection(connectionDefinition);
        dataSourceList.setSelectedValue(connectionDefinition, true);
      }
    }
  }
  catch (XulException e1)
  {
    designTimeContext.error(e1);
  }
}
 
Example 6
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 7
/**
 * @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 8
private void insertReports( final TreeModel model,
                            final Object currentLevel,
                            final XulMenupopup popup ) throws XulException {
  final int childCount = model.getChildCount( currentLevel );
  for ( int i = 0; i < childCount; i += 1 ) {
    final ReportDesignerView frame = context.getView();

    final Object child = model.getChild( currentLevel, i );
    if ( model.isLeaf( child ) ) {
      final DefaultMutableTreeNode node = (DefaultMutableTreeNode) child;
      final File file = new File( String.valueOf( node.getUserObject() ) );
      final OpenSampleReportAction action = new OpenSampleReportAction( file, node.toString() );
      action.setReportDesignerContext( context );
      popup.addChild( frame.createMenuItem( action ) );
    } else {
      final XulMenupopup childPopup = frame.createPopupMenu( String.valueOf( child ), popup );
      insertReports( model, child, childPopup );
    }
  }
}
 
Example 9
@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 10
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 11
Source Project: pentaho-kettle   Source File: PartitionsController.java    License: Apache License 2.0 6 votes vote down vote up
protected boolean doLazyInit() {
  // Load the SWT Shell from the explorer dialog
  shell = ( (SwtDialog) document.getElementById( "repository-explorer-dialog" ) ).getShell();

  try {
    mainController = (MainController) this.getXulDomContainer().getEventHandler( "mainController" );
  } catch ( XulException e ) {
    return false;
  }

  enableButtons( true, false, false );
  bf = new SwtBindingFactory();
  bf.setDocument( this.getXulDomContainer().getDocumentRoot() );

  if ( bf != null ) {
    createBindings();
  }

  return true;
}
 
Example 12
Source Project: pentaho-kettle   Source File: SlavesController.java    License: Apache License 2.0 6 votes vote down vote up
@Override
protected boolean doLazyInit() {
  // Load the SWT Shell from the explorer dialog
  shell = ( (SwtDialog) document.getElementById( "repository-explorer-dialog" ) ).getShell();

  enableButtons( true, false, false );
  bf = new SwtBindingFactory();
  bf.setDocument( this.getXulDomContainer().getDocumentRoot() );

  try {
    mainController = (MainController) this.getXulDomContainer().getEventHandler( "mainController" );
  } catch ( XulException e ) {
    return false;
  }

  if ( bf != null ) {
    createBindings();
  }

  return true;
}
 
Example 13
Source Project: pentaho-kettle   Source File: BaseStepGenericXulDialog.java    License: 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 14
Source Project: pentaho-kettle   Source File: BaseStepGenericXulDialog.java    License: Apache License 2.0 6 votes vote down vote up
public int showPromptMessage( final String message, final String title, Object[] buttons ) {

    try {

      final XulMessageBox msg = (XulMessageBox) document.createElement( "messagebox" );
      msg.setModalParent( modalParent );
      msg.setTitle( title );
      msg.setMessage( message );
      msg.setButtons( buttons );
      return msg.open();

    } catch ( XulException e ) {
      log.logError( "Error displaying message: {0}", message );
    }
    return -1;
  }
 
Example 15
public boolean promptIfSaveRequired() throws XulException {
  // prompt to save if the app is in a non-saved state
  if (workspace.isApplicationUnlocked() && !workspace.getWorkspaceUpToDate()) {
    XulMessageBox msgBox = (XulMessageBox) document.createElement("messagebox");
    msgBox.setTitle(Messages.getString("MainController.SaveWorkspaceTitle"));
    msgBox.setMessage(Messages.getString("MainController.SaveWorkspaceMessage"));
    msgBox.setButtons(new String[]{
        Messages.getString("MainController.SaveButton"),
        Messages.getString("MainController.DoNotSaveButton"),
        Messages.getString("MainController.CancelButton")});

    int id = msgBox.open();
    if (id == 2) { // CANCEL
      return false;
    } else if (id == 0) { // SAVE
      // what if they click cancel?
      return saveWorkspace(false);
    }
  }
  return true;
}
 
Example 16
public void setConnected(boolean connected) throws XulException {
  final String OVERLAY = "org/pentaho/aggdes/ui/resources/exportDialogOverlay.xul"; //$NON-NLS-1$
  if (!connected) {
    document.removeOverlay(OVERLAY);
    overlayAdded = false;
    return;
  }

  boolean addOverlay = false;
  Class[] classes = outputService.getSupportedArtifactGeneratorClasses();
  for (Class clazz : classes) {
    if (PopulateScriptGenerator.class.isAssignableFrom(clazz)) {
      // just check for DML and assume that schema generator is there too
      addOverlay = true;
    }
  }

  if (addOverlay) {
    // don't add more than once
    if (!overlayAdded) {
      document.addOverlay(OVERLAY);
      overlayAdded = true;
    }
  }
}
 
Example 17
Source Project: pentaho-kettle   Source File: FragmentHandler.java    License: 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 18
Source Project: kettle-beam   Source File: BeamSpoonPlugin.java    License: 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 19
Source Project: pentaho-kettle   Source File: RevisionController.java    License: Apache License 2.0 5 votes vote down vote up
private SwtConfirmBox promptCommitComment( org.pentaho.ui.xul.dom.Document document ) throws XulException {
  SwtConfirmBox confirmbox = (SwtConfirmBox) document.createElement( "confirmbox" );
  confirmbox.setTitle( BaseMessages.getString( PKG, "RepositoryExplorer.CommitTitle" ) ); //$NON-NLS-1$
  confirmbox.setButtons( new DialogConstant[] { DialogConstant.OK, DialogConstant.CANCEL } );

  confirmbox.setMessage( BaseMessages.getString( PKG, "RepositoryExplorer.CommitLabel" ) ); //$NON-NLS-1$//$NON-NLS-1$
  return confirmbox;
}
 
Example 20
Source Project: kettle-beam   Source File: BeamPerspective.java    License: Apache License 2.0 5 votes vote down vote up
public boolean onTabClose( final int pos ) throws XulException {
  // Never close the admin tab
  //
  if ( pos == 0 ) {
    return false;
  }
  return true;
}
 
Example 21
@Override
public void applyToContainer( String category, XulDomContainer container ) throws XulException {
  container.registerClassLoader( getClass().getClassLoader() );
  if ( category.equals( "spoon" ) ) {
    container.loadOverlay( "neo4j_spoon_overlays.xul", resourceBundle );
    container.addEventHandler( Neo4jHelper.getInstance() );
  }
}
 
Example 22
Neo4jPerspective() throws XulException {
  KettleXulLoader loader = new KettleXulLoader();
  loader.registerClassLoader( getClass().getClassLoader() );
  container = loader.loadXul( "neo4j_perspective.xul", resourceBundle );

  try {

    document = container.getDocumentRoot();
    tabs = (XulTabs) document.getElementById( "tabs" );
    panels = (XulTabpanels) document.getElementById( "tabpanels" );
    tabbox = (XulTabbox) tabs.getParent();

    container.addEventHandler( this );
    connectionFactory = new MetaStoreFactory<>( NeoConnection.class, Spoon.getInstance().getMetaStore(), Neo4jDefaults.NAMESPACE );
    modelsFactory = new MetaStoreFactory<>( GraphModel.class, Spoon.getInstance().getMetaStore(), Neo4jDefaults.NAMESPACE );

    // addAdminTab();

    /*
     * To make compatible with webSpoon
     * Create a temporary parent for the UI and then call layout().
     * A different parent will be assigned to the UI in SpoonPerspectiveManager.PerspectiveManager.performInit().
     */
    SwtDeck deck = (SwtDeck) Spoon.getInstance().getXulDomContainer().getDocumentRoot().getElementById( "canvas-deck" );
    box = deck.createVBoxCard();
    getUI().setParent( (Composite) box.getManagedObject() );
    getUI().layout();

  } catch ( Exception e ) {
    logger.logError( "Error initializing perspective", e );
  }

}
 
Example 23
public boolean onTabClose( final int pos ) throws XulException {
  // Never close the admin tab
  //
  if ( pos == 0 ) {
    return false;
  }
  return true;
}
 
Example 24
public XulComponent createElement(String elementName) throws XulException { 
  if (elementName.equals("messagebox")) {
    return new XulMessageBoxStub();
  } else if (elementName.equals("filedialog")) {
    return new XulFileDialogStub();
  } else {
    return null;
  }
}
 
Example 25
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 26
public void actionPerformed(final ActionEvent e)
{
  final JdbcConnectionDefinition existingConnection =
      (JdbcConnectionDefinition) dataSourceList.getSelectedValue();

  final DesignTimeContext designTimeContext = getDesignTimeContext();
  try
  {
    final Window parentWindow = LibSwingUtil.getWindowAncestor(ConnectionPanel.this);
    final XulDatabaseDialog connectionDialog = new XulDatabaseDialog(parentWindow, designTimeContext);
    final JdbcConnectionDefinition connectionDefinition = connectionDialog.open(existingConnection);

    // See if the edit completed...
    if (connectionDefinition != null)
    {
      // If the name changed, delete it before the update is performed
      if (existingConnection.getName().equals(connectionDefinition.getName()) == false)
      {
        getDialogModel().getConnectionDefinitionManager().removeSource(existingConnection.getName());
      }
      final DataSourceDialogModel dialogModel = getDialogModel();
      // Add / update the JNDI source
      getDialogModel().getConnectionDefinitionManager().updateSourceList(connectionDefinition);

      dialogModel.editConnection(existingConnection, connectionDefinition);
      dataSourceList.setSelectedValue(connectionDefinition, true);
    }
  }
  catch (XulException e1)
  {
    designTimeContext.error(e1);
  }
}
 
Example 27
Source Project: pentaho-aggdesigner   Source File: UIMain.java    License: 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 28
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 29
public void createPresentationComponent( final XulDomContainer mainWizardContainer ) throws XulException {
  super.createPresentationComponent( mainWizardContainer );

  mainWizardContainer.loadOverlay( DATASOURCE_AND_QUERY_STEP_OVERLAY );
  mainWizardContainer.addEventHandler( new DatasourceAndQueryStepHandler() );
  final XulListbox box = (XulListbox) getDocument().getElementById( DATASOURCE_SELECTIONS_BOX_ID );
  box.removeItems();
  for ( final XulEditorDataFactoryMetaData dfMeta : dataFactoryMetas ) {
    box.addItem( dfMeta );
  }
  box.addPropertyChangeListener( new SelectedIndexUpdateHandler() );
}
 
Example 30
Source Project: pentaho-kettle   Source File: DataHandler.java    License: Apache License 2.0 5 votes vote down vote up
protected void showMessage( String message, boolean scroll ) {
  try {
    XulMessageBox box = (XulMessageBox) document.createElement( "messagebox" );
    box.setMessage( message );
    box.setModalParent( ( (XulRoot) document.getElementById( "general-datasource-window" ) ).getRootObject() );
    if ( scroll ) {
      box.setScrollable( true );
      box.setWidth( 500 );
      box.setHeight( 400 );
    }
    box.open();
  } catch ( XulException e ) {
    System.out.println( "Error creating messagebox " + e.getMessage() );
  }
}