Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
Copyright (c) 2000, 2008 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 java.util.Map;
 
 import  org.eclipse.swt.SWT;
 import  org.eclipse.swt.events.SelectionAdapter;
 import  org.eclipse.swt.events.SelectionEvent;
 import  org.eclipse.swt.events.SelectionListener;
 import  org.eclipse.swt.graphics.Color;
 import  org.eclipse.swt.graphics.Font;
 import  org.eclipse.swt.graphics.RGB;
 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.Label;
 import  org.eclipse.swt.widgets.Link;
 import  org.eclipse.swt.widgets.TabFolder;
 import  org.eclipse.swt.widgets.TabItem;
 import  org.eclipse.swt.widgets.Text;
 import  org.eclipse.swt.widgets.Widget;
 
 /*
  * The page for setting the editor options.
  */
 	
 	protected static class ControlData {
 		private String fKey;
 		private String[] fValues;
 		
 		public ControlData(String keyString[] values) {
 			key;
 			values;
 		}
 		
 		public String getKey() {
 			return ;
 		}
 		
 		public String getValue(boolean selection) {
 			int indexselection ? 0 : 1;
 			return [index];
 		}
 		
 		public String getValue(int index) {
 			return [index];
 		}
 		
 		public int getSelection(String value) {
 			if (value != null) {
 				for (int i= 0; i < .i++) {
 					if (value.equals([i])) {
 						return i;
 					}
 				}
 			}
 			return . -1; // assume the last option is the least severe
		}
	}

Item in the highlighting color list.

Since:
3.0
	private class HighlightingColorListItem {
Display name
		private String fDisplayName;
Color preference key
		private String fColorKey;
Bold preference key
		private String fBoldKey;
Italic preference key
		private String fItalicKey;
Item color
		private Color fItemColor;

Initialize the item with the given values.

Parameters:
displayName the display name
colorKey the color preference key
boldKey the bold preference key
italicKey the italic preference key
itemColor the item color
		public HighlightingColorListItem(String displayNameString colorKeyString boldKeyString italicKey, Color itemColor) {
			displayName;
			colorKey;
			boldKey;
			italicKey;
			itemColor;
		}

Returns:
the bold preference key
		public String getBoldKey() {
			return ;
		}

Returns:
the bold preference key
		public String getItalicKey() {
			return ;
		}

Returns:
the color preference key
		public String getColorKey() {
			return ;
		}

Returns:
the display name
		public String getDisplayName() {
			return ;
		}

Returns:
the item color
		public Color getItemColor() {
			return ;
		}
	}

Color list label provider.

Since:
3.0
	private class ColorListLabelProvider extends LabelProvider implements IColorProvider {
		/*
		 * @see org.eclipse.jface.viewers.ILabelProvider#getText(java.lang.Object)
		 */
		public String getText(Object element) {
		}
		/*
		 * @see org.eclipse.jface.viewers.IColorProvider#getForeground(java.lang.Object)
		 */
		public Color getForeground(Object element) {
		}
		/*
		 * @see org.eclipse.jface.viewers.IColorProvider#getBackground(java.lang.Object)
		 */
		public Color getBackground(Object element) {
			return null;
		}
	}

Color list content provider.

Since:
3.0
		/*
		 * @see org.eclipse.jface.viewers.IStructuredContentProvider#getElements(java.lang.Object)
		 */
		public Object[] getElements(Object inputElement) {
			return ((java.util.List)inputElement).toArray();
		}
		/*
		 * @see org.eclipse.jface.viewers.IContentProvider#dispose()
		 */
		public void dispose() {
		}
		/*
		 * @see org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object)
		 */
		public void inputChanged(Viewer viewerObject oldInputObject newInput) {
		}
	}

The keys of the overlay store.
	private final String[] fProblemPreferenceKeysnew String[] {
		};
	private Button fBoldCheckBox;
	private Button fItalicCheckBox;
	private final java.util.List fHighlightingColorListnew ArrayList(5);
	private SelectionListener fSelectionListener;
	protected Map fWorkingValues;
	protected List fComboBoxes;
	private Button fIgnoreAllProblems;
	private Label fSeverityLabel;
		super();
	}
			};
		ArrayList overlayKeysnew ArrayList();
		for (int i= 0; i < .i++) {
			String colorKey[i][1];
			addTextKeyToCover(overlayKeyscolorKey);
		}
		overlayKeys.toArray(keys);
	}
	private void addTextKeyToCover(ArrayList overlayKeysString mainKey) {
	}
	private Control createAppearancePage(Composite parent) {
		Font fontparent.getFont();
		Composite appearanceCompositenew Composite(parent, SWT.NONE);
		appearanceComposite.setFont(font);
		GridLayout layoutnew GridLayout();
		layout.numColumns= 2;
		appearanceComposite.setLayout(layout);
		return appearanceComposite;
	}
	/* (non-Javadoc)
	 * @see org.eclipse.jface.preference.PreferencePage#createContents(org.eclipse.swt.widgets.Composite)
	 */
	protected Control createContents(Composite parent) {
		createHeader(parent);
		TabFolder foldernew TabFolder(parent, SWT.NONE);
		folder.setLayout(new TabFolderLayout());
		folder.setLayoutData(new GridData(GridData.FILL_BOTH));
		TabItem itemnew TabItem(folder, SWT.NONE);
		item.setControl(createAppearancePage(folder));
		itemnew TabItem(folder, SWT.NONE);
		item.setControl(createSyntaxPage(folder));
		itemnew TabItem(folder, SWT.NONE);
		item.setControl(createProblemsTabContent(folder));
		itemnew TabItem(folder, SWT.NONE);
		item.setControl(createFoldingTabContent(folder));
		return folder;
	}
	private Control createFoldingTabContent(TabFolder folder) {
		Composite compositenew Composite(folder, SWT.NULL);
		GridLayout layoutnew GridLayout();
		layout.numColumns= 2;
		composite.setLayout(layout);
		Label labelnew Label(composite, SWT.LEFT);
		return composite;
	}
	private void initialize() {
		for (int i= 0, n.i < ni++) {
		}
	}
	/* (non-Javadoc)
	 * @see org.eclipse.ant.internal.ui.preferences.AbstractAntEditorPreferencePage#handleDefaults()
	 */
	protected void handleDefaults() {
	}
	private Control createSyntaxPage(Composite parent) {
		Composite colorCompositenew Composite(parent, SWT.NONE);
		colorComposite.setLayout(new GridLayout());
		Label labelnew Label(colorComposite, SWT.LEFT);
		label.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
		Composite editorCompositenew Composite(colorComposite, SWT.NONE);
		GridLayout layoutnew GridLayout();
		layout.numColumns= 2;
		layout.marginHeight= 0;
		layout.marginWidth= 0;
		editorComposite.setLayout(layout);
		GridData gdnew GridData(GridData.FILL_BOTH);
		editorComposite.setLayoutData(gd);
		new TableViewer(editorComposite, SWT.SINGLE | SWT.V_SCROLL | SWT.BORDER | SWT.FULL_SELECTION);
		gdnew GridData(GridData.FILL_BOTH);
		gd.heightHint= convertHeightInCharsToPixels(5);
		Composite stylesCompositenew Composite(editorComposite, SWT.NONE);
		layoutnew GridLayout();
		layout.marginHeight= 0;
		layout.marginWidth= 0;
		layout.numColumns= 2;
		stylesComposite.setLayout(layout);
		stylesComposite.setLayoutData(new GridData(GridData.FILL_BOTH));
		labelnew Label(stylesComposite, SWT.LEFT);
		gdnew GridData();
		gd.horizontalAlignment= GridData.BEGINNING;
		label.setLayoutData(gd);
		Button foregroundColorButton.getButton();
		gdnew GridData(GridData.FILL_HORIZONTAL);
		gd.horizontalAlignment= GridData.BEGINNING;
		foregroundColorButton.setLayoutData(gd);
		new Button(stylesComposite, SWT.CHECK);
		gdnew GridData(GridData.FILL_HORIZONTAL);
		gd.horizontalAlignment= GridData.BEGINNING;
		gd.horizontalSpan= 2;
		.setLayoutData(gd);
		new Button(stylesComposite, SWT.CHECK);
		gdnew GridData(GridData.FILL_HORIZONTAL);
		gd.horizontalAlignment= GridData.BEGINNING;
		gd.horizontalSpan= 2;
		.setLayoutData(gd);
		labelnew Label(colorComposite, SWT.LEFT);
		label.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
		Control previewercreatePreviewer(colorComposite);
		gdnew GridData(GridData.FILL_BOTH);
		gd.widthHint= convertWidthInCharsToPixels(20);
		gd.heightHint= convertHeightInCharsToPixels(5);
		previewer.setLayoutData(gd);
			public void selectionChanged(SelectionChangedEvent event) {
			}
		});
		foregroundColorButton.addSelectionListener(new SelectionListener() {
			public void widgetDefaultSelected(SelectionEvent e) {
				// do nothing
			}
			public void widgetSelected(SelectionEvent e) {
			}
		});
		.addSelectionListener(new SelectionListener() {
			public void widgetDefaultSelected(SelectionEvent e) {
				// do nothing
			}
			public void widgetSelected(SelectionEvent e) {
			}
		});
		.addSelectionListener(new SelectionListener() {
			public void widgetDefaultSelected(SelectionEvent e) {
				// do nothing
			}
			public void widgetSelected(SelectionEvent e) {
			}
		});
		return colorComposite;
	}
	private Control createPreviewer(Composite parent) {
		 = new SourceViewer(parentnullnullfalse, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL);
        
		.configure(configuration);
		Font font= JFaceResources.getFont(.);
		new AntPreviewerUpdater(configurationstore);
		String contentloadPreviewContentFromFile("SyntaxPreviewCode.txt"); //$NON-NLS-1$
		IDocument document = new Document(content);
	}
		RGB rgb= PreferenceConverter.getColor(getOverlayStore(), item.getColorKey());
	}

Returns the current highlighting color list item.

Returns:
the current highlighting color list item
Since:
3.0
	}
	/* (non-Javadoc)
	 * @see org.eclipse.jface.dialogs.IDialogPage#dispose()
	 */
	public void dispose() {
		super.dispose();
		if ( != null) {
		}
	}
	private Composite createProblemsTabContent(TabFolder folder) {
		String[] errorWarningIgnoreLabelsnew String[] {
		String[] errorWarningIgnorenew String[] {
		int nColumns= 3;
		GridLayout layoutnew GridLayout();
		layout.numColumns= nColumns;
		Composite othersCompositenew Composite(folder, SWT.NULL);
		othersComposite.setLayout(layout);
		 = new Label(othersComposite, SWT.WRAP);
		GridData gdnew GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL);
		gd.horizontalSpan= nColumns;
		new Label(othersComposite, SWT.WRAP);
		gdnew GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL);
		gd.horizontalSpan= nColumns;
		.setLayoutData(gd);
		addComboBox(othersCompositelabel.errorWarningIgnoreerrorWarningIgnoreLabels, 0);
		addComboBox(othersCompositelabel.errorWarningIgnoreerrorWarningIgnoreLabels, 0);
		addComboBox(othersCompositelabel.errorWarningIgnoreerrorWarningIgnoreLabels, 0);
		addComboBox(othersCompositelabel.errorWarningIgnoreerrorWarningIgnoreLabels, 0);
        
        addComboBox(othersCompositelabel.errorWarningIgnoreerrorWarningIgnoreLabels, 0);
		return othersComposite;
	}
	private void initializeWorkingValues() {
		for (int i = 0; i < .i++) {
		}
	}
		for (int i = 0; i < .i++) {
		}
	}
	protected Combo addComboBox(Composite parentString labelString keyString[] valuesString[] valueLabelsint indent) {
		ControlData datanew ControlData(keyvalues);
		GridData gdnew GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
		gd.horizontalIndent= indent;
		Label labelControlnew Label(parent, SWT.LEFT | SWT.WRAP);
		labelControl.setText(label);
		labelControl.setLayoutData(gd);
		Combo comboBoxnew Combo(parent, SWT.READ_ONLY);
		comboBox.setItems(valueLabels);
		comboBox.setData(data);
		comboBox.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL));
		comboBox.addSelectionListener(getSelectionListener());
		Label placeHoldernew Label(parent, SWT.NONE);
		placeHolder.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
		String currValue= (String).get(key);
		comboBox.select(data.getSelection(currValue));
		.add(labelControl);
		.add(comboBox);
		return comboBox;
	}
	protected SelectionListener getSelectionListener() {
		if ( == null) {
			new SelectionListener() {
				public void widgetDefaultSelected(SelectionEvent e) {}
				public void widgetSelected(SelectionEvent e) {
					controlChanged(e.widget);
				}
			};
		}
	}
	protected void controlChanged(Widget widget) {
		ControlData data= (ControlDatawidget.getData();
		String newValuenull;
		if (widget instanceof Button) {
			if (widget == ) {
				updateControlsForProblemReporting(!((Button)widget).getSelection());
				return;
			}
			newValuedata.getValue(((Button)widget).getSelection());
else if (widget instanceof Combo) {
			newValuedata.getValue(((Combo)widget).getSelectionIndex());
else {
			return;
		}
		.put(data.getKey(), newValue);
	}
	private void updateControlsForProblemReporting(boolean reportProblems) {
		for (int i.size() - 1; i >= 0; i--) {
			((Control) .get(i)).setEnabled(reportProblems);
			((Control) .get(i)).setEnabled(reportProblems);
		}
		.setEnabled(reportProblems);
		.setEnabled(reportProblems);
		.setEnabled(reportProblems);
		.setEnabled(reportProblems);
	}
	protected void updateControls() {
		// update the UI
		for (int i.size() - 1; i >= 0; i--) {
			Combo curr= (Combo) .get(i);
			ControlData data= (ControlDatacurr.getData();
			String currValue= (String.get(data.getKey());
			curr.select(data.getSelection(currValue));
		}
	}
	/* (non-Javadoc)
	 * @see org.eclipse.jface.preference.IPreferencePage#performOk()
	 */
	public boolean performOk() {
		while (iter.hasNext()) {
			String key = (Stringiter.next();
			store.putValue(key, (String).get(key));
		}
		if (store.needsSaving()) {
            //any AntModels listen for changes to the "PROBLEM" pref
            //this is so that the models do not update for each and every pref modification
			store.putValue(."changed"); //$NON-NLS-1$
			//ensure to clear as there may not be any models open currently
            store.setToDefault(.);
		}
		return super.performOk();
	}
	private void createHeader(Composite contents) {
		final Link linknew Link(contents, SWT.NONE);
		final String target"org.eclipse.ui.preferencePages.GeneralTextEditor"//$NON-NLS-1$
		link.addSelectionListener(new SelectionAdapter() {
			public void widgetSelected(SelectionEvent e) {
				PreferencesUtil.createPreferenceDialogOn(link.getShell(), targetnullnull);
			}
		});
		link.setToolTipText(linktooltip);
	}
New to GrepCode? Check out our FAQ X