org.pentaho.ui.xul.binding.DefaultBindingFactory Java Examples

The following examples show how to use org.pentaho.ui.xul.binding.DefaultBindingFactory. 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: AbsContextMenuController.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
public void init( Repository repository ) throws ControllerInitializationException {
  try {
    if ( repository.hasService( IAbsSecurityProvider.class ) ) {
      service = (IAbsSecurityProvider) repository.getService( IAbsSecurityProvider.class );
      bf = new DefaultBindingFactory();
      bf.setDocument( this.getXulDomContainer().getDocumentRoot() );

      if ( bf != null ) {
        createBindings();
      }
      setAllowed( allowedActionsContains( service, IAbsSecurityProvider.CREATE_CONTENT_ACTION ) );
    }
  } catch ( KettleException e ) {
    throw new ControllerInitializationException( e );
  }
}
 
Example #2
Source File: RevisionController.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
public void init( Repository repository ) throws ControllerInitializationException {
  try {
    this.repository = repository;
    mainController = (MainController) this.getXulDomContainer().getEventHandler( "mainController" ); //$NON-NLS-1$
    browseController = (BrowseController) this.getXulDomContainer().getEventHandler( "browseController" ); //$NON-NLS-1$
    bf = new DefaultBindingFactory();
    bf.setDocument( this.getXulDomContainer().getDocumentRoot() );

    messageBox = (XulMessageBox) document.createElement( "messagebox" ); //$NON-NLS-1$
    createBindings();
  } catch ( Exception e ) {
    if ( mainController == null || !mainController.handleLostRepository( e ) ) {
      throw new ControllerInitializationException( e );
    }
  }
}
 
Example #3
Source File: EmbeddedWizard.java    From pentaho-reporting with GNU Lesser General Public License v2.1 5 votes vote down vote up
private void init() {
  dataSourceAndQueryStep = new DataSourceAndQueryStep();

  wizardController = new LinearWizardController( new WizardEditorModel(), new DefaultBindingFactory() );

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

  wizardController.addPropertyChangeListener( WizardController.CANCELLED_PROPERTY_NAME, new CancelHandler() );
  wizardController.addPropertyChangeListener( WizardController.FINISHED_PROPERTY_NAME, new FinishedHandler() );
}
 
Example #4
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 #5
Source File: AbstractMqlEditor.java    From mql-editor with GNU Lesser General Public License v2.1 5 votes vote down vote up
private void init() {
  try {

    XulLoader loader = getLoader();
    loader.setOuterContext( parentWindow );
    container = loader.loadXul( "org/pentaho/commons/metadata/mqleditor/editor/xul/mainFrame.xul" );

    getRunner().addContainer( container );

    BindingFactory bf = new DefaultBindingFactory();
    bf.setDocument( container.getDocumentRoot() );

    mainController.setBindingFactory( bf );
    selectedColumnController.setBindingFactory( bf );
    constraintController.setBindingFactory( bf );
    orderController.setBindingFactory( bf );
    previewController.setBindingFactory( bf );

    container.addEventHandler( mainController );
    container.addEventHandler( selectedColumnController );
    container.addEventHandler( constraintController );
    container.addEventHandler( orderController );
    container.addEventHandler( previewController );

    mainController.setWorkspace( workspace );
    selectedColumnController.setWorkspace( workspace );
    constraintController.setWorkspace( workspace );
    orderController.setWorkspace( workspace );
    previewController.setWorkspace( workspace );

  } catch ( XulException e ) {
    log.error( "error loading Xul application", e );
  }
}
 
Example #6
Source File: XulPreviewRowsController.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
public XulPreviewRowsController( Shell aShell, DatabaseMeta aDatabaseMeta, String aSchema, String aTable,
  int aLimit ) {
  this.shell = aShell;
  this.databaseMeta = aDatabaseMeta;
  this.schema = aSchema;
  this.table = aTable;
  this.limit = aLimit;
  this.bf = new DefaultBindingFactory();
}
 
Example #7
Source File: XulStepFieldsController.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
public XulStepFieldsController( Shell aShell, DatabaseMeta aDatabaseMeta, String schemaTableCombo,
  RowMetaInterface anInput ) {
  this.shell = aShell;
  this.databaseMeta = aDatabaseMeta;
  this.schemaTableCombo = schemaTableCombo;
  this.bf = new DefaultBindingFactory();
  this.model = new XulStepFieldsModel();
  this.rowMetaInterface = anInput;
}
 
Example #8
Source File: XulDatabaseExplorerController.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
public XulDatabaseExplorerController( Shell shell, DatabaseMeta databaseMeta, List<DatabaseMeta> databases,
  boolean aLook ) {
  this.model = new XulDatabaseExplorerModel( databaseMeta );
  this.shell = shell;
  this.bf = new DefaultBindingFactory();
  this.databases = databases;
  this.dbcache = DBCache.getInstance();
  this.isJustLook = aLook;
}
 
Example #9
Source File: RepositoryConfigController.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
public void init() throws ControllerInitializationException {
  bf = new DefaultBindingFactory();
  bf.setDocument( this.getXulDomContainer().getDocumentRoot() );
  try {
    messageBox = (XulMessageBox) document.createElement( "messagebox" ); //$NON-NLS-1$
  } catch ( Throwable th ) {
    throw new ControllerInitializationException( th );
  }
  model = new RepositoryConfigModel();
  if ( bf != null ) {
    createBindings();
  }
  initializeModel();
}
 
Example #10
Source File: RepositoryLockController.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
public void init( Repository rep ) throws ControllerInitializationException {
  try {
    if ( rep != null && rep.hasService( ILockService.class ) ) {
      repository = rep;
      service = (ILockService) rep.getService( ILockService.class );
    } else {
      throw new ControllerInitializationException( BaseMessages.getString( PKG,
          "RepositoryLockController.ERROR_0001_UNABLE_TO_INITIAL_REPOSITORY_SERVICE", ILockService.class ) ); //$NON-NLS-1$

    }

    bindingFactory = new DefaultBindingFactory();
    bindingFactory.setDocument( getXulDomContainer().getDocumentRoot() );

    XulEventHandler eventHandler = getXulDomContainer().getEventHandler( "browseController" ); //$NON-NLS-1$

    if ( eventHandler instanceof BrowseController ) {
      browseController = (BrowseController) eventHandler;
    }

    // Disable row dragging if it is locked and the user does not have permissions
    fileTable = (XulTree) getXulDomContainer().getDocumentRoot().getElementById( "file-table" ); //$NON-NLS-1$
    folderTree = (XulTree) document.getElementById( "folder-tree" ); //$NON-NLS-1$
    lockFileMenuItem = (XulMenuitem) getXulDomContainer().getDocumentRoot().getElementById( "file-context-lock" ); //$NON-NLS-1$
    deleteFileMenuItem = (XulMenuitem) getXulDomContainer().getDocumentRoot().getElementById( "file-context-delete" ); //$NON-NLS-1$
    renameFileMenuItem = (XulMenuitem) getXulDomContainer().getDocumentRoot().getElementById( "file-context-rename" ); //$NON-NLS-1$

    messageBox = (XulMessageBox) document.createElement( "messagebox" ); //$NON-NLS-1$

    createBindings();
  } catch ( Exception e ) {
    throw new RuntimeException( e );
  }
}
 
Example #11
Source File: DefaultXulDrillDownController.java    From pentaho-reporting with GNU Lesser General Public License v2.1 4 votes vote down vote up
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 #12
Source File: FileOverwriteDialogController.java    From pentaho-kettle with Apache License 2.0 4 votes vote down vote up
protected FileOverwriteDialogController( XulDomContainer container, List<UIRepositoryObject> objects ) {
  this.container = container;
  this.objects = new UIRepositoryObjectsList( objects );
  this.dialog = (XulDialog) this.container.getDocumentRoot().getElementById( "file-overwrite-dialog" );
  this.bf = new DefaultBindingFactory();
}
 
Example #13
Source File: SpoonLockController.java    From pentaho-kettle with Apache License 2.0 4 votes vote down vote up
protected void init() {
  try {
    if ( ( Spoon.getInstance().getRepository() != null )
        && ( Spoon.getInstance().getRepository().hasService( IAbsSecurityProvider.class ) ) ) {
      IAbsSecurityProvider securityService =
          (IAbsSecurityProvider) Spoon.getInstance().getRepository().getService( IAbsSecurityProvider.class );

      setCreateAllowed( allowedActionsContains( securityService, IAbsSecurityProvider.CREATE_CONTENT_ACTION ) );
    }

    shell = ( ( (Spoon) SpoonFactory.getInstance() ).getShell() );
    XulDomContainer container = getXulDomContainer();

    bindingFactory = new DefaultBindingFactory();
    bindingFactory.setDocument( container.getDocumentRoot() );

    bindingFactory.setBindingType( Type.ONE_WAY );

    bindingFactory.createBinding( this, "activeMetaUnlocked", "lock-context-locknotes", "disabled" ); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
    bindingFactory.createBinding( this, "lockingNotAllowed", "lock-context-lock", "disabled" ); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$

    // Get trans* object to gain access to the *Meta object to determine if we are initially locked or not
    // Try transformation
    if ( container.getEventHandlers().containsKey( "transgraph" ) ) { //$NON-NLS-1$
      workingMeta = ( (TransGraph) container.getEventHandler( "transgraph" ) ).getMeta(); //$NON-NLS-1$
    } else if ( container.getEventHandlers().containsKey( "jobgraph" ) ) { //$NON-NLS-1$
      workingMeta = ( (JobGraph) container.getEventHandler( "jobgraph" ) ).getMeta(); //$NON-NLS-1$
    }

    RepositoryLock repoLock = fetchRepositoryLock( workingMeta );
    if ( repoLock != null ) {
      XulMenuitem lockMenuItem = (XulMenuitem) container.getDocumentRoot().getElementById( "lock-context-lock" ); //$NON-NLS-1$
      lockMenuItem.setSelected( true );
      // Permit locking/unlocking if the user owns the lock
      if ( Spoon.getInstance().getRepository() instanceof PurRepository ) {
        setLockingAllowed( new UnifiedRepositoryLockService(
            ( (PurRepository) Spoon.getInstance().getRepository() ).getUnderlyingRepository() )
                .canUnlockFileById( workingMeta.getObjectId() ) );
      } else {
        setLockingAllowed( repoLock.getLogin().equalsIgnoreCase(
            Spoon.getInstance().getRepository().getUserInfo().getLogin() ) );
      }
    } else {
      setLockingAllowed( true );
    }

    firePropertyChange( "activeMetaUnlocked", null, repoLock == null ); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
  } catch ( Exception e ) {
    log.error( BaseMessages.getString( PKG, "LockController.NoLockingSupport" ), e );//$NON-NLS-1$
    new ErrorDialog( ( (Spoon) SpoonFactory.getInstance() ).getShell(),
        BaseMessages.getString( PKG, "Dialog.Error" ), e.getMessage(), e ); //$NON-NLS-1$

  }
}