Java Code Examples for org.pentaho.ui.xul.XulComponent

The following examples show how to use org.pentaho.ui.xul.XulComponent. These examples are extracted from open source projects. 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 Project: kettle-beam   Source File: BeamPerspective.java    License: 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
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 3
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 4
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 5
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 6
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 7
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 8
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 9
Source Project: pentaho-kettle   Source File: SpoonPerspectiveManager.java    License: 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 10
Source Project: pentaho-kettle   Source File: FragmentHandler.java    License: 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 11
public XulDatabaseDialog( final Window parent ) throws XulException {
  final SwingXulLoader loader = new SwingXulLoader();

  if ( parent != null ) {
    loader.setOuterContext( parent );
  }
  final XulDomContainer container = loader.loadXul( DIALOG_DEFINITION_FILE, Messages.getBundle() );
  container.getDocumentRoot().addOverlay( OVERLAY_DEFINITION_FILE );
  container.initialize();

  handler = new XulDatabaseHandler();
  container.addEventHandler( handler );   //$NON-NLS-1$

  final Document documentRoot = container.getDocumentRoot();
  final XulComponent root = documentRoot.getRootElement();

  if ( root instanceof XulDialog ) {
    dialog = (XulDialog) root;
    dialog.setResizable( Boolean.TRUE );
  } else {
    throw new XulException( "Error getting Xul Database Dialog root, element of type: " + root );
  }

  final ObjectFactory objectFactory = ClassicEngineBoot.getInstance().getObjectFactory();
  final IDatabaseDialectService dialectService = objectFactory.get( IDatabaseDialectService.class );
  this.databaseTypeHelper = new DatabaseTypeHelper( dialectService.getDatabaseTypes() );

}
 
Example 12
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
public SwingXulPopupMenu( final Element self, final XulComponent parent, final XulDomContainer domContainer,
                          final String tagName ) {
  super( tagName );

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

}
 
Example 14
public SwingXulToolbar( final Element self,
                        final XulComponent parent,
                        final XulDomContainer domContainer,
                        final String tagName ) {
  super( tagName );

  container = new JToolBar();
  container.setOpaque( false );

  setManagedObject( container );

  resetContainer();
}
 
Example 15
public PrdSwingMenu( final Element self,
                     final XulComponent parent,
                     final XulDomContainer domContainer,
                     final String tagName ) {
  super( self, parent, domContainer, tagName );
  menu = (JMenu) getManagedObject();
}
 
Example 16
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 17
private boolean computeParentToolbar( XulComponent parent ) {
  while ( parent != null ) {
    if ( parent.getManagedObject() instanceof JToolBar ) {
      return true;
    }
    parent = parent.getParent();
  }
  return false;
}
 
Example 18
public <T extends XulComponent> T getXulComponent( String id, Class<T> type ) {
  final XulComponent mainMenuBar = window.getElementById( id );
  if ( mainMenuBar == null ) {
    return null;
  }
  if ( type.isInstance( mainMenuBar ) ) {
    return (T) mainMenuBar;
  }
  return null;
}
 
Example 19
private void installContext( final XulComponent component ) {
  final List<XulComponent> xulComponents = component.getChildNodes();
  for ( int i = 0; i < xulComponents.size(); i++ ) {
    final XulComponent child = xulComponents.get( i );
    if ( child instanceof DesignerContextComponent ) {
      final DesignerContextComponent asm = (DesignerContextComponent) child;
      asm.setReportDesignerContext( reportDesignerContext );
    }
    installContext( child );
  }
}
 
Example 20
@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 21
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 22
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 23
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 24
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 25
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 26
Source Project: pentaho-kettle   Source File: AbstractGraph.java    License: 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 27
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 Project: pentaho-kettle   Source File: ExtTextbox.java    License: 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 Project: pentaho-kettle   Source File: DataHandler.java    License: 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();
  }
}
 
Example 30
Source Project: pentaho-kettle   Source File: DataHandler.java    License: 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;
}