org.pentaho.ui.xul.XulComponent Java Examples

The following examples show how to use org.pentaho.ui.xul.XulComponent. 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: Neo4jPerspective.java    From knowbi-pentaho-pdi-neo4j-output with Apache License 2.0 6 votes vote down vote up
public void setNameForTab( XulTab tab, String name ) {
  String tabName = name;
  List<String> usedNames = new ArrayList<String>();
  for ( XulComponent c : tabs.getChildNodes() ) {
    if ( c != tab ) {
      usedNames.add( ( (SwtTab) c ).getLabel() );
    }
  }
  if ( usedNames.contains( name ) ) {
    int num = 2;
    while ( true ) {
      tabName = name + " (" + num + ")";
      if ( usedNames.contains( tabName ) == false ) {
        break;
      }
      num++;
    }
  }

  tab.setLabel( tabName );
}
 
Example #2
Source File: ReportDesignerFrame.java    From pentaho-reporting with GNU Lesser General Public License v2.1 6 votes vote down vote up
private void createZoomMenu() {
  final XulComponent zoomMenu =
    context.getView().getXulComponent( "view-zoom-selection-popup", XulMenupopup.class );// NON-NLS
  if ( zoomMenu == null ) {
    return;
  }

  final InternalZoomAction zoom50action = new InternalZoomAction( 50 );
  final InternalZoomAction zoom100action = new InternalZoomAction( 100 );
  final InternalZoomAction zoom200action = new InternalZoomAction( 200 );
  final InternalZoomAction zoom400action = new InternalZoomAction( 400 );

  zoom50action.setReportDesignerContext( context );
  zoom100action.setReportDesignerContext( context );
  zoom200action.setReportDesignerContext( context );
  zoom400action.setReportDesignerContext( context );

  zoomMenu.addChild( context.getView().createMenuItem( zoom50action ) );
  zoomMenu.addChild( context.getView().createMenuItem( zoom100action ) );
  zoomMenu.addChild( context.getView().createMenuItem( zoom200action ) );
  zoomMenu.addChild( context.getView().createMenuItem( zoom400action ) );
}
 
Example #3
Source File: ReportDesignerFrame.java    From pentaho-reporting with GNU Lesser General Public License v2.1 6 votes vote down vote up
private void createSamplesMenu() {
  final XulMenupopup samplesPopup =
    context.getView().getXulComponent( "help-samples-popup", XulMenupopup.class );// NON-NLS
  if ( samplesPopup == null ) {
    return;
  }

  for ( final XulComponent childNode : new ArrayList<XulComponent>( samplesPopup.getChildNodes() ) ) {
    samplesPopup.removeChild( childNode );
  }

  final TreeModel treeModel = SamplesTreeBuilder.getSampleTreeModel();
  final Object root = treeModel.getRoot();
  try {
    insertReports( treeModel, root, samplesPopup );
  } catch ( XulException e ) {
    logger.warn( "Failed to initialize sample menu", e );
  }
}
 
Example #4
Source File: PrdSwingMenu.java    From pentaho-reporting with GNU Lesser General Public License v2.1 6 votes vote down vote up
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 #5
Source File: BeamPerspective.java    From kettle-beam with Apache License 2.0 6 votes vote down vote up
public void setNameForTab( XulTab tab, String name ) {
  String tabName = name;
  List<String> usedNames = new ArrayList<String>();
  for ( XulComponent c : tabs.getChildNodes() ) {
    if ( c != tab ) {
      usedNames.add( ( (SwtTab) c ).getLabel() );
    }
  }
  if ( usedNames.contains( name ) ) {
    int num = 2;
    while ( true ) {
      tabName = name + " (" + num + ")";
      if ( usedNames.contains( tabName ) == false ) {
        break;
      }
      num++;
    }
  }

  tab.setLabel( tabName );
}
 
Example #6
Source File: SwingXulToolbar.java    From pentaho-reporting with GNU Lesser General Public License v2.1 6 votes vote down vote up
public void layout() {
  if ( getBgcolor() != null ) {
    container.setOpaque( true );
    container.setBackground( Color.decode( getBgcolor() ) );
  }

  final List<XulComponent> xulComponents = getChildNodes();
  for ( int i = 0; i < xulComponents.size(); i++ ) {
    final XulComponent component = xulComponents.get( i );
    final Object maybeComponent = component.getManagedObject();
    if ( maybeComponent == null || !( maybeComponent instanceof Component ) ) {
      continue;
    }
    if ( maybeComponent instanceof JSeparator ) {
      container.addSeparator();
    } else {
      container.add( (Component) maybeComponent );
    }
  }

  initialized = true;
}
 
Example #7
Source File: SpoonPerspectiveManager.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
public void removePerspective( SpoonPerspective per ) {
  perspectives.remove( per );
  orderedPerspectives.remove( per );
  Document document = domContainer.getDocumentRoot();

  XulComponent comp = document.getElementById( "perspective-" + per.getId() );
  comp.getParent().removeChild( comp );

  comp = document.getElementById( "perspective-btn-" + per.getId() );
  comp.getParent().removeChild( comp );
  XulToolbar mainToolbar = (XulToolbar) domContainer.getDocumentRoot().getElementById( "main-toolbar" );
  ( (Composite) mainToolbar.getManagedObject() ).layout( true, true );

  deck.setSelectedIndex( 0 );

}
 
Example #8
Source File: FragmentHandler.java    From pentaho-kettle with 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 #9
Source File: SwingXulPopupMenu.java    From pentaho-reporting with GNU Lesser General Public License v2.1 6 votes vote down vote up
public void layout() {
  this.menu.removeAll();
  for ( final XulComponent comp : getChildNodes() ) {
    if ( comp.isVisible() == false ) {
      continue;
    }

    if ( comp instanceof XulMenuseparator ) {
      this.menu.addSeparator();
    } else if ( comp instanceof SwingXulPopupMenu ) {
      this.menu.add( (JMenu) comp.getManagedObject() );
    } else {
      this.menu.add( (JMenuItem) comp.getManagedObject() );
    }
  }
  initialized = true;
}
 
Example #10
Source File: XulDialogHelper.java    From pentaho-reporting with GNU Lesser General Public License v2.1 6 votes vote down vote up
public JComponent createEditor() throws ReportDataFactoryException {
  if ( editor != null ) {
    return editor;
  }

  dialog = createDialog();
  if ( dialog == null ) {
    editor = new JPanel();
    return editor;
  }

  // validate is a hardcoded name inside the xul dialogs
  dialog.addPropertyChangeListener( new ChangeHandler() );
  dialog.validate();

  XulComponent root = dialog.getXulDomContainer().getDocumentRoot().getElementById( "root" );

  // Without the following two lines of code, message boxes and prompts will freeze the dialog...
  // There must be a better way.
  SwingDialog parent = (SwingDialog) root.getParent();
  JComponent panel = parent.getContainer();
  dialog.setModalParent( panel );
  editor = panel;
  return panel;
}
 
Example #11
Source File: FragmentHandlerTest.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
@Test( expected = XulException.class )
public void testLoadDatabaseOptionsFragmentWithException() throws Exception {
  XulComponent component = mock( XulComponent.class );
  XulComponent parent = mock( XulComponent.class );
  when( component.getParent() ).thenReturn( parent );
  when( document.getElementById( "database-options-box" ) ).thenReturn( component );
  when( xulDomContainer.loadFragment( anyString(), any( Object.class ) ) ).thenThrow( new XulException() );
  fragmentHandler.loadDatabaseOptionsFragment( null );
}
 
Example #12
Source File: PentahoDrillDownController.java    From pentaho-reporting with GNU Lesser General Public License v2.1 5 votes vote down vote up
protected void configureDisableTableOnEmptyFile() {
  final Document doc = getXulDomContainer().getDocumentRoot();
  final XulComponent paramTableElement = doc.getElementById( "parameter-table" ); // NON-NLS
  if ( paramTableElement instanceof XulDrillDownParameterTable == false ) {
    return;
  }

  pentahoPathWrapper.addPropertyChangeListener( PentahoPathModel.LOCAL_PATH_PROPERTY, new CheckEmptyPathHandler(
      paramTableElement ) );
}
 
Example #13
Source File: SwingXulPopupMenu.java    From pentaho-reporting with GNU Lesser General Public License v2.1 5 votes vote down vote up
public SwingXulPopupMenu( final Element self, final XulComponent parent, final XulDomContainer domContainer,
                          final String tagName ) {
  super( tagName );

  menu = new JPopupMenu();
  setManagedObject( menu );

}
 
Example #14
Source File: ActionSwingMenuitem.java    From pentaho-reporting with GNU Lesser General Public License v2.1 5 votes vote down vote up
public void setVisible( final boolean visible ) {
  super.setVisible( visible );
  menuitem.setVisible( visible );

  final XulComponent parent = getParent();
  if ( parent instanceof AbstractXulComponent ) {
    final AbstractXulComponent parentComp = (AbstractXulComponent) parent;
    parentComp.layout();
  }
}
 
Example #15
Source File: PrdSwingMenu.java    From pentaho-reporting with GNU Lesser General Public License v2.1 5 votes vote down vote up
public PrdSwingMenu( final Element self,
                     final XulComponent parent,
                     final XulDomContainer domContainer,
                     final String tagName ) {
  super( self, parent, domContainer, tagName );
  menu = (JMenu) getManagedObject();
}
 
Example #16
Source File: ExportHandlerTest.java    From pentaho-aggdesigner with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void testShowPreviewWithAggs() throws Exception {
  final XulDialog diag = context.mock(XulDialog.class);
  final XulTextbox textbox = context.mock(XulTextbox.class);
  final XulComponent ignored = context.mock(XulComponent.class);
  context.checking(new Expectations() {
    {
      // get preview dialog
      one(doc).getElementById(with(any(String.class)));
      will(returnValue(diag));
      // get ddl field
      one(doc).getElementById(with(any(String.class)));
      will(returnValue(textbox));
      one(outputService).getFullArtifact(with(any(List.class)), with(equal(CreateScriptGenerator.class)));
      one(textbox).setValue(with(any(String.class)));
      // get dml field
      one(doc).getElementById(with(any(String.class)));
      will(returnValue(textbox));
      // get dml tab (if exists)
      one(doc).getElementById(with(any(String.class)));
      // returnValue doesn't matter as long as not null
      will(returnValue(ignored));
      one(outputService).getFullArtifact(with(any(List.class)), with(equal(PopulateScriptGenerator.class)));
      one(textbox).setValue(with(any(String.class)));
      // get olap field
      one(doc).getElementById(with(any(String.class)));
      will(returnValue(textbox));
      one(outputService).getFullArtifact(with(any(List.class)), with(equal(SchemaGenerator.class)));
      one(textbox).setValue(with(any(String.class)));
      one(diag).show();
    }
  });
  aggList.addAgg(new UIAggregateImpl());
  controller.showPreview();
}
 
Example #17
Source File: ReportDesignerFrame.java    From pentaho-reporting with GNU Lesser General Public License v2.1 5 votes vote down vote up
public <T extends XulComponent> T getXulComponent( final String id, final Class<T> type ) {
  T xulComponentById = xulDesignerFrame.getXulComponent( id, type );
  if ( type.isInstance( xulComponentById ) ) {
    return (T) xulComponentById;
  }
  return null;
}
 
Example #18
Source File: XulDrillDownParameterTable.java    From pentaho-reporting with GNU Lesser General Public License v2.1 5 votes vote down vote up
public XulDrillDownParameterTable( final Element self,
                                   final XulComponent parent,
                                   final XulDomContainer domContainer,
                                   final String tagName ) {
  super( tagName );
  this.table = new DrillDownParameterTable();
  setManagedObject( table );

  table.addPropertyChangeListener( DrillDownParameterTable.DRILL_DOWN_PARAMETER_PROPERTY,
    new ForwardChangeEventsHandler() );
  table.addPropertyChangeListener( DrillDownParameterTable.HIDE_PARAMETER_UI_PARAMETER_PROPERTY,
    new ForwardChangeEventsHandler() );
}
 
Example #19
Source File: DocumentStub.java    From pentaho-aggdesigner with GNU General Public License v2.0 5 votes vote down vote up
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 #20
Source File: ReportDesignerFrame.java    From pentaho-reporting with GNU Lesser General Public License v2.1 5 votes vote down vote up
private void rebuildReportMenu() {
  final XulComponent reopenMenu = context.getView().getXulComponent( "window.reports-area", XulComponent.class );
  if ( reopenMenu == null ) {
    return;
  }

  final List<XulComponent> xulComponents = reopenMenu.getChildNodes();
  final XulComponent[] objects = xulComponents.toArray( new XulComponent[ xulComponents.size() ] );
  for ( int i = 0; i < objects.length; i++ ) {
    final XulComponent object = objects[ i ];
    reopenMenu.removeChild( object );
  }

  final JTabbedPane tabbedPane = getReportEditorPane();
  final int count = tabbedPane.getTabCount();
  if ( count > 0 ) {
    reopenMenu.addChild( new SwingMenuseparator( null, null, null, "menu-separator" ) ); // NON-NLS
    for ( int i = 0; i < count; i++ ) {
      final Component at = tabbedPane.getTabComponentAt( i );
      final String tabName;
      if ( at instanceof TabRenderer ) {
        final TabRenderer renderer = (TabRenderer) at;
        tabName = renderer.getTitle();
      } else {
        tabName = tabbedPane.getTitleAt( i );
      }
      final SelectTabAction action = new SelectTabAction( i, tabName );
      final ActionSwingMenuitem actionSwingMenuitem = context.getView().createMenuItem( action );
      actionSwingMenuitem.setReportDesignerContext( context );
      reopenMenu.addChild( actionSwingMenuitem );
    }
  }
}
 
Example #21
Source File: GenericUrlDrillDownController.java    From pentaho-reporting with GNU Lesser General Public License v2.1 5 votes vote down vote up
protected void configureDisableTableOnEmptyFile() {
  final Document doc = getXulDomContainer().getDocumentRoot();
  final XulComponent paramTableElement = doc.getElementById( "parameter-table" );//NON-NLS
  if ( paramTableElement instanceof XulDrillDownParameterTable == false ) {
    return;
  }

  getWrapper().getModel().addPropertyChangeListener
    ( DrillDownModel.DRILL_DOWN_PATH_PROPERTY, new CheckEmptyPathHandler( paramTableElement ) );

}
 
Example #22
Source File: DataHandler.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
private boolean windowClosed() {
  boolean closedWindow = true;
  XulComponent window = document.getElementById( "general-datasource-window" );

  if ( window == null ) { // window must be root
    window = document.getRootElement();
  }
  if ( window instanceof XulWindow ) {
    closedWindow = ( (XulWindow) window ).isClosed();
  }
  return closedWindow;
}
 
Example #23
Source File: XulFormulaTextField.java    From pentaho-reporting with GNU Lesser General Public License v2.1 5 votes vote down vote up
public XulFormulaTextField( final Element self,
                            final XulComponent parent,
                            final XulDomContainer domContainer,
                            final String tagName ) {
  super( tagName );
  setManagedObject( null );
  disabled = false;
  value = "";
  type = TextType.NORMAL;
  readonly = false;
  maxlength = -1;
  oldValue = null;
}
 
Example #24
Source File: AbstractGraph.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
public void dispose() {
  super.dispose();
  List<XulComponent> pops = xulDomContainer.getDocumentRoot().getElementsByTagName( "menupopup" );
  for ( XulComponent pop : pops ) {
    ( (MenuManager) pop.getManagedObject() ).dispose();
  }
}
 
Example #25
Source File: FragmentHandlerTest.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
@Test
public void testLoadDatabaseOptionsFragment() throws Exception {
  XulComponent component = mock( XulComponent.class );
  XulComponent parent = mock( XulComponent.class );
  when( component.getParent() ).thenReturn( parent );
  when( document.getElementById( "database-options-box" ) ).thenReturn( component );
  XulDomContainer fragmentContainer = mock( XulDomContainer.class );
  Document mockDoc = mock( Document.class );
  XulComponent firstChild = mock( XulComponent.class );
  when( mockDoc.getFirstChild() ).thenReturn( firstChild );
  when( fragmentContainer.getDocumentRoot() ).thenReturn( mockDoc );
  when( xulDomContainer.loadFragment( anyString(), any( Object.class ) ) ).thenReturn( fragmentContainer );
  fragmentHandler.loadDatabaseOptionsFragment( null );
}
 
Example #26
Source File: FragmentHandlerTest.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
@Test
public void testRefreshOptions() throws Exception {
  XulListbox connectionBox = mock( XulListbox.class );
  when( document.getElementById( "connection-type-list" ) ).thenReturn( connectionBox );
  when( connectionBox.getSelectedItem() ).thenReturn( "myDb" );
  XulListbox accessBox = mock( XulListbox.class );
  when( document.getElementById( "access-type-list" ) ).thenReturn( accessBox );
  when( accessBox.getSelectedItem() ).thenReturn( "Native" );
  DataHandler dataHandler = mock( DataHandler.class );
  when( xulDomContainer.getEventHandler( "dataHandler" ) ).thenReturn( dataHandler );
  DatabaseInterface dbInterface = mock( DatabaseInterface.class );
  when( dbInterface.getDefaultDatabasePort() ).thenReturn( 5309 );
  DataHandler.connectionMap.put( "myDb", dbInterface );

  XulComponent component = mock( XulComponent.class );
  XulComponent parent = mock( XulComponent.class );
  when( component.getParent() ).thenReturn( parent );
  when( document.getElementById( "database-options-box" ) ).thenReturn( component );
  XulDomContainer fragmentContainer = mock( XulDomContainer.class );
  Document mockDoc = mock( Document.class );
  XulComponent firstChild = mock( XulComponent.class );
  when( mockDoc.getFirstChild() ).thenReturn( firstChild );
  when( fragmentContainer.getDocumentRoot() ).thenReturn( mockDoc );
  when( xulDomContainer.loadFragment( anyString(), any( Object.class ) ) ).thenReturn( fragmentContainer );

  XulTextbox portBox = mock( XulTextbox.class );
  when( document.getElementById( "port-number-text" ) ).thenReturn( portBox );

  fragmentHandler.refreshOptions();

  // Iterate through the other database access types
  when( accessBox.getSelectedItem() ).thenReturn( "JNDI" );
  fragmentHandler.refreshOptions();
  when( accessBox.getSelectedItem() ).thenReturn( "ODBC" );
  fragmentHandler.refreshOptions();
  when( accessBox.getSelectedItem() ).thenReturn( "OCI" );
  fragmentHandler.refreshOptions();
  when( accessBox.getSelectedItem() ).thenReturn( "Plugin" );
  fragmentHandler.refreshOptions();
}
 
Example #27
Source File: XulDatabaseExplorerController.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
public void onClose( XulComponent aSender, Status aReturnCode, Object aRetVal ) {
  if ( aReturnCode == Status.ACCEPT ) {
    try {
      this.limit = Integer.parseInt( aRetVal.toString() );
    } catch ( NumberFormatException e ) {
      LogChannel.GENERAL.logError( "Error parsing string '" + aRetVal.toString() + "'", e );
    }
  }
}
 
Example #28
Source File: ExtTextbox.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
public ExtTextbox( Element self, XulComponent parent, XulDomContainer container, String tagName ) {
  super( self, parent, container, tagName );
  String typeAttribute = self.getAttributeValue( "type" );
  if ( typeAttribute != null ) {
    this.type = TextType.valueOf( typeAttribute.toUpperCase() );
  }
  createNewExtText( parent );
}
 
Example #29
Source File: DataHandler.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
private void traverseDomSetReadOnly( XulComponent component, boolean readonly ) {
  component.setDisabled( readonly );
  List<XulComponent> children = component.getChildNodes();
  if ( children != null && children.size() > 0 ) {
    for ( XulComponent child : children ) {
      child.setDisabled( readonly );
      traverseDomSetReadOnly( child, readonly );
    }
  }
}
 
Example #30
Source File: DataHandler.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
private void close() {
  XulComponent window = document.getElementById( "general-datasource-window" );

  if ( window == null ) { // window must be root
    window = document.getRootElement();
  }
  if ( window instanceof XulDialog ) {
    ( (XulDialog) window ).hide();
  } else if ( window instanceof XulWindow ) {
    ( (XulWindow) window ).close();
  }
}