Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
Copyright (c) 2000, 2005 IBM Corporation and others. 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: IBM Corporation - initial API and implementation /
 
 
 package org.eclipse.ant.internal.ui.preferences;
 
 import java.util.List;
 
 import  org.eclipse.swt.SWT;
 import  org.eclipse.swt.graphics.Font;
 import  org.eclipse.swt.layout.GridData;
 import  org.eclipse.swt.layout.GridLayout;
 import  org.eclipse.swt.widgets.Composite;
 import  org.eclipse.swt.widgets.Control;
 import  org.eclipse.swt.widgets.Group;
 import  org.eclipse.swt.widgets.Label;
 
 /*
  * The page to configure the code formatter options.
  */
 	
 	
 		List overlayKeysnew ArrayList();
 		
 		overlayKeys.toArray(keys);
 		return new OverlayPreferenceStore(getPreferenceStore(), keys);
 	}
 	
 	/*
 	 * @see PreferencePage#createControl(Composite)
 	 */
 	public void createControl(Composite parent) {
 		super.createControl(parent);
 		//TODO set help
 		//WorkbenchHelp.setHelp(getControl(), "ANT_FORMATTER_PREFERENCE_PAGE");
 	}
 
 	protected Control createContents(Composite parent) {
 		int numColumns= 2;
 		Composite resultnew Composite(parent, SWT.NONE);
 		GridLayout layoutnew GridLayout();
 		layout.marginHeight= 0;
 		layout.marginWidth= 0;
 		result.setLayout(layout);
 		
 		Group indentationGroupcreateGroup(numColumnsresult.);
 		
 		addTextField(indentationGrouplabelText., 3, 0, errorMessages);
 		
 		addCheckBox(indentationGrouplabelText., 1);
 		
 		Group wrappingGroupcreateGroup(numColumnsresult.);
 		addTextField(wrappingGrouplabelText., 3, 0, errorMessages);
 		addCheckBox(wrappingGrouplabelText., 1);
 		
 		
 		Label labelnew Label(result, SWT.LEFT);
 		label.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
		Control previewercreatePreviewer(result);
		GridData gdnew GridData(GridData.FILL_BOTH);
		gd.widthHint= convertWidthInCharsToPixels(20);
		gd.heightHint= convertHeightInCharsToPixels(5);
		previewer.setLayoutData(gd);
		return result;
	}

Convenience method to create a group
	private Group createGroup(int numColumns, Composite parentString text ) {
		final Group groupnew Group(parent, SWT.NONE);
		GridData gdnew GridData(GridData.FILL_HORIZONTAL);
		gd.horizontalSpan= numColumns;
		gd.widthHint= 0;
		group.setLayoutData(gd);
		group.setFont(parent.getFont());
		final GridLayout layoutnew GridLayout(numColumnsfalse);
		group.setLayout(layout);
		group.setText(text);
		return group;
	}
	private Control createPreviewer(Composite parent) {
		 = new SourceViewer(parentnullnullfalse, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL);
        
		AntSourceViewerConfiguration configuration = new AntSourceViewerConfiguration();        
		.configure(configuration);
		Font font= JFaceResources.getFont(.);
		.getTextWidget().setFont(font);    
		new AntPreviewerUpdater(configurationstore);
		String contentloadPreviewContentFromFile("FormatPreviewCode.txt"); //$NON-NLS-1$
		contentformatContent(contentstore);
		IDocument document = new Document(content);       
	}
	private String formatContent(String contentIPreferenceStore preferenceStore) {
		prefs.setPreferenceStore(preferenceStore);
		return XmlFormatter.format(contentprefs);
	}
	/* (non-Javadoc)
	 * @see org.eclipse.ant.internal.ui.preferences.AbstractAntEditorPreferencePage#handleDefaults()
	 */
	protected void handleDefaults() {
	}
	/* (non-Javadoc)
	 * @see org.eclipse.jface.dialogs.IDialogPage#dispose()
	 */
	public void dispose() {
		super.dispose();
		if ( != null) {
		}
	}
New to GrepCode? Check out our FAQ X