<commit_before>/*******************************************************************************
 * Copyright (c) 2005 Actuate Corporation.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *  Actuate Corporation  - initial API and implementation
 *******************************************************************************/

package org.eclipse.birt.report.designer.ui.cubebuilder.page;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

import org.eclipse.birt.report.designer.data.ui.property.AbstractTitlePropertyDialog;
import org.eclipse.birt.report.designer.data.ui.property.PropertyNode;
import org.eclipse.birt.report.designer.ui.cubebuilder.nls.Messages;
import org.eclipse.birt.report.model.api.DesignElementHandle;
import org.eclipse.birt.report.model.api.DimensionConditionHandle;
import org.eclipse.birt.report.model.api.DimensionJoinConditionHandle;
import org.eclipse.birt.report.model.api.ModuleUtil;
import org.eclipse.birt.report.model.api.activity.NotificationEvent;
import org.eclipse.birt.report.model.api.olap.CubeHandle;
import org.eclipse.birt.report.model.api.olap.HierarchyHandle;
import org.eclipse.birt.report.model.api.olap.TabularCubeHandle;
import org.eclipse.birt.report.model.api.olap.TabularDimensionHandle;
import org.eclipse.birt.report.model.api.olap.TabularHierarchyHandle;
import org.eclipse.birt.report.model.elements.interfaces.ICubeModel;
import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.preference.IPreferencePageContainer;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Shell;

public class CubeBuilder extends AbstractTitlePropertyDialog implements
		IPreferencePageContainer
{

	// public static final String MEASURESPAGE =
	// "org.eclipse.birt.datasource.editor.cubebuilder.measurespage";
	public static final String GROUPPAGE = "org.eclipse.birt.datasource.editor.cubebuilder.grouppage";
	public static final String DATASETSELECTIONPAGE = "org.eclipse.birt.datasource.editor.cubebuilder.datasetselectionpage";
	public static final String LINKGROUPSPAGE = "org.eclipse.birt.datasource.editor.cubebuilder.linkgroupspage";
	private TabularCubeHandle input;

	public CubeBuilder( Shell parentShell, TabularCubeHandle input )
	{
		super( parentShell, input );
		addCommonPage( input );
		this.input = input;
	}

	private DatasetSelectionPage datasetPage = null;
	private GroupsPage groupsPage = null;
	private LinkGroupsPage linkGroupsPage = null;

	private void addCommonPage( TabularCubeHandle model )
	{
		datasetNode = new PropertyNode( DATASETSELECTIONPAGE,
				Messages.getString( "DatasetPage.Title" ),
				null,
				datasetPage = new DatasetSelectionPage( this, model ) );
		groupsNode = new PropertyNode( GROUPPAGE,
				Messages.getString( "GroupsPage.Title" ),
				null,
				groupsPage = new GroupsPage( this, model ) );
		linkGroupNode = new PropertyNode( LINKGROUPSPAGE,
				Messages.getString( "LinkGroupsPage.Title" ),
				null,
				linkGroupsPage = new LinkGroupsPage( this, model ) );
		addNodeTo( "/", datasetNode );
		addNodeTo( "/", groupsNode );
		addNodeTo( "/", linkGroupNode );
	}
	private String showNodeId;

	public void showPage( String nodeId )
	{
		this.showNodeId = nodeId;
	}

	public boolean performCancel( )
	{
		return true;
	}

	public boolean performOk( )
	{
		if ( checkCubeLink( ) )
			return true;
		else
			return false;
	}

	private boolean checkCubeLink( )
	{
		List childList = new ArrayList( );
		if ( input != null )
		{
			TabularDimensionHandle[] dimensions = (TabularDimensionHandle[]) input.getContents( ICubeModel.DIMENSIONS_PROP )
					.toArray( new TabularDimensionHandle[0] );
			for ( int i = 0; i < dimensions.length; i++ )
			{
				TabularHierarchyHandle hierarchy = (TabularHierarchyHandle) dimensions[i].getDefaultHierarchy( );
				if ( hierarchy != null && hierarchy.getDataSet( ) != null )
					// && hierarchy.getDataSet( ) != input.getDataSet( ) )
					childList.add( hierarchy );
			}
		}
		if ( childList.size( ) == 0 )
			return true;
		else
		{
			boolean flag = true;
			for ( int i = 0; i < childList.size( ); i++ )
			{
				flag = true;
				HierarchyHandle hierarchy = (HierarchyHandle) childList.get( i );
				Iterator iter = input.joinConditionsIterator( );
				while ( iter.hasNext( ) )
				{
					DimensionConditionHandle condition = (DimensionConditionHandle) iter.next( );
					HierarchyHandle conditionHierarchy = (HierarchyHandle) condition.getHierarchy( );<commit_msg>- Summary: BIRT Crosstab - Cube builder does not close<commit_after>/*******************************************************************************
 * Copyright (c) 2005 Actuate Corporation.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *  Actuate Corporation  - initial API and implementation
 *******************************************************************************/

package org.eclipse.birt.report.designer.ui.cubebuilder.page;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

import org.eclipse.birt.report.designer.data.ui.property.AbstractTitlePropertyDialog;
import org.eclipse.birt.report.designer.data.ui.property.PropertyNode;
import org.eclipse.birt.report.designer.ui.cubebuilder.nls.Messages;
import org.eclipse.birt.report.model.api.DesignElementHandle;
import org.eclipse.birt.report.model.api.DimensionConditionHandle;
import org.eclipse.birt.report.model.api.ModuleUtil;
import org.eclipse.birt.report.model.api.activity.NotificationEvent;
import org.eclipse.birt.report.model.api.olap.CubeHandle;
import org.eclipse.birt.report.model.api.olap.HierarchyHandle;
import org.eclipse.birt.report.model.api.olap.TabularCubeHandle;
import org.eclipse.birt.report.model.api.olap.TabularDimensionHandle;
import org.eclipse.birt.report.model.api.olap.TabularHierarchyHandle;
import org.eclipse.birt.report.model.elements.interfaces.ICubeModel;
import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.preference.IPreferencePageContainer;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Shell;

public class CubeBuilder extends AbstractTitlePropertyDialog implements
		IPreferencePageContainer
{

	// public static final String MEASURESPAGE =
	// "org.eclipse.birt.datasource.editor.cubebuilder.measurespage";
	public static final String GROUPPAGE = "org.eclipse.birt.datasource.editor.cubebuilder.grouppage";
	public static final String DATASETSELECTIONPAGE = "org.eclipse.birt.datasource.editor.cubebuilder.datasetselectionpage";
	public static final String LINKGROUPSPAGE = "org.eclipse.birt.datasource.editor.cubebuilder.linkgroupspage";
	private TabularCubeHandle input;

	public CubeBuilder( Shell parentShell, TabularCubeHandle input )
	{
		super( parentShell, input );
		addCommonPage( input );
		this.input = input;
	}

	private DatasetSelectionPage datasetPage = null;
	private GroupsPage groupsPage = null;
	private LinkGroupsPage linkGroupsPage = null;

	private void addCommonPage( TabularCubeHandle model )
	{
		datasetNode = new PropertyNode( DATASETSELECTIONPAGE,
				Messages.getString( "DatasetPage.Title" ),
				null,
				datasetPage = new DatasetSelectionPage( this, model ) );
		groupsNode = new PropertyNode( GROUPPAGE,
				Messages.getString( "GroupsPage.Title" ),
				null,
				groupsPage = new GroupsPage( this, model ) );
		linkGroupNode = new PropertyNode( LINKGROUPSPAGE,
				Messages.getString( "LinkGroupsPage.Title" ),
				null,
				linkGroupsPage = new LinkGroupsPage( this, model ) );
		addNodeTo( "/", datasetNode );
		addNodeTo( "/", groupsNode );
		addNodeTo( "/", linkGroupNode );
	}
	private String showNodeId;

	public void showPage( String nodeId )
	{
		this.showNodeId = nodeId;
	}

	public boolean performCancel( )
	{
		return true;
	}

	public boolean performOk( )
	{
		if ( checkCubeLink( ) )
			return true;
		else
			return false;
	}

	private boolean checkCubeLink( )
	{
		List childList = new ArrayList( );
		if ( input != null )
		{
			TabularDimensionHandle[] dimensions = (TabularDimensionHandle[]) input.getContents( ICubeModel.DIMENSIONS_PROP )
					.toArray( new TabularDimensionHandle[0] );
			for ( int i = 0; i < dimensions.length; i++ )
			{
				TabularHierarchyHandle hierarchy = (TabularHierarchyHandle) dimensions[i].getDefaultHierarchy( );
				if ( hierarchy != null && hierarchy.getDataSet( ) != null && hierarchy.getDataSet( ) != input.getDataSet( ) )
					childList.add( hierarchy );
			}
		}
		if ( childList.size( ) == 0 )
			return true;
		else
		{
			boolean flag = true;
			for ( int i = 0; i < childList.size( ); i++ )
			{
				flag = true;
				HierarchyHandle hierarchy = (HierarchyHandle) childList.get( i );
				Iterator iter = input.joinConditionsIterator( );
				while ( iter.hasNext( ) )
				{
					DimensionConditionHandle condition = (DimensionConditionHandle) iter.next( );
					HierarchyHandle conditionHierarchy = (HierarchyHandle) condition.getHierarchy( );
{'fraction_non_alphanumeric': 0.13465897383062023, 'fraction_numerical': 0.00247269730063878, 'mean_word_length': 4.767676767676767, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3116439', 'n_tokens_mistral': 3189, 'n_tokens_neox': 2941, 'n_words': 606}