Java Code Examples for org.pentaho.ui.xul.binding.DefaultBindingFactory#setDocument()

The following examples show how to use org.pentaho.ui.xul.binding.DefaultBindingFactory#setDocument() . 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: 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 4
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 5
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 6
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$

  }
}