org.pentaho.ui.xul.components.XulMessageBox Java Examples

The following examples show how to use org.pentaho.ui.xul.components.XulMessageBox. 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: ExportHandlerTest.java    From pentaho-aggdesigner with GNU General Public License v2.0 6 votes vote down vote up
@Test
public void testOpenDialogNoEnabledAggs() throws Exception {
  final XulMessageBox msgBox = context.mock(XulMessageBox.class);
  context.checking(new Expectations() {
    {
      // show error messagebox stating no aggs
      one(doc).createElement(with(equal("messagebox")));
      will(returnValue(msgBox));
      ignoring(msgBox).setMessage(with(any(String.class)));
      ignoring(msgBox).setTitle(with(any(String.class)));
      one(msgBox).open();
    }
  });
  UIAggregate agg = new UIAggregateImpl();
  agg.setEnabled(false);
  aggList.addAgg(agg);
  controller.openDialog();
}
 
Example #2
Source File: MainController.java    From pentaho-aggdesigner with GNU General Public License v2.0 6 votes vote down vote up
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 #3
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 #4
Source File: BaseStepGenericXulDialog.java    From pentaho-kettle with 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 #5
Source File: ChangedWarningDialog.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
protected XulMessageBox runXulChangedWarningDialog( String fileName ) throws IllegalArgumentException,
  XulException {
  container = Spoon.getInstance().getMainSpoonContainer();

  XulMessageBox messageBox = (XulMessageBox) container.getDocumentRoot().createElement( "messagebox" );
  messageBox.setTitle( BaseMessages.getString( PKG, "Spoon.Dialog.PromptSave.Title" ) );

  if ( fileName != null ) {
    messageBox.setMessage( BaseMessages.getString( PKG, "Spoon.Dialog.PromptToSave.Message", fileName ) );
  } else {
    messageBox.setMessage( BaseMessages.getString( PKG, "Spoon.Dialog.PromptSave.Message" ) );
  }

  messageBox.setButtons( new Integer[] { SWT.YES, SWT.NO, SWT.CANCEL } );

  return messageBox;
}
 
Example #6
Source File: XulDatabaseExplorerController.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
public void displayRowCount() {
  if ( this.model.getTable() == null ) {
    return;
  }
  try {
    GetTableSizeProgressDialog pd =
      new GetTableSizeProgressDialog(
        this.dbExplorerDialog.getShell(), this.model.getDatabaseMeta(), this.model.getTable(), model
          .getSchema() );
    Long theCount = pd.open();
    if ( theCount != null ) {
      XulMessageBox theMessageBox = (XulMessageBox) document.createElement( "messagebox" );
      theMessageBox.setModalParent( this.dbExplorerDialog.getShell() );
      theMessageBox.setTitle( BaseMessages.getString( PKG, "DatabaseExplorerDialog.TableSize.Title" ) );
      theMessageBox.setMessage( BaseMessages.getString(
        PKG, "DatabaseExplorerDialog.TableSize.Message", this.model.getTable(), theCount.toString() ) );
      theMessageBox.open();
    }
  } catch ( XulException e ) {
    LogChannel.GENERAL.logError( "Error displaying row count", e );
  }
}
 
Example #7
Source File: EESpoonPlugin.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
public static void updateChangedWarningDialog( boolean overrideDefaultDialogBehavior ) {
  if ( !overrideDefaultDialogBehavior ) {
    // Update the ChangedWarningDialog - Disable the yes button
    ChangedWarningDialog.setInstance( new ChangedWarningDialog() {

      public int show() {
        return show( null );
      }

      public int show( String fileName ) {
        XulMessageBox msgBox = null;
        try {
          msgBox = runXulChangedWarningDialog( fileName );
          if ( fileName != null ) {
            msgBox.setMessage( BaseMessages.getString( PKG,
                "Spoon.Dialog.PromptToSave.Fail.Message.WithParam", fileName ) ); //$NON-NLS-1$
          } else {
            msgBox.setMessage( BaseMessages.getString( PKG, "Spoon.Dialog.PromptToSave.Fail.Message" ) ); //$NON-NLS-1$
          }

          msgBox.setButtons( new Integer[] { SWT.YES | SWT.NO } );
        } catch ( Exception e ) {
          e.printStackTrace();
          throw new RuntimeException( e );
        }
        int retVal = msgBox.open();

        // Map from this question to make sense in the original context
        // (Yes = save, No = no-save , Cancel = do not disconnect)
        if ( retVal == SWT.YES ) {
          return SWT.NO;
        } else {
          return SWT.CANCEL;
        }
      }
    } );
  } else {
    ChangedWarningDialog.setInstance( new ChangedWarningDialog() );
  }
}
 
Example #8
Source File: PurRepositoryDialog.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
private void displayRepositoryAlreadyExistMessage( String name ) {
  try {
    XulMessageBox messageBox = (XulMessageBox) container.getDocumentRoot().createElement( "messagebox" );
    messageBox.setTitle( resourceBundle.getString( "Dialog.Error" ) );//$NON-NLS-1$
    messageBox.setAcceptLabel( resourceBundle.getString( "Dialog.Ok" ) );//$NON-NLS-1$
    messageBox.setMessage( BaseMessages.getString( PKG, "PurRepositoryDialog.Dialog.ErrorIdExist.Message", name ) );//$NON-NLS-1$
    messageBox.open();

  } catch ( XulException e ) {
    throw new RuntimeException( e );
  }
}
 
Example #9
Source File: RepositoryLockController.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
public void viewLockNote() throws Exception {
  List<UIRepositoryObject> selectedRepoObjects = browseController.getSelectedFileItems();
  if ( selectedRepoObjects.size() > 0 && selectedRepoObjects.get( 0 ) instanceof UIRepositoryContent ) {
    final UIRepositoryContent contentToLock = (UIRepositoryContent) selectedRepoObjects.get( 0 );

    XulMessageBox msgBox = (XulMessageBox) document.createElement( "messagebox" ); //$NON-NLS-1$
    msgBox.setTitle( BaseMessages.getString( PKG, "PurRepository.LockNote.Title" ) ); //$NON-NLS-1$
    msgBox.setMessage( ( (ILockObject) contentToLock ).getLockMessage() );

    msgBox.open();
  }
}
 
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: AbsController.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
/**
 * Save the permission for the selected system role
 */
public void applySystemRoleActionPermission() {
  XulMessageBox messageBox = this.getMessageBox();
  IUIRole role = null;
  IUIAbsRole absRole = null;
  try {
    role = absSecurity.getSelectedSystemRole();
    if ( role instanceof IUIAbsRole ) {
      absRole = (IUIAbsRole) role;
    } else {
      throw new IllegalStateException();
    }
    ( (IAbsSecurityManager) service ).setLogicalRoles( absRole.getName(), absRole.getLogicalRoles() );
    messageBox.setTitle( BaseMessages.getString( PKG, "Dialog.Success" ) );//$NON-NLS-1$
    messageBox.setAcceptLabel( BaseMessages.getString( PKG, "Dialog.Ok" ) );//$NON-NLS-1$
    messageBox.setMessage( BaseMessages.getString( PKG, "AbsController.RoleActionPermission.Success" ) );//$NON-NLS-1$
    messageBox.open();
    // Refresh permissions in open tabs
    SpoonPluginManager.getInstance().notifyLifecycleListeners(
        SpoonLifecycleListener.SpoonLifeCycleEvent.REPOSITORY_CHANGED );
  } catch ( KettleException e ) {
    messageBox.setTitle( BaseMessages.getString( PKG, "Dialog.Error" ) );//$NON-NLS-1$
    messageBox.setAcceptLabel( BaseMessages.getString( PKG, "Dialog.Ok" ) );//$NON-NLS-1$
    messageBox.setMessage( BaseMessages.getString( PKG,
        "AbsController.RoleActionPermission.UnableToApplyPermissions", role.getName(), e.getLocalizedMessage() ) );//$NON-NLS-1$
    messageBox.open();
  }
}
 
Example #12
Source File: AbsController.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
/**
 * Save the permission for the selected role
 */
public void applyRoleActionPermission() {
  XulMessageBox messageBox = this.getMessageBox();
  IUIRole role = null;
  IUIAbsRole absRole = null;
  try {
    role = absSecurity.getSelectedRole();
    if ( role instanceof IUIAbsRole ) {
      absRole = (IUIAbsRole) role;
    } else {
      throw new IllegalStateException();
    }
    ( (IAbsSecurityManager) service ).setLogicalRoles( absRole.getName(), absRole.getLogicalRoles() );
    messageBox.setTitle( BaseMessages.getString( PKG, "Dialog.Success" ) );//$NON-NLS-1$
    messageBox.setAcceptLabel( BaseMessages.getString( PKG, "Dialog.Ok" ) );//$NON-NLS-1$
    messageBox.setMessage( BaseMessages.getString( PKG, "AbsController.RoleActionPermission.Success" ) );//$NON-NLS-1$
    messageBox.open();
    // Refresh permissions in open tabs
    SpoonPluginManager.getInstance().notifyLifecycleListeners(
        SpoonLifecycleListener.SpoonLifeCycleEvent.REPOSITORY_CHANGED );
  } catch ( KettleException e ) {
    messageBox.setTitle( BaseMessages.getString( PKG, "Dialog.Error" ) );//$NON-NLS-1$
    messageBox.setAcceptLabel( BaseMessages.getString( PKG, "Dialog.Ok" ) );//$NON-NLS-1$
    messageBox.setMessage( BaseMessages.getString( PKG,
        "AbsController.RoleActionPermission.UnableToApplyPermissions", role.getName(), e.getLocalizedMessage() ) );//$NON-NLS-1$
    messageBox.open();
  }
}
 
Example #13
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 #14
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 #15
Source File: FragmentHandlerTest.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
@Test
public void testShowMessage() throws Exception {
  XulMessageBox messageBox = mock( XulMessageBox.class );
  when( document.createElement( "messagebox" ) ).thenReturn( messageBox );
  fragmentHandler.showMessage( null );

  // Generate exception, should see a message in standard output
  when( document.createElement( "messagebox" ) ).thenThrow( new XulException() );
  fragmentHandler.showMessage( "" );
}
 
Example #16
Source File: DataHandler.java    From pentaho-kettle with 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() );
  }
}
 
Example #17
Source File: FragmentHandler.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
protected void showMessage( String message ) {
  try {
    XulMessageBox box = (XulMessageBox) document.createElement( "messagebox" );
    box.setMessage( message );
    box.open();
  } catch ( XulException e ) {
    System.out.println( "Error creating messagebox " + e.getMessage() );
  }
}
 
Example #18
Source File: BaseStepGenericXulDialog.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
public void showMessage( final String message, final String title ) {

    try {

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

    } catch ( XulException e ) {
      log.logError( "Error displaying message: {0}", message );
    }

  }
 
Example #19
Source File: ExportHandlerTest.java    From pentaho-aggdesigner with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void testOpenDialogNoAggs() throws Exception {
  final XulMessageBox msgBox = context.mock(XulMessageBox.class);
  context.checking(new Expectations() {
    {
      // show error messagebox stating no aggs
      one(doc).createElement(with(equal("messagebox")));
      will(returnValue(msgBox));
      ignoring(msgBox).setMessage(with(any(String.class)));
      ignoring(msgBox).setTitle(with(any(String.class)));
      one(msgBox).open();
    }
  });
  controller.openDialog();
}
 
Example #20
Source File: RepositoriesController.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
public void init() throws ControllerInitializationException {
  // TODO Initialize the Repository Login Dialog
  try {
    messageBox = (XulMessageBox) document.createElement( "messagebox" );
    confirmBox = (XulConfirmBox) document.createElement( "confirmbox" );
  } catch ( Exception e ) {
    throw new ControllerInitializationException( e );
  }
  if ( bf != null ) {
    createBindings();
  }
}
 
Example #21
Source File: BrowseController.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings( "deprecation" )
public void init( Repository repository ) throws ControllerInitializationException {
  try {
    this.repository = repository;

    mainController = (MainController) this.getXulDomContainer().getEventHandler( "mainController" );

    RepositoryDirectoryInterface root;
    try {
      if ( repository instanceof RepositoryExtended ) {
        root = ( (RepositoryExtended) repository ).loadRepositoryDirectoryTree( false );
      } else {
        root = repository.loadRepositoryDirectoryTree();
      }
      this.repositoryDirectory =
        UIObjectRegistry.getInstance().constructUIRepositoryDirectory( root,
          null, repository );
    } catch ( UIObjectCreationException uoe ) {
      this.repositoryDirectory =
        new UIRepositoryDirectory( repository.loadRepositoryDirectoryTree(), null, repository );
    }
    this.repositoryDirectory.populateChildren();
    dirMap = new HashMap<ObjectId, UIRepositoryDirectory>();
    populateDirMap( repositoryDirectory );

    bf = new SwtBindingFactory();
    bf.setDocument( this.getXulDomContainer().getDocumentRoot() );
    messageBox = (XulMessageBox) document.createElement( "messagebox" );
    createBindings();
  } catch ( Exception e ) {
    throw new ControllerInitializationException( e );
  }
}
 
Example #22
Source File: DataHandlerTest.java    From pentaho-kettle with Apache License 2.0 4 votes vote down vote up
@Before
public void setUp() throws Exception {
  dataHandler = new DataHandler();
  xulDomContainer = mock( XulDomContainer.class );

  document = mock( Document.class );
  XulComponent rootElement = mock( XulComponent.class );
  when( document.getRootElement() ).thenReturn( rootElement );

  // Mock the UI components

  accessBox = mock( XulListbox.class );
  when( document.getElementById( "access-type-list" ) ).thenReturn( accessBox );
  connectionBox = mock( XulListbox.class );
  when( document.getElementById( "connection-type-list" ) ).thenReturn( connectionBox );
  connectionNameBox = mock( XulTextbox.class );
  when( document.getElementById( "connection-name-text" ) ).thenReturn( connectionNameBox );
  dialogDeck = mock( XulDeck.class );
  when( document.getElementById( "dialog-panel-deck" ) ).thenReturn( dialogDeck );
  deckOptionsBox = mock( XulListbox.class );
  when( document.getElementById( "deck-options-list" ) ).thenReturn( deckOptionsBox );
  hostNameBox = mock( XulTextbox.class );
  when( document.getElementById( "server-host-name-text" ) ).thenReturn( hostNameBox );
  databaseNameBox = mock( XulTextbox.class );
  when( document.getElementById( "database-name-text" ) ).thenReturn( databaseNameBox );
  portNumberBox = mock( XulTextbox.class );
  when( document.getElementById( "port-number-text" ) ).thenReturn( portNumberBox );
  userNameBox = mock( XulTextbox.class );
  when( document.getElementById( "username-text" ) ).thenReturn( userNameBox );
  passwordBox = mock( XulTextbox.class );
  when( document.getElementById( "password-text" ) ).thenReturn( passwordBox );
  serverInstanceBox = mock( XulTextbox.class );
  when( document.getElementById( "instance-text" ) ).thenReturn( serverInstanceBox );
  when( serverInstanceBox.getValue() ).thenReturn( "instance" );
  when( serverInstanceBox.getAttributeValue( "shouldDisablePortIfPopulated" ) ).thenReturn( "true" );
  webappName = mock( XulTextbox.class );
  when( document.getElementById( "web-application-name-text" ) ).thenReturn( webappName );
  when( webappName.getValue() ).thenReturn( "webappName" );

  messageBox = mock( XulMessageBox.class );
  when( document.createElement( "messagebox" ) ).thenReturn( messageBox );
  when( xulDomContainer.getDocumentRoot() ).thenReturn( document );

  generalDatasourceWindow = mock( XulRoot.class );
  when( generalDatasourceWindow.getRootObject() ).thenReturn( mock( XulComponent.class ) );
  when( document.getElementById( "general-datasource-window" ) ).thenReturn( generalDatasourceWindow );
  dataHandler.setXulDomContainer( xulDomContainer );
}
 
Example #23
Source File: SecurityController.java    From pentaho-kettle with Apache License 2.0 4 votes vote down vote up
public XulMessageBox getMessageBox() {
  return messageBox;
}
 
Example #24
Source File: RepositoriesController.java    From pentaho-kettle with Apache License 2.0 4 votes vote down vote up
public void setMessageBox( XulMessageBox messageBox ) {
  this.messageBox = messageBox;
}
 
Example #25
Source File: RepositoriesController.java    From pentaho-kettle with Apache License 2.0 4 votes vote down vote up
public XulMessageBox getMessageBox() {
  return messageBox;
}
 
Example #26
Source File: SecurityController.java    From pentaho-kettle with Apache License 2.0 4 votes vote down vote up
public void setMessageBox( XulMessageBox messageBox ) {
  this.messageBox = messageBox;
}