<commit_before>/*
 *************************************************************************
 * Copyright (c) 2013 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.data.oda.mongodb.ui.impl;

import org.eclipse.birt.data.oda.mongodb.impl.MongoDBDriver.ReadPreferenceChoice;
import org.eclipse.birt.data.oda.mongodb.internal.impl.QueryProperties;
import org.eclipse.birt.data.oda.mongodb.ui.i18n.Messages;
import org.eclipse.birt.data.oda.mongodb.ui.util.IHelpConstants;
import org.eclipse.birt.data.oda.mongodb.ui.util.UIHelper;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.jface.dialogs.StatusDialog;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.events.ModifyListener;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Group;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;
import org.eclipse.ui.PlatformUI;

public class MongoDBAdvancedSettingsDialog extends StatusDialog
{

	private static String DIALOG_TITLE = Messages.getString( "MongoDBAdvancedSettingsDialog.dialogTitle" ); //$NON-NLS-1$

	private String batchSizeValue, docSearchLimitValue, maxSkipDocValue,
			indexExpr, queryPreferenceMode, tagSetValue;

	private Combo queryPreferenceModeCombo;
	private Text batchSizeText, docSearchLimitText, maxSkipDocText,
			indexExprText, tagSetText;
	private Button noTimeOutCheckbox, allowPartialResultsCheckbox,
			flattenNestedDocCheckbox;
	private boolean noTimeOut, allowsPartialResults, flattenNestedDocument;

	public MongoDBAdvancedSettingsDialog( Shell parent )
	{
		super( parent );
	}

	public void create( )
	{
		super.create( );

		Point pt = getShell( ).computeSize( -1, -1 );
		pt.x = Math.max( pt.x, 250 );
		pt.y = Math.max( pt.y, 300 );
		getShell( ).setSize( pt );
		getShell( ).setText( DIALOG_TITLE );

		validatePageStatus( );

	}

	protected boolean isResizable( )
	{
		return true;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets
	 * .Composite)
	 */
	protected Control createDialogArea( Composite parent )
	{
		Composite composite = (Composite) super.createDialogArea( parent );
		GridLayout layout = new GridLayout( );
		layout.marginHeight = 20;
		layout.marginWidth = 20;
		layout.numColumns = 2;
		composite.setLayout( layout );

		createMainArea( composite );

		initDialogControls( );

		UIHelper.setSystemHelp( composite,
				IHelpConstants.CONTEXT_ID_DIALOG_MONGODB_DATASET_ADVANCED_SETTING );

		return composite;

	}

	private void createMainArea( Composite parent )
	{
		Label maxResObjLabel = new Label( parent, SWT.NONE );
		maxResObjLabel.setText( Messages.getString( "MongoDBAdvancedSettingsDialog.Label.MaxResultObjects" ) ); //$NON-NLS-1$
		maxResObjLabel.setToolTipText( Messages.getString( "MongoDBAdvancedSettingsDialog.Tooltip.MaxResultObjects" ) ); //$NON-NLS-1$

		batchSizeText = new Text( parent, SWT.BORDER );
		batchSizeText.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ) );
		batchSizeText.addModifyListener( new ModifyListener( ) {

			public void modifyText( ModifyEvent e )
			{
				batchSizeValue = batchSizeText.getText( ).trim( );
				validatePageStatus( );

			}

		} );

		Label maxSearchDocLabel = new Label( parent, SWT.NONE );
		maxSearchDocLabel.setText( Messages.getString( "MongoDBAdvancedSettingsDialog.Label.MaxDocumentsToSearch" ) ); //$NON-NLS-1$
		maxSearchDocLabel.setToolTipText( Messages.getString( "MongoDBAdvancedSettingsDialog.Tooltip.MaxDocumentsToSearch" ) ); //$NON-NLS-1$

		docSearchLimitText = new Text( parent, SWT.BORDER );
		docSearchLimitText.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ) );
		docSearchLimitText.addModifyListener( new ModifyListener( ) {

			public void modifyText( ModifyEvent e )
			{
				docSearchLimitValue = docSearchLimitText.getText( ).trim( );
				validatePageStatus( );

			}

		} );

		Label maxSkipDocLabel = new Label( parent, SWT.NONE );
		maxSkipDocLabel.setText( Messages.getString( "MongoDBAdvancedSettingsDialog.Label.MaxDocumentsToSkip" ) ); //$NON-NLS-1$
		maxSkipDocLabel.setToolTipText( Messages.getString( "MongoDBAdvancedSettingsDialog.Tooltip.MaxDocumentsToSkip" ) ); //$NON-NLS-1$

		maxSkipDocText = new Text( parent, SWT.BORDER );
		maxSkipDocText.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ) );
		maxSkipDocText.addModifyListener( new ModifyListener( ) {

			public void modifyText( ModifyEvent e )
			{
				maxSkipDocValue = maxSkipDocText.getText( ).trim( );
				validatePageStatus( );

			}

		} );

		Label indexExprLabel = new Label( parent, SWT.NONE );
		indexExprLabel.setText( Messages.getString( "MongoDBAdvancedSettingsDialog.Label.IndexHintExpression" ) ); //$NON-NLS-1$
		indexExprLabel.setToolTipText( Messages.getString( "MongoDBAdvancedSettingsDialog.Tooltip.IndexHintExpression" ) ); //$NON-NLS-1$

		indexExprText = new Text( parent, SWT.BORDER );
		indexExprText.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ) );
		indexExprText.addModifyListener( new ModifyListener( ) {

			public void modifyText( ModifyEvent e )
			{
				indexExpr = indexExprText.getText( ).trim( );
				validatePageStatus( );

			}

		} );

		createQueryPreferenceGroup(parent);

		GridData gd = new GridData( GridData.FILL_HORIZONTAL );
		gd.horizontalSpan = 2;<commit_msg>Adjust the UI layout of the MongoDB Advanced Settings page.<commit_after>/*
 *************************************************************************
 * Copyright (c) 2013 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.data.oda.mongodb.ui.impl;

import org.eclipse.birt.data.oda.mongodb.impl.MongoDBDriver.ReadPreferenceChoice;
import org.eclipse.birt.data.oda.mongodb.internal.impl.QueryProperties;
import org.eclipse.birt.data.oda.mongodb.ui.i18n.Messages;
import org.eclipse.birt.data.oda.mongodb.ui.util.IHelpConstants;
import org.eclipse.birt.data.oda.mongodb.ui.util.UIHelper;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.jface.dialogs.StatusDialog;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.events.ModifyListener;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Group;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;
import org.eclipse.ui.PlatformUI;

public class MongoDBAdvancedSettingsDialog extends StatusDialog
{

	private static String DIALOG_TITLE = Messages.getString( "MongoDBAdvancedSettingsDialog.dialogTitle" ); //$NON-NLS-1$

	private String batchSizeValue, docSearchLimitValue, maxSkipDocValue,
			indexExpr, queryPreferenceMode, tagSetValue;

	private Combo queryPreferenceModeCombo;
	private Text batchSizeText, docSearchLimitText, maxSkipDocText,
			indexExprText, tagSetText;
	private Button noTimeOutCheckbox, allowPartialResultsCheckbox,
			flattenNestedDocCheckbox;
	private boolean noTimeOut, allowsPartialResults, flattenNestedDocument;

	public MongoDBAdvancedSettingsDialog( Shell parent )
	{
		super( parent );
	}

	public void create( )
	{
		super.create( );

		Point pt = getShell( ).computeSize( -1, -1 );
		pt.x = Math.max( pt.x, 250 );
		pt.y = Math.max( pt.y, 300 );
		getShell( ).setSize( pt );
		getShell( ).setText( DIALOG_TITLE );

		validatePageStatus( );

	}

	protected boolean isResizable( )
	{
		return true;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets
	 * .Composite)
	 */
	protected Control createDialogArea( Composite parent )
	{
		Composite composite = (Composite) super.createDialogArea( parent );
		GridLayout layout = new GridLayout( );
		layout.marginHeight = 20;
		layout.marginWidth = 20;
		layout.numColumns = 2;
		composite.setLayout( layout );

		createMainArea( composite );

		initDialogControls( );

		UIHelper.setSystemHelp( composite,
				IHelpConstants.CONTEXT_ID_DIALOG_MONGODB_DATASET_ADVANCED_SETTING );

		return composite;

	}

	private void createMainArea( Composite parent )
	{
		Label maxResObjLabel = new Label( parent, SWT.NONE );
		maxResObjLabel.setText( Messages.getString( "MongoDBAdvancedSettingsDialog.Label.MaxResultObjects" ) ); //$NON-NLS-1$
		maxResObjLabel.setToolTipText( Messages.getString( "MongoDBAdvancedSettingsDialog.Tooltip.MaxResultObjects" ) ); //$NON-NLS-1$

		batchSizeText = new Text( parent, SWT.BORDER );
		batchSizeText.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ) );
		batchSizeText.addModifyListener( new ModifyListener( ) {

			public void modifyText( ModifyEvent e )
			{
				batchSizeValue = batchSizeText.getText( ).trim( );
				validatePageStatus( );

			}

		} );

		Label maxSearchDocLabel = new Label( parent, SWT.NONE );
		maxSearchDocLabel.setText( Messages.getString( "MongoDBAdvancedSettingsDialog.Label.MaxDocumentsToSearch" ) ); //$NON-NLS-1$
		maxSearchDocLabel.setToolTipText( Messages.getString( "MongoDBAdvancedSettingsDialog.Tooltip.MaxDocumentsToSearch" ) ); //$NON-NLS-1$

		docSearchLimitText = new Text( parent, SWT.BORDER );
		docSearchLimitText.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ) );
		docSearchLimitText.addModifyListener( new ModifyListener( ) {

			public void modifyText( ModifyEvent e )
			{
				docSearchLimitValue = docSearchLimitText.getText( ).trim( );
				validatePageStatus( );

			}

		} );

		Label maxSkipDocLabel = new Label( parent, SWT.NONE );
		maxSkipDocLabel.setText( Messages.getString( "MongoDBAdvancedSettingsDialog.Label.MaxDocumentsToSkip" ) ); //$NON-NLS-1$
		maxSkipDocLabel.setToolTipText( Messages.getString( "MongoDBAdvancedSettingsDialog.Tooltip.MaxDocumentsToSkip" ) ); //$NON-NLS-1$

		maxSkipDocText = new Text( parent, SWT.BORDER );
		maxSkipDocText.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ) );
		maxSkipDocText.addModifyListener( new ModifyListener( ) {

			public void modifyText( ModifyEvent e )
			{
				maxSkipDocValue = maxSkipDocText.getText( ).trim( );
				validatePageStatus( );

			}

		} );

		Label indexExprLabel = new Label( parent, SWT.NONE );
		indexExprLabel.setText( Messages.getString( "MongoDBAdvancedSettingsDialog.Label.IndexHintExpression" ) ); //$NON-NLS-1$
		indexExprLabel.setToolTipText( Messages.getString( "MongoDBAdvancedSettingsDialog.Tooltip.IndexHintExpression" ) ); //$NON-NLS-1$

		indexExprText = new Text( parent, SWT.BORDER );
		indexExprText.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ) );
		indexExprText.addModifyListener( new ModifyListener( ) {

			public void modifyText( ModifyEvent e )
			{
				indexExpr = indexExprText.getText( ).trim( );
				validatePageStatus( );

			}

		} );

		createQueryPreferenceGroup(parent);

		GridData gd = new GridData( GridData.FILL_HORIZONTAL );
		gd.horizontalSpan = 2;
		gd.verticalIndent = 8;
{'fraction_non_alphanumeric': 0.13104397829432252, 'fraction_numerical': 0.005426419373127075, 'mean_word_length': 4.8996655518394645, 'pattern_counts': {'":': 0, '<': 3, '<?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': '6083614', 'n_tokens_mistral': 4298, 'n_tokens_neox': 3883, 'n_words': 726}