org.pentaho.ui.xul.components.XulMenuitem Java Examples
The following examples show how to use
org.pentaho.ui.xul.components.XulMenuitem.
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: PrdSwingMenu.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 6 votes |
public void layout() { this.menu.removeAll(); for ( Element comp : getChildNodes() ) { if ( comp instanceof SwingMenupopup ) { for ( XulComponent compInner : comp.getChildNodes() ) { if ( compInner.isVisible() == false ) { continue; } if ( compInner instanceof XulMenuseparator ) { menu.addSeparator(); } else if ( compInner instanceof SwingMenu ) { menu.add( (JMenu) compInner.getManagedObject() ); } else if ( compInner instanceof XulMenuitem ) { menu.add( (JMenuItem) compInner.getManagedObject() ); } } } } initialized = true; }
Example #2
Source File: RecentFilesUpdateHandler.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 5 votes |
public RecentFilesUpdateHandler( final ReportDesignerContext context, final XulMenupopup reopenMenu, final XulMenuitem clearMenu ) { this.context = context; this.xulDesignerFrame = context.getView(); this.reopenMenu = reopenMenu; this.clearMenu = clearMenu; }
Example #3
Source File: ReportDesignerFrame.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 5 votes |
private void createRecentFilesMenu() { final XulMenupopup reopenMenu = context.getView().getXulComponent( "file-reopen-popup", XulMenupopup.class ); // NON-NLS final XulMenuitem clearMenuitem = context.getView().getXulComponent( "file-clear-recent", XulMenuitem.class );// NON-NLS if ( reopenMenu != null && clearMenuitem != null ) { final RecentFilesUpdateHandler updateHandler = new RecentFilesUpdateHandler( context, reopenMenu, clearMenuitem ); updateHandler.settingsChanged(); context.getRecentFilesModel().addSettingsListener( updateHandler ); } }
Example #4
Source File: TransGraphTest.java From pentaho-kettle with Apache License 2.0 | 5 votes |
@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 #5
Source File: SpoonMenuLockController.java From pentaho-kettle with Apache License 2.0 | 5 votes |
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 #6
Source File: RepositoryLockController.java From pentaho-kettle with Apache License 2.0 | 5 votes |
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 #7
Source File: SpoonLockController.java From pentaho-kettle with Apache License 2.0 | 4 votes |
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$ } }
Example #8
Source File: EESpoonPlugin.java From pentaho-kettle with Apache License 2.0 | 4 votes |
/** * 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 #9
Source File: RepositoryLockControllerTest.java From pentaho-kettle with Apache License 2.0 | 4 votes |
@Test public void testBlockLock() throws Exception { RepositoryLockController repositoryLockController = new RepositoryLockController(); List<UIRepositoryObject> selectedRepoObjects = new ArrayList<>(); UIEETransformation lockObject = Mockito.mock( UIEETransformation.class ); selectedRepoObjects.add( lockObject ); Mockito.when( lockObject.isLocked() ).thenReturn( true ); ObjectId objectId = Mockito.mock( ObjectId.class ); Mockito.when( lockObject.getObjectId() ).thenReturn( objectId ); XulMenuitem lockFileMenuItem = Mockito.mock( XulMenuitem.class ); Field lockFileMenuItemField = repositoryLockController.getClass().getDeclaredField( "lockFileMenuItem" ); lockFileMenuItemField.setAccessible( true ); lockFileMenuItemField.set( repositoryLockController, lockFileMenuItem ); XulMenuitem deleteFileMenuItem = Mockito.mock( XulMenuitem.class ); Field deleteFileMenuItemField = repositoryLockController.getClass().getDeclaredField( "deleteFileMenuItem" ); deleteFileMenuItemField.setAccessible( true ); deleteFileMenuItemField.set( repositoryLockController, deleteFileMenuItem ); XulMenuitem renameFileMenuItem = Mockito.mock( XulMenuitem.class ); Field renameFileMenuItemField = repositoryLockController.getClass().getDeclaredField( "renameFileMenuItem" ); renameFileMenuItemField.setAccessible( true ); renameFileMenuItemField.set( repositoryLockController, renameFileMenuItem ); Repository repository = Mockito.mock( Repository.class ); PurRepositoryMeta repositoryMeta = Mockito.mock( PurRepositoryMeta.class ); Mockito.when( repository.getRepositoryMeta() ).thenReturn( repositoryMeta ); Field repositoryField = repositoryLockController.getClass().getDeclaredField( "repository" ); repositoryField.setAccessible( true ); repositoryField.set( repositoryLockController, repository ); ILockService service = Mockito.mock( ILockService.class ); Mockito.when( service.canUnlockFileById( objectId ) ).thenReturn( true ); Field serviceField = repositoryLockController.getClass().getDeclaredField( "service" ); serviceField.setAccessible( true ); serviceField.set( repositoryLockController, service ); repositoryLockController.setMenuItemEnabledState( selectedRepoObjects ); Assert.assertFalse( lockFileMenuItem.isDisabled() ); Mockito.verify( lockFileMenuItem ).setDisabled( false ); }