issue_id
int64
2.03k
426k
title
stringlengths
9
251
body
stringlengths
1
32.8k
status
stringclasses
6 values
after_fix_sha
stringlengths
7
7
project_name
stringclasses
6 values
repo_url
stringclasses
6 values
repo_name
stringclasses
6 values
language
stringclasses
1 value
issue_url
null
before_fix_sha
null
pull_url
null
commit_datetime
timestamp[us, tz=UTC]
report_datetime
timestamp[us, tz=UTC]
updated_file
stringlengths
2
187
file_content
stringlengths
0
368k
42,700
Bug 42700 Add support for editing values in Externalize Strings wizard
null
resolved fixed
dddfb15
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2003-09-10T14:49:41Z
2003-09-08T14:06:40Z
org.eclipse.jdt.ui.tests.refactoring/test
42,700
Bug 42700 Add support for editing values in Externalize Strings wizard
null
resolved fixed
dddfb15
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2003-09-10T14:49:41Z
2003-09-08T14:06:40Z
cases/org/eclipse/jdt/ui/tests/nls/NLSRefactoringTester.java
42,700
Bug 42700 Add support for editing values in Externalize Strings wizard
null
resolved fixed
dddfb15
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2003-09-10T14:49:41Z
2003-09-08T14:06:40Z
org.eclipse.jdt.ui/core
42,700
Bug 42700 Add support for editing values in Externalize Strings wizard
null
resolved fixed
dddfb15
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2003-09-10T14:49:41Z
2003-09-08T14:06:40Z
refactoring/org/eclipse/jdt/internal/corext/refactoring/nls/NLSHolder.java
42,700
Bug 42700 Add support for editing values in Externalize Strings wizard
null
resolved fixed
dddfb15
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2003-09-10T14:49:41Z
2003-09-08T14:06:40Z
org.eclipse.jdt.ui/core
42,700
Bug 42700 Add support for editing values in Externalize Strings wizard
null
resolved fixed
dddfb15
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2003-09-10T14:49:41Z
2003-09-08T14:06:40Z
refactoring/org/eclipse/jdt/internal/corext/refactoring/nls/NLSRefactoring.java
42,700
Bug 42700 Add support for editing values in Externalize Strings wizard
null
resolved fixed
dddfb15
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2003-09-10T14:49:41Z
2003-09-08T14:06:40Z
org.eclipse.jdt.ui/ui
42,700
Bug 42700 Add support for editing values in Externalize Strings wizard
null
resolved fixed
dddfb15
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2003-09-10T14:49:41Z
2003-09-08T14:06:40Z
refactoring/org/eclipse/jdt/internal/ui/refactoring/nls/ExternalizeWizardPage.java
42,767
Bug 42767 Grabbing vertically on add constructor/ gen contructors using fields action
The source actions related to creating constructors is not relayouting properly on resize. The lowermost checkbox is grabbing vertically when it shouldn't be. In the case of the gen. constructors using fields dialog, the upper combobox and label are grabbing vertical space when they shouldn't be either.
resolved fixed
1be3aba
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2003-09-10T14:56:07Z
2003-09-09T09:33:20Z
org.eclipse.jdt.ui/ui/org/eclipse/jdt/ui/actions/AddUnimplementedConstructorsAction.java
/******************************************************************************* * Copyright (c) 2000, 2003 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Common Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/cpl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.jdt.ui.actions; import java.lang.reflect.InvocationTargetException; import java.util.ArrayList; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IStatus; import org.eclipse.swt.SWT; import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.events.SelectionListener; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Control; import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.Shell; import org.eclipse.jface.dialogs.IDialogConstants; import org.eclipse.jface.dialogs.IDialogSettings; import org.eclipse.jface.dialogs.MessageDialog; import org.eclipse.jface.operation.IRunnableContext; import org.eclipse.jface.text.IRewriteTarget; import org.eclipse.jface.text.ITextSelection; import org.eclipse.jface.viewers.CheckboxTreeViewer; import org.eclipse.jface.viewers.ILabelProvider; import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.jface.viewers.ITreeContentProvider; import org.eclipse.jface.viewers.Viewer; import org.eclipse.jface.window.Window; import org.eclipse.ui.IEditorPart; import org.eclipse.ui.IWorkbenchSite; import org.eclipse.ui.dialogs.ISelectionStatusValidator; import org.eclipse.ui.help.WorkbenchHelp; import org.eclipse.jdt.core.ICompilationUnit; import org.eclipse.jdt.core.IJavaElement; import org.eclipse.jdt.core.IMethod; import org.eclipse.jdt.core.IType; import org.eclipse.jdt.core.JavaModelException; import org.eclipse.jdt.ui.JavaElementLabelProvider; import org.eclipse.jdt.ui.JavaElementSorter; import org.eclipse.jdt.internal.corext.codemanipulation.AddUnimplementedConstructorsOperation; import org.eclipse.jdt.internal.corext.codemanipulation.CodeGenerationSettings; import org.eclipse.jdt.internal.corext.codemanipulation.StubUtility; import org.eclipse.jdt.internal.corext.util.JavaModelUtil; import org.eclipse.jdt.internal.ui.IJavaHelpContextIds; import org.eclipse.jdt.internal.ui.JavaPlugin; import org.eclipse.jdt.internal.ui.actions.ActionMessages; import org.eclipse.jdt.internal.ui.actions.ActionUtil; import org.eclipse.jdt.internal.ui.actions.SelectionConverter; import org.eclipse.jdt.internal.ui.actions.WorkbenchRunnableAdapter; import org.eclipse.jdt.internal.ui.dialogs.SourceActionDialog; import org.eclipse.jdt.internal.ui.dialogs.StatusInfo; import org.eclipse.jdt.internal.ui.javaeditor.CompilationUnitEditor; import org.eclipse.jdt.internal.ui.javaeditor.EditorUtility; import org.eclipse.jdt.internal.ui.preferences.JavaPreferencesSettings; import org.eclipse.jdt.internal.ui.refactoring.IVisibilityChangeListener; import org.eclipse.jdt.internal.ui.util.BusyIndicatorRunnableContext; import org.eclipse.jdt.internal.ui.util.ElementValidator; import org.eclipse.jdt.internal.ui.util.ExceptionHandler; /** * Creates unimplemented constructors for a type. * <p> * Will open the parent compilation unit in a Java editor. Opens a dialog * with a list of constructors from the super class which can be generated. * User is able to check or uncheck items before constructors are generated. * The result is unsaved, so the user can decide if the changes are acceptable. * <p> * The action is applicable to structured selections containing elements * of type <code>IType</code>. * * <p> * This class may be instantiated; it is not intended to be subclassed. * </p> * * @since 2.0 */ public class AddUnimplementedConstructorsAction extends SelectionDispatchAction { private CompilationUnitEditor fEditor; private static final String dialogTitle= ActionMessages.getString("AddUnimplementedConstructorsAction.error.title"); //$NON-NLS-1$ /** * Creates a new <code>AddUnimplementedConstructorsAction</code>. The action requires * that the selection provided by the site's selection provider is of type <code> * org.eclipse.jface.viewers.IStructuredSelection</code>. * * @param site the site providing context information for this action */ public AddUnimplementedConstructorsAction(IWorkbenchSite site) { super(site); setText(ActionMessages.getString("AddUnimplementedConstructorsAction.label")); //$NON-NLS-1$ setDescription(ActionMessages.getString("AddUnimplementedConstructorsAction.description")); //$NON-NLS-1$ setToolTipText(ActionMessages.getString("AddUnimplementedConstructorsAction.tooltip")); //$NON-NLS-1$ WorkbenchHelp.setHelp(this, IJavaHelpContextIds.ADD_UNIMPLEMENTED_CONSTRUCTORS_ACTION); } /** * Note: This constructor is for internal use only. Clients should not call this constructor. */ public AddUnimplementedConstructorsAction(CompilationUnitEditor editor) { this(editor.getEditorSite()); fEditor= editor; setEnabled(checkEnabledEditor()); } //---- Structured Viewer ----------------------------------------------------------- /* (non-Javadoc) * Method declared on SelectionDispatchAction */ public void selectionChanged(IStructuredSelection selection) { try { setEnabled(canEnable(selection)); } catch (JavaModelException e) { // http://bugs.eclipse.org/bugs/show_bug.cgi?id=19253 if (JavaModelUtil.filterNotPresentException(e)) JavaPlugin.log(e); setEnabled(false); } } private boolean canEnable(IStructuredSelection selection) throws JavaModelException { if ((selection.size() == 1) && (selection.getFirstElement() instanceof IType)) { IType type= (IType) selection.getFirstElement(); return type.getCompilationUnit() != null && type.isClass(); // look if class: not cheap but done by all source generation actions } if ((selection.size() == 1) && (selection.getFirstElement() instanceof ICompilationUnit)) return true; return false; } /* (non-Javadoc) * Method declared on SelectionDispatchAction */ public void run(IStructuredSelection selection) { Shell shell= getShell(); try { IType type= getSelectedType(selection); if (type == null) { MessageDialog.openInformation(getShell(), getDialogTitle(), ActionMessages.getString("AddUnimplementedConstructorsAction.not_applicable")); //$NON-NLS-1$ return; } // open an editor and work on a working copy IEditorPart editor= EditorUtility.openInEditor(type); type= (IType)EditorUtility.getWorkingCopy(type); if (type == null) { MessageDialog.openError(shell, getDialogTitle(), ActionMessages.getString("AddUnimplementedConstructorsAction.error.type_removed_in_editor")); //$NON-NLS-1$ return; } run(shell, type, editor, false); } catch (CoreException e) { ExceptionHandler.handle(e, shell, getDialogTitle(), null); } } //---- Java Editior -------------------------------------------------------------- /* (non-Javadoc) * Method declared on SelectionDispatchAction */ protected void selectionChanged(ITextSelection selection) { } /* (non-Javadoc) * Method declared on SelectionDispatchAction */ public void run(ITextSelection selection) { Shell shell= getShell(); try { IType type= SelectionConverter.getTypeAtOffset(fEditor); if (type != null) run(shell, type, fEditor, true); else MessageDialog.openInformation(shell, getDialogTitle(), ActionMessages.getString("AddUnimplementedConstructorsAction.not_applicable")); //$NON-NLS-1$ } catch (JavaModelException e) { ExceptionHandler.handle(e, getShell(), getDialogTitle(), null); } catch (CoreException e) { ExceptionHandler.handle(e, getShell(), getDialogTitle(), null); } } private boolean checkEnabledEditor() { return fEditor != null && SelectionConverter.canOperateOn(fEditor); } //---- Helpers ------------------------------------------------------------------- private void run(Shell shell, IType type, IEditorPart editor, boolean activatedFromEditor) throws CoreException { if (!ElementValidator.check(type, getShell(), getDialogTitle(), activatedFromEditor)) { return; } if (!ActionUtil.isProcessable(getShell(), type)) { return; } IMethod[] constructorMethods= StubUtility.getOverridableConstructors(type); if (constructorMethods.length == 0) { MessageDialog.openInformation(getShell(), getDialogTitle(), ActionMessages.getString("AddUnimplementedConstructorsAction.error.nothing_found")); //$NON-NLS-1$ return; } JavaElementLabelProvider labelProvider= new JavaElementLabelProvider(JavaElementLabelProvider.SHOW_DEFAULT); AddUnimplementedConstructorsContentProvider contentProvider = new AddUnimplementedConstructorsContentProvider(constructorMethods); AddUnimplementedConstructorsDialog dialog= new AddUnimplementedConstructorsDialog(shell, labelProvider, contentProvider, fEditor, type); dialog.setCommentString(ActionMessages.getString("SourceActionDialog.createConstructorComment")); //$NON-NLS-1$ dialog.setTitle(ActionMessages.getString("AddUnimplementedConstructorsAction.dialog.title")); //$NON-NLS-1$ dialog.setInitialSelections(constructorMethods); dialog.setContainerMode(true); dialog.setSorter(new JavaElementSorter()); dialog.setSize(60, 18); dialog.setInput(new Object()); dialog.setMessage(ActionMessages.getString("AddUnimplementedConstructorsAction.dialog.label")); //$NON-NLS-1$ dialog.setValidator(createValidator(constructorMethods.length)); IMethod[] selected= null; int dialogResult = dialog.open(); if (dialogResult == Window.OK) { Object[] checkedElements = dialog.getResult(); if (checkedElements == null) return; ArrayList result= new ArrayList(checkedElements.length); for (int i= 0; i < checkedElements.length; i++) { Object curr= checkedElements[i]; if (curr instanceof IMethod) { result.add(curr); } } selected= (IMethod[]) result.toArray(new IMethod[result.size()]); CodeGenerationSettings settings= JavaPreferencesSettings.getCodeGenerationSettings(); settings.createComments= dialog.getGenerateComment(); IJavaElement elementPosition= dialog.getElementPosition(); AddUnimplementedConstructorsOperation op= new AddUnimplementedConstructorsOperation(type, settings, selected, false, elementPosition); op.setVisbility(dialog.getVisibilityModifier()); op.setOmitSuper(dialog.isOmitSuper()); IRewriteTarget target= editor != null ? (IRewriteTarget) editor.getAdapter(IRewriteTarget.class) : null; if (target != null) { target.beginCompoundChange(); } try { IRunnableContext context= JavaPlugin.getActiveWorkbenchWindow(); if (context == null) { context= new BusyIndicatorRunnableContext(); } context.run(false, true, new WorkbenchRunnableAdapter(op)); IMethod[] res= op.getCreatedMethods(); if (res == null || res.length == 0) { MessageDialog.openInformation(shell, getDialogTitle(), ActionMessages.getString("AddUnimplementedConstructorsAction.error.nothing_found")); //$NON-NLS-1$ } else if (editor != null) { if (res[0].getCompilationUnit().isWorkingCopy()) { synchronized(res[0].getCompilationUnit()) { res[0].getCompilationUnit().reconcile(); } } EditorUtility.revealInEditor(editor, res[0]); } } catch (InvocationTargetException e) { ExceptionHandler.handle(e, shell, getDialogTitle(), null); } catch (InterruptedException e) { // Do nothing. Operation has been canceled by user. } finally { if (target != null) { target.endCompoundChange(); } } } } private static ISelectionStatusValidator createValidator(int entries) { AddUnimplementedConstructorsValidator validator= new AddUnimplementedConstructorsValidator(entries); return validator; } private IType getSelectedType(IStructuredSelection selection) throws JavaModelException { Object[] elements= selection.toArray(); if (elements.length == 1 && (elements[0] instanceof IType)) { IType type= (IType) elements[0]; if (type.getCompilationUnit() != null && type.isClass()) { return type; } } else if (elements[0] instanceof ICompilationUnit) { ICompilationUnit cu= (ICompilationUnit) elements[0]; IType type= cu.findPrimaryType(); if (type != null && !type.isInterface()) return type; } return null; } private String getDialogTitle() { return dialogTitle; } private static class AddUnimplementedConstructorsContentProvider implements ITreeContentProvider { private IMethod[] fMethodsList; private static final Object[] EMPTY= new Object[0]; public AddUnimplementedConstructorsContentProvider(IMethod[] methodList) { fMethodsList= methodList; } /* * @see ITreeContentProvider#getChildren(Object) */ public Object[] getChildren(Object parentElement) { return EMPTY; } /* * @see ITreeContentProvider#getParent(Object) */ public Object getParent(Object element) { return null; } /* * @see ITreeContentProvider#hasChildren(Object) */ public boolean hasChildren(Object element) { return getChildren(element).length > 0; } /* * @see IStructuredContentProvider#getElements(Object) */ public Object[] getElements(Object inputElement) { return fMethodsList; } /* * @see IContentProvider#dispose() */ public void dispose() { } /* * @see IContentProvider#inputChanged(Viewer, Object, Object) */ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { } } private static class AddUnimplementedConstructorsValidator implements ISelectionStatusValidator { private static int fEntries; AddUnimplementedConstructorsValidator(int entries) { super(); fEntries= entries; } public IStatus validate(Object[] selection) { int count= countSelectedMethods(selection); if (count == 0) return new StatusInfo(IStatus.ERROR, ""); //$NON-NLS-1$ String message= ActionMessages.getFormattedString("AddUnimplementedConstructorsAction.methods_selected", //$NON-NLS-1$ new Object[] { String.valueOf(count), String.valueOf(fEntries)} ); return new StatusInfo(IStatus.INFO, message); } private int countSelectedMethods(Object[] selection){ int count= 0; for (int i = 0; i < selection.length; i++) { if (selection[i] instanceof IMethod) count++; } return count; } } private static class AddUnimplementedConstructorsDialog extends SourceActionDialog { private boolean fOmitSuper; private int fWidth= 60; private int fHeight= 18; private IDialogSettings fAddConstructorsSettings; private final String SETTINGS_SECTION= "AddUnimplementedConstructorsDialog"; //$NON-NLS-1$ private final String OMIT_SUPER="OmitCallToSuper"; //$NON-NLS-1$ public AddUnimplementedConstructorsDialog(Shell parent, ILabelProvider labelProvider, ITreeContentProvider contentProvider, CompilationUnitEditor editor, IType type) { super(parent, labelProvider, contentProvider, editor, type); IDialogSettings dialogSettings= JavaPlugin.getDefault().getDialogSettings(); fAddConstructorsSettings= dialogSettings.getSection(SETTINGS_SECTION); if (fAddConstructorsSettings == null) { fAddConstructorsSettings= dialogSettings.addNewSection(SETTINGS_SECTION); fAddConstructorsSettings.put(OMIT_SUPER, false); //$NON-NLS-1$ } fOmitSuper= fAddConstructorsSettings.getBoolean(OMIT_SUPER); } protected Composite createEntryPtCombo(Composite composite) { Composite entryComposite= super.createEntryPtCombo(composite); addVisibilityAndModifiersChoices(entryComposite); return entryComposite; } protected Composite createVisibilityControlAndModifiers(Composite parent, final IVisibilityChangeListener visibilityChangeListener, int[] availableVisibilities, int correctVisibility) { Composite visibilityComposite= createVisibilityControl(parent, visibilityChangeListener, availableVisibilities, correctVisibility); return visibilityComposite; } public boolean isOmitSuper() { return fOmitSuper; } public void setOmitSuper(boolean omitSuper) { if (fOmitSuper != omitSuper) { fOmitSuper= omitSuper; fAddConstructorsSettings.put(OMIT_SUPER, omitSuper); } } protected Composite createOmitSuper(Composite composite) { Composite omitSuperComposite= new Composite(composite, SWT.NONE); GridLayout layout= new GridLayout(); layout.marginHeight= 0; layout.marginWidth= 0; omitSuperComposite.setLayout(layout); omitSuperComposite.setFont(composite.getFont()); Button omitSuperButton= new Button(omitSuperComposite, SWT.CHECK); omitSuperButton.setText(ActionMessages.getString("AddUnimplementedConstructorsDialog.omit.super")); //$NON-NLS-1$ omitSuperButton.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL)); omitSuperButton.addSelectionListener(new SelectionListener() { public void widgetSelected(SelectionEvent e) { boolean isSelected= (((Button) e.widget).getSelection()); setOmitSuper(isSelected); } public void widgetDefaultSelected(SelectionEvent e) { widgetSelected(e); } }); omitSuperButton.setSelection(isOmitSuper()); GridData gd= new GridData(GridData.HORIZONTAL_ALIGN_FILL); gd.horizontalSpan= 2; omitSuperButton.setLayoutData(gd); return omitSuperComposite; } protected Control createDialogArea(Composite parent) { initializeDialogUnits(parent); Composite composite= new Composite(parent, SWT.NONE); GridLayout layout= new GridLayout(); GridData gd= null; layout.marginHeight= convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN); layout.marginWidth= convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN); layout.verticalSpacing= convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING); layout.horizontalSpacing= convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING); composite.setLayout(layout); Label messageLabel = createMessageArea(composite); if (messageLabel != null) { gd= new GridData(GridData.HORIZONTAL_ALIGN_FILL); gd.horizontalSpan= 2; messageLabel.setLayoutData(gd); } Composite inner= new Composite(composite, SWT.NONE); GridLayout innerLayout = new GridLayout(); innerLayout.numColumns= 2; innerLayout.marginHeight= 0; innerLayout.marginWidth= 0; inner.setLayout(innerLayout); inner.setFont(parent.getFont()); CheckboxTreeViewer treeViewer= createTreeViewer(inner); gd= new GridData(GridData.FILL_BOTH); gd.widthHint = convertWidthInCharsToPixels(fWidth); gd.heightHint = convertHeightInCharsToPixels(fHeight); treeViewer.getControl().setLayoutData(gd); Composite buttonComposite= createSelectionButtons(inner); gd= new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_FILL); buttonComposite.setLayoutData(gd); gd= new GridData(GridData.FILL_BOTH); inner.setLayoutData(gd); Composite entryComposite= createEntryPtCombo(composite); entryComposite.setLayoutData(new GridData(GridData.FILL_BOTH)); Composite commentComposite= createCommentSelection(composite); commentComposite.setLayoutData(new GridData(GridData.FILL_BOTH)); Composite overrideSuperComposite= createOmitSuper(composite); overrideSuperComposite.setLayoutData(new GridData(GridData.FILL_BOTH)); gd= new GridData(GridData.FILL_BOTH); composite.setLayoutData(gd); applyDialogFont(composite); return composite; } } }
42,767
Bug 42767 Grabbing vertically on add constructor/ gen contructors using fields action
The source actions related to creating constructors is not relayouting properly on resize. The lowermost checkbox is grabbing vertically when it shouldn't be. In the case of the gen. constructors using fields dialog, the upper combobox and label are grabbing vertical space when they shouldn't be either.
resolved fixed
1be3aba
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2003-09-10T14:56:07Z
2003-09-09T09:33:20Z
org.eclipse.jdt.ui/ui/org/eclipse/jdt/ui/actions/GenerateNewConstructorUsingFieldsAction.java
/******************************************************************************* * Copyright (c) 2000, 2003 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Common Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/cpl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.jdt.ui.actions; import java.lang.reflect.InvocationTargetException; import java.util.ArrayList; import java.util.List; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IStatus; 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.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.Shell; import org.eclipse.jface.dialogs.IDialogConstants; import org.eclipse.jface.dialogs.IDialogSettings; import org.eclipse.jface.dialogs.MessageDialog; import org.eclipse.jface.operation.IRunnableContext; import org.eclipse.jface.text.IRewriteTarget; import org.eclipse.jface.text.ITextSelection; import org.eclipse.jface.viewers.CheckboxTreeViewer; import org.eclipse.jface.viewers.DoubleClickEvent; import org.eclipse.jface.viewers.IDoubleClickListener; import org.eclipse.jface.viewers.ILabelProvider; import org.eclipse.jface.viewers.ISelectionChangedListener; import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.jface.viewers.ITreeContentProvider; import org.eclipse.jface.viewers.SelectionChangedEvent; import org.eclipse.jface.viewers.StructuredSelection; import org.eclipse.jface.viewers.Viewer; import org.eclipse.jface.window.Window; import org.eclipse.ui.IEditorPart; import org.eclipse.ui.IWorkbenchSite; import org.eclipse.ui.dialogs.ISelectionStatusValidator; import org.eclipse.ui.help.WorkbenchHelp; import org.eclipse.jdt.core.Flags; import org.eclipse.jdt.core.ICompilationUnit; import org.eclipse.jdt.core.IField; import org.eclipse.jdt.core.IJavaElement; import org.eclipse.jdt.core.IMethod; import org.eclipse.jdt.core.IType; import org.eclipse.jdt.core.ITypeHierarchy; import org.eclipse.jdt.core.JavaModelException; import org.eclipse.jdt.core.ToolFactory; import org.eclipse.jdt.core.compiler.IScanner; import org.eclipse.jdt.core.compiler.ITerminalSymbols; import org.eclipse.jdt.ui.JavaElementLabelProvider; import org.eclipse.jdt.internal.corext.codemanipulation.AddCustomConstructorOperation; import org.eclipse.jdt.internal.corext.codemanipulation.CodeGenerationSettings; import org.eclipse.jdt.internal.corext.dom.TokenScanner; import org.eclipse.jdt.internal.corext.util.JavaModelUtil; import org.eclipse.jdt.internal.ui.IJavaHelpContextIds; import org.eclipse.jdt.internal.ui.JavaPlugin; import org.eclipse.jdt.internal.ui.actions.ActionMessages; import org.eclipse.jdt.internal.ui.actions.ActionUtil; import org.eclipse.jdt.internal.ui.actions.SelectionConverter; import org.eclipse.jdt.internal.ui.actions.WorkbenchRunnableAdapter; import org.eclipse.jdt.internal.ui.dialogs.SourceActionDialog; import org.eclipse.jdt.internal.ui.dialogs.StatusInfo; import org.eclipse.jdt.internal.ui.javaeditor.CompilationUnitEditor; import org.eclipse.jdt.internal.ui.javaeditor.EditorUtility; import org.eclipse.jdt.internal.ui.preferences.JavaPreferencesSettings; import org.eclipse.jdt.internal.ui.refactoring.IVisibilityChangeListener; import org.eclipse.jdt.internal.ui.util.BusyIndicatorRunnableContext; import org.eclipse.jdt.internal.ui.util.ElementValidator; import org.eclipse.jdt.internal.ui.util.ExceptionHandler; import org.eclipse.jdt.internal.ui.viewsupport.JavaElementLabels; public class GenerateNewConstructorUsingFieldsAction extends SelectionDispatchAction { private CompilationUnitEditor fEditor; private static final String fDialogTitle= ActionMessages.getString("GenerateConstructorUsingFieldsAction.error.title"); //$NON-NLS-1$ private static final int UP_INDEX= 0; private static final int DOWN_INDEX= 1; /** * Creates a new <code>GenerateConstructorUsingFieldsAction</code>. The action requires * that the selection provided by the site's selection provider is of type <code> * org.eclipse.jface.viewers.IStructuredSelection</code>. * * @param site the site providing context information for this action */ public GenerateNewConstructorUsingFieldsAction(IWorkbenchSite site) { super(site); setText(ActionMessages.getString("GenerateConstructorUsingFieldsAction.label")); //$NON-NLS-1$ setDescription(ActionMessages.getString("GenerateConstructorUsingFieldsAction.description")); //$NON-NLS-1$ setToolTipText(ActionMessages.getString("GenerateConstructorUsingFieldsAction.tooltip")); //$NON-NLS-1$ WorkbenchHelp.setHelp(this, IJavaHelpContextIds.CREATE_NEW_CONSTRUCTOR_ACTION); } /** * Note: This constructor is for internal use only. Clients should not call this constructor. */ public GenerateNewConstructorUsingFieldsAction(CompilationUnitEditor editor) { this(editor.getEditorSite()); fEditor= editor; setEnabled(checkEnabledEditor()); } //---- Structured Viewer ----------------------------------------------------------- /* (non-Javadoc) * Method declared on SelectionDispatchAction */ public void selectionChanged(IStructuredSelection selection) { try { setEnabled(canEnable(selection)); } catch (JavaModelException e) { // http://bugs.eclipse.org/bugs/show_bug.cgi?id=19253 if (JavaModelUtil.filterNotPresentException(e)) JavaPlugin.log(e); setEnabled(false); } } private boolean canEnable(IStructuredSelection selection) throws JavaModelException { if (getSelectedFields(selection) != null) return true; if ((selection.size() == 1) && (selection.getFirstElement() instanceof IType)) { IType type= (IType) selection.getFirstElement(); return type.getCompilationUnit() != null && type.isClass(); // look if class: not cheap but done by all source generation actions } if ((selection.size() == 1) && (selection.getFirstElement() instanceof ICompilationUnit)) return true; return false; } /* (non-Javadoc) * Method declared on SelectionDispatchAction */ public void run(IStructuredSelection selection) { try { IType selectionType= getSelectedType(selection); if (selectionType == null) { MessageDialog.openInformation(getShell(), getDialogTitle(), ActionMessages.getString("GenerateConstructorUsingFieldsAction.not_applicable")); //$NON-NLS-1$ return; } IField[] selectedFields= getSelectedFields(selection); // open an editor and work on a working copy IEditorPart editor= null; if (selectedFields != null) editor= EditorUtility.openInEditor(selectedFields[0]); else editor= EditorUtility.openInEditor(getSelectedType(selection).getCompilationUnit()); if (canRunOn(selectedFields)) { run((IType) EditorUtility.getWorkingCopy(selectedFields[0].getDeclaringType()), selectedFields, editor, false); return; } Object firstElement= selection.getFirstElement(); if (firstElement instanceof IType) run((IType) EditorUtility.getWorkingCopy((IType) firstElement), new IField[0], editor, false); else if (firstElement instanceof ICompilationUnit) { IType type= ((ICompilationUnit) firstElement).findPrimaryType(); if (type.isInterface()) { MessageDialog.openInformation(getShell(), fDialogTitle, ActionMessages.getString("GenerateConstructorUsingFieldsAction.interface_not_applicable")); //$NON-NLS-1$ return; } else run((IType) EditorUtility.getWorkingCopy(((ICompilationUnit) firstElement).findPrimaryType()), new IField[0], editor, false); } } catch (CoreException e) { ExceptionHandler.handle(e, getShell(), fDialogTitle, ActionMessages.getString("GenerateConstructorUsingFieldsAction.error.actionfailed")); //$NON-NLS-1$ } } private IType getSelectedType(IStructuredSelection selection) throws JavaModelException { Object[] elements= selection.toArray(); if (elements.length == 1 && (elements[0] instanceof IType)) { IType type= (IType) elements[0]; if (type.getCompilationUnit() != null && type.isClass()) { return type; } } else if (elements[0] instanceof ICompilationUnit) { ICompilationUnit cu= (ICompilationUnit) elements[0]; IType type= cu.findPrimaryType(); if (type != null && !type.isInterface()) return type; } else if (elements[0] instanceof IField) { return ((IField) elements[0]).getCompilationUnit().findPrimaryType(); } return null; } private static boolean canRunOn(IField[] fields) throws JavaModelException { return fields != null && fields.length > 0; } /* * Returns fields in the selection or <code>null</code> if the selection is * empty or not valid. */ private IField[] getSelectedFields(IStructuredSelection selection) { List elements= selection.toList(); int nElements= elements.size(); if (nElements > 0) { IField[] res= new IField[nElements]; ICompilationUnit cu= null; for (int i= 0; i < nElements; i++) { Object curr= elements.get(i); if (curr instanceof IField) { IField fld= (IField) curr; if (i == 0) { // remember the cu of the first element cu= fld.getCompilationUnit(); if (cu == null) { return null; } } else if (!cu.equals(fld.getCompilationUnit())) { // all fields must be in the same CU return null; } try { if (fld.getDeclaringType().isInterface()) { // no constructors for interfaces return null; } } catch (JavaModelException e) { JavaPlugin.log(e); return null; } res[i]= fld; } else { return null; } } return res; } return null; } //---- Java Editior -------------------------------------------------------------- /* (non-Javadoc) * Method declared on SelectionDispatchAction */ public void selectionChanged(ITextSelection selection) { } /* (non-Javadoc) * Method declared on SelectionDispatchAction */ public void run(ITextSelection selection) { try { IJavaElement[] elements= SelectionConverter.codeResolve(fEditor); if (elements.length == 1 && (elements[0] instanceof IField)) { IField field= (IField) elements[0]; run(field.getDeclaringType(), new IField[] { field }, fEditor, false); return; } IJavaElement element= SelectionConverter.getElementAtOffset(fEditor); if (element != null) { IType type= (IType) element.getAncestor(IJavaElement.TYPE); if (type != null) { if (type.getFields().length > 0) { run(type, new IField[0], fEditor, true); return; } } } MessageDialog.openInformation(getShell(), fDialogTitle, ActionMessages.getString("GenerateConstructorUsingFieldsAction.not_applicable")); //$NON-NLS-1$ } catch (CoreException e) { ExceptionHandler.handle(e, getShell(), getDialogTitle(), null); } } private boolean checkEnabledEditor() { return fEditor != null && SelectionConverter.canOperateOn(fEditor); } //---- Helpers ------------------------------------------------------------------- private void run(IType type, IField[] preselected, IEditorPart editor, boolean activatedFromEditor) throws CoreException { if (!ElementValidator.check(type, getShell(), getDialogTitle(), activatedFromEditor)) { return; } if (!ActionUtil.isProcessable(getShell(), type)) { return; } IField[] constructorFields= type.getFields(); ArrayList constructorFieldsList= new ArrayList(); for (int i= 0; i < constructorFields.length; i++) { boolean isStatic= Flags.isStatic(constructorFields[i].getFlags()); boolean isFinal= Flags.isFinal(constructorFields[i].getFlags()); if (!isStatic) { if (isFinal) { try { // Do not add final fields which have been set in the <clinit> IScanner scanner= ToolFactory.createScanner(true, false, false, false); scanner.setSource(constructorFields[i].getSource().toCharArray()); TokenScanner tokenScanner= new TokenScanner(scanner); tokenScanner.getTokenStartOffset(ITerminalSymbols.TokenNameEQUAL, 0); } catch (JavaModelException e) { } catch (CoreException e) { constructorFieldsList.add(constructorFields[i]); } } else constructorFieldsList.add(constructorFields[i]); } } if (constructorFieldsList.isEmpty()) { MessageDialog.openInformation(getShell(), fDialogTitle, ActionMessages.getString("GenerateConstructorUsingFieldsAction.typeContainsNoFields.message")); //$NON-NLS-1$ return; } IMethod[] superConstructors= getSuperConstructors(type); if (superConstructors.length == 0) { MessageDialog.openInformation(getShell(), getDialogTitle(), ActionMessages.getString("GenerateConstructorUsingFieldsAction.error.nothing_found")); //$NON-NLS-1$ return; } JavaElementLabelProvider labelProvider= new JavaElementLabelProvider(JavaElementLabelProvider.SHOW_DEFAULT); GenerateConstructorUsingFieldsContentProvider contentProvider= new GenerateConstructorUsingFieldsContentProvider(constructorFieldsList); GenerateConstructorUsingFieldsSelectionDialog dialog= new GenerateConstructorUsingFieldsSelectionDialog(getShell(), labelProvider, contentProvider, fEditor, type, superConstructors); dialog.setCommentString(ActionMessages.getString("SourceActionDialog.createConstructorComment")); //$NON-NLS-1$ dialog.setTitle(ActionMessages.getString("GenerateConstructorUsingFieldsAction.dialog.title")); //$NON-NLS-1$ dialog.setInitialSelections(preselected); dialog.setContainerMode(true); dialog.setSize(60, 18); dialog.setInput(new Object()); dialog.setMessage(ActionMessages.getString("GenerateConstructorUsingFieldsAction.dialog.label")); //$NON-NLS-1$ dialog.setValidator(createValidator(constructorFieldsList.size(), dialog, type)); IField[] selected= null; int dialogResult= dialog.open(); if (dialogResult == Window.OK) { Object[] checkedElements= dialog.getResult(); if (checkedElements == null) return; ArrayList result= new ArrayList(checkedElements.length); for (int i= 0; i < checkedElements.length; i++) { Object curr= checkedElements[i]; if (curr instanceof IField) { result.add(curr); } } selected= (IField[]) result.toArray(new IField[result.size()]); CodeGenerationSettings settings= JavaPreferencesSettings.getCodeGenerationSettings(); settings.createComments= dialog.getGenerateComment(); IJavaElement elementPosition= dialog.getElementPosition(); IMethod selectedConstructor= dialog.getSuperConstructorChoice(); AddCustomConstructorOperation op= new AddCustomConstructorOperation(type, settings, selected, false, elementPosition, selectedConstructor); op.setVisbility(dialog.getVisibilityModifier()); // Ignore the omit super() checkbox if the default constructor is not chosen if (selectedConstructor.getParameterNames().length == 0) op.setOmitSuper(dialog.isOmitSuper()); IRewriteTarget target= editor != null ? (IRewriteTarget) editor.getAdapter(IRewriteTarget.class) : null; if (target != null) { target.beginCompoundChange(); } try { IRunnableContext context= JavaPlugin.getActiveWorkbenchWindow(); if (context == null) { context= new BusyIndicatorRunnableContext(); } context.run(false, true, new WorkbenchRunnableAdapter(op)); IMethod res= op.getCreatedConstructor(); if (res.getCompilationUnit().isWorkingCopy()) { synchronized (res.getCompilationUnit()) { res.getCompilationUnit().reconcile(); } } EditorUtility.revealInEditor(editor, res); } catch (InvocationTargetException e) { ExceptionHandler.handle(e, getShell(), getDialogTitle(), null); } catch (InterruptedException e) { // Do nothing. Operation has been canceled by user. } finally { if (target != null) { target.endCompoundChange(); } } } } public static IMethod[] getSuperConstructors(IType type) throws CoreException { List constructorMethods= new ArrayList(); ITypeHierarchy hierarchy= type.newSupertypeHierarchy(null); IType supertype= hierarchy.getSuperclass(type); if (supertype != null) { IMethod[] superMethods= supertype.getMethods(); boolean constuctorFound= false; for (int i= 0; i < superMethods.length; i++) { IMethod curr= superMethods[i]; if (curr.isConstructor()) { constuctorFound= true; if (JavaModelUtil.isVisibleInHierarchy(curr, type.getPackageFragment())) { constructorMethods.add(curr); } } } if (!constuctorFound) { IType objectType= type.getJavaProject().findType("java.lang.Object"); //$NON-NLS-1$ IMethod curr= objectType.getMethod("Object", new String[0]); //$NON-NLS-1$ constructorMethods.add(curr); } } return (IMethod[]) constructorMethods.toArray(new IMethod[constructorMethods.size()]); } private static ISelectionStatusValidator createValidator(int entries, GenerateConstructorUsingFieldsSelectionDialog dialog, IType type) { GenerateConstructorUsingFieldsValidator validator= new GenerateConstructorUsingFieldsValidator(entries, dialog, type); return validator; } private String getDialogTitle() { return fDialogTitle; } private static class GenerateConstructorUsingFieldsValidator implements ISelectionStatusValidator { private static int fEntries; private IType fType; private GenerateConstructorUsingFieldsSelectionDialog fDialog; List fExistingSigs; GenerateConstructorUsingFieldsValidator(int entries) { super(); fEntries= entries; fType= null; } GenerateConstructorUsingFieldsValidator(int entries, GenerateConstructorUsingFieldsSelectionDialog dialog, IType type) { super(); fEntries= entries; fDialog= dialog; fType= type; // Create the potential signature and compare it to the existing ones fExistingSigs= getExistingConstructorSignatures(); } public IStatus validate(Object[] selection) { StringBuffer buffer= new StringBuffer(); buffer.append("("); //$NON-NLS-1$ // first form the part of the signature corresponding to the super constructor combo choice IMethod chosenSuper= fDialog.getSuperConstructorChoice(); try { String superParamTypes[]= chosenSuper.getParameterTypes(); for (int i= 0; i < superParamTypes.length; i++) { buffer.append(superParamTypes[i]); } // second form the part of the signature corresponding to the fields selected for (int i= 0; i < selection.length; i++) { if (selection[i] instanceof IField) { buffer.append(((IField) selection[i]).getTypeSignature()); } } } catch (JavaModelException e) { } buffer.append(")V"); //$NON-NLS-1$ if (fExistingSigs.contains(buffer.toString())) { return new StatusInfo(IStatus.WARNING, ActionMessages.getString("GenerateConstructorUsingFieldsAction.error.duplicate_constructor")); //$NON-NLS-1$ } int fieldCount= countSelectedFields(selection); String message= ActionMessages.getFormattedString("GenerateConstructorUsingFieldsAction.fields_selected", //$NON-NLS-1$ new Object[] { String.valueOf(fieldCount), String.valueOf(fEntries)}); return new StatusInfo(IStatus.INFO, message); } private int countSelectedFields(Object[] selection) { int count= 0; for (int i= 0; i < selection.length; i++) { if (selection[i] instanceof IField) count++; } return count; } private List getExistingConstructorSignatures() { List constructorMethods= new ArrayList(); try { IMethod[] methods= fType.getMethods(); for (int i= 0; i < methods.length; i++) { IMethod curr= methods[i]; if (curr.isConstructor()) { constructorMethods.add(curr.getSignature()); } } } catch (JavaModelException e) { } return constructorMethods; } } private static class GenerateConstructorUsingFieldsSelectionDialog extends SourceActionDialog { private GenerateConstructorUsingFieldsContentProvider fContentProvider; private int fSuperIndex; private int fWidth= 60; private int fHeight= 18; protected Button[] fButtonControls; private boolean[] fButtonsEnabled; private boolean fOmitSuper; private IMethod[] fSuperConstructors; private IDialogSettings fGenConstructorSettings; protected CheckboxTreeViewer fTreeViewer; private GenerateConstructorUsingFieldsTreeViewerAdapter fTreeViewerAdapter; private static final int UP_BUTTON= IDialogConstants.CLIENT_ID + 1; private static final int DOWN_BUTTON= IDialogConstants.CLIENT_ID + 2; private final String SETTINGS_SECTION= "GenerateConstructorUsingFieldsSelectionDialog"; //$NON-NLS-1$ private final String OMIT_SUPER="OmitCallToSuper"; //$NON-NLS-1$ private Button fOmitSuperButton; public GenerateConstructorUsingFieldsSelectionDialog(Shell parent, ILabelProvider labelProvider, GenerateConstructorUsingFieldsContentProvider contentProvider, CompilationUnitEditor editor, IType type, IMethod[] superConstructors) { super(parent, labelProvider, contentProvider, editor, type); fContentProvider= contentProvider; fTreeViewerAdapter= new GenerateConstructorUsingFieldsTreeViewerAdapter(); fSuperConstructors= superConstructors; IDialogSettings dialogSettings= JavaPlugin.getDefault().getDialogSettings(); fGenConstructorSettings= dialogSettings.getSection(SETTINGS_SECTION); if (fGenConstructorSettings == null) { fGenConstructorSettings= dialogSettings.addNewSection(SETTINGS_SECTION); fGenConstructorSettings.put(OMIT_SUPER, false); //$NON-NLS-1$ } fOmitSuper= fGenConstructorSettings.getBoolean(OMIT_SUPER); } protected Composite createVisibilityControlAndModifiers(Composite parent, final IVisibilityChangeListener visibilityChangeListener, int[] availableVisibilities, int correctVisibility) { Composite visibilityComposite= createVisibilityControl(parent, visibilityChangeListener, availableVisibilities, correctVisibility); return visibilityComposite; } protected Control createDialogArea(Composite parent) { initializeDialogUnits(parent); Composite composite= new Composite(parent, SWT.NONE); GridLayout layout= new GridLayout(); GridData gd= null; layout.marginHeight= convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN); layout.marginWidth= convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN); layout.verticalSpacing= convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING); layout.horizontalSpacing= convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING); composite.setLayout(layout); Composite classConstructorComposite= addSuperClassConstructorChoices(composite); gd= new GridData(GridData.FILL_BOTH); classConstructorComposite.setLayoutData(gd); Composite inner= new Composite(composite, SWT.NONE); GridLayout innerLayout= new GridLayout(); innerLayout.numColumns= 2; innerLayout.marginHeight= 0; innerLayout.marginWidth= 0; inner.setLayout(innerLayout); Label messageLabel= createMessageArea(inner); if (messageLabel != null) { gd= new GridData(GridData.HORIZONTAL_ALIGN_FILL); gd.horizontalSpan= 2; messageLabel.setLayoutData(gd); } fTreeViewer= createTreeViewer(inner); gd= new GridData(GridData.FILL_BOTH); gd.widthHint= convertWidthInCharsToPixels(fWidth); gd.heightHint= convertHeightInCharsToPixels(fHeight); fTreeViewer.getControl().setLayoutData(gd); fTreeViewer.setContentProvider(fContentProvider); fTreeViewer.addSelectionChangedListener(fTreeViewerAdapter); Composite buttonComposite= createSelectionButtons(inner); gd= new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_FILL); buttonComposite.setLayoutData(gd); gd= new GridData(GridData.FILL_BOTH); inner.setLayoutData(gd); Composite entryComposite= createEntryPtCombo(composite); entryComposite.setLayoutData(new GridData(GridData.FILL_BOTH)); Composite commentComposite= createCommentSelection(composite); commentComposite.setLayoutData(new GridData(GridData.FILL_BOTH)); Composite overrideSuperComposite= createOmitSuper(composite); overrideSuperComposite.setLayoutData(new GridData(GridData.FILL_BOTH)); gd= new GridData(GridData.FILL_BOTH); composite.setLayoutData(gd); applyDialogFont(composite); return composite; } protected Composite createOmitSuper(Composite composite) { Composite omitSuperComposite= new Composite(composite, SWT.NONE); GridLayout layout= new GridLayout(); layout.marginHeight= 0; layout.marginWidth= 0; omitSuperComposite.setLayout(layout); fOmitSuperButton= new Button(omitSuperComposite, SWT.CHECK); fOmitSuperButton.setText(ActionMessages.getString("GenerateConstructorUsingFieldsSelectionDialog.omit.super")); //$NON-NLS-1$ fOmitSuperButton.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL)); fOmitSuperButton.addSelectionListener(new SelectionListener() { public void widgetSelected(SelectionEvent e) { boolean isSelected= (((Button) e.widget).getSelection()); setOmitSuper(isSelected); } public void widgetDefaultSelected(SelectionEvent e) { widgetSelected(e); } }); fOmitSuperButton.setSelection(isOmitSuper()); // Disable omit super checkbox unless default constructor fOmitSuperButton.setEnabled(getSuperConstructorChoice().getNumberOfParameters() == 0); GridData gd= new GridData(GridData.HORIZONTAL_ALIGN_FILL); gd.horizontalSpan= 2; fOmitSuperButton.setLayoutData(gd); return omitSuperComposite; } protected Composite createSelectionButtons(Composite composite) { Composite buttonComposite= super.createSelectionButtons(composite); GridLayout layout= new GridLayout(); buttonComposite.setLayout(layout); createUpDownButtons(buttonComposite); layout.marginHeight= 0; layout.marginWidth= 0; layout.numColumns= 1; return buttonComposite; } protected void createUpDownButtons(Composite buttonComposite) { int numButtons= 2; // up, down fButtonControls= new Button[numButtons]; fButtonsEnabled= new boolean[numButtons]; fButtonControls[UP_INDEX]= createButton(buttonComposite, UP_BUTTON, ActionMessages.getString("GenerateConstructorUsingFieldsSelectionDialog.up_button"), false); //$NON-NLS-1$ fButtonControls[DOWN_INDEX]= createButton(buttonComposite, DOWN_BUTTON, ActionMessages.getString("GenerateConstructorUsingFieldsSelectionDialog.down_button"), false); //$NON-NLS-1$ boolean defaultState= false; fButtonControls[UP_INDEX].setEnabled(defaultState); fButtonControls[DOWN_INDEX].setEnabled(defaultState); fButtonsEnabled[UP_INDEX]= defaultState; fButtonsEnabled[DOWN_INDEX]= defaultState; } protected void buttonPressed(int buttonId) { super.buttonPressed(buttonId); switch (buttonId) { case UP_BUTTON : { fContentProvider.up(getElementList(), getTreeViewer()); updateOKStatus(); break; } case DOWN_BUTTON : { fContentProvider.down(getElementList(), getTreeViewer()); updateOKStatus(); break; } } } private List getElementList() { IStructuredSelection selection= (IStructuredSelection) getTreeViewer().getSelection(); List elements= selection.toList(); ArrayList elementList= new ArrayList(); for (int i= 0; i < elements.size(); i++) { elementList.add(elements.get(i)); } return elementList; } protected Composite createEntryPtCombo(Composite composite) { Composite entryComposite= super.createEntryPtCombo(composite); addVisibilityAndModifiersChoices(entryComposite); return entryComposite; } private Composite addSuperClassConstructorChoices(Composite composite) { Label label= new Label(composite, SWT.NONE); label.setText(ActionMessages.getString("GenerateConstructorUsingFieldsSelectionDialog.sort_constructor_choices.label")); //$NON-NLS-1$ GridData gd= new GridData(GridData.FILL_BOTH); label.setLayoutData(gd); final Combo combo= new Combo(composite, SWT.READ_ONLY); for (int i= 0; i < fSuperConstructors.length; i++) { combo.add(JavaElementLabels.getElementLabel(fSuperConstructors[i], JavaElementLabels.M_PARAMETER_TYPES)); } // TODO: Can we be a little more intelligent about guessing the super() ? combo.setText(combo.getItem(0)); combo.setLayoutData(new GridData(GridData.FILL_BOTH)); combo.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { fSuperIndex= combo.getSelectionIndex(); // Disable omit super checkbox unless default constructor fOmitSuperButton.setEnabled(getSuperConstructorChoice().getNumberOfParameters() == 0); updateOKStatus(); } }); return composite; } public CheckboxTreeViewer getTreeViewer() { return fTreeViewer; } public IMethod getSuperConstructorChoice() { return fSuperConstructors[fSuperIndex]; } private class GenerateConstructorUsingFieldsTreeViewerAdapter implements ISelectionChangedListener, IDoubleClickListener { public void selectionChanged(SelectionChangedEvent event) { IStructuredSelection selection= (IStructuredSelection) fTreeViewer.getSelection(); List selectedList= selection.toList(); GenerateConstructorUsingFieldsContentProvider cp= (GenerateConstructorUsingFieldsContentProvider) getContentProvider(); fButtonControls[UP_INDEX].setEnabled(cp.canMoveUp(selectedList)); fButtonControls[DOWN_INDEX].setEnabled(cp.canMoveDown(selectedList)); } public void doubleClick(DoubleClickEvent event) { // Do nothing } } public void setOmitSuper(boolean omitSuper) { if (fOmitSuper != omitSuper) { fOmitSuper= omitSuper; fGenConstructorSettings.put(OMIT_SUPER, omitSuper); } } public boolean isOmitSuper() { return fOmitSuper; } } private static class GenerateConstructorUsingFieldsContentProvider implements ITreeContentProvider { private List fFieldsList; private static final Object[] EMPTY= new Object[0]; public GenerateConstructorUsingFieldsContentProvider(List fieldList) { fFieldsList= fieldList; } /* * @see ITreeContentProvider#getChildren(Object) */ public Object[] getChildren(Object parentElement) { return EMPTY; } /* * @see ITreeContentProvider#getParent(Object) */ public Object getParent(Object element) { return null; } /* * @see ITreeContentProvider#hasChildren(Object) */ public boolean hasChildren(Object element) { return getChildren(element).length > 0; } /* * @see IStructuredContentProvider#getElements(Object) */ public Object[] getElements(Object inputElement) { return fFieldsList.toArray(); } /* * @see IContentProvider#dispose() */ public void dispose() { } /* * @see IContentProvider#inputChanged(Viewer, Object, Object) */ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { } private List moveUp(List elements, List move) { int nElements= elements.size(); List res= new ArrayList(nElements); Object floating= null; for (int i= 0; i < nElements; i++) { Object curr= elements.get(i); if (move.contains(curr)) { res.add(curr); } else { if (floating != null) { res.add(floating); } floating= curr; } } if (floating != null) { res.add(floating); } return res; } private List reverse(List p) { List reverse= new ArrayList(p.size()); for (int i= p.size() - 1; i >= 0; i--) { reverse.add(p.get(i)); } return reverse; } public void setElements(List elements, CheckboxTreeViewer tree) { fFieldsList= new ArrayList(elements); if (tree != null) tree.refresh(); } public void up(List checkedElements, CheckboxTreeViewer tree) { if (checkedElements.size() > 0) { setElements(moveUp(fFieldsList, checkedElements), tree); tree.reveal(checkedElements.get(0)); } tree.setSelection(new StructuredSelection(checkedElements)); } public void down(List checkedElements, CheckboxTreeViewer tree) { if (checkedElements.size() > 0) { setElements(reverse(moveUp(reverse(fFieldsList), checkedElements)), tree); tree.reveal(checkedElements.get(checkedElements.size() - 1)); } tree.setSelection(new StructuredSelection(checkedElements)); } public boolean canMoveUp(List selectedElements) { int nSelected= selectedElements.size(); int nElements= fFieldsList.size(); for (int i= 0; i < nElements && nSelected > 0; i++) { if (!selectedElements.contains(fFieldsList.get(i))) { return true; } nSelected--; } return false; } public boolean canMoveDown(List selectedElements) { int nSelected= selectedElements.size(); for (int i= fFieldsList.size() - 1; i >= 0 && nSelected > 0; i--) { if (!selectedElements.contains(fFieldsList.get(i))) { return true; } nSelected--; } return false; } public List getFieldsList() { return fFieldsList; } } }
40,772
Bug 40772 [plan item] Smart tab on empty lines
When having the caret on an empty line, pressing tab cleans up the line and sets the caret it the right indentation column.
resolved fixed
adaf274
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2003-09-11T13:25:24Z
2003-07-25T13:33:20Z
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/actions/IndentAction.java
40,772
Bug 40772 [plan item] Smart tab on empty lines
When having the caret on an empty line, pressing tab cleans up the line and sets the caret it the right indentation column.
resolved fixed
adaf274
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2003-09-11T13:25:24Z
2003-07-25T13:33:20Z
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/CompilationUnitEditor.java
/******************************************************************************* * Copyright (c) 2000, 2003 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Common Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/cpl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.jdt.internal.ui.javaeditor; import java.lang.reflect.InvocationTargetException; import java.text.MessageFormat; import java.util.ArrayList; import java.util.Iterator; import java.util.List; import java.util.Stack; import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IWorkspace; import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.Preferences; import org.eclipse.swt.custom.VerifyKeyListener; import org.eclipse.swt.events.VerifyEvent; import org.eclipse.swt.graphics.Point; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Shell; import org.eclipse.jface.action.Action; import org.eclipse.jface.action.IMenuManager; import org.eclipse.jface.dialogs.ErrorDialog; import org.eclipse.jface.dialogs.IMessageProvider; import org.eclipse.jface.dialogs.MessageDialog; import org.eclipse.jface.dialogs.ProgressMonitorDialog; import org.eclipse.jface.preference.IPreferenceStore; import org.eclipse.jface.util.PropertyChangeEvent; import org.eclipse.jface.viewers.ISelectionProvider; import org.eclipse.jface.window.Window; import org.eclipse.jface.text.BadLocationException; import org.eclipse.jface.text.DocumentCommand; import org.eclipse.jface.text.IAutoEditStrategy; import org.eclipse.jface.text.IDocument; import org.eclipse.jface.text.ILineTracker; import org.eclipse.jface.text.IRegion; import org.eclipse.jface.text.ITextOperationTarget; import org.eclipse.jface.text.ITextSelection; import org.eclipse.jface.text.ITextViewerExtension; import org.eclipse.jface.text.ITypedRegion; import org.eclipse.jface.text.IWidgetTokenKeeper; import org.eclipse.jface.text.Position; import org.eclipse.jface.text.TextUtilities; import org.eclipse.jface.text.contentassist.ContentAssistant; import org.eclipse.jface.text.contentassist.IContentAssistant; import org.eclipse.jface.text.source.IOverviewRuler; import org.eclipse.jface.text.source.ISourceViewer; import org.eclipse.jface.text.source.IVerticalRuler; import org.eclipse.jface.text.source.SourceViewerConfiguration; import org.eclipse.ui.IEditorInput; import org.eclipse.ui.IFileEditorInput; import org.eclipse.ui.actions.ActionContext; import org.eclipse.ui.actions.ActionGroup; import org.eclipse.ui.actions.WorkspaceModifyOperation; import org.eclipse.ui.dialogs.SaveAsDialog; import org.eclipse.ui.editors.text.IStorageDocumentProvider; import org.eclipse.ui.help.WorkbenchHelp; import org.eclipse.ui.part.FileEditorInput; import org.eclipse.ui.texteditor.ContentAssistAction; import org.eclipse.ui.texteditor.ExtendedTextEditorPreferenceConstants; import org.eclipse.ui.texteditor.IDocumentProvider; import org.eclipse.ui.texteditor.ITextEditorActionConstants; import org.eclipse.ui.texteditor.TextOperationAction; import org.eclipse.jdt.core.ICompilationUnit; import org.eclipse.jdt.core.IJavaElement; import org.eclipse.jdt.core.ISourceRange; import org.eclipse.jdt.core.ISourceReference; import org.eclipse.jdt.core.JavaCore; import org.eclipse.jdt.core.JavaModelException; import org.eclipse.jdt.ui.IWorkingCopyManager; import org.eclipse.jdt.ui.PreferenceConstants; import org.eclipse.jdt.ui.actions.GenerateActionGroup; import org.eclipse.jdt.ui.actions.IJavaEditorActionDefinitionIds; import org.eclipse.jdt.ui.actions.RefactorActionGroup; import org.eclipse.jdt.internal.ui.IJavaHelpContextIds; import org.eclipse.jdt.internal.ui.JavaPlugin; import org.eclipse.jdt.internal.ui.actions.AddBlockCommentAction; import org.eclipse.jdt.internal.ui.actions.CompositeActionGroup; import org.eclipse.jdt.internal.ui.actions.RemoveBlockCommentAction; import org.eclipse.jdt.internal.ui.compare.LocalHistoryActionGroup; import org.eclipse.jdt.internal.ui.text.ContentAssistPreference; import org.eclipse.jdt.internal.ui.text.IJavaPartitions; import org.eclipse.jdt.internal.ui.text.correction.JavaCorrectionAssistant; import org.eclipse.jdt.internal.ui.text.java.IReconcilingParticipant; import org.eclipse.jdt.internal.ui.text.java.SmartSemicolonAutoEditStrategy; import org.eclipse.jdt.internal.ui.text.link.LinkedPositionManager; import org.eclipse.jdt.internal.ui.text.link.LinkedPositionUI; import org.eclipse.jdt.internal.ui.text.link.LinkedPositionUI.ExitFlags; /** * Java specific text editor. */ public class CompilationUnitEditor extends JavaEditor implements IReconcilingParticipant { /** * Text operation code for requesting correction assist to show correction * proposals for the current position. */ public static final int CORRECTIONASSIST_PROPOSALS= 50; interface ITextConverter { void customizeDocumentCommand(IDocument document, DocumentCommand command); } class AdaptedSourceViewer extends JavaSourceViewer { private List fTextConverters; private boolean fIgnoreTextConverters= false; private JavaCorrectionAssistant fCorrectionAssistant; public AdaptedSourceViewer(Composite parent, IVerticalRuler verticalRuler, IOverviewRuler overviewRuler, boolean showAnnotationsOverview, int styles) { super(parent, verticalRuler, overviewRuler, showAnnotationsOverview, styles); } public IContentAssistant getContentAssistant() { return fContentAssistant; } /* * @see ITextOperationTarget#doOperation(int) */ public void doOperation(int operation) { if (getTextWidget() == null) return; switch (operation) { case CONTENTASSIST_PROPOSALS: String msg= fContentAssistant.showPossibleCompletions(); setStatusLineErrorMessage(msg); return; case CORRECTIONASSIST_PROPOSALS: msg= fCorrectionAssistant.showPossibleCompletions(); setStatusLineErrorMessage(msg); return; case UNDO: fIgnoreTextConverters= true; break; case REDO: fIgnoreTextConverters= true; break; } super.doOperation(operation); } /* * @see ITextOperationTarget#canDoOperation(int) */ public boolean canDoOperation(int operation) { if (operation == CORRECTIONASSIST_PROPOSALS) return isEditable(); return super.canDoOperation(operation); } /* * @see TextViewer#handleDispose() */ protected void handleDispose() { if (fCorrectionAssistant != null) { fCorrectionAssistant.uninstall(); fCorrectionAssistant= null; } super.handleDispose(); } public void insertTextConverter(ITextConverter textConverter, int index) { throw new UnsupportedOperationException(); } public void addTextConverter(ITextConverter textConverter) { if (fTextConverters == null) { fTextConverters= new ArrayList(1); fTextConverters.add(textConverter); } else if (!fTextConverters.contains(textConverter)) fTextConverters.add(textConverter); } public void removeTextConverter(ITextConverter textConverter) { if (fTextConverters != null) { fTextConverters.remove(textConverter); if (fTextConverters.size() == 0) fTextConverters= null; } } /* * @see TextViewer#customizeDocumentCommand(DocumentCommand) */ protected void customizeDocumentCommand(DocumentCommand command) { super.customizeDocumentCommand(command); if (!fIgnoreTextConverters && fTextConverters != null) { for (Iterator e = fTextConverters.iterator(); e.hasNext();) ((ITextConverter) e.next()).customizeDocumentCommand(getDocument(), command); } fIgnoreTextConverters= false; } // http://dev.eclipse.org/bugs/show_bug.cgi?id=19270 public void updateIndentationPrefixes() { SourceViewerConfiguration configuration= getSourceViewerConfiguration(); String[] types= configuration.getConfiguredContentTypes(this); for (int i= 0; i < types.length; i++) { String[] prefixes= configuration.getIndentPrefixes(this, types[i]); if (prefixes != null && prefixes.length > 0) setIndentPrefixes(prefixes, types[i]); } } /* * @see IWidgetTokenOwner#requestWidgetToken(IWidgetTokenKeeper) */ public boolean requestWidgetToken(IWidgetTokenKeeper requester) { if (WorkbenchHelp.isContextHelpDisplayed()) return false; return super.requestWidgetToken(requester); } /* * @see IWidgetTokenOwnerExtension#requestWidgetToken(IWidgetTokenKeeper, int) * @since 3.0 */ public boolean requestWidgetToken(IWidgetTokenKeeper requester, int priority) { if (WorkbenchHelp.isContextHelpDisplayed()) return false; return super.requestWidgetToken(requester, priority); } /* * @see org.eclipse.jface.text.source.ISourceViewer#configure(org.eclipse.jface.text.source.SourceViewerConfiguration) */ public void configure(SourceViewerConfiguration configuration) { super.configure(configuration); fCorrectionAssistant= new JavaCorrectionAssistant(CompilationUnitEditor.this); fCorrectionAssistant.install(this); IAutoEditStrategy smartSemi= new SmartSemicolonAutoEditStrategy(IJavaPartitions.JAVA_PARTITIONING); prependAutoEditStrategy(smartSemi, IDocument.DEFAULT_CONTENT_TYPE); } } static class TabConverter implements ITextConverter { private int fTabRatio; private ILineTracker fLineTracker; public TabConverter() { } public void setNumberOfSpacesPerTab(int ratio) { fTabRatio= ratio; } public void setLineTracker(ILineTracker lineTracker) { fLineTracker= lineTracker; } private int insertTabString(StringBuffer buffer, int offsetInLine) { if (fTabRatio == 0) return 0; int remainder= offsetInLine % fTabRatio; remainder= fTabRatio - remainder; for (int i= 0; i < remainder; i++) buffer.append(' '); return remainder; } public void customizeDocumentCommand(IDocument document, DocumentCommand command) { String text= command.text; if (text == null) return; int index= text.indexOf('\t'); if (index > -1) { StringBuffer buffer= new StringBuffer(); fLineTracker.set(command.text); int lines= fLineTracker.getNumberOfLines(); try { for (int i= 0; i < lines; i++) { int offset= fLineTracker.getLineOffset(i); int endOffset= offset + fLineTracker.getLineLength(i); String line= text.substring(offset, endOffset); int position= 0; if (i == 0) { IRegion firstLine= document.getLineInformationOfOffset(command.offset); position= command.offset - firstLine.getOffset(); } int length= line.length(); for (int j= 0; j < length; j++) { char c= line.charAt(j); if (c == '\t') { position += insertTabString(buffer, position); } else { buffer.append(c); ++ position; } } } command.text= buffer.toString(); } catch (BadLocationException x) { } } } } private class ExitPolicy implements LinkedPositionUI.ExitPolicy { final char fExitCharacter; final char fEscapeCharacter; final Stack fStack; final int fSize; public ExitPolicy(char exitCharacter, char escapeCharacter, Stack stack) { fExitCharacter= exitCharacter; fEscapeCharacter= escapeCharacter; fStack= stack; fSize= fStack.size(); } /* * @see org.eclipse.jdt.internal.ui.text.link.LinkedPositionUI.ExitPolicy#doExit(org.eclipse.jdt.internal.ui.text.link.LinkedPositionManager, org.eclipse.swt.events.VerifyEvent, int, int) */ public ExitFlags doExit(LinkedPositionManager manager, VerifyEvent event, int offset, int length) { if (event.character == fExitCharacter) { if (fSize == fStack.size() && !isMasked(offset)) { if (manager.anyPositionIncludes(offset, length)) return new ExitFlags(LinkedPositionUI.COMMIT| LinkedPositionUI.UPDATE_CARET, false); else return new ExitFlags(LinkedPositionUI.COMMIT, true); } } Position p= manager.getFirstPosition(); int pEndOffset= p.offset + p.length; // if the bracket position gets deleted or replaced, take the linked UI down. // 1: the event has to happen so that it occurs on or before the position end if (pEndOffset >= offset) { int endOffset= offset + length; // 2: either it is a replace event (selection length > 0, selection extends over closing peer, character != 0) // or it is a delete event right at the end of the position, with no selection if (pEndOffset < endOffset && event.character != 0 || length == 0 && pEndOffset == endOffset && event.keyCode == 127) return new ExitFlags(LinkedPositionUI.COMMIT, true); } switch (event.character) { case '\b': { if (p.offset == offset && p.length == length) return new ExitFlags(0, false); else return null; } case '\n': case '\r': return new ExitFlags(LinkedPositionUI.COMMIT, true); case ';': if (getInsertMode() == SMART_INSERT) return new ExitFlags(LinkedPositionUI.COMMIT, true); // else fall through default: return null; } } private boolean isMasked(int offset) { IDocument document= getSourceViewer().getDocument(); try { return fEscapeCharacter == document.getChar(offset - 1); } catch (BadLocationException e) { } return false; } } private static class BracketLevel { int fOffset; int fLength; LinkedPositionManager fManager; LinkedPositionUI fEditor; } private class BracketInserter implements VerifyKeyListener, LinkedPositionUI.ExitListener { private boolean fCloseBrackets= true; private boolean fCloseStrings= true; private Stack fBracketLevelStack= new Stack(); public void setCloseBracketsEnabled(boolean enabled) { fCloseBrackets= enabled; } public void setCloseStringsEnabled(boolean enabled) { fCloseStrings= enabled; } private boolean hasIdentifierToTheRight(IDocument document, int offset) { try { int end= offset; IRegion endLine= document.getLineInformationOfOffset(end); int maxEnd= endLine.getOffset() + endLine.getLength(); while (end != maxEnd && Character.isWhitespace(document.getChar(end))) ++end; return end != maxEnd && Character.isJavaIdentifierPart(document.getChar(end)); } catch (BadLocationException e) { // be conservative return true; } } private boolean hasIdentifierToTheLeft(IDocument document, int offset) { try { int start= offset; IRegion startLine= document.getLineInformationOfOffset(start); int minStart= startLine.getOffset(); while (start != minStart && Character.isWhitespace(document.getChar(start - 1))) --start; return start != minStart && Character.isJavaIdentifierPart(document.getChar(start - 1)); } catch (BadLocationException e) { return true; } } private boolean hasCharacterToTheRight(IDocument document, int offset, char character) { try { int end= offset; IRegion endLine= document.getLineInformationOfOffset(end); int maxEnd= endLine.getOffset() + endLine.getLength(); while (end != maxEnd && Character.isWhitespace(document.getChar(end))) ++end; return end != maxEnd && document.getChar(end) == character; } catch (BadLocationException e) { // be conservative return true; } } /* * @see org.eclipse.swt.custom.VerifyKeyListener#verifyKey(org.eclipse.swt.events.VerifyEvent) */ public void verifyKey(VerifyEvent event) { if (!event.doit || getInsertMode() != SMART_INSERT) return; final ISourceViewer sourceViewer= getSourceViewer(); IDocument document= sourceViewer.getDocument(); final Point selection= sourceViewer.getSelectedRange(); final int offset= selection.x; final int length= selection.y; switch (event.character) { case '(': if (hasCharacterToTheRight(document, offset + length, '(')) return; // fall through case '[': if (!fCloseBrackets) return; if (hasIdentifierToTheRight(document, offset + length)) return; // fall through case '\'': if (event.character == '\'') { if (!fCloseStrings) return; if (hasIdentifierToTheLeft(document, offset) || hasIdentifierToTheRight(document, offset + length)) return; } // fall through case '"': if (event.character == '"') { if (!fCloseStrings) return; if (hasIdentifierToTheLeft(document, offset) || hasIdentifierToTheRight(document, offset + length)) return; } try { ITypedRegion partition= TextUtilities.getPartition(document, IJavaPartitions.JAVA_PARTITIONING, offset); if (! IDocument.DEFAULT_CONTENT_TYPE.equals(partition.getType()) && partition.getOffset() != offset) return; if (!validateEditorInputState()) return; final char character= event.character; final char closingCharacter= getPeerCharacter(character); final StringBuffer buffer= new StringBuffer(); buffer.append(character); buffer.append(closingCharacter); document.replace(offset, length, buffer.toString()); BracketLevel level= new BracketLevel(); fBracketLevelStack.push(level); level.fManager= new LinkedPositionManager(document, fBracketLevelStack.size() > 1); level.fManager.addPosition(offset + 1, 0); level.fOffset= offset; level.fLength= 2; level.fEditor= new LinkedPositionUI(sourceViewer, level.fManager); level.fEditor.setCancelListener(this); level.fEditor.setExitPolicy(new ExitPolicy(closingCharacter, getEscapeCharacter(closingCharacter), fBracketLevelStack)); level.fEditor.setFinalCaretOffset(offset + 2); level.fEditor.enter(); IRegion newSelection= level.fEditor.getSelectedRegion(); sourceViewer.setSelectedRange(newSelection.getOffset(), newSelection.getLength()); event.doit= false; } catch (BadLocationException e) { } break; } } /* * @see org.eclipse.jdt.internal.ui.text.link.LinkedPositionUI.ExitListener#exit(boolean) */ public void exit(boolean accept) { BracketLevel level= (BracketLevel) fBracketLevelStack.pop(); if (accept) return; // remove brackets try { final ISourceViewer sourceViewer= getSourceViewer(); IDocument document= sourceViewer.getDocument(); document.replace(level.fOffset, level.fLength, null); } catch (BadLocationException e) { } } } /** Preference key for code formatter tab size */ private final static String CODE_FORMATTER_TAB_SIZE= JavaCore.FORMATTER_TAB_SIZE; /** Preference key for inserting spaces rather than tabs */ private final static String SPACES_FOR_TABS= PreferenceConstants.EDITOR_SPACES_FOR_TABS; /** Preference key for automatically closing strings */ private final static String CLOSE_STRINGS= PreferenceConstants.EDITOR_CLOSE_STRINGS; /** Preference key for automatically closing brackets and parenthesis */ private final static String CLOSE_BRACKETS= PreferenceConstants.EDITOR_CLOSE_BRACKETS; /** The editor's save policy */ protected ISavePolicy fSavePolicy; /** Listener to annotation model changes that updates the error tick in the tab image */ private JavaEditorErrorTickUpdater fJavaEditorErrorTickUpdater; /** The editor's tab converter */ private TabConverter fTabConverter; /** The remembered java element */ private IJavaElement fRememberedElement; /** The remembered selection */ private ITextSelection fRememberedSelection; /** The remembered java element offset */ private int fRememberedElementOffset; /** The bracket inserter. */ private BracketInserter fBracketInserter= new BracketInserter(); /** The standard action groups added to the menu */ private GenerateActionGroup fGenerateActionGroup; private CompositeActionGroup fContextMenuGroup; /** * Creates a new compilation unit editor. */ public CompilationUnitEditor() { super(); setDocumentProvider(JavaPlugin.getDefault().getCompilationUnitDocumentProvider()); setEditorContextMenuId("#CompilationUnitEditorContext"); //$NON-NLS-1$ setRulerContextMenuId("#CompilationUnitRulerContext"); //$NON-NLS-1$ setOutlinerContextMenuId("#CompilationUnitOutlinerContext"); //$NON-NLS-1$ // don't set help contextId, we install our own help context fSavePolicy= null; fJavaEditorErrorTickUpdater= new JavaEditorErrorTickUpdater(this); } /* * @see AbstractTextEditor#createActions() */ protected void createActions() { super.createActions(); Action action= new TextOperationAction(JavaEditorMessages.getResourceBundle(), "CorrectionAssistProposal.", this, CORRECTIONASSIST_PROPOSALS); //$NON-NLS-1$ action.setActionDefinitionId(IJavaEditorActionDefinitionIds.CORRECTION_ASSIST_PROPOSALS); setAction("CorrectionAssistProposal", action); //$NON-NLS-1$ markAsStateDependentAction("CorrectionAssistProposal", true); //$NON-NLS-1$ WorkbenchHelp.setHelp(action, IJavaHelpContextIds.QUICK_FIX_ACTION); action= new ContentAssistAction(JavaEditorMessages.getResourceBundle(), "ContentAssistProposal.", this); //$NON-NLS-1$ action.setActionDefinitionId(IJavaEditorActionDefinitionIds.CONTENT_ASSIST_PROPOSALS); setAction("ContentAssistProposal", action); //$NON-NLS-1$ markAsStateDependentAction("ContentAssistProposal", true); //$NON-NLS-1$ WorkbenchHelp.setHelp(action, IJavaHelpContextIds.CONTENT_ASSIST_ACTION); action= new TextOperationAction(JavaEditorMessages.getResourceBundle(), "ContentAssistContextInformation.", this, ISourceViewer.CONTENTASSIST_CONTEXT_INFORMATION); //$NON-NLS-1$ action.setActionDefinitionId(IJavaEditorActionDefinitionIds.CONTENT_ASSIST_CONTEXT_INFORMATION); setAction("ContentAssistContextInformation", action); //$NON-NLS-1$ markAsStateDependentAction("ContentAssistContextInformation", true); //$NON-NLS-1$ WorkbenchHelp.setHelp(action, IJavaHelpContextIds.PARAMETER_HINTS_ACTION); action= new TextOperationAction(JavaEditorMessages.getResourceBundle(), "Comment.", this, ITextOperationTarget.PREFIX); //$NON-NLS-1$ action.setActionDefinitionId(IJavaEditorActionDefinitionIds.COMMENT); setAction("Comment", action); //$NON-NLS-1$ markAsStateDependentAction("Comment", true); //$NON-NLS-1$ WorkbenchHelp.setHelp(action, IJavaHelpContextIds.COMMENT_ACTION); action= new TextOperationAction(JavaEditorMessages.getResourceBundle(), "Uncomment.", this, ITextOperationTarget.STRIP_PREFIX); //$NON-NLS-1$ action.setActionDefinitionId(IJavaEditorActionDefinitionIds.UNCOMMENT); setAction("Uncomment", action); //$NON-NLS-1$ markAsStateDependentAction("Uncomment", true); //$NON-NLS-1$ WorkbenchHelp.setHelp(action, IJavaHelpContextIds.UNCOMMENT_ACTION); action= new TextOperationAction(JavaEditorMessages.getResourceBundle(), "Format.", this, ISourceViewer.FORMAT); //$NON-NLS-1$ action.setActionDefinitionId(IJavaEditorActionDefinitionIds.FORMAT); setAction("Format", action); //$NON-NLS-1$ markAsStateDependentAction("Format", true); //$NON-NLS-1$ markAsSelectionDependentAction("Format", true); //$NON-NLS-1$ WorkbenchHelp.setHelp(action, IJavaHelpContextIds.FORMAT_ACTION); action= new AddBlockCommentAction(JavaEditorMessages.getResourceBundle(), "AddBlockComment.", this); //$NON-NLS-1$ action.setActionDefinitionId(IJavaEditorActionDefinitionIds.ADD_BLOCK_COMMENT); setAction("AddBlockComment", action); //$NON-NLS-1$ markAsStateDependentAction("AddBlockComment", true); //$NON-NLS-1$ markAsSelectionDependentAction("AddBlockComment", true); //$NON-NLS-1$ WorkbenchHelp.setHelp(action, IJavaHelpContextIds.ADD_BLOCK_COMMENT_ACTION); action= new RemoveBlockCommentAction(JavaEditorMessages.getResourceBundle(), "RemoveBlockComment.", this); //$NON-NLS-1$ action.setActionDefinitionId(IJavaEditorActionDefinitionIds.REMOVE_BLOCK_COMMENT); setAction("RemoveBlockComment", action); //$NON-NLS-1$ markAsStateDependentAction("RemoveBlockComment", true); //$NON-NLS-1$ markAsSelectionDependentAction("RemoveBlockComment", true); //$NON-NLS-1$ WorkbenchHelp.setHelp(action, IJavaHelpContextIds.REMOVE_BLOCK_COMMENT_ACTION); fGenerateActionGroup= new GenerateActionGroup(this, ITextEditorActionConstants.GROUP_EDIT); ActionGroup rg= new RefactorActionGroup(this, ITextEditorActionConstants.GROUP_EDIT); fActionGroups.addGroup(rg); fActionGroups.addGroup(fGenerateActionGroup); // We have to keep the context menu group separate to have better control over positioning fContextMenuGroup= new CompositeActionGroup(new ActionGroup[] { fGenerateActionGroup, rg, new LocalHistoryActionGroup(this, ITextEditorActionConstants.GROUP_EDIT)}); } /* * @see JavaEditor#getElementAt(int) */ protected IJavaElement getElementAt(int offset) { return getElementAt(offset, true); } /** * Returns the most narrow element including the given offset. If <code>reconcile</code> * is <code>true</code> the editor's input element is reconciled in advance. If it is * <code>false</code> this method only returns a result if the editor's input element * does not need to be reconciled. * * @param offset the offset included by the retrieved element * @param reconcile <code>true</code> if working copy should be reconciled */ protected IJavaElement getElementAt(int offset, boolean reconcile) { IWorkingCopyManager manager= JavaPlugin.getDefault().getWorkingCopyManager(); ICompilationUnit unit= manager.getWorkingCopy(getEditorInput()); if (unit != null) { try { if (reconcile) { synchronized (unit) { unit.reconcile(); } return unit.getElementAt(offset); } else if (unit.isConsistent()) return unit.getElementAt(offset); } catch (JavaModelException x) { if (!x.isDoesNotExist()) JavaPlugin.log(x.getStatus()); // nothing found, be tolerant and go on } } return null; } /* * @see JavaEditor#getCorrespondingElement(IJavaElement) */ protected IJavaElement getCorrespondingElement(IJavaElement element) { try { return EditorUtility.getWorkingCopy(element, true); } catch (JavaModelException x) { JavaPlugin.log(x.getStatus()); // nothing found, be tolerant and go on } return null; } /* * @see AbstractTextEditor#editorContextMenuAboutToShow(IMenuManager) */ public void editorContextMenuAboutToShow(IMenuManager menu) { super.editorContextMenuAboutToShow(menu); ActionContext context= new ActionContext(getSelectionProvider().getSelection()); fContextMenuGroup.setContext(context); fContextMenuGroup.fillContextMenu(menu); fContextMenuGroup.setContext(null); } /* * @see JavaEditor#setOutlinePageInput(JavaOutlinePage, IEditorInput) */ protected void setOutlinePageInput(JavaOutlinePage page, IEditorInput input) { if (page != null) { IWorkingCopyManager manager= JavaPlugin.getDefault().getWorkingCopyManager(); page.setInput(manager.getWorkingCopy(input)); } } /* * @see AbstractTextEditor#performSaveOperation(WorkspaceModifyOperation, IProgressMonitor) */ protected void performSaveOperation(WorkspaceModifyOperation operation, IProgressMonitor progressMonitor) { IDocumentProvider p= getDocumentProvider(); if (p instanceof ICompilationUnitDocumentProvider) { ICompilationUnitDocumentProvider cp= (ICompilationUnitDocumentProvider) p; cp.setSavePolicy(fSavePolicy); } try { super.performSaveOperation(operation, progressMonitor); } finally { if (p instanceof ICompilationUnitDocumentProvider) { ICompilationUnitDocumentProvider cp= (ICompilationUnitDocumentProvider) p; cp.setSavePolicy(null); } } } /* * @see AbstractTextEditor#doSaveAs */ public void doSaveAs() { if (askIfNonWorkbenchEncodingIsOk()) { super.doSaveAs(); } } /* * @see AbstractTextEditor#doSave(IProgressMonitor) */ public void doSave(IProgressMonitor progressMonitor) { IDocumentProvider p= getDocumentProvider(); if (p == null) { // editor has been closed return; } if (!askIfNonWorkbenchEncodingIsOk()) { progressMonitor.setCanceled(true); return; } if (p.isDeleted(getEditorInput())) { if (isSaveAsAllowed()) { /* * 1GEUSSR: ITPUI:ALL - User should never loose changes made in the editors. * Changed Behavior to make sure that if called inside a regular save (because * of deletion of input element) there is a way to report back to the caller. */ performSaveAs(progressMonitor); } else { /* * 1GF5YOX: ITPJUI:ALL - Save of delete file claims it's still there * Missing resources. */ Shell shell= getSite().getShell(); MessageDialog.openError(shell, JavaEditorMessages.getString("CompilationUnitEditor.error.saving.title1"), JavaEditorMessages.getString("CompilationUnitEditor.error.saving.message1")); //$NON-NLS-1$ //$NON-NLS-2$ } } else { setStatusLineErrorMessage(null); IWorkingCopyManager manager= JavaPlugin.getDefault().getWorkingCopyManager(); ICompilationUnit unit= manager.getWorkingCopy(getEditorInput()); if (unit != null) { synchronized (unit) { performSaveOperation(createSaveOperation(false), progressMonitor); } } else performSaveOperation(createSaveOperation(false), progressMonitor); } } /** * Asks the user if it is ok to store in non-workbench encoding. * @return <true> if the user wants to continue */ private boolean askIfNonWorkbenchEncodingIsOk() { IDocumentProvider provider= getDocumentProvider(); if (provider instanceof IStorageDocumentProvider) { IEditorInput input= getEditorInput(); IStorageDocumentProvider storageProvider= (IStorageDocumentProvider)provider; String encoding= storageProvider.getEncoding(input); String defaultEncoding= storageProvider.getDefaultEncoding(); if (encoding != null && !encoding.equals(defaultEncoding)) { Shell shell= getSite().getShell(); String title= JavaEditorMessages.getString("CompilationUnitEditor.warning.save.nonWorkbenchEncoding.title"); //$NON-NLS-1$ String msg; if (input != null) msg= MessageFormat.format(JavaEditorMessages.getString("CompilationUnitEditor.warning.save.nonWorkbenchEncoding.message1"), new String[] {input.getName(), encoding});//$NON-NLS-1$ else msg= MessageFormat.format(JavaEditorMessages.getString("CompilationUnitEditor.warning.save.nonWorkbenchEncoding.message2"), new String[] {encoding});//$NON-NLS-1$ return MessageDialog.openQuestion(shell, title, msg); } } return true; } public boolean isSaveAsAllowed() { return true; } /** * The compilation unit editor implementation of this <code>AbstractTextEditor</code> * method asks the user for the workspace path of a file resource and saves the document * there. See http://dev.eclipse.org/bugs/show_bug.cgi?id=6295 */ protected void performSaveAs(IProgressMonitor progressMonitor) { Shell shell= getSite().getShell(); IEditorInput input = getEditorInput(); SaveAsDialog dialog= new SaveAsDialog(shell); IFile original= (input instanceof IFileEditorInput) ? ((IFileEditorInput) input).getFile() : null; if (original != null) dialog.setOriginalFile(original); dialog.create(); IDocumentProvider provider= getDocumentProvider(); if (provider == null) { // editor has been programmatically closed while the dialog was open return; } if (provider.isDeleted(input) && original != null) { String message= JavaEditorMessages.getFormattedString("CompilationUnitEditor.warning.save.delete", new Object[] { original.getName() }); //$NON-NLS-1$ dialog.setErrorMessage(null); dialog.setMessage(message, IMessageProvider.WARNING); } if (dialog.open() == Window.CANCEL) { if (progressMonitor != null) progressMonitor.setCanceled(true); return; } IPath filePath= dialog.getResult(); if (filePath == null) { if (progressMonitor != null) progressMonitor.setCanceled(true); return; } IWorkspace workspace= ResourcesPlugin.getWorkspace(); IFile file= workspace.getRoot().getFile(filePath); final IEditorInput newInput= new FileEditorInput(file); WorkspaceModifyOperation op= new WorkspaceModifyOperation() { public void execute(final IProgressMonitor monitor) throws CoreException { getDocumentProvider().saveDocument(monitor, newInput, getDocumentProvider().getDocument(getEditorInput()), true); } }; boolean success= false; try { provider.aboutToChange(newInput); new ProgressMonitorDialog(shell).run(false, true, op); success= true; } catch (InterruptedException x) { } catch (InvocationTargetException x) { Throwable t= x.getTargetException(); if (t instanceof CoreException) { CoreException cx= (CoreException) t; ErrorDialog.openError(shell, JavaEditorMessages.getString("CompilationUnitEditor.error.saving.title2"), JavaEditorMessages.getString("CompilationUnitEditor.error.saving.message2"), cx.getStatus()); //$NON-NLS-1$ //$NON-NLS-2$ } else { MessageDialog.openError(shell, JavaEditorMessages.getString("CompilationUnitEditor.error.saving.title3"), JavaEditorMessages.getString("CompilationUnitEditor.error.saving.message3") + t.getMessage()); //$NON-NLS-1$ //$NON-NLS-2$ } } finally { provider.changed(newInput); if (success) setInput(newInput); } if (progressMonitor != null) progressMonitor.setCanceled(!success); } /* * @see AbstractTextEditor#doSetInput(IEditorInput) */ protected void doSetInput(IEditorInput input) throws CoreException { super.doSetInput(input); configureTabConverter(); } private void configureTabConverter() { if (fTabConverter != null) { IDocumentProvider provider= getDocumentProvider(); if (provider instanceof ICompilationUnitDocumentProvider) { ICompilationUnitDocumentProvider cup= (ICompilationUnitDocumentProvider) provider; fTabConverter.setLineTracker(cup.createLineTracker(getEditorInput())); } } } private int getTabSize() { Preferences preferences= JavaCore.getPlugin().getPluginPreferences(); return preferences.getInt(CODE_FORMATTER_TAB_SIZE); } private void startTabConversion() { if (fTabConverter == null) { fTabConverter= new TabConverter(); configureTabConverter(); fTabConverter.setNumberOfSpacesPerTab(getTabSize()); AdaptedSourceViewer asv= (AdaptedSourceViewer) getSourceViewer(); asv.addTextConverter(fTabConverter); // http://dev.eclipse.org/bugs/show_bug.cgi?id=19270 asv.updateIndentationPrefixes(); } } private void stopTabConversion() { if (fTabConverter != null) { AdaptedSourceViewer asv= (AdaptedSourceViewer) getSourceViewer(); asv.removeTextConverter(fTabConverter); // http://dev.eclipse.org/bugs/show_bug.cgi?id=19270 asv.updateIndentationPrefixes(); fTabConverter= null; } } private boolean isTabConversionEnabled() { IPreferenceStore store= getPreferenceStore(); return store.getBoolean(SPACES_FOR_TABS); } public void dispose() { ISourceViewer sourceViewer= getSourceViewer(); if (sourceViewer instanceof ITextViewerExtension) ((ITextViewerExtension) sourceViewer).removeVerifyKeyListener(fBracketInserter); if (fJavaEditorErrorTickUpdater != null) { fJavaEditorErrorTickUpdater.dispose(); fJavaEditorErrorTickUpdater= null; } if (fActionGroups != null) { fActionGroups.dispose(); fActionGroups= null; } super.dispose(); } /* * @see AbstractTextEditor#createPartControl(Composite) */ public void createPartControl(Composite parent) { super.createPartControl(parent); if (isTabConversionEnabled()) startTabConversion(); IPreferenceStore preferenceStore= getPreferenceStore(); boolean closeBrackets= preferenceStore.getBoolean(CLOSE_BRACKETS); boolean closeStrings= preferenceStore.getBoolean(CLOSE_STRINGS); fBracketInserter.setCloseBracketsEnabled(closeBrackets); fBracketInserter.setCloseStringsEnabled(closeStrings); ISourceViewer sourceViewer= getSourceViewer(); if (sourceViewer instanceof ITextViewerExtension) ((ITextViewerExtension) sourceViewer).prependVerifyKeyListener(fBracketInserter); } private static char getEscapeCharacter(char character) { switch (character) { case '"': case '\'': return '\\'; default: return 0; } } private static char getPeerCharacter(char character) { switch (character) { case '(': return ')'; case ')': return '('; case '[': return ']'; case ']': return '['; case '"': return character; case '\'': return character; default: throw new IllegalArgumentException(); } } /* * @see AbstractTextEditor#handlePreferenceStoreChanged(PropertyChangeEvent) */ protected void handlePreferenceStoreChanged(PropertyChangeEvent event) { try { AdaptedSourceViewer asv= (AdaptedSourceViewer) getSourceViewer(); if (asv != null) { String p= event.getProperty(); if (CLOSE_BRACKETS.equals(p)) { fBracketInserter.setCloseBracketsEnabled(getPreferenceStore().getBoolean(p)); return; } if (CLOSE_STRINGS.equals(p)) { fBracketInserter.setCloseStringsEnabled(getPreferenceStore().getBoolean(p)); return; } if (SPACES_FOR_TABS.equals(p)) { if (isTabConversionEnabled()) startTabConversion(); else stopTabConversion(); return; } IContentAssistant c= asv.getContentAssistant(); if (c instanceof ContentAssistant) ContentAssistPreference.changeConfiguration((ContentAssistant) c, getPreferenceStore(), event); } } finally { super.handlePreferenceStoreChanged(event); } } /* * @see org.eclipse.jdt.internal.ui.javaeditor.JavaEditor#handlePreferencePropertyChanged(org.eclipse.core.runtime.Preferences.PropertyChangeEvent) */ protected void handlePreferencePropertyChanged(org.eclipse.core.runtime.Preferences.PropertyChangeEvent event) { AdaptedSourceViewer asv= (AdaptedSourceViewer) getSourceViewer(); if (asv != null) { String p= event.getProperty(); if (CODE_FORMATTER_TAB_SIZE.equals(p)) { asv.updateIndentationPrefixes(); if (fTabConverter != null) fTabConverter.setNumberOfSpacesPerTab(getTabSize()); } } super.handlePreferencePropertyChanged(event); } /* * @see org.eclipse.jdt.internal.ui.javaeditor.JavaEditor#createJavaSourceViewer(org.eclipse.swt.widgets.Composite, org.eclipse.jface.text.source.IVerticalRuler, org.eclipse.jface.text.source.IOverviewRuler, boolean, int) */ protected ISourceViewer createJavaSourceViewer(Composite parent, IVerticalRuler verticalRuler, IOverviewRuler overviewRuler, boolean isOverviewRulerVisible, int styles) { return new AdaptedSourceViewer(parent, verticalRuler, overviewRuler, isOverviewRulerVisible, styles); } /* * @see IReconcilingParticipant#reconciled() */ public void reconciled() { if (PreferenceConstants.getPreferenceStore().getBoolean(PreferenceConstants.EDITOR_SYNC_OUTLINE_ON_CURSOR_MOVE)) { Shell shell= getSite().getShell(); if (shell != null && !shell.isDisposed()) { shell.getDisplay().asyncExec(new Runnable() { public void run() { synchronizeOutlinePageSelection(); } }); } } } protected void updateStateDependentActions() { super.updateStateDependentActions(); fGenerateActionGroup.editorStateChanged(); } /** * Returns the updated java element for the old java element. */ private IJavaElement findElement(IJavaElement element) { if (element == null) return null; IWorkingCopyManager manager= JavaPlugin.getDefault().getWorkingCopyManager(); ICompilationUnit unit= manager.getWorkingCopy(getEditorInput()); if (unit != null) { try { synchronized (unit) { unit.reconcile(); } IJavaElement[] findings= unit.findElements(element); if (findings != null && findings.length > 0) return findings[0]; } catch (JavaModelException x) { JavaPlugin.log(x.getStatus()); // nothing found, be tolerant and go on } } return null; } /** * Returns the offset of the given Java element. */ private int getOffset(IJavaElement element) { if (element instanceof ISourceReference) { ISourceReference sr= (ISourceReference) element; try { ISourceRange srcRange= sr.getSourceRange(); if (srcRange != null) return srcRange.getOffset(); } catch (JavaModelException e) { } } return -1; } /* * @see AbstractTextEditor#rememberSelection() */ protected void rememberSelection() { ISelectionProvider sp= getSelectionProvider(); fRememberedSelection= (sp == null ? null : (ITextSelection) sp.getSelection()); if (fRememberedSelection != null) { fRememberedElement= getElementAt(fRememberedSelection.getOffset(), true); fRememberedElementOffset= getOffset(fRememberedElement); } } /* * @see AbstractTextEditor#restoreSelection() */ protected void restoreSelection() { try { if (getSourceViewer() == null || fRememberedSelection == null) return; IJavaElement newElement= findElement(fRememberedElement); int newOffset= getOffset(newElement); int delta= (newOffset > -1 && fRememberedElementOffset > -1) ? newOffset - fRememberedElementOffset : 0; if (isValidSelection(delta + fRememberedSelection.getOffset(), fRememberedSelection.getLength())) selectAndReveal(delta + fRememberedSelection.getOffset(), fRememberedSelection.getLength()); } finally { fRememberedSelection= null; fRememberedElement= null; fRememberedElementOffset= -1; } } private boolean isValidSelection(int offset, int length) { IDocumentProvider provider= getDocumentProvider(); if (provider != null) { IDocument document= provider.getDocument(getEditorInput()); if (document != null) { int end= offset + length; int documentLength= document.getLength(); return 0 <= offset && offset <= documentLength && 0 <= end && end <= documentLength; } } return false; } /* * @see AbstractTextEditor#canHandleMove(IEditorInput, IEditorInput) */ protected boolean canHandleMove(IEditorInput originalElement, IEditorInput movedElement) { String oldExtension= ""; //$NON-NLS-1$ if (originalElement instanceof IFileEditorInput) { IFile file= ((IFileEditorInput) originalElement).getFile(); if (file != null) { String ext= file.getFileExtension(); if (ext != null) oldExtension= ext; } } String newExtension= ""; //$NON-NLS-1$ if (movedElement instanceof IFileEditorInput) { IFile file= ((IFileEditorInput) movedElement).getFile(); if (file != null) newExtension= file.getFileExtension(); } return oldExtension.equals(newExtension); } /* * @see org.eclipse.ui.texteditor.ExtendedTextEditor#isPrefQuickDiffAlwaysOn() */ protected boolean isPrefQuickDiffAlwaysOn() { // reestablishes the behaviour from ExtendedTextEditor which was hacked by JavaEditor // to disable the change bar for the class file (attached source) java editor. IPreferenceStore store= getPreferenceStore(); return store.getBoolean(ExtendedTextEditorPreferenceConstants.QUICK_DIFF_ALWAYS_ON); } }
40,772
Bug 40772 [plan item] Smart tab on empty lines
When having the caret on an empty line, pressing tab cleans up the line and sets the caret it the right indentation column.
resolved fixed
adaf274
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2003-09-11T13:25:24Z
2003-07-25T13:33:20Z
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/CompilationUnitEditorActionContributor.java
/******************************************************************************* * Copyright (c) 2000, 2003 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Common Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/cpl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.jdt.internal.ui.javaeditor; import org.eclipse.ui.IActionBars; import org.eclipse.ui.IEditorPart; import org.eclipse.ui.texteditor.ITextEditor; import org.eclipse.jdt.ui.actions.JdtActionConstants; public class CompilationUnitEditorActionContributor extends BasicEditorActionContributor { public CompilationUnitEditorActionContributor() { super(); } /* * @see IEditorActionBarContributor#setActiveEditor(IEditorPart) */ public void setActiveEditor(IEditorPart part) { super.setActiveEditor(part); ITextEditor textEditor= null; if (part instanceof ITextEditor) textEditor= (ITextEditor) part; // Source menu. IActionBars bars= getActionBars(); bars.setGlobalActionHandler(JdtActionConstants.COMMENT, getAction(textEditor, "Comment")); //$NON-NLS-1$ bars.setGlobalActionHandler(JdtActionConstants.UNCOMMENT, getAction(textEditor, "Uncomment")); //$NON-NLS-1$ bars.setGlobalActionHandler(JdtActionConstants.FORMAT, getAction(textEditor, "Format")); //$NON-NLS-1$ bars.setGlobalActionHandler(JdtActionConstants.ADD_BLOCK_COMMENT, getAction(textEditor, "AddBlockComment")); //$NON-NLS-1$ bars.setGlobalActionHandler(JdtActionConstants.REMOVE_BLOCK_COMMENT, getAction(textEditor, "RemoveBlockComment")); //$NON-NLS-1$ } }
40,772
Bug 40772 [plan item] Smart tab on empty lines
When having the caret on an empty line, pressing tab cleans up the line and sets the caret it the right indentation column.
resolved fixed
adaf274
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2003-09-11T13:25:24Z
2003-07-25T13:33:20Z
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/WorkInProgressPreferencePage.java
/******************************************************************************* * Copyright (c) 2000, 2003 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Common Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/cpl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.jdt.internal.ui.preferences; import java.util.ArrayList; import java.util.HashSet; import java.util.Iterator; import java.util.List; import java.util.Set; import org.eclipse.swt.SWT; import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.events.SelectionListener; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Button; 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.Text; import org.eclipse.jface.dialogs.IDialogConstants; import org.eclipse.jface.preference.IPreferenceStore; import org.eclipse.jface.preference.PreferencePage; import org.eclipse.ui.IWorkbench; import org.eclipse.ui.IWorkbenchPreferencePage; import org.eclipse.ui.help.WorkbenchHelp; import org.eclipse.ui.texteditor.ExtendedTextEditorPreferenceConstants; import org.eclipse.ui.texteditor.quickdiff.QuickDiff; import org.eclipse.ui.texteditor.quickdiff.ReferenceProviderDescriptor; import org.eclipse.jdt.ui.PreferenceConstants; import org.eclipse.jdt.internal.ui.JavaPlugin; /** * Preference page for work in progress. */ public class WorkInProgressPreferencePage extends PreferencePage implements IWorkbenchPreferencePage { /** prefix for resources */ private static final String PREFIX= "WorkInProgress."; //$NON-NLS-1$ /** * All FieldEditors except <code>smartTyping</code>, whose enable state * is controlled by the smartTyping preference. */ private Set fSmartTypingItems= new HashSet(); private List fCheckBoxes; private List fRadioButtons; private List fTextControls; /** List for the reference provider default. */ private org.eclipse.swt.widgets.List fQuickDiffProviderList; /** The reference provider default's list model. */ private String[][] fQuickDiffProviderListModel; /** Button controlling default setting of the selected reference provider. */ private Button fSetDefaultButton; /** * creates a new preference page. */ public WorkInProgressPreferencePage() { setPreferenceStore(getPreferenceStore()); fRadioButtons= new ArrayList(); fCheckBoxes= new ArrayList(); fTextControls= new ArrayList(); List providers= new QuickDiff().getReferenceProviderDescriptors(); fQuickDiffProviderListModel= createQuickDiffReferenceListModel(providers); } private String[][] createQuickDiffReferenceListModel(List providers) { ArrayList listModelItems= new ArrayList(); for (Iterator it= providers.iterator(); it.hasNext();) { ReferenceProviderDescriptor provider= (ReferenceProviderDescriptor) it.next(); String label= provider.getLabel(); int i= label.indexOf('&'); while (i >= 0) { if (i < label.length()) label= label.substring(0, i) + label.substring(i+1); else label.substring(0, i); i= label.indexOf('&'); } listModelItems.add(new String[] { provider.getId(), label }); } String[][] items= new String[listModelItems.size()][]; listModelItems.toArray(items); return items; } private void handleProviderListSelection() { int i= fQuickDiffProviderList.getSelectionIndex(); boolean b= getPreferenceStore().getString(ExtendedTextEditorPreferenceConstants.QUICK_DIFF_DEFAULT_PROVIDER).equals(fQuickDiffProviderListModel[i][0]); fSetDefaultButton.setEnabled(!b); } private Button addCheckBox(Composite parent, String label, String key) { GridData gd= new GridData(GridData.HORIZONTAL_ALIGN_FILL); Button button= new Button(parent, SWT.CHECK); button.setText(label); button.setData(key); button.setLayoutData(gd); button.setSelection(getPreferenceStore().getBoolean(key)); fCheckBoxes.add(button); return button; } /* * @see PreferencePage#createControl(Composite) */ public void createControl(Composite parent) { super.createControl(parent); WorkbenchHelp.setHelp(getControl(), "WORK_IN_PROGRESS_PREFERENCE_PAGE"); //$NON-NLS-1$ } protected Control createContents(Composite parent) { initializeDialogUnits(parent); Composite result= new Composite(parent, SWT.NONE); GridLayout layout= new GridLayout(); layout.marginHeight= convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN); layout.marginWidth= 0; layout.verticalSpacing= convertVerticalDLUsToPixels(10); layout.horizontalSpacing= convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING); result.setLayout(layout); Group group= new Group(result, SWT.NONE); group.setLayout(new GridLayout()); group.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); group.setText(PreferencesMessages.getString(PREFIX + "editor")); //$NON-NLS-1$ addCheckBox(group, PreferencesMessages.getString(PREFIX + "overwriteMode"), PreferenceConstants.EDITOR_DISABLE_OVERWRITE_MODE); //$NON-NLS-1$ // addCheckBox(group, PreferencesMessages.getString(PREFIX + "formatComments"), "work_in_progress_enable_comment_formatting"); //$NON-NLS-1$ //$NON-NLS-2$ createSpacer(group, 1); Label label= new Label(group, SWT.NONE); label.setText(PreferencesMessages.getString(PREFIX + "smartTyping.label")); //$NON-NLS-1$ Button button= addCheckBox(group, PreferencesMessages.getString(PREFIX + "smartTyping.smartSemicolon"), PreferenceConstants.EDITOR_SMART_SEMICOLON); //$NON-NLS-1$ fSmartTypingItems.add(button); button= addCheckBox(group, PreferencesMessages.getString(PREFIX + "smartTyping.smartOpeningBrace"), PreferenceConstants.EDITOR_SMART_OPENING_BRACE); //$NON-NLS-1$ fSmartTypingItems.add(button); /* line change bar */ group= new Group(result, SWT.NONE); group.setLayout(new GridLayout()); group.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); group.setText(PreferencesMessages.getString(PREFIX + "quickdiff")); //$NON-NLS-1$ Label l= new Label(group, SWT.LEFT ); GridData gd= new GridData(GridData.HORIZONTAL_ALIGN_FILL); gd.horizontalSpan= 2; gd.heightHint= convertHeightInCharsToPixels(1) / 2; l.setLayoutData(gd); button= addCheckBox(group, PreferencesMessages.getString(PREFIX + "showQuickDiffPerDefault"), ExtendedTextEditorPreferenceConstants.QUICK_DIFF_ALWAYS_ON); //$NON-NLS-1$ button= addCheckBox(group, PreferencesMessages.getString(PREFIX + "quickdiff.characterMode"), ExtendedTextEditorPreferenceConstants.QUICK_DIFF_CHARACTER_MODE); //$NON-NLS-1$ l= new Label(group, SWT.LEFT ); gd= new GridData(GridData.HORIZONTAL_ALIGN_FILL); gd.horizontalSpan= 2; gd.heightHint= convertHeightInCharsToPixels(1) / 2; l.setLayoutData(gd); l= new Label(group, SWT.LEFT); l.setText(PreferencesMessages.getString(PREFIX + "quickdiff.referenceprovidertitle")); //$NON-NLS-1$ gd= new GridData(GridData.HORIZONTAL_ALIGN_FILL); gd.horizontalSpan= 2; l.setLayoutData(gd); Composite editorComposite= new Composite(group, SWT.NONE); layout= new GridLayout(); layout.numColumns= 2; layout.marginHeight= 0; layout.marginWidth= 0; editorComposite.setLayout(layout); gd= new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.FILL_VERTICAL); gd.horizontalSpan= 2; editorComposite.setLayoutData(gd); fQuickDiffProviderList= new org.eclipse.swt.widgets.List(editorComposite, SWT.SINGLE | SWT.V_SCROLL | SWT.BORDER); gd= new GridData(GridData.VERTICAL_ALIGN_BEGINNING | GridData.FILL_HORIZONTAL); gd.heightHint= convertHeightInCharsToPixels(4); fQuickDiffProviderList.setLayoutData(gd); Composite stylesComposite= new Composite(editorComposite, SWT.NONE); layout= new GridLayout(); layout.marginHeight= 0; layout.marginWidth= 0; layout.numColumns= 2; stylesComposite.setLayout(layout); stylesComposite.setLayoutData(new GridData(GridData.FILL_BOTH)); fSetDefaultButton= new Button(stylesComposite, SWT.PUSH); fSetDefaultButton.setText(PreferencesMessages.getString(PREFIX + "quickdiff.setDefault")); //$NON-NLS-1$ gd= new GridData(GridData.FILL_HORIZONTAL); gd.horizontalAlignment= GridData.BEGINNING; gd.horizontalSpan= 2; fSetDefaultButton.setLayoutData(gd); fQuickDiffProviderList.addSelectionListener(new SelectionListener() { public void widgetDefaultSelected(SelectionEvent e) { // do nothing } public void widgetSelected(SelectionEvent e) { handleProviderListSelection(); } }); fSetDefaultButton.addSelectionListener(new SelectionListener() { public void widgetDefaultSelected(SelectionEvent e) { // do nothing } public void widgetSelected(SelectionEvent e) { int i= fQuickDiffProviderList.getSelectionIndex(); for (int j= 0; j < fQuickDiffProviderListModel.length; j++) { if (getPreferenceStore().getString(ExtendedTextEditorPreferenceConstants.QUICK_DIFF_DEFAULT_PROVIDER).equals(fQuickDiffProviderListModel[j][0])) { fQuickDiffProviderList.remove(j); fQuickDiffProviderList.add(fQuickDiffProviderListModel[j][1], j); } if (i == j) { fQuickDiffProviderList.remove(j); fQuickDiffProviderList.add(fQuickDiffProviderListModel[j][1] + " " + PreferencesMessages.getString(PREFIX + "quickdiff.defaultlabel"), j); //$NON-NLS-1$//$NON-NLS-2$ } } fSetDefaultButton.setEnabled(false); fQuickDiffProviderList.setSelection(i); fQuickDiffProviderList.redraw(); getPreferenceStore().setValue(ExtendedTextEditorPreferenceConstants.QUICK_DIFF_DEFAULT_PROVIDER, fQuickDiffProviderListModel[i][0]); } }); for (int i= 0; i < fQuickDiffProviderListModel.length; i++) { String sLabel= fQuickDiffProviderListModel[i][1]; if (getPreferenceStore().getString(ExtendedTextEditorPreferenceConstants.QUICK_DIFF_DEFAULT_PROVIDER).equals(fQuickDiffProviderListModel[i][0])) sLabel += " " + PreferencesMessages.getString(PREFIX + "quickdiff.defaultlabel"); //$NON-NLS-1$ //$NON-NLS-2$ fQuickDiffProviderList.add(sLabel); } fQuickDiffProviderList.getDisplay().asyncExec(new Runnable() { public void run() { if (fQuickDiffProviderList != null && !fQuickDiffProviderList.isDisposed()) { fQuickDiffProviderList.select(0); handleProviderListSelection(); } } }); group= new Group(result, SWT.NONE); group.setLayout(new GridLayout()); group.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); group.setText(PreferencesMessages.getString(PREFIX + "refactoring")); //$NON-NLS-1$ button= addCheckBox(group, PreferencesMessages.getString(PREFIX + "refactoring.participants"), "org.eclipse.jdt.refactoring.participants"); //$NON-NLS-1$ //$NON-NLS-2$ group= new Group(result, SWT.NONE); group.setLayout(new GridLayout()); group.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); group.setText(PreferencesMessages.getString(PREFIX + "quickassist.group")); //$NON-NLS-1$ button= addCheckBox(group, PreferencesMessages.getString(PREFIX + "quickassist.option"), PreferenceConstants.APPEARANCE_QUICKASSIST_LIGHTBULB); //$NON-NLS-1$ //$NON-NLS-2$ return result; } /* * @see org.eclipse.ui.IWorkbenchPreferencePage#init(org.eclipse.ui.IWorkbench) */ public void init(IWorkbench workbench) { } protected void createSpacer(Composite composite, int columnSpan) { Label label= new Label(composite, SWT.NONE); GridData gd= new GridData(); gd.horizontalSpan= columnSpan; label.setLayoutData(gd); } /* * @see org.eclipse.jface.preference.PreferencePage#doGetPreferenceStore() */ protected IPreferenceStore doGetPreferenceStore() { return JavaPlugin.getDefault().getPreferenceStore(); } /* * @see PreferencePage#performDefaults() */ protected void performDefaults() { IPreferenceStore store= getPreferenceStore(); for (int i= 0; i < fCheckBoxes.size(); i++) { Button button= (Button) fCheckBoxes.get(i); String key= (String) button.getData(); button.setSelection(store.getDefaultBoolean(key)); } for (int i= 0; i < fRadioButtons.size(); i++) { Button button= (Button) fRadioButtons.get(i); String[] info= (String[]) button.getData(); button.setSelection(info[1].equals(store.getDefaultString(info[0]))); } for (int i= 0; i < fTextControls.size(); i++) { Text text= (Text) fTextControls.get(i); String key= (String) text.getData(); text.setText(store.getDefaultString(key)); } handleProviderListSelection(); super.performDefaults(); } /* * @see IPreferencePage#performOk() */ public boolean performOk() { IPreferenceStore store= getPreferenceStore(); for (int i= 0; i < fCheckBoxes.size(); i++) { Button button= (Button) fCheckBoxes.get(i); String key= (String) button.getData(); store.setValue(key, button.getSelection()); } for (int i= 0; i < fRadioButtons.size(); i++) { Button button= (Button) fRadioButtons.get(i); if (button.getSelection()) { String[] info= (String[]) button.getData(); store.setValue(info[0], info[1]); } } for (int i= 0; i < fTextControls.size(); i++) { Text text= (Text) fTextControls.get(i); String key= (String) text.getData(); store.setValue(key, text.getText()); } JavaPlugin.getDefault().savePluginPreferences(); return super.performOk(); } /** * @param store */ public static void initDefaults(IPreferenceStore store) { store.setDefault("work_in_progress_enable_comment_formatting", false); //$NON-NLS-1$ store.setDefault(PreferenceConstants.EDITOR_DISABLE_OVERWRITE_MODE, false); store.setDefault(PreferenceConstants.EDITOR_SMART_SEMICOLON, false); store.setDefault(PreferenceConstants.EDITOR_SMART_OPENING_BRACE, false); store.setDefault(PreferenceConstants.APPEARANCE_QUICKASSIST_LIGHTBULB, false); } }
40,772
Bug 40772 [plan item] Smart tab on empty lines
When having the caret on an empty line, pressing tab cleans up the line and sets the caret it the right indentation column.
resolved fixed
adaf274
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2003-09-11T13:25:24Z
2003-07-25T13:33:20Z
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/JavaHeuristicScanner.java
40,772
Bug 40772 [plan item] Smart tab on empty lines
When having the caret on an empty line, pressing tab cleans up the line and sets the caret it the right indentation column.
resolved fixed
adaf274
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2003-09-11T13:25:24Z
2003-07-25T13:33:20Z
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/JavaIndenter.java
40,772
Bug 40772 [plan item] Smart tab on empty lines
When having the caret on an empty line, pressing tab cleans up the line and sets the caret it the right indentation column.
resolved fixed
adaf274
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2003-09-11T13:25:24Z
2003-07-25T13:33:20Z
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/Symbols.java
40,772
Bug 40772 [plan item] Smart tab on empty lines
When having the caret on an empty line, pressing tab cleans up the line and sets the caret it the right indentation column.
resolved fixed
adaf274
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2003-09-11T13:25:24Z
2003-07-25T13:33:20Z
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/java/JavaAutoIndentStrategy.java
/******************************************************************************* * Copyright (c) 2000, 2003 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Common Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/cpl-v10.html * * Contributors: * IBM Corporation - initial API and implementation * Nikolay Metchev - Fixed bug 29909 *******************************************************************************/ package org.eclipse.jdt.internal.ui.text.java; import java.util.Arrays; import java.util.Iterator; import java.util.NoSuchElementException; import org.eclipse.jface.preference.IPreferenceStore; import org.eclipse.jface.text.BadLocationException; import org.eclipse.jface.text.DefaultAutoIndentStrategy; import org.eclipse.jface.text.Document; import org.eclipse.jface.text.DocumentCommand; import org.eclipse.jface.text.IDocument; import org.eclipse.jface.text.IRegion; import org.eclipse.jface.text.ITypedRegion; import org.eclipse.jface.text.Region; import org.eclipse.jface.text.TextUtilities; import org.eclipse.ui.IEditorPart; import org.eclipse.ui.IWorkbenchPage; import org.eclipse.ui.texteditor.ITextEditorExtension3; import org.eclipse.jdt.core.ToolFactory; import org.eclipse.jdt.core.compiler.IProblem; import org.eclipse.jdt.core.compiler.IScanner; import org.eclipse.jdt.core.compiler.ITerminalSymbols; import org.eclipse.jdt.core.compiler.InvalidInputException; import org.eclipse.jdt.core.dom.AST; import org.eclipse.jdt.core.dom.ASTNode; import org.eclipse.jdt.core.dom.CompilationUnit; import org.eclipse.jdt.core.dom.DoStatement; import org.eclipse.jdt.core.dom.Expression; import org.eclipse.jdt.core.dom.ForStatement; import org.eclipse.jdt.core.dom.IfStatement; import org.eclipse.jdt.core.dom.Statement; import org.eclipse.jdt.core.dom.WhileStatement; import org.eclipse.jdt.ui.PreferenceConstants; import org.eclipse.jdt.internal.corext.Assert; import org.eclipse.jdt.internal.corext.dom.NodeFinder; import org.eclipse.jdt.internal.corext.util.CodeFormatterUtil; import org.eclipse.jdt.internal.ui.JavaPlugin; import org.eclipse.jdt.internal.ui.text.IJavaPartitions; /** * Auto indent strategy sensitive to brackets. */ public class JavaAutoIndentStrategy extends DefaultAutoIndentStrategy { /** * Internal line interator working on <code>IDocument</code>. */ private static final class LineIterator implements Iterator { /** The document to iterator over. */ private final IDocument fDocument; /** The line index. */ private int fLineIndex; /** * Creates a line iterator. */ public LineIterator(String string) { fDocument= new Document(string); } /* * @see java.util.Iterator#hasNext() */ public boolean hasNext() { return fLineIndex != fDocument.getNumberOfLines(); } /* * @see java.util.Iterator#next() */ public Object next() { try { IRegion region= fDocument.getLineInformation(fLineIndex++); return fDocument.get(region.getOffset(), region.getLength()); } catch (BadLocationException e) { JavaPlugin.log(e); throw new NoSuchElementException(); } } /* * @see java.util.Iterator#remove() */ public void remove() { throw new UnsupportedOperationException(); } } private static class CompilationUnitInfo { public char[] buffer; public int delta; public CompilationUnitInfo(char[] buffer, int delta) { this.buffer= buffer; this.delta= delta; } } private final static String COMMENT= "//"; //$NON-NLS-1$ private int fTabWidth; private boolean fUseSpaces; private boolean fCloseBrace; private boolean fIsSmartMode; private String fPartitioning; /** * Creates a new Java auto indent strategy for the given document partitioning. * * @param partitioning the document partitioning */ public JavaAutoIndentStrategy(String partitioning) { fPartitioning= partitioning; } /** * Evaluates the given line for the opening bracket that matches the closing bracket on the given line. */ private int findMatchingOpenBracket(IDocument d, int lineNumber, int endOffset, int closingBracketIncrease) throws BadLocationException { int startOffset= d.getLineOffset(lineNumber); int bracketCount= getBracketCount(d, startOffset, endOffset, false) - closingBracketIncrease; // sum up the brackets counts of each line (closing brackets count negative, // opening positive) until we find a line the brings the count to zero while (bracketCount < 0) { --lineNumber; if (lineNumber < 0) return -1; startOffset= d.getLineOffset(lineNumber); endOffset= startOffset + d.getLineLength(lineNumber) - 1; bracketCount += getBracketCount(d, startOffset, endOffset, false); } return lineNumber; } private int getBracketCount(IDocument d, int startOffset, int endOffset, boolean ignoreCloseBrackets) throws BadLocationException { int bracketCount= 0; while (startOffset < endOffset) { char curr= d.getChar(startOffset); startOffset++; switch (curr) { case '/' : if (startOffset < endOffset) { char next= d.getChar(startOffset); if (next == '*') { // a comment starts, advance to the comment end startOffset= getCommentEnd(d, startOffset + 1, endOffset); } else if (next == '/') { // '//'-comment: nothing to do anymore on this line startOffset= endOffset; } } break; case '*' : if (startOffset < endOffset) { char next= d.getChar(startOffset); if (next == '/') { // we have been in a comment: forget what we read before bracketCount= 0; startOffset++; } } break; case '{' : bracketCount++; ignoreCloseBrackets= false; break; case '}' : if (!ignoreCloseBrackets) { bracketCount--; } break; case '"' : case '\'' : startOffset= getStringEnd(d, startOffset, endOffset, curr); break; default : } } return bracketCount; } // ----------- bracket counting ------------------------------------------------------ private int getCommentEnd(IDocument d, int offset, int endOffset) throws BadLocationException { while (offset < endOffset) { char curr= d.getChar(offset); offset++; if (curr == '*') { if (offset < endOffset && d.getChar(offset) == '/') { return offset + 1; } } } return endOffset; } private String getIndentOfLine(IDocument d, int line) throws BadLocationException { if (line > -1) { int start= d.getLineOffset(line); int end= start + d.getLineLength(line) - 1; int whiteEnd= findEndOfWhiteSpace(d, start, end); return d.get(start, whiteEnd - start); } else { return ""; //$NON-NLS-1$ } } private int getStringEnd(IDocument d, int offset, int endOffset, char ch) throws BadLocationException { while (offset < endOffset) { char curr= d.getChar(offset); offset++; if (curr == '\\') { // ignore escaped characters offset++; } else if (curr == ch) { return offset; } } return endOffset; } private void smartIndentAfterClosingBracket(IDocument d, DocumentCommand c) { if (c.offset == -1 || d.getLength() == 0) return; try { int p= (c.offset == d.getLength() ? c.offset - 1 : c.offset); int line= d.getLineOfOffset(p); int start= d.getLineOffset(line); int whiteend= findEndOfWhiteSpace(d, start, c.offset); // shift only when line does not contain any text up to the closing bracket if (whiteend == c.offset) { // evaluate the line with the opening bracket that matches out closing bracket int indLine= findMatchingOpenBracket(d, line, c.offset, 1); if (indLine != -1 && indLine != line) { // take the indent of the found line StringBuffer replaceText= new StringBuffer(getIndentOfLine(d, indLine)); // add the rest of the current line including the just added close bracket replaceText.append(d.get(whiteend, c.offset - whiteend)); replaceText.append(c.text); // modify document command c.length += c.offset - start; c.offset= start; c.text= replaceText.toString(); } } } catch (BadLocationException e) { JavaPlugin.log(e); } } private void smartIndentAfterOpeningBracket(IDocument d, DocumentCommand c) { if (c.offset == -1 || d.getLength() == 0) return; int p= (c.offset == d.getLength() ? c.offset - 1 : c.offset); try { // current line int line= d.getLineOfOffset(p); int lineOffset= d.getLineOffset(line); // line of last javacode int pos= firstNonWhitespaceBackward(d, p, IJavaPartitions.JAVA_PARTITIONING, -1); int lastLine= d.getLineOfOffset(pos); int lastLineOffset= d.getLineOffset(lastLine); // only shift if the last java line is further up and is a braceless block candidate if (lastLine < line) { if (isBracelessBlockStart(d, pos + 1, lastLineOffset)) { // if the last line was a braceless block candidate, we have indented // after the new line. This has to be undone as we *are* starting a block // on the new line StringBuffer replace= new StringBuffer(getIndentOfLine(d, lastLine)); c.length += replace.length(); replace.append(c.text); c.offset= lineOffset; c.text= replace.toString(); } } } catch (BadLocationException e) { JavaPlugin.log(e); } } private void smartIndentAfterNewLine(IDocument d, DocumentCommand c) { int docLength= d.getLength(); if (c.offset == -1 || docLength == 0) return; try { int p= (c.offset == docLength ? c.offset - 1 : c.offset); int line= d.getLineOfOffset(p); StringBuffer buf= new StringBuffer(c.text); if (c.offset < docLength && d.getChar(c.offset) == '}') { int indLine= findMatchingOpenBracket(d, line, c.offset, 0); if (indLine == -1) { indLine= line; } buf.append(getIndentOfLine(d, indLine)); } else { int start= d.getLineOffset(line); ITypedRegion region= TextUtilities.getPartition(d, fPartitioning, start); if (IJavaPartitions.JAVA_DOC.equals(region.getType())) start= d.getLineInformationOfOffset(region.getOffset()).getOffset(); int whiteend= findEndOfWhiteSpace(d, start, c.offset); int length= whiteend - start; buf.append(d.get(start, length)); if (getBracketCount(d, start, c.offset, true) > 0) { buf.append(createIndent(1, useSpaces())); if (closeBrace() && !isClosed(d, c.offset, c.length)) { c.caretOffset= c.offset + buf.length(); c.shiftsCaret= false; // copy old content of line behind insertion point to new line // unless we think we are inserting an anonymous type definition IRegion reg= d.getLineInformation(line); int lineEnd= reg.getOffset() + reg.getLength(); if (!(computeAnonymousPosition(d, c.offset - 1, fPartitioning, lineEnd) != -1)) { int contentStart= findEndOfWhiteSpace(d, c.offset, lineEnd); if (lineEnd - contentStart > 0) { c.length= lineEnd - c.offset; buf.append(d.get(contentStart, lineEnd - contentStart).toCharArray()); } } buf.append(getLineDelimiter(d)); buf.append(d.get(start, length)); buf.append('}'); } } else if (isBracelessBlockStart(d, c.offset, start)) { buf.append(createIndent(1, useSpaces())); } } c.text= buf.toString(); } catch (BadLocationException e) { JavaPlugin.log(e); } } /** * Checks if the line seems to be an open condition not followed by a block (i.e. an if, while, * or for statement with just one following statement, see example below). * * <pre> * if (condition) * doStuff(); * </pre> * * <p>Algorithm: if the last non-WS, non-Comment code on the line is an if (condition), while (condition), * for( expression), do, else, and there is no statement after that </p> * * @param document the document worked on * @param position the insert position of the new character * @param bound the lowest position to consider * @return <code>true</code> if the code is a conditional statement or loop without a block, <code>false</code> otherwise */ private boolean isBracelessBlockStart(IDocument document, int position, int bound) { if (position < 1) return false; position= firstNonWhitespaceBackward(document, position - 1, fPartitioning, bound); if (position < 1) return false; // new line after do, else without brace if (looksLike(document, position, "do") //$NON-NLS-1$ || looksLike(document, position, "else")) //$NON-NLS-1$ return true; try { // new line after if,while,for + expression if (")".equals(document.get(position, 1))) { //$NON-NLS-1$ position= findOpeningParenMatch(document, position, fPartitioning); if (position > 0) { position= firstNonWhitespaceBackward(document, position - 1, fPartitioning, -1); if (position != -1) { if (looksLike(document, position, "if") //$NON-NLS-1$ || looksLike(document, position, "for") //$NON-NLS-1$ || looksLike(document, position, "while")) //$NON-NLS-1$ return true; } } } } catch (BadLocationException e) { // ignore and return false } return false; } /** * Checks whether code>document</code> contains the <code>String</code> <code>like</code> such * that its last character is at <code>position</code>. If <code>like</code> starts with a * identifier part (as determined by {@link Character.isJavaIdentifier(char)}), it is also made * sure that <code>like</code> is preceded by some non-identifier character or stands at the * document start. * * @param document the document being modified * @param position the first character position in <code>document</code> to be considered * @param like the <code>String</code> to look for. * @return <code>true</code> if <code>document</code> contains <code>like</code> such that it ends at <code>position</code>, <code>false</code> otherwise */ private static boolean looksLike(IDocument document, int position, String like) { int length= like.length(); if (position < length - 1) return false; try { if (!like.equals(document.get(position - length + 1, length))) return false; if (position >= length && Character.isJavaIdentifierPart(like.charAt(0)) && Character.isJavaIdentifierPart(document.getChar(position - length))) return false; } catch (BadLocationException e) { return false; } return true; } /** * Computes an insert position for an opening brace if <code>offset</code> maps to a position in * <code>document</code> with a expression in parenthesis that will take a block after the closing parenthesis. * * @param document the document being modified * @param offset the offset of the caret position, relative to the line start. * @param partitioning the document partitioning * @param max the max position * @return an insert position relative to the line start if <code>line</code> contains a parenthesized expression that can be followed by a block, -1 otherwise */ private static int computeAnonymousPosition(IDocument document, int offset, String partitioning, int max) { // find the opening parenthesis for every closing parenthesis on the current line after offset // return the position behind the closing parenthesis if it looks like a method declaration // or an expression for an if, while, for, catch statement int pos= offset; int length= max; int scanTo= scanForward(document, pos, partitioning, length, '}'); if (scanTo == -1) scanTo= length; int closingParen= findClosingParenToLeft(document, pos, partitioning) - 1; while (true) { int startScan= closingParen + 1; closingParen= scanForward(document, startScan, partitioning, scanTo, ')'); if (closingParen == -1) break; int openingParen= findOpeningParenMatch(document, closingParen, partitioning); // no way an expression at the beginning of the document can mean anything if (openingParen < 1) break; // only select insert positions for parenthesis currently embracing the caret if (openingParen > pos) continue; if (looksLikeAnonymousClassDef(document, openingParen - 1, partitioning)) return closingParen + 1; } return -1; } /** * Finds a closing parenthesis to the left of <code>position</code> in document, where that parenthesis is only * separated by whitespace from <code>position</code>. If no such parenthesis can be found, <code>position</code> is returned. * * @param document the document being modified * @param position the first character position in <code>document</code> to be considered * @param partitioning the document partitioning * @return the position of a closing parenthesis left to <code>position</code> separated only by whitespace, or <code>position</code> if no parenthesis can be found */ private static int findClosingParenToLeft(IDocument document, int position, String partitioning) { final char CLOSING_PAREN= ')'; try { if (position < 1) return position; int nonWS= firstNonWhitespaceBackward(document, position - 1, partitioning, -1); if (nonWS != -1 && document.getChar(nonWS) == CLOSING_PAREN) return nonWS; } catch (BadLocationException e1) { } return position; } /** * Finds the highest position in <code>document</code> such that the position is &lt;= <code>position</code> * and &gt; <code>bound</code> and <code>Character.isWhitespace(document.getChar(pos))</code> evaluates to <code>false</code> * and the position is in the default partition. * * @param document the document being modified * @param position the first character position in <code>document</code> to be considered * @param partitioning the document partitioning * @param bound the first position in <code>document</code> to not consider any more, with <code>bound</code> &gt; <code>position</code> * @return the highest position of one element in <code>chars</code> in [<code>position</code>, <code>scanTo</code>) that resides in a Java partition, or <code>-1</code> if none can be found */ private static int firstNonWhitespaceBackward(IDocument document, int position, String partitioning, int bound) { Assert.isTrue(position < document.getLength()); Assert.isTrue(bound >= -1); try { while (position > bound) { char ch= document.getChar(position); if (!Character.isWhitespace(ch) && isDefaultPartition(document, position, partitioning)) return position; position--; } } catch (BadLocationException e) { } return -1; } /** * Finds the lowest position in <code>document</code> such that the position is &gt;= <code>position</code> * and &lt; <code>bound</code> and <code>document.getChar(position) == ch</code> evaluates to <code>true</code> for at least one * ch in <code>chars</code> and the position is in the default partition. * * @param document the document being modified * @param position the first character position in <code>document</code> to be considered * @param partitioning the document partitioning * @param bound the first position in <code>document</code> to not consider any more, with <code>scanTo</code> &gt; <code>position</code> * @param chars an array of <code>char</code> to search for * @return the lowest position of one element in <code>chars</code> in [<code>position</code>, <code>bound</code>) that resides in a Java partition, or <code>-1</code> if none can be found */ private static int scanForward(IDocument document, int position, String partitioning, int bound, char[] chars) { Assert.isTrue(position >= 0); Assert.isTrue(bound <= document.getLength()); Arrays.sort(chars); try { while (position < bound) { if (Arrays.binarySearch(chars, document.getChar(position)) >= 0 && isDefaultPartition(document, position, partitioning)) return position; position++; } } catch (BadLocationException e) { } return -1; } /** * Finds the lowest position in <code>document</code> such that the position is &gt;= <code>position</code> * and &lt; <code>bound</code> and <code>document.getChar(position) == ch</code> evaluates to <code>true</code> * and the position is in the default partition. * * @param document the document being modified * @param position the first character position in <code>document</code> to be considered * @param partitioning the document partitioning * @param bound the first position in <code>document</code> to not consider any more, with <code>scanTo</code> &gt; <code>position</code> * @param ch the <code>char</code> to search for * @return the lowest position of <code>ch</code> in (<code>bound</code>, <code>position</code>] that resides in a Java partition, or <code>-1</code> if none can be found */ private static int scanForward(IDocument document, int position, String partitioning, int bound, char ch) { return scanForward(document, position, partitioning, bound, new char[] {ch}); } /** * Checks whether the content of <code>document</code> in the range (<code>offset</code>, <code>length</code>) * contains the <code>new</code> keyword. * * @param document the document being modified * @param offset the first character position in <code>document</code> to be considered * @param length the length of the character range to be considered * @param partitioning the document partitioning * @return <code>true</code> if the specified character range contains a <code>new</code> keyword, <code>false</code> otherwise. */ private static boolean isNewMatch(IDocument document, int offset, int length, String partitioning) { Assert.isTrue(length >= 0); Assert.isTrue(offset >= 0); Assert.isTrue(offset + length < document.getLength() + 1); try { String text= document.get(offset, length); int pos= text.indexOf("new"); //$NON-NLS-1$ while (pos != -1 && !isDefaultPartition(document, pos + offset, partitioning)) pos= text.indexOf("new", pos + 2); //$NON-NLS-1$ if (pos < 0) return false; if (pos != 0 && Character.isJavaIdentifierPart(document.getChar(pos - 1))) return false; if (pos + 3 < length && Character.isJavaIdentifierPart(document.getChar(pos + 3))) return false; return true; } catch (BadLocationException e) { } return false; } /** * Checks whether the content of <code>document</code> at <code>position</code> looks like an * anonymous class definition. <code>position</code> must be to the left of the opening * parenthesis of the definition's parameter list. * * @param document the document being modified * @param position the first character position in <code>document</code> to be considered * @param partitioning the document partitioning * @return <code>true</code> if the content of <code>document</code> looks like an anonymous class definition, <code>false</code> otherwise */ private static boolean looksLikeAnonymousClassDef(IDocument document, int position, String partitioning) { int previousCommaOrParen= scanBackward(document, position - 1, partitioning, -1, new char[] {',', '('}); if (previousCommaOrParen == -1 || position < previousCommaOrParen + 5) // 2 for borders, 3 for "new" return false; if (isNewMatch(document, previousCommaOrParen + 1, position - previousCommaOrParen - 2, partitioning)) return true; return false; } /** * Checks whether <code>position</code> resides in a default (Java) partition of <code>document</code>. * * @param document the document being modified * @param position the position to be checked * @param partitioning the document partitioning * @return <code>true</code> if <code>position</code> is in the default partition of <code>document</code>, <code>false</code> otherwise */ private static boolean isDefaultPartition(IDocument document, int position, String partitioning) { Assert.isTrue(position >= 0); Assert.isTrue(position <= document.getLength()); try { ITypedRegion region= TextUtilities.getPartition(document, partitioning, position); return region.getType().equals(IDocument.DEFAULT_CONTENT_TYPE); } catch (BadLocationException e) { } return false; } /** * Finds the position of the parenthesis matching the closing parenthesis at <code>position</code>. * * @param document the document being modified * @param position the position in <code>document</code> of a closing parenthesis * @param partitioning the document partitioning * @return the position in <code>document</code> of the matching parenthesis, or -1 if none can be found */ private static int findOpeningParenMatch(IDocument document, int position, String partitioning) { final char CLOSING_PAREN= ')'; final char OPENING_PAREN= '('; Assert.isTrue(position < document.getLength()); Assert.isTrue(position >= 0); Assert.isTrue(isDefaultPartition(document, position, partitioning)); try { Assert.isTrue(document.getChar(position) == CLOSING_PAREN); int depth= 1; while (true) { position= scanBackward(document, position - 1, partitioning, -1, new char[] {CLOSING_PAREN, OPENING_PAREN}); if (position == -1) return -1; if (document.getChar(position) == CLOSING_PAREN) depth++; else depth--; if (depth == 0) return position; } } catch (BadLocationException e) { return -1; } } /** * Finds the highest position in <code>document</code> such that the position is &lt;= <code>position</code> * and &gt; <code>bound</code> and <code>document.getChar(position) == ch</code> evaluates to <code>true</code> for at least one * ch in <code>chars</code> and the position is in the default partition. * * @param document the document being modified * @param position the first character position in <code>document</code> to be considered * @param partitioning the document partitioning * @param bound the first position in <code>document</code> to not consider any more, with <code>scanTo</code> &gt; <code>position</code> * @param chars an array of <code>char</code> to search for * @return the highest position of one element in <code>chars</code> in [<code>position</code>, <code>scanTo</code>) that resides in a Java partition, or <code>-1</code> if none can be found */ private static int scanBackward(IDocument document, int position, String partitioning, int bound, char[] chars) { Assert.isTrue(bound >= -1); Assert.isTrue(position < document.getLength() ); Arrays.sort(chars); try { while (position > bound) { if (Arrays.binarySearch(chars, document.getChar(position)) >= 0 && isDefaultPartition(document, position, partitioning)) return position; position--; } } catch (BadLocationException e) { } return -1; } private boolean isClosed(IDocument document, int offset, int length) { CompilationUnitInfo info= getCompilationUnitForMethod(document, offset, fPartitioning); if (info == null) return false; CompilationUnit compilationUnit= null; try { compilationUnit= AST.parseCompilationUnit(info.buffer); } catch (ArrayIndexOutOfBoundsException x) { // work around for parser problem return false; } IProblem[] problems= compilationUnit.getProblems(); for (int i= 0; i != problems.length; ++i) { if (problems[i].getID() == IProblem.UnmatchedBracket) return true; } final int relativeOffset= offset - info.delta; ASTNode node= NodeFinder.perform(compilationUnit, relativeOffset, length); if (node == null) return false; if (length == 0) { while (node != null && (relativeOffset == node.getStartPosition() || relativeOffset == node.getStartPosition() + node.getLength())) node= node.getParent(); } switch (node.getNodeType()) { case ASTNode.BLOCK: return areBlocksConsistent(document, offset, fPartitioning); case ASTNode.IF_STATEMENT: { IfStatement ifStatement= (IfStatement) node; Expression expression= ifStatement.getExpression(); IRegion expressionRegion= createRegion(expression, info.delta); Statement thenStatement= ifStatement.getThenStatement(); IRegion thenRegion= createRegion(thenStatement, info.delta); // between expression and then statement if (expressionRegion.getOffset() + expressionRegion.getLength() <= offset && offset + length <= thenRegion.getOffset()) return thenStatement != null; Statement elseStatement= ifStatement.getElseStatement(); IRegion elseRegion= createRegion(elseStatement, info.delta); IRegion elseToken= null; if (elseStatement != null) { int sourceOffset= thenRegion.getOffset() + thenRegion.getLength(); int sourceLength= elseRegion.getOffset() - sourceOffset; elseToken= getToken(document, new Region(sourceOffset, sourceLength), ITerminalSymbols.TokenNameelse); } // between 'else' keyword and else statement if (elseToken.getOffset() + elseToken.getLength() <= offset && offset + length < elseRegion.getOffset()) return elseStatement != null; } break; case ASTNode.WHILE_STATEMENT: case ASTNode.FOR_STATEMENT: { Expression expression= node.getNodeType() == ASTNode.WHILE_STATEMENT ? ((WhileStatement) node).getExpression() : ((ForStatement) node).getExpression(); IRegion expressionRegion= createRegion(expression, info.delta); Statement body= node.getNodeType() == ASTNode.WHILE_STATEMENT ? ((WhileStatement) node).getBody() : ((ForStatement) node).getBody(); IRegion bodyRegion= createRegion(body, info.delta); // between expression and body statement if (expressionRegion.getOffset() + expressionRegion.getLength() <= offset && offset + length <= bodyRegion.getOffset()) return body != null; } break; case ASTNode.DO_STATEMENT: { DoStatement doStatement= (DoStatement) node; IRegion doRegion= createRegion(doStatement, info.delta); Statement body= doStatement.getBody(); IRegion bodyRegion= createRegion(body, info.delta); if (doRegion.getOffset() + doRegion.getLength() <= offset && offset + length <= bodyRegion.getOffset()) return body != null; } break; } return true; } private static String getLineDelimiter(IDocument document) { try { if (document.getNumberOfLines() > 1) return document.getLineDelimiter(0); } catch (BadLocationException e) { JavaPlugin.log(e); } return System.getProperty("line.separator"); //$NON-NLS-1$ } private static boolean startsWithClosingBrace(String string) { final int length= string.length(); int i= 0; while (i != length && Character.isWhitespace(string.charAt(i))) ++i; if (i == length) return false; return string.charAt(i) == '}'; } private void smartPaste(IDocument document, DocumentCommand command) { String lineDelimiter= getLineDelimiter(document); try { String pastedText= command.text; Assert.isNotNull(pastedText); Assert.isTrue(pastedText.length() > 1); // extend selection begin if only whitespaces int selectionStart= command.offset; IRegion region= document.getLineInformationOfOffset(selectionStart); String notSelected= document.get(region.getOffset(), selectionStart - region.getOffset()); String selected= document.get(selectionStart, region.getOffset() + region.getLength() - selectionStart); if (notSelected.trim().length() == 0 && selected.trim().length() != 0) { pastedText= notSelected + pastedText; command.length += notSelected.length(); command.offset= region.getOffset(); } // choose smaller indent of block and preceeding non-empty line String blockIndent= getBlockIndent(document, command); String insideBlockIndent= blockIndent == null ? "" : blockIndent + createIndent(1, useSpaces()); //$NON-NLS-1$ // add one indent level int insideBlockIndentSize= calculateDisplayedWidth(insideBlockIndent, getTabWidth()); int previousIndentSize= getIndentSize(document, command); int newIndentSize= insideBlockIndentSize < previousIndentSize ? insideBlockIndentSize : previousIndentSize; // indent is different if block starts with '}' if (startsWithClosingBrace(pastedText)) { int outsideBlockIndentSize= blockIndent == null ? 0 : calculateDisplayedWidth(blockIndent, getTabWidth()); newIndentSize = outsideBlockIndentSize; } // check selection int offset= command.offset; int line= document.getLineOfOffset(offset); int lineOffset= document.getLineOffset(line); String prefix= document.get(lineOffset, offset - lineOffset); boolean formatFirstLine= prefix.trim().length() == 0; String formattedParagraph= format(pastedText, newIndentSize, lineDelimiter, formatFirstLine); // paste if (formatFirstLine) { int end= command.offset + command.length; command.offset= lineOffset; command.length= end - command.offset; } command.text= formattedParagraph; } catch (BadLocationException e) { JavaPlugin.log(e); } } private static String getIndentOfLine(String line) { int i= 0; for (; i < line.length(); i++) { if (! Character.isWhitespace(line.charAt(i))) break; } return line.substring(0, i); } /** * Returns the indent of the first non empty line. * A line is considered empty if it only consists of whitespaces or if it * begins with a single line comment followed by whitespaces only. */ private static int getIndentSizeOfFirstLine(String paragraph, boolean includeFirstLine, int tabWidth) { for (final Iterator iterator= new LineIterator(paragraph); iterator.hasNext();) { final String line= (String) iterator.next(); if (!includeFirstLine) { includeFirstLine= true; continue; } String indent= null; if (line.startsWith(COMMENT)) { String commentedLine= line.substring(2); // line is empty if (commentedLine.trim().length() == 0) continue; indent= COMMENT + getIndentOfLine(commentedLine); } else { // line is empty if (line.trim().length() == 0) continue; indent= getIndentOfLine(line); } return calculateDisplayedWidth(indent, tabWidth); } return 0; } /** * Returns the minimal indent size of all non empty lines; */ private static int getMinimalIndentSize(String paragraph, boolean includeFirstLine, int tabWidth) { int minIndentSize= Integer.MAX_VALUE; for (final Iterator iterator= new LineIterator(paragraph); iterator.hasNext();) { final String line= (String) iterator.next(); if (!includeFirstLine) { includeFirstLine= true; continue; } String indent= null; if (line.startsWith(COMMENT)) { String commentedLine= line.substring(2); // line is empty if (commentedLine.trim().length() == 0) continue; indent= COMMENT + getIndentOfLine(commentedLine); } else { // line is empty if (line.trim().length() == 0) continue; indent=getIndentOfLine(line); } final int indentSize= calculateDisplayedWidth(indent, tabWidth); if (indentSize < minIndentSize) minIndentSize= indentSize; } return minIndentSize == Integer.MAX_VALUE ? 0 : minIndentSize; } /** * Returns the displayed width of a string, taking in account the displayed tab width. * The result can be compared against the print margin. */ private static int calculateDisplayedWidth(String string, int tabWidth) { int column= 0; for (int i= 0; i < string.length(); i++) if ('\t' == string.charAt(i)) column += tabWidth - (column % tabWidth); else column++; return column; } private static boolean isLineEmpty(IDocument document, int line) throws BadLocationException { IRegion region= document.getLineInformation(line); String string= document.get(region.getOffset(), region.getLength()); return string.trim().length() == 0; } private int getIndentSize(IDocument document, DocumentCommand command) { StringBuffer buffer= new StringBuffer(); int docLength= document.getLength(); if (command.offset == -1 || docLength == 0) return 0; try { int p= (command.offset == docLength ? command.offset - 1 : command.offset); int line= document.getLineOfOffset(p); IRegion region= document.getLineInformation(line); String string= document.get(region.getOffset(), command.offset - region.getOffset()); if (line != 0 && string.trim().length() == 0) --line; while (line != 0 && isLineEmpty(document, line)) --line; int start= document.getLineOffset(line); // if line is at end of a javadoc comment, take the indent from the comment's begin line ITypedRegion typedRegion= TextUtilities.getPartition(document, fPartitioning, start); if (IJavaPartitions.JAVA_DOC.equals(typedRegion.getType())) { start= document.getLineInformationOfOffset(typedRegion.getOffset()).getOffset(); } else if (IJavaPartitions.JAVA_SINGLE_LINE_COMMENT.equals(typedRegion.getType())) { buffer.append(COMMENT); start += 2; } int whiteend= findEndOfWhiteSpace(document, start, command.offset); buffer.append(document.get(start, whiteend - start)); if (getBracketCount(document, start, command.offset, true) > 0) { buffer.append(createIndent(1, useSpaces())); } } catch (BadLocationException e) { JavaPlugin.log(e); } return calculateDisplayedWidth(buffer.toString(), getTabWidth()); } private String getBlockIndent(IDocument d, DocumentCommand c) { if (c.offset < 0 || d.getLength() == 0) return null; try { int p= (c.offset == d.getLength() ? c.offset - 1 : c.offset); int line= d.getLineOfOffset(p); // evaluate the line with the opening bracket that matches out closing bracket int indLine= findMatchingOpenBracket(d, line, c.offset, 1); if (indLine != -1) // take the indent of the found line return getIndentOfLine(d, indLine); } catch (BadLocationException e) { JavaPlugin.log(e); } return null; } private String createIndent(int level, boolean useSpaces) { StringBuffer buffer= new StringBuffer(); if (useSpaces) { // Fix for bug 29909 contributed by Nikolay Metchev int width= level * getTabWidth(); for (int i= 0; i != width; ++i) buffer.append(' '); } else { for (int i= 0; i != level; ++i) buffer.append('\t'); } return buffer.toString(); } /** * Extends the string to match displayed width. * String is either the empty string or "//" and should not contain whites. */ private static String changePrefix(String string, int displayedWidth, boolean useSpaces, int tabWidth) { // assumption: string contains no whitespace final StringBuffer buffer= new StringBuffer(string); int column= calculateDisplayedWidth(buffer.toString(), tabWidth); if (column > displayedWidth) return string; if (useSpaces) { while (column != displayedWidth) { buffer.append(' '); ++column; } } else { while (column != displayedWidth) { if (column + tabWidth - (column % tabWidth) <= displayedWidth) { buffer.append('\t'); column += tabWidth - (column % tabWidth); } else { buffer.append(' '); ++column; } } } return buffer.toString(); } /** * Formats a paragraph such that the first non-empty line of the paragraph * will have an indent of size newIndentSize. */ private String format(String paragraph, int newIndentSize, String lineDelimiter, boolean indentFirstLine) { final int tabWidth= getTabWidth(); final int firstLineIndentSize= getIndentSizeOfFirstLine(paragraph, indentFirstLine, tabWidth); final int minIndentSize= getMinimalIndentSize(paragraph, indentFirstLine, tabWidth); if (newIndentSize < firstLineIndentSize - minIndentSize) newIndentSize= firstLineIndentSize - minIndentSize; final StringBuffer buffer= new StringBuffer(); for (final Iterator iterator= new LineIterator(paragraph); iterator.hasNext();) { String line= (String) iterator.next(); if (indentFirstLine) { String lineIndent= null; if (line.startsWith(COMMENT)) lineIndent= COMMENT + getIndentOfLine(line.substring(2)); else lineIndent= getIndentOfLine(line); String lineContent= line.substring(lineIndent.length()); if (lineContent.length() == 0) { // line was empty; insert as is buffer.append(line); } else { int indentSize= calculateDisplayedWidth(lineIndent, tabWidth); int deltaSize= newIndentSize - firstLineIndentSize; lineIndent= changePrefix(lineIndent.trim(), indentSize + deltaSize, useSpaces(), tabWidth); buffer.append(lineIndent); buffer.append(lineContent); } } else { indentFirstLine= true; buffer.append(line); } if (iterator.hasNext()) buffer.append(lineDelimiter); } return buffer.toString(); } private boolean isLineDelimiter(IDocument document, String text) { String[] delimiters= document.getLegalLineDelimiters(); if (delimiters != null) return TextUtilities.equals(delimiters, text) > -1; return false; } private void smartIndentAfterBlockDelimiter(IDocument document, DocumentCommand command) { if (command.text.charAt(0) == '}') smartIndentAfterClosingBracket(document, command); else if (command.text.charAt(0) == '{') smartIndentAfterOpeningBracket(document, command); } /* * @see org.eclipse.jface.text.IAutoIndentStrategy#customizeDocumentCommand(org.eclipse.jface.text.IDocument, org.eclipse.jface.text.DocumentCommand) */ public void customizeDocumentCommand(IDocument d, DocumentCommand c) { clearCachedValues(); if (!isSmartMode()) return; if (c.length == 0 && c.text != null && isLineDelimiter(d, c.text)) smartIndentAfterNewLine(d, c); else if (c.text.length() == 1) smartIndentAfterBlockDelimiter(d, c); else if (c.text.length() > 1 && getPreferenceStore().getBoolean(PreferenceConstants.EDITOR_SMART_PASTE)) smartPaste(d, c); } private static IPreferenceStore getPreferenceStore() { return JavaPlugin.getDefault().getPreferenceStore(); } private boolean useSpaces() { return fUseSpaces; } private boolean closeBrace() { return fCloseBrace; } private int getTabWidth() { return fTabWidth; } private boolean isSmartMode() { return fIsSmartMode; } private void clearCachedValues() { // Fix for bug 29909 contributed by Nikolay Metchev fTabWidth= CodeFormatterUtil.getTabWidth(); IPreferenceStore preferenceStore= getPreferenceStore(); fUseSpaces= preferenceStore.getBoolean(PreferenceConstants.EDITOR_SPACES_FOR_TABS); fCloseBrace= preferenceStore.getBoolean(PreferenceConstants.EDITOR_CLOSE_BRACES); fIsSmartMode= computeSmartMode(); } private boolean computeSmartMode() { IWorkbenchPage page= JavaPlugin.getActivePage(); if (page != null) { IEditorPart part= page.getActiveEditor(); if (part instanceof ITextEditorExtension3) { ITextEditorExtension3 extension= (ITextEditorExtension3) part; return extension.getInsertMode() == ITextEditorExtension3.SMART_INSERT; } } return false; } private static int searchForClosingPeer(IDocument document, int position, String partitioning, final char openingPeer, final char closingPeer) { Assert.isTrue(position >= 0); try { int length= document.getLength(); int depth= 1; position -= 1; while (true) { position= scanForward(document, position + 1, partitioning, length, new char[] {openingPeer, closingPeer}); if (position == -1) return -1; if (document.getChar(position) == openingPeer) depth++; else depth--; if (depth == 0) return position; } } catch (BadLocationException e) { return -1; } } private static int searchForOpeningPeer(IDocument document, int position, String partitioning, final char openingPeer, final char closingPeer) { Assert.isTrue(position < document.getLength()); try { int depth= 1; position += 1; while (true) { position= scanBackward(document, position - 1, partitioning, -1, new char[] {openingPeer, closingPeer}); if (position == -1) return -1; if (document.getChar(position) == closingPeer) depth++; else depth--; if (depth == 0) return position; } } catch (BadLocationException e) { return -1; } } private static IRegion getSurroundingBlock(IDocument document, int offset, String partitioning) { if (offset < 1 || offset >= document.getLength()) return null; int begin= searchForOpeningPeer(document, offset - 1, partitioning, '{', '}'); int end= searchForClosingPeer(document, offset, partitioning, '{', '}'); if (begin == -1 || end == -1) return null; return new Region(begin, end + 1 - begin); } private static CompilationUnitInfo getCompilationUnitForMethod(IDocument document, int offset, String partitioning) { try { IRegion sourceRange= getSurroundingBlock(document, offset, partitioning); if (sourceRange == null) return null; String source= document.get(sourceRange.getOffset(), sourceRange.getLength()); StringBuffer contents= new StringBuffer(); contents.append("class ____C{void ____m()"); //$NON-NLS-1$ final int methodOffset= contents.length(); contents.append(source); contents.append('}'); char[] buffer= contents.toString().toCharArray(); return new CompilationUnitInfo(buffer, sourceRange.getOffset() - methodOffset); } catch (BadLocationException e) { JavaPlugin.log(e); } return null; } private static boolean areBlocksConsistent(IDocument document, int offset, String partitioning) { if (offset < 1 || offset >= document.getLength()) return false; int begin= offset; int end= offset - 1; while (true) { begin= searchForOpeningPeer(document, begin - 1, partitioning, '{', '}'); end= searchForClosingPeer(document, end + 1, partitioning, '{', '}'); if (begin == -1 && end == -1) return true; if (begin == -1 || end == -1) return false; } } private static IRegion createRegion(ASTNode node, int delta) { return node == null ? null : new Region(node.getStartPosition() + delta, node.getLength()); } private static IRegion getToken(IDocument document, IRegion scanRegion, int tokenId) { try { final String source= document.get(scanRegion.getOffset(), scanRegion.getLength()); IScanner scanner= ToolFactory.createScanner(false, false, false, false); scanner.setSource(source.toCharArray()); int id= scanner.getNextToken(); while (id != ITerminalSymbols.TokenNameEOF && id != tokenId) id= scanner.getNextToken(); if (id == ITerminalSymbols.TokenNameEOF) return null; int tokenOffset= scanner.getCurrentTokenStartPosition(); int tokenLength= scanner.getCurrentTokenEndPosition() + 1 - tokenOffset; // inclusive end return new Region(tokenOffset + scanRegion.getOffset(), tokenLength); } catch (InvalidInputException x) { return null; } catch (BadLocationException x) { return null; } } }
40,772
Bug 40772 [plan item] Smart tab on empty lines
When having the caret on an empty line, pressing tab cleans up the line and sets the caret it the right indentation column.
resolved fixed
adaf274
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2003-09-11T13:25:24Z
2003-07-25T13:33:20Z
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/java/JavaStringAutoIndentStrategy.java
/******************************************************************************* * Copyright (c) 2000, 2003 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Common Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/cpl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.jdt.internal.ui.text.java; import org.eclipse.jface.preference.IPreferenceStore; import org.eclipse.jface.text.BadLocationException; import org.eclipse.jface.text.DefaultAutoIndentStrategy; import org.eclipse.jface.text.Document; import org.eclipse.jface.text.DocumentCommand; import org.eclipse.jface.text.IDocument; import org.eclipse.jface.text.IRegion; import org.eclipse.jface.text.ITypedRegion; import org.eclipse.jface.text.TextUtilities; import org.eclipse.ui.IEditorPart; import org.eclipse.ui.IWorkbenchPage; import org.eclipse.ui.texteditor.ITextEditorExtension3; import org.eclipse.jdt.ui.PreferenceConstants; import org.eclipse.jdt.internal.ui.JavaPlugin; /** * Auto indent strategy for java strings */ public class JavaStringAutoIndentStrategy extends DefaultAutoIndentStrategy { private String fPartitioning; /** * Creates a new Java string auto indent strategy for the given document partitioning. * * @param partitioning the document partitioning */ public JavaStringAutoIndentStrategy(String partitioning) { super(); fPartitioning= partitioning; } private boolean isLineDelimiter(IDocument document, String text) { String[] delimiters= document.getLegalLineDelimiters(); if (delimiters != null) return TextUtilities.equals(delimiters, text) > -1; return false; } private String getLineIndentation(IDocument document, int offset) throws BadLocationException { // find start of line int adjustedOffset= (offset == document.getLength() ? offset - 1 : offset); IRegion line= document.getLineInformationOfOffset(adjustedOffset); int start= line.getOffset(); // find white spaces int end= findEndOfWhiteSpace(document, start, offset); return document.get(start, end - start); } private String getModifiedText(String string, String lineDelimiter, String indentation) throws BadLocationException { String indentedLine= lineDelimiter + indentation; IDocument document= new Document(string); StringBuffer buffer= new StringBuffer(); IRegion line= document.getLineInformation(0); buffer.append(document.get(line.getOffset(), line.getLength())); buffer.append("\" +"); //$NON-NLS-1$ int lineCount= document.getNumberOfLines(); for (int i= 1; i < lineCount - 1; i++) { line= document.getLineInformation(i); buffer.append(indentedLine); buffer.append('\"'); buffer.append(document.get(line.getOffset(), line.getLength())); buffer.append("\" +"); //$NON-NLS-1$ } line= document.getLineInformation(lineCount - 1); buffer.append(indentedLine); buffer.append('\"'); buffer.append(document.get(line.getOffset(), line.getLength())); return buffer.toString(); } private void javaStringIndentAfterNewLine(IDocument document, DocumentCommand command) throws BadLocationException { ITypedRegion partition= TextUtilities.getPartition(document, fPartitioning, command.offset); int offset= partition.getOffset(); int length= partition.getLength(); if (command.offset == offset) return; if (command.offset == offset + length && document.getChar(offset + length - 1) == '\"') return; String[] legalLineDelimiters= document.getLegalLineDelimiters(); String lineDelimiter= legalLineDelimiters[0]; String indentation= getLineIndentation(document, command.offset); IRegion line= document.getLineInformationOfOffset(offset); String string= document.get(line.getOffset(), offset - line.getOffset()); if (string.trim().length() != 0) indentation += String.valueOf('\t'); command.text= getModifiedText(command.text, lineDelimiter, indentation); } private boolean isSmartMode() { IWorkbenchPage page= JavaPlugin.getActivePage(); if (page != null) { IEditorPart part= page.getActiveEditor(); if (part instanceof ITextEditorExtension3) { ITextEditorExtension3 extension= (ITextEditorExtension3) part; return extension.getInsertMode() == ITextEditorExtension3.SMART_INSERT; } } return false; } /* * @see org.eclipse.jface.text.IAutoIndentStrategy#customizeDocumentCommand(IDocument, DocumentCommand) */ public void customizeDocumentCommand(IDocument document, DocumentCommand command) { try { if (command.length != 0 || command.text == null) return; IPreferenceStore preferenceStore= JavaPlugin.getDefault().getPreferenceStore(); if (preferenceStore.getBoolean(PreferenceConstants.EDITOR_WRAP_STRINGS) && isLineDelimiter(document, command.text) && isSmartMode()) javaStringIndentAfterNewLine(document, command); } catch (BadLocationException e) { } } }
40,772
Bug 40772 [plan item] Smart tab on empty lines
When having the caret on an empty line, pressing tab cleans up the line and sets the caret it the right indentation column.
resolved fixed
adaf274
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2003-09-11T13:25:24Z
2003-07-25T13:33:20Z
org.eclipse.jdt.ui/ui/org/eclipse/jdt/ui/PreferenceConstants.java
/******************************************************************************* * Copyright (c) 2000, 2003 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Common Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/cpl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.jdt.ui; import org.eclipse.swt.SWT; import org.eclipse.swt.graphics.RGB; import org.eclipse.jface.action.Action; import org.eclipse.jface.preference.IPreferenceStore; import org.eclipse.jface.preference.PreferenceConverter; import org.eclipse.ui.texteditor.AbstractTextEditor; import org.eclipse.ui.texteditor.ExtendedTextEditorPreferenceConstants; import org.eclipse.jdt.core.IClasspathEntry; import org.eclipse.jdt.core.JavaCore; import org.eclipse.jdt.ui.text.IJavaColorConstants; import org.eclipse.jdt.internal.ui.JavaPlugin; import org.eclipse.jdt.internal.ui.preferences.NewJavaProjectPreferencePage; import org.eclipse.jdt.internal.ui.preferences.WorkInProgressPreferencePage; /** * Preference constants used in the JDT-UI preference store. Clients should only read the * JDT-UI preference store using these values. Clients are not allowed to modify the * preference store programmatically. * * @since 2.0 */ public class PreferenceConstants { private PreferenceConstants() { } /** * A named preference that controls return type rendering of methods in the UI. * <p> * Value is of type <code>Boolean</code>: if <code>true</code> return types * are rendered * </p> */ public static final String APPEARANCE_METHOD_RETURNTYPE= "org.eclipse.jdt.ui.methodreturntype";//$NON-NLS-1$ /** * A named preference that controls if override indicators are rendered in the UI. * <p> * Value is of type <code>Boolean</code>: if <code>true</code> override * indicators are rendered * </p> */ public static final String APPEARANCE_OVERRIDE_INDICATOR= "org.eclipse.jdt.ui.overrideindicator";//$NON-NLS-1$ /** * A named preference that controls if quick assist light bulbs are shown. * <p> * Value is of type <code>Boolean</code>: if <code>true</code> light bulbs are shown * for quick assists. * </p> */ public static final String APPEARANCE_QUICKASSIST_LIGHTBULB="org.eclipse.jdt.quickassist.lightbulb"; //$NON-NLS-1$ /** * A named preference that defines the pattern used for package name compression. * <p> * Value is of type <code>String</code>. For example foe the given package name 'org.eclipse.jdt' pattern * '.' will compress it to '..jdt', '1~' to 'o~.e~.jdt'. * </p> */ public static final String APPEARANCE_PKG_NAME_PATTERN_FOR_PKG_VIEW= "PackagesView.pkgNamePatternForPackagesView";//$NON-NLS-1$ /** * A named preference that controls if package name compression is turned on or off. * <p> * Value is of type <code>Boolean</code>. * </p> * * @see #APPEARANCE_PKG_NAME_PATTERN_FOR_PKG_VIEW */ public static final String APPEARANCE_COMPRESS_PACKAGE_NAMES= "org.eclipse.jdt.ui.compresspackagenames";//$NON-NLS-1$ /** * A named preference that controls if empty inner packages are folded in * the hierarchical mode of the package explorer. * <p> * Value is of type <code>Boolean</code>: if <code>true</code> empty * inner packages are folded. * </p> * @since 2.1 */ public static final String APPEARANCE_FOLD_PACKAGES_IN_PACKAGE_EXPLORER= "org.eclipse.jdt.ui.flatPackagesInPackageExplorer";//$NON-NLS-1$ /** * A named preference that defines how member elements are ordered by the * Java views using the <code>JavaElementSorter</code>. * <p> * Value is of type <code>String</code>: A comma separated list of the * following entries. Each entry must be in the list, no duplication. List * order defines the sort order. * <ul> * <li><b>T</b>: Types</li> * <li><b>C</b>: Constructors</li> * <li><b>I</b>: Initializers</li> * <li><b>M</b>: Methods</li> * <li><b>F</b>: Fields</li> * <li><b>SI</b>: Static Initializers</li> * <li><b>SM</b>: Static Methods</li> * <li><b>SF</b>: Static Fields</li> * </ul> * </p> * @since 2.1 */ public static final String APPEARANCE_MEMBER_SORT_ORDER= "outlinesortoption"; //$NON-NLS-1$ /** * A named preference that controls if prefix removal during setter/getter generation is turned on or off. * <p> * Value is of type <code>Boolean</code>. * </p> * @deprecated Use JavaCore preference store (key JavaCore. * CODEASSIST_FIELD_PREFIXES and CODEASSIST_STATIC_FIELD_PREFIXES) */ public static final String CODEGEN_USE_GETTERSETTER_PREFIX= "org.eclipse.jdt.ui.gettersetter.prefix.enable";//$NON-NLS-1$ /** * A named preference that holds a list of prefixes to be removed from a local variable to compute setter * and gettter names. * <p> * Value is of type <code>String</code>: comma separated list of prefixed * </p> * * @deprecated Use JavaCore preference store (key JavaCore. * CODEASSIST_FIELD_PREFIXES and CODEASSIST_STATIC_FIELD_PREFIXES) */ public static final String CODEGEN_GETTERSETTER_PREFIX= "org.eclipse.jdt.ui.gettersetter.prefix.list";//$NON-NLS-1$ /** * A named preference that controls if suffix removal during setter/getter generation is turned on or off. * <p> * Value is of type <code>Boolean</code>. * </p> * @deprecated Use JavaCore preference store (key JavaCore. * CODEASSIST_FIELD_PREFIXES and CODEASSIST_STATIC_FIELD_PREFIXES) */ public static final String CODEGEN_USE_GETTERSETTER_SUFFIX= "org.eclipse.jdt.ui.gettersetter.suffix.enable";//$NON-NLS-1$ /** * A named preference that holds a list of suffixes to be removed from a local variable to compute setter * and getter names. * <p> * Value is of type <code>String</code>: comma separated list of suffixes * </p> * @deprecated Use setting from JavaCore preference store (key JavaCore. * CODEASSIST_FIELD_SUFFIXES and CODEASSIST_STATIC_FIELD_SUFFIXES) */ public static final String CODEGEN_GETTERSETTER_SUFFIX= "org.eclipse.jdt.ui.gettersetter.suffix.list"; //$NON-NLS-1$ /** * A named preference that controls whether the keyword "this" will be added * automatically to field accesses in autogenerated methods. * <p> * Value is of type <code>Boolean</code>. * </p> * @since 3.0 */ public static final String CODEGEN_KEYWORD_THIS= "org.eclipse.jdt.ui.keywordthis"; //$NON-NLS-1$ /** * A named preference that controls whether to use the prefix "is" or the prefix "get" for * automatically created getters which return a boolean field. * <p> * Value is of type <code>Boolean</code>. * </p> * @since 3.0 */ public static final String CODEGEN_IS_FOR_GETTERS= "org.eclipse.jdt.ui.gettersetter.use.is"; //$NON-NLS-1$ /** * A named preference that controls if comment stubs will be added * automatically to newly created types and methods. * <p> * Value is of type <code>Boolean</code>. * </p> * @since 2.1 */ public static final String CODEGEN_ADD_COMMENTS= "org.eclipse.jdt.ui.javadoc"; //$NON-NLS-1$ /** * A named preference that controls if a comment stubs will be added * automatocally to newly created types and methods. * <p> * Value is of type <code>Boolean</code>. * </p> * @deprecated Use CODEGEN_ADD_COMMENTS instead (Name is more precice). */ public static final String CODEGEN__JAVADOC_STUBS= CODEGEN_ADD_COMMENTS; /** * A named preference that controls if a non-javadoc comment gets added to methods generated via the * "Override Methods" operation. * <p> * Value is of type <code>Boolean</code>. * </p> * @deprecated New code template story: user can * specify the overriding method comment. */ public static final String CODEGEN__NON_JAVADOC_COMMENTS= "org.eclipse.jdt.ui.seecomments"; //$NON-NLS-1$ /** * A named preference that controls if a file comment gets added to newly created files. * <p> * Value is of type <code>Boolean</code>. * </p> * @deprecated New code template story: user can * specify the new type code template. */ public static final String CODEGEN__FILE_COMMENTS= "org.eclipse.jdt.ui.filecomments"; //$NON-NLS-1$ /** * A named preference that holds a list of comma separated package names. The list specifies the import order used by * the "Organize Imports" opeation. * <p> * Value is of type <code>String</code>: semicolon separated list of package * names * </p> */ public static final String ORGIMPORTS_IMPORTORDER= "org.eclipse.jdt.ui.importorder"; //$NON-NLS-1$ /** * A named preference that specifies the number of imports added before a star-import declaration is used. * <p> * Value is of type <code>Int</code>: positive value specifing the number of non star-import is used * </p> */ public static final String ORGIMPORTS_ONDEMANDTHRESHOLD= "org.eclipse.jdt.ui.ondemandthreshold"; //$NON-NLS-1$ /** * A named preferences that controls if types that start with a lower case letters get added by the * "Organize Import" operation. * <p> * Value is of type <code>Boolean</code>. * </p> */ public static final String ORGIMPORTS_IGNORELOWERCASE= "org.eclipse.jdt.ui.ignorelowercasenames"; //$NON-NLS-1$ /** * A named preference that speficies whether children of a compilation unit are shown in the package explorer. * <p> * Value is of type <code>Boolean</code>. * </p> */ public static final String SHOW_CU_CHILDREN= "org.eclipse.jdt.ui.packages.cuchildren"; //$NON-NLS-1$ /** * A named preference that controls whether the package explorer's selection is linked to the active editor. * <p> * Value is of type <code>Boolean</code>. * </p> */ public static final String LINK_PACKAGES_TO_EDITOR= "org.eclipse.jdt.ui.packages.linktoeditor"; //$NON-NLS-1$ /** * A named preference that controls whether the hierarchy view's selection is linked to the active editor. * <p> * Value is of type <code>Boolean</code>. * </p> */ public static final String LINK_TYPEHIERARCHY_TO_EDITOR= "org.eclipse.jdt.ui.packages.linktypehierarchytoeditor"; //$NON-NLS-1$ /** * A named preference that controls whether the projects view's selection is * linked to the active editor. * <p> * Value is of type <code>Boolean</code>. * </p> * @since 2.1 */ public static final String LINK_BROWSING_PROJECTS_TO_EDITOR= "org.eclipse.jdt.ui.browsing.projectstoeditor"; //$NON-NLS-1$ /** * A named preference that controls whether the packages view's selection is * linked to the active editor. * <p> * Value is of type <code>Boolean</code>. * </p> * @since 2.1 */ public static final String LINK_BROWSING_PACKAGES_TO_EDITOR= "org.eclipse.jdt.ui.browsing.packagestoeditor"; //$NON-NLS-1$ /** * A named preference that controls whether the types view's selection is * linked to the active editor. * <p> * Value is of type <code>Boolean</code>. * </p> * @since 2.1 */ public static final String LINK_BROWSING_TYPES_TO_EDITOR= "org.eclipse.jdt.ui.browsing.typestoeditor"; //$NON-NLS-1$ /** * A named preference that controls whether the members view's selection is * linked to the active editor. * <p> * Value is of type <code>Boolean</code>. * </p> * @since 2.1 */ public static final String LINK_BROWSING_MEMBERS_TO_EDITOR= "org.eclipse.jdt.ui.browsing.memberstoeditor"; //$NON-NLS-1$ /** * A named preference that controls whether new projects are generated using source and output folder. * <p> * Value is of type <code>Boolean</code>. if <code>true</code> new projects are created with a source and * output folder. If <code>false</code> source and output folder equals to the project. * </p> */ public static final String SRCBIN_FOLDERS_IN_NEWPROJ= "org.eclipse.jdt.ui.wizards.srcBinFoldersInNewProjects"; //$NON-NLS-1$ /** * A named preference that specifies the source folder name used when creating a new Java project. Value is inactive * if <code>SRCBIN_FOLDERS_IN_NEWPROJ</code> is set to <code>false</code>. * <p> * Value is of type <code>String</code>. * </p> * * @see #SRCBIN_FOLDERS_IN_NEWPROJ */ public static final String SRCBIN_SRCNAME= "org.eclipse.jdt.ui.wizards.srcBinFoldersSrcName"; //$NON-NLS-1$ /** * A named preference that specifies the output folder name used when creating a new Java project. Value is inactive * if <code>SRCBIN_FOLDERS_IN_NEWPROJ</code> is set to <code>false</code>. * <p> * Value is of type <code>String</code>. * </p> * * @see #SRCBIN_FOLDERS_IN_NEWPROJ */ public static final String SRCBIN_BINNAME= "org.eclipse.jdt.ui.wizards.srcBinFoldersBinName"; //$NON-NLS-1$ /** * A named preference that holds a list of possible JRE libraries used by the New Java Project wizard. An library * consists of a description and an arbitrary number of <code>IClasspathEntry</code>s, that will represent the * JRE on the new project's classpath. * <p> * Value is of type <code>String</code>: a semicolon separated list of encoded JRE libraries. * <code>NEWPROJECT_JRELIBRARY_INDEX</code> defines the currently used library. Clients * should use the method <code>encodeJRELibrary</code> to encode a JRE library into a string * and the methods <code>decodeJRELibraryDescription(String)</code> and <code> * decodeJRELibraryClasspathEntries(String)</code> to decode the description and the array * of classpath entries from an encoded string. * </p> * * @see #NEWPROJECT_JRELIBRARY_INDEX * @see #encodeJRELibrary(String, IClasspathEntry[]) * @see #decodeJRELibraryDescription(String) * @see #decodeJRELibraryClasspathEntries(String) */ public static final String NEWPROJECT_JRELIBRARY_LIST= "org.eclipse.jdt.ui.wizards.jre.list"; //$NON-NLS-1$ /** * A named preferences that specifies the current active JRE library. * <p> * Value is of type <code>Int</code>: an index into the list of possible JRE libraries. * </p> * * @see #NEWPROJECT_JRELIBRARY_LIST */ public static final String NEWPROJECT_JRELIBRARY_INDEX= "org.eclipse.jdt.ui.wizards.jre.index"; //$NON-NLS-1$ /** * A named preference that controls if a new type hierarchy gets opened in a * new type hierarchy perspective or inside the type hierarchy view part. * <p> * Value is of type <code>String</code>: possible values are <code> * OPEN_TYPE_HIERARCHY_IN_PERSPECTIVE</code> or <code> * OPEN_TYPE_HIERARCHY_IN_VIEW_PART</code>. * </p> * * @see #OPEN_TYPE_HIERARCHY_IN_PERSPECTIVE * @see #OPEN_TYPE_HIERARCHY_IN_VIEW_PART */ public static final String OPEN_TYPE_HIERARCHY= "org.eclipse.jdt.ui.openTypeHierarchy"; //$NON-NLS-1$ /** * A string value used by the named preference <code>OPEN_TYPE_HIERARCHY</code>. * * @see #OPEN_TYPE_HIERARCHY */ public static final String OPEN_TYPE_HIERARCHY_IN_PERSPECTIVE= "perspective"; //$NON-NLS-1$ /** * A string value used by the named preference <code>OPEN_TYPE_HIERARCHY</code>. * * @see #OPEN_TYPE_HIERARCHY */ public static final String OPEN_TYPE_HIERARCHY_IN_VIEW_PART= "viewPart"; //$NON-NLS-1$ /** * A named preference that controls the behaviour when double clicking on a container in the packages view. * <p> * Value is of type <code>String</code>: possible values are <code> * DOUBLE_CLICK_GOES_INTO</code> or <code> * DOUBLE_CLICK_EXPANDS</code>. * </p> * * @see #DOUBLE_CLICK_EXPANDS * @see #DOUBLE_CLICK_GOES_INTO */ public static final String DOUBLE_CLICK= "packageview.doubleclick"; //$NON-NLS-1$ /** * A string value used by the named preference <code>DOUBLE_CLICK</code>. * * @see #DOUBLE_CLICK */ public static final String DOUBLE_CLICK_GOES_INTO= "packageview.gointo"; //$NON-NLS-1$ /** * A string value used by the named preference <code>DOUBLE_CLICK</code>. * * @see #DOUBLE_CLICK */ public static final String DOUBLE_CLICK_EXPANDS= "packageview.doubleclick.expands"; //$NON-NLS-1$ /** * A named preference that controls whether Java views update their presentation while editing or when saving the * content of an editor. * <p> * Value is of type <code>String</code>: possible values are <code> * UPDATE_ON_SAVE</code> or <code> * UPDATE_WHILE_EDITING</code>. * </p> * * @see #UPDATE_ON_SAVE * @see #UPDATE_WHILE_EDITING */ public static final String UPDATE_JAVA_VIEWS= "JavaUI.update"; //$NON-NLS-1$ /** * A string value used by the named preference <code>UPDATE_JAVA_VIEWS</code> * * @see #UPDATE_JAVA_VIEWS */ public static final String UPDATE_ON_SAVE= "JavaUI.update.onSave"; //$NON-NLS-1$ /** * A string value used by the named preference <code>UPDATE_JAVA_VIEWS</code> * * @see #UPDATE_JAVA_VIEWS */ public static final String UPDATE_WHILE_EDITING= "JavaUI.update.whileEditing"; //$NON-NLS-1$ /** * A named preference that holds the path of the Javadoc command used by the Javadoc creation wizard. * <p> * Value is of type <code>String</code>. * </p> */ public static final String JAVADOC_COMMAND= "command"; //$NON-NLS-1$ /** * A named preference that defines whether hint to make hover sticky should be shown. * * @see JavaUI * @since 3.0 */ public static String EDITOR_SHOW_TEXT_HOVER_AFFORDANCE= "PreferenceConstants.EDITOR_SHOW_TEXT_HOVER_AFFORDANCE"; //$NON-NLS-1$ /** * A named preference that defines the key for the hover modifiers. * * @see JavaUI * @since 2.1 */ public static final String EDITOR_TEXT_HOVER_MODIFIERS= "hoverModifiers"; //$NON-NLS-1$ /** * A named preference that defines the key for the hover modifier state masks. * The value is only used if the value of <code>EDITOR_TEXT_HOVER_MODIFIERS</code> * cannot be resolved to valid SWT modifier bits. * * @see JavaUI * @see #EDITOR_TEXT_HOVER_MODIFIERS * @since 2.1.1 */ public static final String EDITOR_TEXT_HOVER_MODIFIER_MASKS= "hoverModifierMasks"; //$NON-NLS-1$ /** * The id of the best match hover contributed for extension point * <code>javaEditorTextHovers</code>. * * @since 2.1 */ public static String ID_BESTMATCH_HOVER= "org.eclipse.jdt.ui.BestMatchHover"; //$NON-NLS-1$ /** * The id of the source code hover contributed for extension point * <code>javaEditorTextHovers</code>. * * @since 2.1 */ public static String ID_SOURCE_HOVER= "org.eclipse.jdt.ui.JavaSourceHover"; //$NON-NLS-1$ /** * The id of the javadoc hover contributed for extension point * <code>javaEditorTextHovers</code>. * * @since 2.1 */ public static String ID_JAVADOC_HOVER= "org.eclipse.jdt.ui.JavadocHover"; //$NON-NLS-1$ /** * The id of the problem hover contributed for extension point * <code>javaEditorTextHovers</code>. * * @since 2.1 */ public static String ID_PROBLEM_HOVER= "org.eclipse.jdt.ui.ProblemHover"; //$NON-NLS-1$ /** * A named preference that controls whether bracket matching highlighting is turned on or off. * <p> * Value is of type <code>Boolean</code>. * </p> */ public final static String EDITOR_MATCHING_BRACKETS= "matchingBrackets"; //$NON-NLS-1$ /** * A named preference that holds the color used to highlight matching brackets. * <p> * Value is of type <code>String</code>. A RGB color value encoded as a string * using class <code>PreferenceConverter</code> * </p> * * @see org.eclipse.jface.resource.StringConverter * @see org.eclipse.jface.preference.PreferenceConverter */ public final static String EDITOR_MATCHING_BRACKETS_COLOR= "matchingBracketsColor"; //$NON-NLS-1$ /** * A named preference that controls whether the current line highlighting is turned on or off. * <p> * Value is of type <code>Boolean</code>. * </p> * @deprecated as of 3.0 replaced by {@link org.eclipse.ui.texteditor.ExtendedTextEditorPreferenceConstants} */ public final static String EDITOR_CURRENT_LINE= "currentLine"; //$NON-NLS-1$ /** * A named preference that holds the color used to highlight the current line. * <p> * Value is of type <code>String</code>. A RGB color value encoded as a string * using class <code>PreferenceConverter</code> * </p> * * @see org.eclipse.jface.resource.StringConverter * @see org.eclipse.jface.preference.PreferenceConverter * @deprecated as of 3.0 replaced by {@link org.eclipse.ui.texteditor.ExtendedTextEditorPreferenceConstants} */ public final static String EDITOR_CURRENT_LINE_COLOR= "currentLineColor"; //$NON-NLS-1$ /** * A named preference that controls whether the print margin is turned on or off. * <p> * Value is of type <code>Boolean</code>. * </p> * @deprecated as of 3.0 replaced by {@link org.eclipse.ui.texteditor.ExtendedTextEditorPreferenceConstants} */ public final static String EDITOR_PRINT_MARGIN= "printMargin"; //$NON-NLS-1$ /** * A named preference that holds the color used to render the print margin. * <p> * Value is of type <code>String</code>. A RGB color value encoded as a string * using class <code>PreferenceConverter</code> * </p> * * @see org.eclipse.jface.resource.StringConverter * @see org.eclipse.jface.preference.PreferenceConverter * @deprecated as of 3.0 replaced by {@link org.eclipse.ui.texteditor.ExtendedTextEditorPreferenceConstants} */ public final static String EDITOR_PRINT_MARGIN_COLOR= "printMarginColor"; //$NON-NLS-1$ /** * Print margin column. Int value. * @deprecated as of 3.0 replaced by {@link org.eclipse.ui.texteditor.ExtendedTextEditorPreferenceConstants} */ public final static String EDITOR_PRINT_MARGIN_COLUMN= "printMarginColumn"; //$NON-NLS-1$ /** * A named preference that holds the color used for the find/replace scope. * <p> * Value is of type <code>String</code>. A RGB color value encoded as a string * using class <code>PreferenceConverter</code> * </p> * * @see org.eclipse.jface.resource.StringConverter * @see org.eclipse.jface.preference.PreferenceConverter */ public final static String EDITOR_FIND_SCOPE_COLOR= AbstractTextEditor.PREFERENCE_COLOR_FIND_SCOPE; /** * A named preference that specifies if the editor uses spaces for tabs. * <p> * Value is of type <code>Boolean</code>. If <code>true</code>spaces instead of tabs are used * in the editor. If <code>false</code> the editor inserts a tab character when pressing the tab * key. * </p> */ public final static String EDITOR_SPACES_FOR_TABS= "spacesForTabs"; //$NON-NLS-1$ /** * A named preference that holds the number of spaces used per tab in the editor. * <p> * Value is of type <code>Int</code>: positive int value specifying the number of * spaces per tab. * </p> */ public final static String EDITOR_TAB_WIDTH= "org.eclipse.jdt.ui.editor.tab.width"; //$NON-NLS-1$ /** * A named preference that controls whether the outline view selection * should stay in sync with with the element at the current cursor position. * <p> * Value is of type <code>Boolean</code>. * </p> * @since 2.1 */ public final static String EDITOR_SYNC_OUTLINE_ON_CURSOR_MOVE= "JavaEditor.SyncOutlineOnCursorMove"; //$NON-NLS-1$ /** * A named preference that controls if correction indicators are shown in the UI. * <p> * Value is of type <code>Boolean</code>. * </p> */ public final static String EDITOR_CORRECTION_INDICATION= "JavaEditor.ShowTemporaryProblem"; //$NON-NLS-1$ /** * A named preference that controls whether the editor shows problem indicators in text (squiggly lines). * <p> * Value is of type <code>Boolean</code>. * </p> * * @deprecated as of 3.0 replaced by {@link org.eclipse.ui.texteditor.MarkerAnnotationPreferences} */ public final static String EDITOR_PROBLEM_INDICATION= "problemIndication"; //$NON-NLS-1$ /** * A named preference that holds the color used to render problem indicators. * <p> * Value is of type <code>String</code>. A RGB color value encoded as a string * using class <code>PreferenceConverter</code> * </p> * * @see #EDITOR_PROBLEM_INDICATION * @see org.eclipse.jface.resource.StringConverter * @see org.eclipse.jface.preference.PreferenceConverter * @deprecated as of 3.0 replaced by {@link org.eclipse.ui.texteditor.MarkerAnnotationPreferences} */ public final static String EDITOR_PROBLEM_INDICATION_COLOR= "problemIndicationColor"; //$NON-NLS-1$ /** * A named preference that controls whether the editor shows warning indicators in text (squiggly lines). * <p> * Value is of type <code>Boolean</code>. * </p> * @since 2.1 * @deprecated as of 3.0 replaced by {@link org.eclipse.ui.texteditor.MarkerAnnotationPreferences} */ public final static String EDITOR_WARNING_INDICATION= "warningIndication"; //$NON-NLS-1$ /** * A named preference that holds the color used to render warning indicators. * <p> * Value is of type <code>String</code>. A RGB color value encoded as a string * using class <code>PreferenceConverter</code> * </p> * * @see #EDITOR_WARNING_INDICATION * @see org.eclipse.jface.resource.StringConverter * @see org.eclipse.jface.preference.PreferenceConverter * @since 2.1 * @deprecated as of 3.0 replaced by {@link org.eclipse.ui.texteditor.MarkerAnnotationPreferences} */ public final static String EDITOR_WARNING_INDICATION_COLOR= "warningIndicationColor"; //$NON-NLS-1$ /** * A named preference that controls whether the editor shows task indicators in text (squiggly lines). * <p> * Value is of type <code>Boolean</code>. * </p> * @since 2.1 * @deprecated as of 3.0 replaced by {@link org.eclipse.ui.texteditor.MarkerAnnotationPreferences} */ public final static String EDITOR_TASK_INDICATION= "taskIndication"; //$NON-NLS-1$ /** * A named preference that holds the color used to render task indicators. * <p> * Value is of type <code>String</code>. A RGB color value encoded as a string * using class <code>PreferenceConverter</code> * </p> * * @see #EDITOR_TASK_INDICATION * @see org.eclipse.jface.resource.StringConverter * @see org.eclipse.jface.preference.PreferenceConverter * @since 2.1 * @deprecated as of 3.0 replaced by {@link org.eclipse.ui.texteditor.MarkerAnnotationPreferences} */ public final static String EDITOR_TASK_INDICATION_COLOR= "taskIndicationColor"; //$NON-NLS-1$ /** * A named preference that controls whether the editor shows bookmark * indicators in text (squiggly lines). * <p> * Value is of type <code>Boolean</code>. * </p> * @since 2.1 * @deprecated as of 3.0 replaced by {@link org.eclipse.ui.texteditor.MarkerAnnotationPreferences} */ public final static String EDITOR_BOOKMARK_INDICATION= "bookmarkIndication"; //$NON-NLS-1$ /** * A named preference that holds the color used to render bookmark indicators. * <p> * Value is of type <code>String</code>. A RGB color value encoded as a string * using class <code>PreferenceConverter</code> * </p> * * @see #EDITOR_BOOKMARK_INDICATION * @see org.eclipse.jface.resource.StringConverter * @see org.eclipse.jface.preference.PreferenceConverter * @since 2.1 * @deprecated as of 3.0 replaced by {@link org.eclipse.ui.texteditor.MarkerAnnotationPreferences} */ public final static String EDITOR_BOOKMARK_INDICATION_COLOR= "bookmarkIndicationColor"; //$NON-NLS-1$ /** * A named preference that controls whether the editor shows search * indicators in text (squiggly lines). * <p> * Value is of type <code>Boolean</code>. * </p> * @since 2.1 * @deprecated as of 3.0 replaced by {@link org.eclipse.ui.texteditor.MarkerAnnotationPreferences} */ public final static String EDITOR_SEARCH_RESULT_INDICATION= "searchResultIndication"; //$NON-NLS-1$ /** * A named preference that holds the color used to render search indicators. * <p> * Value is of type <code>String</code>. A RGB color value encoded as a string * using class <code>PreferenceConverter</code> * </p> * * @see #EDITOR_SEARCH_RESULT_INDICATION * @see org.eclipse.jface.resource.StringConverter * @see org.eclipse.jface.preference.PreferenceConverter * @since 2.1 * @deprecated as of 3.0 replaced by {@link org.eclipse.ui.texteditor.MarkerAnnotationPreferences} */ public final static String EDITOR_SEARCH_RESULT_INDICATION_COLOR= "searchResultIndicationColor"; //$NON-NLS-1$ /** * A named preference that controls whether the editor shows unknown * indicators in text (squiggly lines). * <p> * Value is of type <code>Boolean</code>. * </p> * @since 2.1 * @deprecated as of 3.0 replaced by {@link org.eclipse.ui.texteditor.MarkerAnnotationPreferences} */ public final static String EDITOR_UNKNOWN_INDICATION= "othersIndication"; //$NON-NLS-1$ /** * A named preference that holds the color used to render unknown * indicators. * <p> * Value is of type <code>String</code>. A RGB color value encoded as a string * using class <code>PreferenceConverter</code> * </p> * * @see #EDITOR_UNKNOWN_INDICATION * @see org.eclipse.jface.resource.StringConverter * @see org.eclipse.jface.preference.PreferenceConverter * @since 2.1 * @deprecated * @deprecated as of 3.0 replaced by {@link org.eclipse.ui.texteditor.MarkerAnnotationPreferences} */ public final static String EDITOR_UNKNOWN_INDICATION_COLOR= "othersIndicationColor"; //$NON-NLS-1$ /** * A named preference that controls whether the overview ruler shows error * indicators. * <p> * Value is of type <code>Boolean</code>. * </p> * @since 2.1 * @deprecated as of 3.0 replaced by {@link org.eclipse.ui.texteditor.MarkerAnnotationPreferences} */ public final static String EDITOR_ERROR_INDICATION_IN_OVERVIEW_RULER= "errorIndicationInOverviewRuler"; //$NON-NLS-1$ /** * A named preference that controls whether the overview ruler shows warning * indicators. * <p> * Value is of type <code>Boolean</code>. * </p> * @since 2.1 * @deprecated as of 3.0 replaced by {@link org.eclipse.ui.texteditor.MarkerAnnotationPreferences} */ public final static String EDITOR_WARNING_INDICATION_IN_OVERVIEW_RULER= "warningIndicationInOverviewRuler"; //$NON-NLS-1$ /** * A named preference that controls whether the overview ruler shows task * indicators. * <p> * Value is of type <code>Boolean</code>. * </p> * @since 2.1 * @deprecated as of 3.0 replaced by {@link org.eclipse.ui.texteditor.MarkerAnnotationPreferences} */ public final static String EDITOR_TASK_INDICATION_IN_OVERVIEW_RULER= "taskIndicationInOverviewRuler"; //$NON-NLS-1$ /** * A named preference that controls whether the overview ruler shows * bookmark indicators. * <p> * Value is of type <code>Boolean</code>. * </p> * @since 2.1 * @deprecated as of 3.0 replaced by {@link org.eclipse.ui.texteditor.MarkerAnnotationPreferences} */ public final static String EDITOR_BOOKMARK_INDICATION_IN_OVERVIEW_RULER= "bookmarkIndicationInOverviewRuler"; //$NON-NLS-1$ /** * A named preference that controls whether the overview ruler shows * search result indicators. * <p> * Value is of type <code>Boolean</code>. * </p> * @since 2.1 * @deprecated as of 3.0 replaced by {@link org.eclipse.ui.texteditor.MarkerAnnotationPreferences} */ public final static String EDITOR_SEARCH_RESULT_INDICATION_IN_OVERVIEW_RULER= "searchResultIndicationInOverviewRuler"; //$NON-NLS-1$ /** * A named preference that controls whether the overview ruler shows * unknown indicators. * <p> * Value is of type <code>Boolean</code>. * </p> * @since 2.1 * @deprecated as of 3.0 replaced by {@link org.eclipse.ui.texteditor.MarkerAnnotationPreferences} */ public final static String EDITOR_UNKNOWN_INDICATION_IN_OVERVIEW_RULER= "othersIndicationInOverviewRuler"; //$NON-NLS-1$ /** * A named preference that controls whether the 'close strings' feature * is enabled. * <p> * Value is of type <code>Boolean</code>. * </p> * @since 2.1 */ public final static String EDITOR_CLOSE_STRINGS= "closeStrings"; //$NON-NLS-1$ /** * A named preference that controls whether the 'wrap strings' feature is * enabled. * <p> * Value is of type <code>Boolean</code>. * </p> * @since 2.1 */ public final static String EDITOR_WRAP_STRINGS= "wrapStrings"; //$NON-NLS-1$ /** * A named preference that controls whether the 'close brackets' feature is * enabled. * <p> * Value is of type <code>Boolean</code>. * </p> * @since 2.1 */ public final static String EDITOR_CLOSE_BRACKETS= "closeBrackets"; //$NON-NLS-1$ /** * A named preference that controls whether the 'close braces' feature is * enabled. * <p> * Value is of type <code>Boolean</code>. * </p> * @since 2.1 */ public final static String EDITOR_CLOSE_BRACES= "closeBraces"; //$NON-NLS-1$ /** * A named preference that controls whether the 'close java docs' feature is * enabled. * <p> * Value is of type <code>Boolean</code>. * </p> * @since 2.1 */ public final static String EDITOR_CLOSE_JAVADOCS= "closeJavaDocs"; //$NON-NLS-1$ /** * A named preference that controls whether the 'add JavaDoc tags' feature * is enabled. * <p> * Value is of type <code>Boolean</code>. * </p> * @since 2.1 */ public final static String EDITOR_ADD_JAVADOC_TAGS= "addJavaDocTags"; //$NON-NLS-1$ /** * A named preference that controls whether the 'format Javadoc tags' * feature is enabled. * <p> * Value is of type <code>Boolean</code>. * </p> * @since 2.1 */ public final static String EDITOR_FORMAT_JAVADOCS= "autoFormatJavaDocs"; //$NON-NLS-1$ /** * A named preference that controls whether the 'smart paste' feature is * enabled. * <p> * Value is of type <code>Boolean</code>. * </p> * @since 2.1 */ public final static String EDITOR_SMART_PASTE= "smartPaste"; //$NON-NLS-1$ /** * A named preference that controls whether the 'smart home-end' feature is * enabled. * <p> * Value is of type <code>Boolean</code>. * </p> * @since 2.1 */ public final static String EDITOR_SMART_HOME_END= AbstractTextEditor.PREFERENCE_NAVIGATION_SMART_HOME_END; /** * A named preference that controls whether the 'sub-word navigation' feature is * enabled. * <p> * Value is of type <code>Boolean</code>. * </p> * @since 2.1 */ public final static String EDITOR_SUB_WORD_NAVIGATION= "subWordNavigation"; //$NON-NLS-1$ /** * A named preference that controls if temporary problems are evaluated and shown in the UI. * <p> * Value is of type <code>Boolean</code>. * </p> */ public final static String EDITOR_EVALUTE_TEMPORARY_PROBLEMS= "handleTemporaryProblems"; //$NON-NLS-1$ /** * A named preference that controls if the overview ruler is shown in the UI. * <p> * Value is of type <code>Boolean</code>. * </p> * @deprecated as of 3.0 replaced by {@link org.eclipse.ui.texteditor.ExtendedTextEditorPreferenceConstants} */ public final static String EDITOR_OVERVIEW_RULER= "overviewRuler"; //$NON-NLS-1$ /** * A named preference that controls if the line number ruler is shown in the UI. * <p> * Value is of type <code>Boolean</code>. * </p> * @deprecated as of 3.0 replaced by {@link org.eclipse.ui.texteditor.ExtendedTextEditorPreferenceConstants} */ public final static String EDITOR_LINE_NUMBER_RULER= "lineNumberRuler"; //$NON-NLS-1$ /** * A named preference that holds the color used to render line numbers inside the line number ruler. * <p> * Value is of type <code>String</code>. A RGB color value encoded as a string * using class <code>PreferenceConverter</code> * </p> * * @see org.eclipse.jface.resource.StringConverter * @see org.eclipse.jface.preference.PreferenceConverter * @see #EDITOR_LINE_NUMBER_RULER * @deprecated as of 3.0 replaced by {@link org.eclipse.ui.texteditor.ExtendedTextEditorPreferenceConstants} */ public final static String EDITOR_LINE_NUMBER_RULER_COLOR= "lineNumberColor"; //$NON-NLS-1$ /** * A named preference that holds the color used to render linked positions inside code templates. * <p> * Value is of type <code>String</code>. A RGB color value encoded as a string * using class <code>PreferenceConverter</code> * </p> * * @see org.eclipse.jface.resource.StringConverter * @see org.eclipse.jface.preference.PreferenceConverter */ public final static String EDITOR_LINKED_POSITION_COLOR= "linkedPositionColor"; //$NON-NLS-1$ /** * A named preference that holds the color used as the text foreground. * This value has not effect if the system default color is used. * <p> * Value is of type <code>String</code>. A RGB color value encoded as a string * using class <code>PreferenceConverter</code> * </p> * * @see org.eclipse.jface.resource.StringConverter * @see org.eclipse.jface.preference.PreferenceConverter */ public final static String EDITOR_FOREGROUND_COLOR= AbstractTextEditor.PREFERENCE_COLOR_FOREGROUND; /** * A named preference that describes if the system default foreground color * is used as the text foreground. * <p> * Value is of type <code>Boolean</code>. * </p> */ public final static String EDITOR_FOREGROUND_DEFAULT_COLOR= AbstractTextEditor.PREFERENCE_COLOR_FOREGROUND_SYSTEM_DEFAULT; /** * A named preference that holds the color used as the text background. * This value has not effect if the system default color is used. * <p> * Value is of type <code>String</code>. A RGB color value encoded as a string * using class <code>PreferenceConverter</code> * </p> * * @see org.eclipse.jface.resource.StringConverter * @see org.eclipse.jface.preference.PreferenceConverter */ public final static String EDITOR_BACKGROUND_COLOR= AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND; /** * A named preference that describes if the system default background color * is used as the text background. * <p> * Value is of type <code>Boolean</code>. * </p> */ public final static String EDITOR_BACKGROUND_DEFAULT_COLOR= AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND_SYSTEM_DEFAULT; /** * Preference key suffix for bold text style preference keys. * * @since 2.1 */ public static final String EDITOR_BOLD_SUFFIX= "_bold"; //$NON-NLS-1$ /** * A named preference that holds the color used to render multi line comments. * <p> * Value is of type <code>String</code>. A RGB color value encoded as a string * using class <code>PreferenceConverter</code> * </p> * * @see org.eclipse.jface.resource.StringConverter * @see org.eclipse.jface.preference.PreferenceConverter */ public final static String EDITOR_MULTI_LINE_COMMENT_COLOR= IJavaColorConstants.JAVA_MULTI_LINE_COMMENT; /** * The symbolic font name for the Java editor text font * (value <code>"org.eclipse.jdt.ui.editors.textfont"</code>). * * @since 2.1 */ public final static String EDITOR_TEXT_FONT= "org.eclipse.jdt.ui.editors.textfont"; //$NON-NLS-1$ /** * A named preference that controls whether multi line comments are rendered in bold. * <p> * Value is of type <code>Boolean</code>. If <code>true</code> multi line comments are rendered * in bold. If <code>false</code> the are rendered using no font style attribute. * </p> */ public final static String EDITOR_MULTI_LINE_COMMENT_BOLD= IJavaColorConstants.JAVA_MULTI_LINE_COMMENT + EDITOR_BOLD_SUFFIX; /** * A named preference that holds the color used to render single line comments. * <p> * Value is of type <code>String</code>. A RGB color value encoded as a string * using class <code>PreferenceConverter</code> * </p> * * @see org.eclipse.jface.resource.StringConverter * @see org.eclipse.jface.preference.PreferenceConverter */ public final static String EDITOR_SINGLE_LINE_COMMENT_COLOR= IJavaColorConstants.JAVA_SINGLE_LINE_COMMENT; /** * A named preference that controls whether sinle line comments are rendered in bold. * <p> * Value is of type <code>Boolean</code>. If <code>true</code> single line comments are rendered * in bold. If <code>false</code> the are rendered using no font style attribute. * </p> */ public final static String EDITOR_SINGLE_LINE_COMMENT_BOLD= IJavaColorConstants.JAVA_SINGLE_LINE_COMMENT + EDITOR_BOLD_SUFFIX; /** * A named preference that holds the color used to render java keywords. * <p> * Value is of type <code>String</code>. A RGB color value encoded as a string * using class <code>PreferenceConverter</code> * </p> * * @see org.eclipse.jface.resource.StringConverter * @see org.eclipse.jface.preference.PreferenceConverter */ public final static String EDITOR_JAVA_KEYWORD_COLOR= IJavaColorConstants.JAVA_KEYWORD; /** * A named preference that controls whether keywords are rendered in bold. * <p> * Value is of type <code>Boolean</code>. * </p> */ public final static String EDITOR_JAVA_KEYWORD_BOLD= IJavaColorConstants.JAVA_KEYWORD + EDITOR_BOLD_SUFFIX; /** * A named preference that holds the color used to render string constants. * <p> * Value is of type <code>String</code>. A RGB color value encoded as a string * using class <code>PreferenceConverter</code> * </p> * * @see org.eclipse.jface.resource.StringConverter * @see org.eclipse.jface.preference.PreferenceConverter */ public final static String EDITOR_STRING_COLOR= IJavaColorConstants.JAVA_STRING; /** * A named preference that controls whether string constants are rendered in bold. * <p> * Value is of type <code>Boolean</code>. * </p> */ public final static String EDITOR_STRING_BOLD= IJavaColorConstants.JAVA_STRING + EDITOR_BOLD_SUFFIX; /** * A named preference that holds the color used to render method names. * <p> * Value is of type <code>String</code>. A RGB color value encoded as a string * using class <code>PreferenceConverter</code> * </p> * * @see org.eclipse.jface.resource.StringConverter * @see org.eclipse.jface.preference.PreferenceConverter * @since 3.0 */ public final static String EDITOR_JAVA_METHOD_NAME_COLOR= IJavaColorConstants.JAVA_METHOD_NAME; /** * A named preference that controls whether method names are rendered in bold. * <p> * Value is of type <code>Boolean</code>. * </p> * * @since 3.0 */ public final static String EDITOR_JAVA_METHOD_NAME_BOLD= IJavaColorConstants.JAVA_METHOD_NAME + EDITOR_BOLD_SUFFIX; /** * A named preference that holds the color used to render operators and brackets. * <p> * Value is of type <code>String</code>. A RGB color value encoded as a string * using class <code>PreferenceConverter</code> * </p> * * @see org.eclipse.jface.resource.StringConverter * @see org.eclipse.jface.preference.PreferenceConverter * @since 3.0 */ public final static String EDITOR_JAVA_OPERATOR_COLOR= IJavaColorConstants.JAVA_OPERATOR; /** * A named preference that controls whether operators and brackets are rendered in bold. * <p> * Value is of type <code>Boolean</code>. * </p> * * @since 3.0 */ public final static String EDITOR_JAVA_OPERATOR_BOLD= IJavaColorConstants.JAVA_OPERATOR + EDITOR_BOLD_SUFFIX; /** * A named preference that holds the color used to render java default text. * <p> * Value is of type <code>String</code>. A RGB color value encoded as a string * using class <code>PreferenceConverter</code> * </p> * * @see org.eclipse.jface.resource.StringConverter * @see org.eclipse.jface.preference.PreferenceConverter */ public final static String EDITOR_JAVA_DEFAULT_COLOR= IJavaColorConstants.JAVA_DEFAULT; /** * A named preference that controls whether Java default text is rendered in bold. * <p> * Value is of type <code>Boolean</code>. * </p> */ public final static String EDITOR_JAVA_DEFAULT_BOLD= IJavaColorConstants.JAVA_DEFAULT + EDITOR_BOLD_SUFFIX; /** * A named preference that holds the color used to render task tags. * <p> * Value is of type <code>String</code>. A RGB color value encoded as a string * using class <code>PreferenceConverter</code> * </p> * * @see org.eclipse.jface.resource.StringConverter * @see org.eclipse.jface.preference.PreferenceConverter * @since 2.1 */ public final static String EDITOR_TASK_TAG_COLOR= IJavaColorConstants.TASK_TAG; /** * A named preference that controls whether task tags are rendered in bold. * <p> * Value is of type <code>Boolean</code>. * </p> * @since 2.1 */ public final static String EDITOR_TASK_TAG_BOLD= IJavaColorConstants.TASK_TAG + EDITOR_BOLD_SUFFIX; /** * A named preference that holds the color used to render javadoc keywords. * <p> * Value is of type <code>String</code>. A RGB color value encoded as a string * using class <code>PreferenceConverter</code> * </p> * * @see org.eclipse.jface.resource.StringConverter * @see org.eclipse.jface.preference.PreferenceConverter */ public final static String EDITOR_JAVADOC_KEYWORD_COLOR= IJavaColorConstants.JAVADOC_KEYWORD; /** * A named preference that controls whether javadoc keywords are rendered in bold. * <p> * Value is of type <code>Boolean</code>. * </p> */ public final static String EDITOR_JAVADOC_KEYWORD_BOLD= IJavaColorConstants.JAVADOC_KEYWORD + EDITOR_BOLD_SUFFIX; /** * A named preference that holds the color used to render javadoc tags. * <p> * Value is of type <code>String</code>. A RGB color value encoded as a string * using class <code>PreferenceConverter</code> * </p> * * @see org.eclipse.jface.resource.StringConverter * @see org.eclipse.jface.preference.PreferenceConverter */ public final static String EDITOR_JAVADOC_TAG_COLOR= IJavaColorConstants.JAVADOC_TAG; /** * A named preference that controls whether javadoc tags are rendered in bold. * <p> * Value is of type <code>Boolean</code>. * </p> */ public final static String EDITOR_JAVADOC_TAG_BOLD= IJavaColorConstants.JAVADOC_TAG + EDITOR_BOLD_SUFFIX; /** * A named preference that holds the color used to render javadoc links. * <p> * Value is of type <code>String</code>. A RGB color value encoded as a string * using class <code>PreferenceConverter</code> * </p> * * @see org.eclipse.jface.resource.StringConverter * @see org.eclipse.jface.preference.PreferenceConverter */ public final static String EDITOR_JAVADOC_LINKS_COLOR= IJavaColorConstants.JAVADOC_LINK; /** * A named preference that controls whether javadoc links are rendered in bold. * <p> * Value is of type <code>Boolean</code>. * </p> */ public final static String EDITOR_JAVADOC_LINKS_BOLD= IJavaColorConstants.JAVADOC_LINK + EDITOR_BOLD_SUFFIX; /** * A named preference that holds the color used to render javadoc default text. * <p> * Value is of type <code>String</code>. A RGB color value encoded as a string * using class <code>PreferenceConverter</code> * </p> * * @see org.eclipse.jface.resource.StringConverter * @see org.eclipse.jface.preference.PreferenceConverter */ public final static String EDITOR_JAVADOC_DEFAULT_COLOR= IJavaColorConstants.JAVADOC_DEFAULT; /** * A named preference that controls whether javadoc default text is rendered in bold. * <p> * Value is of type <code>Boolean</code>. * </p> */ public final static String EDITOR_JAVADOC_DEFAULT_BOLD= IJavaColorConstants.JAVADOC_DEFAULT + EDITOR_BOLD_SUFFIX; /** * A named preference that holds the color used for 'linked-mode' underline. * <p> * Value is of type <code>String</code>. A RGB color value encoded as a string * using class <code>PreferenceConverter</code> * </p> * * @see org.eclipse.jface.resource.StringConverter * @see org.eclipse.jface.preference.PreferenceConverter * @since 2.1 */ public final static String EDITOR_LINK_COLOR= "linkColor"; //$NON-NLS-1$ /** * A named preference that controls whether hover tooltips in the editor are turned on or off. * <p> * Value is of type <code>Boolean</code>. * </p> */ public static final String EDITOR_SHOW_HOVER= "org.eclipse.jdt.ui.editor.showHover"; //$NON-NLS-1$ /** * A named preference that defines the hover shown when no control key is * pressed. * <p>Value is of type <code>String</code>: possible values are <code> * EDITOR_NO_HOVER_CONFIGURED_ID</code> or * <code>EDITOR_DEFAULT_HOVER_CONFIGURED_ID</code> or the hover id of a hover * contributed as <code>javaEditorTextHovers</code>. * </p> * @see #EDITOR_NO_HOVER_CONFIGURED_ID * @see #EDITOR_DEFAULT_HOVER_CONFIGURED_ID * @see JavaUI * @since 2.1 * @deprecated Will soon be removed - replaced by {@link #EDITOR_TEXT_HOVER_MODIFIERS} */ public static final String EDITOR_NONE_HOVER= "noneHover"; //$NON-NLS-1$ /** * A named preference that defines the hover shown when the * <code>CTRL</code> modifier key is pressed. * <p>Value is of type <code>String</code>: possible values are <code> * EDITOR_NO_HOVER_CONFIGURED_ID</code> or * <code>EDITOR_DEFAULT_HOVER_CONFIGURED_ID</code> or the hover id of a * hover contributed as <code>javaEditorTextHovers</code>. * </p> * @see #EDITOR_NO_HOVER_CONFIGURED_ID * @see #EDITOR_DEFAULT_HOVER_CONFIGURED_ID * @see JavaUI * @since 2.1 * @deprecated Will soon be removed - replaced by {@link #EDITOR_TEXT_HOVER_MODIFIERS} */ public static final String EDITOR_CTRL_HOVER= "ctrlHover"; //$NON-NLS-1$ /** * A named preference that defines the hover shown when the * <code>SHIFT</code> modifier key is pressed. * <p>Value is of type <code>String</code>: possible values are <code> * EDITOR_NO_HOVER_CONFIGURED_ID</code> or * <code>EDITOR_DEFAULT_HOVER_CONFIGURED_ID</code> or the hover id of a * hover contributed as <code>javaEditorTextHovers</code>. * </p> * @see #EDITOR_NO_HOVER_CONFIGURED_ID * @see #EDITOR_DEFAULT_HOVER_CONFIGURED_ID * @see JavaUI ID_*_HOVER * @since 2.1 * @deprecated Will soon be removed - replaced by {@link #EDITOR_TEXT_HOVER_MODIFIERS} */ public static final String EDITOR_SHIFT_HOVER= "shiftHover"; //$NON-NLS-1$ /** * A named preference that defines the hover shown when the * <code>CTRL + ALT</code> modifier keys is pressed. * <p>Value is of type <code>String</code>: possible values are <code> * EDITOR_NO_HOVER_CONFIGURED_ID</code> or * <code>EDITOR_DEFAULT_HOVER_CONFIGURED_ID</code> or the hover id of a * hover contributed as <code>javaEditorTextHovers</code>. * </p> * @see #EDITOR_NO_HOVER_CONFIGURED_ID * @see #EDITOR_DEFAULT_HOVER_CONFIGURED_ID * @see JavaUI ID_*_HOVER * @since 2.1 */ public static final String EDITOR_CTRL_ALT_HOVER= "ctrlAltHover"; //$NON-NLS-1$ /** * A named preference that defines the hover shown when the * <code>CTRL + ALT + SHIFT</code> modifier keys is pressed. * <p>Value is of type <code>String</code>: possible values are <code> * EDITOR_NO_HOVER_CONFIGURED_ID</code> or * <code>EDITOR_DEFAULT_HOVER_CONFIGURED_ID</code> or the hover id of a * hover contributed as <code>javaEditorTextHovers</code>. * </p> * @see #EDITOR_NO_HOVER_CONFIGURED_ID * @see #EDITOR_DEFAULT_HOVER_CONFIGURED_ID * @see JavaUI ID_*_HOVER * @since 2.1 */ public static final String EDITOR_CTRL_ALT_SHIFT_HOVER= "ctrlAltShiftHover"; //$NON-NLS-1$ /** * A named preference that defines the hover shown when the * <code>CTRL + SHIFT</code> modifier keys is pressed. * <p>Value is of type <code>String</code>: possible values are <code> * EDITOR_NO_HOVER_CONFIGURED_ID</code> or * <code>EDITOR_DEFAULT_HOVER_CONFIGURED_ID</code> or the hover id of a * hover contributed as <code>javaEditorTextHovers</code>. * </p> * @see #EDITOR_NO_HOVER_CONFIGURED_ID * @see #EDITOR_DEFAULT_HOVER_CONFIGURED_ID * @see JavaUI ID_*_HOVER * @since 2.1 * @deprecated Will be removed in one of the next builds. */ public static final String EDITOR_CTRL_SHIFT_HOVER= "ctrlShiftHover"; //$NON-NLS-1$ /** * A named preference that defines the hover shown when the * <code>ALT</code> modifier key is pressed. * <p>Value is of type <code>String</code>: possible values are <code> * EDITOR_NO_HOVER_CONFIGURED_ID</code>, * <code>EDITOR_DEFAULT_HOVER_CONFIGURED_ID</code> or the hover id of a * hover contributed as <code>javaEditorTextHovers</code>. * </p> * @see #EDITOR_NO_HOVER_CONFIGURED_ID * @see #EDITOR_DEFAULT_HOVER_CONFIGURED_ID * @see JavaUI ID_*_HOVER * @deprecated Will soon be removed - replaced by {@link #EDITOR_TEXT_HOVER_MODIFIERS} * @since 2.1 */ public static final String EDITOR_ALT_SHIFT_HOVER= "altShiftHover"; //$NON-NLS-1$ /** * A string value used by the named preferences for hover configuration to * descibe that no hover should be shown for the given key modifiers. * @deprecated Will soon be removed - replaced by {@link #EDITOR_TEXT_HOVER_MODIFIERS} * @since 2.1 */ public static final String EDITOR_NO_HOVER_CONFIGURED_ID= "noHoverConfiguredId"; //$NON-NLS-1$ /** * A string value used by the named preferences for hover configuration to * descibe that the default hover should be shown for the given key * modifiers. The default hover is described by the * <code>EDITOR_DEFAULT_HOVER</code> property. * @since 2.1 * @deprecated Will soon be removed - replaced by {@link #EDITOR_TEXT_HOVER_MODIFIERS} */ public static final String EDITOR_DEFAULT_HOVER_CONFIGURED_ID= "defaultHoverConfiguredId"; //$NON-NLS-1$ /** * A named preference that defines the hover named the 'default hover'. * Value is of type <code>String</code>: possible values are <code> * EDITOR_NO_HOVER_CONFIGURED_ID</code> or <code> the hover id of a hover * contributed as <code>javaEditorTextHovers</code>. * </p> * @since 2.1 * @deprecated Will soon be removed - replaced by {@link #EDITOR_TEXT_HOVER_MODIFIERS} */ public static final String EDITOR_DEFAULT_HOVER= "defaultHover"; //$NON-NLS-1$ /** * A named preference that controls if segmented view (show selected element only) is turned on or off. * <p> * Value is of type <code>Boolean</code>. * </p> */ public static final String EDITOR_SHOW_SEGMENTS= "org.eclipse.jdt.ui.editor.showSegments"; //$NON-NLS-1$ /** * A named preference that controls if browser like links are turned on or off. * <p> * Value is of type <code>Boolean</code>. * </p> * * @since 2.1 */ public static final String EDITOR_BROWSER_LIKE_LINKS= "browserLikeLinks"; //$NON-NLS-1$ /** * A named preference that controls the key modifier for browser like links. * <p> * Value is of type <code>String</code>. * </p> * * @since 2.1 */ public static final String EDITOR_BROWSER_LIKE_LINKS_KEY_MODIFIER= "browserLikeLinksKeyModifier"; //$NON-NLS-1$ /** * A named preference that controls the key modifier mask for browser like links. * The value is only used if the value of <code>EDITOR_BROWSER_LIKE_LINKS</code> * cannot be resolved to valid SWT modifier bits. * <p> * Value is of type <code>String</code>. * </p> * * @see #EDITOR_BROWSER_LIKE_LINKS_KEY_MODIFIER * @since 2.1.1 */ public static final String EDITOR_BROWSER_LIKE_LINKS_KEY_MODIFIER_MASK= "browserLikeLinksKeyModifierMask"; //$NON-NLS-1$ /** * A named preference that controls disabling of the overwrite mode. * <p> * Value is of type <code>Boolean</code>. * </p> * * @since 3.0 */ public static final String EDITOR_DISABLE_OVERWRITE_MODE= "disable_overwrite_mode"; //$NON-NLS-1$ /** * A named preference that controls the "smart semicolon" smart typing handler * <p> * Value is of type <code>Boolean</code>. * </p> * * @since 3.0 */ public static final String EDITOR_SMART_SEMICOLON= "smart_semicolon"; //$NON-NLS-1$ /** * A named preference that controls the "smart opening brace" smart typing handler * <p> * Value is of type <code>Boolean</code>. * </p> * * @since 3.0 */ public static final String EDITOR_SMART_OPENING_BRACE= "smart_opening_brace"; //$NON-NLS-1$ /** * A named preference that controls if the Java code assist gets auto activated. * <p> * Value is of type <code>Boolean</code>. * </p> */ public final static String CODEASSIST_AUTOACTIVATION= "content_assist_autoactivation"; //$NON-NLS-1$ /** * A name preference that holds the auto activation delay time in milli seconds. * <p> * Value is of type <code>Int</code>. * </p> */ public final static String CODEASSIST_AUTOACTIVATION_DELAY= "content_assist_autoactivation_delay"; //$NON-NLS-1$ /** * A named preference that controls if code assist contains only visible proposals. * <p> * Value is of type <code>Boolean</code>. if <code>true<code> code assist only contains visible members. If * <code>false</code> all members are included. * </p> */ public final static String CODEASSIST_SHOW_VISIBLE_PROPOSALS= "content_assist_show_visible_proposals"; //$NON-NLS-1$ /** * A named preference that controls if the Java code assist inserts a * proposal automatically if only one proposal is available. * <p> * Value is of type <code>Boolean</code>. * </p> * @since 2.1 */ public final static String CODEASSIST_AUTOINSERT= "content_assist_autoinsert"; //$NON-NLS-1$ /** * A named preference that controls if the Java code assist adds import * statements. * <p> * Value is of type <code>Boolean</code>. * </p> * @since 2.1 */ public final static String CODEASSIST_ADDIMPORT= "content_assist_add_import"; //$NON-NLS-1$ /** * A named preference that controls if the Java code assist only inserts * completions. If set to false the proposals can also _replace_ code. * <p> * Value is of type <code>Boolean</code>. * </p> * @since 2.1 */ public final static String CODEASSIST_INSERT_COMPLETION= "content_assist_insert_completion"; //$NON-NLS-1$ /** * A named preference that controls whether code assist proposals filtering is case sensitive or not. * <p> * Value is of type <code>Boolean</code>. * </p> */ public final static String CODEASSIST_CASE_SENSITIVITY= "content_assist_case_sensitivity"; //$NON-NLS-1$ /** * A named preference that defines if code assist proposals are sorted in alphabetical order. * <p> * Value is of type <code>Boolean</code>. If <code>true</code> that are sorted in alphabetical * order. If <code>false</code> that are unsorted. * </p> */ public final static String CODEASSIST_ORDER_PROPOSALS= "content_assist_order_proposals"; //$NON-NLS-1$ /** * A named preference that controls if argument names are filled in when a method is selected from as list * of code assist proposal. * <p> * Value is of type <code>Boolean</code>. * </p> */ public final static String CODEASSIST_FILL_ARGUMENT_NAMES= "content_assist_fill_method_arguments"; //$NON-NLS-1$ /** * A named preference that controls if method arguments are guessed when a * method is selected from as list of code assist proposal. * <p> * Value is of type <code>Boolean</code>. * </p> * @since 2.1 */ public final static String CODEASSIST_GUESS_METHOD_ARGUMENTS= "content_assist_guess_method_arguments"; //$NON-NLS-1$ /** * A named preference that holds the characters that auto activate code assist in Java code. * <p> * Value is of type <code>Sring</code>. All characters that trigger auto code assist in Java code. * </p> */ public final static String CODEASSIST_AUTOACTIVATION_TRIGGERS_JAVA= "content_assist_autoactivation_triggers_java"; //$NON-NLS-1$ /** * A named preference that holds the characters that auto activate code assist in Javadoc. * <p> * Value is of type <code>Sring</code>. All characters that trigger auto code assist in Javadoc. * </p> */ public final static String CODEASSIST_AUTOACTIVATION_TRIGGERS_JAVADOC= "content_assist_autoactivation_triggers_javadoc"; //$NON-NLS-1$ /** * A named preference that holds the background color used in the code assist selection dialog. * <p> * Value is of type <code>String</code>. A RGB color value encoded as a string * using class <code>PreferenceConverter</code> * </p> * * @see org.eclipse.jface.resource.StringConverter * @see org.eclipse.jface.preference.PreferenceConverter */ public final static String CODEASSIST_PROPOSALS_BACKGROUND= "content_assist_proposals_background"; //$NON-NLS-1$ /** * A named preference that holds the foreground color used in the code assist selection dialog. * <p> * Value is of type <code>String</code>. A RGB color value encoded as a string * using class <code>PreferenceConverter</code> * </p> * * @see org.eclipse.jface.resource.StringConverter * @see org.eclipse.jface.preference.PreferenceConverter */ public final static String CODEASSIST_PROPOSALS_FOREGROUND= "content_assist_proposals_foreground"; //$NON-NLS-1$ /** * A named preference that holds the background color used for parameter hints. * <p> * Value is of type <code>String</code>. A RGB color value encoded as a string * using class <code>PreferenceConverter</code> * </p> * * @see org.eclipse.jface.resource.StringConverter * @see org.eclipse.jface.preference.PreferenceConverter */ public final static String CODEASSIST_PARAMETERS_BACKGROUND= "content_assist_parameters_background"; //$NON-NLS-1$ /** * A named preference that holds the foreground color used in the code assist selection dialog. * <p> * Value is of type <code>String</code>. A RGB color value encoded as a string * using class <code>PreferenceConverter</code> * </p> * * @see org.eclipse.jface.resource.StringConverter * @see org.eclipse.jface.preference.PreferenceConverter */ public final static String CODEASSIST_PARAMETERS_FOREGROUND= "content_assist_parameters_foreground"; //$NON-NLS-1$ /** * A named preference that holds the background color used in the code * assist selection dialog to mark replaced code. * <p> * Value is of type <code>String</code>. A RGB color value encoded as a string * using class <code>PreferenceConverter</code> * </p> * * @see org.eclipse.jface.resource.StringConverter * @see org.eclipse.jface.preference.PreferenceConverter * @since 2.1 */ public final static String CODEASSIST_REPLACEMENT_BACKGROUND= "content_assist_completion_replacement_background"; //$NON-NLS-1$ /** * A named preference that holds the foreground color used in the code * assist selection dialog to mark replaced code. * <p> * Value is of type <code>String</code>. A RGB color value encoded as a string * using class <code>PreferenceConverter</code> * </p> * * @see org.eclipse.jface.resource.StringConverter * @see org.eclipse.jface.preference.PreferenceConverter * @since 2.1 */ public final static String CODEASSIST_REPLACEMENT_FOREGROUND= "content_assist_completion_replacement_foreground"; //$NON-NLS-1$ /** * A named preference that controls the behaviour of the refactoring wizard for showing the error page. * <p> * Value is of type <code>String</code>. Valid values are: * <code>REFACTOR_FATAL_SEVERITY</code>, * <code>REFACTOR_ERROR_SEVERITY</code>, * <code>REFACTOR_WARNING_SEVERITY</code> * <code>REFACTOR_INFO_SEVERITY</code>, * <code>REFACTOR_OK_SEVERITY</code>. * </p> * * @see #REFACTOR_FATAL_SEVERITY * @see #REFACTOR_ERROR_SEVERITY * @see #REFACTOR_WARNING_SEVERITY * @see #REFACTOR_INFO_SEVERITY * @see #REFACTOR_OK_SEVERITY */ public static final String REFACTOR_ERROR_PAGE_SEVERITY_THRESHOLD= "Refactoring.ErrorPage.severityThreshold"; //$NON-NLS-1$ /** * A string value used by the named preference <code>REFACTOR_ERROR_PAGE_SEVERITY_THRESHOLD</code>. * * @see #REFACTOR_ERROR_PAGE_SEVERITY_THRESHOLD */ public static final String REFACTOR_FATAL_SEVERITY= "4"; //$NON-NLS-1$ /** * A string value used by the named preference <code>REFACTOR_ERROR_PAGE_SEVERITY_THRESHOLD</code>. * * @see #REFACTOR_ERROR_PAGE_SEVERITY_THRESHOLD */ public static final String REFACTOR_ERROR_SEVERITY= "3"; //$NON-NLS-1$ /** * A string value used by the named preference <code>REFACTOR_ERROR_PAGE_SEVERITY_THRESHOLD</code>. * * @see #REFACTOR_ERROR_PAGE_SEVERITY_THRESHOLD */ public static final String REFACTOR_WARNING_SEVERITY= "2"; //$NON-NLS-1$ /** * A string value used by the named preference <code>REFACTOR_ERROR_PAGE_SEVERITY_THRESHOLD</code>. * * @see #REFACTOR_ERROR_PAGE_SEVERITY_THRESHOLD */ public static final String REFACTOR_INFO_SEVERITY= "1"; //$NON-NLS-1$ /** * A string value used by the named preference <code>REFACTOR_ERROR_PAGE_SEVERITY_THRESHOLD</code>. * * @see #REFACTOR_ERROR_PAGE_SEVERITY_THRESHOLD */ public static final String REFACTOR_OK_SEVERITY= "0"; //$NON-NLS-1$ /** * A named preference thet controls whether all dirty editors are automatically saved before a refactoring is * executed. * <p> * Value is of type <code>Boolean</code>. * </p> */ public static final String REFACTOR_SAVE_ALL_EDITORS= "Refactoring.savealleditors"; //$NON-NLS-1$ /** * A named preference that controls if the Java Browsing views are linked to the active editor. * <p> * Value is of type <code>Boolean</code>. * </p> * * @see #LINK_PACKAGES_TO_EDITOR */ public static final String BROWSING_LINK_VIEW_TO_EDITOR= "org.eclipse.jdt.ui.browsing.linktoeditor"; //$NON-NLS-1$ /** * A named preference that controls the layout of the Java Browsing views vertically. Boolean value. * <p> * Value is of type <code>Boolean</code>. If <code>true<code> the views are stacked vertical. * If <code>false</code> they are stacked horizontal. * </p> */ public static final String BROWSING_STACK_VERTICALLY= "org.eclipse.jdt.ui.browsing.stackVertically"; //$NON-NLS-1$ /** * A named preference that controls if templates are formatted when applied. * <p> * Value is of type <code>Boolean</code>. * </p> * * @since 2.1 */ public static final String TEMPLATES_USE_CODEFORMATTER= "org.eclipse.jdt.ui.template.format"; //$NON-NLS-1$ /** * Initializes the given preference store with the default values. * * @param store the preference store to be initialized * * @since 2.1 */ public static void initializeDefaultValues(IPreferenceStore store) { // set the default values from ExtendedTextEditor ExtendedTextEditorPreferenceConstants.initializeDefaultValues(store); store.setDefault(PreferenceConstants.EDITOR_SHOW_SEGMENTS, false); // JavaBasePreferencePage store.setDefault(PreferenceConstants.LINK_PACKAGES_TO_EDITOR, false); store.setDefault(PreferenceConstants.LINK_TYPEHIERARCHY_TO_EDITOR, false); store.setDefault(PreferenceConstants.OPEN_TYPE_HIERARCHY, PreferenceConstants.OPEN_TYPE_HIERARCHY_IN_VIEW_PART); store.setDefault(PreferenceConstants.DOUBLE_CLICK, PreferenceConstants.DOUBLE_CLICK_EXPANDS); store.setDefault(PreferenceConstants.UPDATE_JAVA_VIEWS, PreferenceConstants.UPDATE_WHILE_EDITING); store.setDefault(PreferenceConstants.LINK_BROWSING_PROJECTS_TO_EDITOR, true); store.setDefault(PreferenceConstants.LINK_BROWSING_PACKAGES_TO_EDITOR, true); store.setDefault(PreferenceConstants.LINK_BROWSING_TYPES_TO_EDITOR, true); store.setDefault(PreferenceConstants.LINK_BROWSING_MEMBERS_TO_EDITOR, true); // AppearancePreferencePage store.setDefault(PreferenceConstants.APPEARANCE_COMPRESS_PACKAGE_NAMES, false); store.setDefault(PreferenceConstants.APPEARANCE_METHOD_RETURNTYPE, false); store.setDefault(PreferenceConstants.SHOW_CU_CHILDREN, true); store.setDefault(PreferenceConstants.APPEARANCE_OVERRIDE_INDICATOR, true); store.setDefault(PreferenceConstants.BROWSING_STACK_VERTICALLY, false); store.setDefault(PreferenceConstants.APPEARANCE_PKG_NAME_PATTERN_FOR_PKG_VIEW, ""); //$NON-NLS-1$ store.setDefault(PreferenceConstants.APPEARANCE_FOLD_PACKAGES_IN_PACKAGE_EXPLORER, true); // ImportOrganizePreferencePage store.setDefault(PreferenceConstants.ORGIMPORTS_IMPORTORDER, "java;javax;org;com"); //$NON-NLS-1$ store.setDefault(PreferenceConstants.ORGIMPORTS_ONDEMANDTHRESHOLD, 99); store.setDefault(PreferenceConstants.ORGIMPORTS_IGNORELOWERCASE, true); // ClasspathVariablesPreferencePage // CodeFormatterPreferencePage // CompilerPreferencePage // no initialization needed // RefactoringPreferencePage store.setDefault(PreferenceConstants.REFACTOR_ERROR_PAGE_SEVERITY_THRESHOLD, PreferenceConstants.REFACTOR_ERROR_SEVERITY); store.setDefault(PreferenceConstants.REFACTOR_SAVE_ALL_EDITORS, false); // TemplatePreferencePage store.setDefault(PreferenceConstants.TEMPLATES_USE_CODEFORMATTER, true); // CodeGenerationPreferencePage // compatibility code if (store.getBoolean(PreferenceConstants.CODEGEN_USE_GETTERSETTER_PREFIX)) { String prefix= store.getString(PreferenceConstants.CODEGEN_GETTERSETTER_PREFIX); if (prefix.length() > 0) { JavaCore.getPlugin().getPluginPreferences().setValue(JavaCore.CODEASSIST_FIELD_PREFIXES, prefix); store.setToDefault(PreferenceConstants.CODEGEN_USE_GETTERSETTER_PREFIX); store.setToDefault(PreferenceConstants.CODEGEN_GETTERSETTER_PREFIX); } } if (store.getBoolean(PreferenceConstants.CODEGEN_USE_GETTERSETTER_SUFFIX)) { String suffix= store.getString(PreferenceConstants.CODEGEN_GETTERSETTER_SUFFIX); if (suffix.length() > 0) { JavaCore.getPlugin().getPluginPreferences().setValue(JavaCore.CODEASSIST_FIELD_SUFFIXES, suffix); store.setToDefault(PreferenceConstants.CODEGEN_USE_GETTERSETTER_SUFFIX); store.setToDefault(PreferenceConstants.CODEGEN_GETTERSETTER_SUFFIX); } } store.setDefault(PreferenceConstants.CODEGEN_KEYWORD_THIS, false); store.setDefault(PreferenceConstants.CODEGEN_IS_FOR_GETTERS, true); store.setDefault(PreferenceConstants.CODEGEN_ADD_COMMENTS, true); // MembersOrderPreferencePage store.setDefault(PreferenceConstants.APPEARANCE_MEMBER_SORT_ORDER, "T,SI,SF,SM,I,F,C,M"); //$NON-NLS-1$ // must add here to guarantee that it is the first in the listener list store.addPropertyChangeListener(JavaPlugin.getDefault().getMemberOrderPreferenceCache()); // JavaEditorPreferencePage store.setDefault(PreferenceConstants.EDITOR_MATCHING_BRACKETS, true); PreferenceConverter.setDefault(store, PreferenceConstants.EDITOR_MATCHING_BRACKETS_COLOR, new RGB(192, 192,192)); store.setDefault(PreferenceConstants.EDITOR_CURRENT_LINE, true); PreferenceConverter.setDefault(store, PreferenceConstants.EDITOR_CURRENT_LINE_COLOR, new RGB(225, 235, 224)); store.setDefault(PreferenceConstants.EDITOR_PRINT_MARGIN, false); store.setDefault(PreferenceConstants.EDITOR_PRINT_MARGIN_COLUMN, 80); PreferenceConverter.setDefault(store, PreferenceConstants.EDITOR_PRINT_MARGIN_COLOR, new RGB(176, 180 , 185)); PreferenceConverter.setDefault(store, PreferenceConstants.EDITOR_FIND_SCOPE_COLOR, new RGB(185, 176 , 180)); store.setDefault(PreferenceConstants.EDITOR_CORRECTION_INDICATION, true); store.setDefault(PreferenceConstants.EDITOR_SYNC_OUTLINE_ON_CURSOR_MOVE, true); store.setDefault(PreferenceConstants.EDITOR_EVALUTE_TEMPORARY_PROBLEMS, true); store.setDefault(PreferenceConstants.EDITOR_OVERVIEW_RULER, true); store.setDefault(PreferenceConstants.EDITOR_LINE_NUMBER_RULER, false); PreferenceConverter.setDefault(store, PreferenceConstants.EDITOR_LINE_NUMBER_RULER_COLOR, new RGB(0, 0, 0)); PreferenceConverter.setDefault(store, PreferenceConstants.EDITOR_LINKED_POSITION_COLOR, new RGB(0, 200 , 100)); PreferenceConverter.setDefault(store, PreferenceConstants.EDITOR_LINK_COLOR, new RGB(0, 0, 255)); store.setDefault(PreferenceConstants.EDITOR_FOREGROUND_DEFAULT_COLOR, true); store.setDefault(PreferenceConstants.EDITOR_BACKGROUND_DEFAULT_COLOR, true); store.setDefault(PreferenceConstants.EDITOR_TAB_WIDTH, 4); store.setDefault(PreferenceConstants.EDITOR_SPACES_FOR_TABS, false); PreferenceConverter.setDefault(store, PreferenceConstants.EDITOR_MULTI_LINE_COMMENT_COLOR, new RGB(63, 127, 95)); store.setDefault(PreferenceConstants.EDITOR_MULTI_LINE_COMMENT_BOLD, false); PreferenceConverter.setDefault(store, PreferenceConstants.EDITOR_SINGLE_LINE_COMMENT_COLOR, new RGB(63, 127, 95)); store.setDefault(PreferenceConstants.EDITOR_SINGLE_LINE_COMMENT_BOLD, false); PreferenceConverter.setDefault(store, PreferenceConstants.EDITOR_JAVA_KEYWORD_COLOR, new RGB(127, 0, 85)); store.setDefault(PreferenceConstants.EDITOR_JAVA_KEYWORD_BOLD, true); PreferenceConverter.setDefault(store, PreferenceConstants.EDITOR_STRING_COLOR, new RGB(42, 0, 255)); store.setDefault(PreferenceConstants.EDITOR_STRING_BOLD, false); PreferenceConverter.setDefault(store, PreferenceConstants.EDITOR_JAVA_DEFAULT_COLOR, new RGB(0, 0, 0)); store.setDefault(PreferenceConstants.EDITOR_JAVA_DEFAULT_BOLD, false); PreferenceConverter.setDefault(store, PreferenceConstants.EDITOR_JAVA_METHOD_NAME_COLOR, new RGB(0, 0, 0)); store.setDefault(PreferenceConstants.EDITOR_JAVA_METHOD_NAME_BOLD, false); PreferenceConverter.setDefault(store, PreferenceConstants.EDITOR_JAVA_OPERATOR_COLOR, new RGB(0, 0, 0)); store.setDefault(PreferenceConstants.EDITOR_JAVA_OPERATOR_BOLD, false); PreferenceConverter.setDefault(store, PreferenceConstants.EDITOR_TASK_TAG_COLOR, new RGB(127, 159, 191)); store.setDefault(PreferenceConstants.EDITOR_TASK_TAG_BOLD, true); PreferenceConverter.setDefault(store, PreferenceConstants.EDITOR_JAVADOC_KEYWORD_COLOR, new RGB(127, 159, 191)); store.setDefault(PreferenceConstants.EDITOR_JAVADOC_KEYWORD_BOLD, true); PreferenceConverter.setDefault(store, PreferenceConstants.EDITOR_JAVADOC_TAG_COLOR, new RGB(127, 127, 159)); store.setDefault(PreferenceConstants.EDITOR_JAVADOC_TAG_BOLD, false); PreferenceConverter.setDefault(store, PreferenceConstants.EDITOR_JAVADOC_LINKS_COLOR, new RGB(63, 63, 191)); store.setDefault(PreferenceConstants.EDITOR_JAVADOC_LINKS_BOLD, false); PreferenceConverter.setDefault(store, PreferenceConstants.EDITOR_JAVADOC_DEFAULT_COLOR, new RGB(63, 95, 191)); store.setDefault(PreferenceConstants.EDITOR_JAVADOC_DEFAULT_BOLD, false); store.setDefault(PreferenceConstants.CODEASSIST_AUTOACTIVATION, true); store.setDefault(PreferenceConstants.CODEASSIST_AUTOACTIVATION_DELAY, 500); store.setDefault(PreferenceConstants.CODEASSIST_AUTOINSERT, true); PreferenceConverter.setDefault(store, PreferenceConstants.CODEASSIST_PROPOSALS_BACKGROUND, new RGB(254, 241, 233)); PreferenceConverter.setDefault(store, PreferenceConstants.CODEASSIST_PROPOSALS_FOREGROUND, new RGB(0, 0, 0)); PreferenceConverter.setDefault(store, PreferenceConstants.CODEASSIST_PARAMETERS_BACKGROUND, new RGB(254, 241, 233)); PreferenceConverter.setDefault(store, PreferenceConstants.CODEASSIST_PARAMETERS_FOREGROUND, new RGB(0, 0, 0)); PreferenceConverter.setDefault(store, PreferenceConstants.CODEASSIST_REPLACEMENT_BACKGROUND, new RGB(255, 255, 0)); PreferenceConverter.setDefault(store, PreferenceConstants.CODEASSIST_REPLACEMENT_FOREGROUND, new RGB(255, 0, 0)); store.setDefault(PreferenceConstants.CODEASSIST_AUTOACTIVATION_TRIGGERS_JAVA, "."); //$NON-NLS-1$ store.setDefault(PreferenceConstants.CODEASSIST_AUTOACTIVATION_TRIGGERS_JAVADOC, "@"); //$NON-NLS-1$ store.setDefault(PreferenceConstants.CODEASSIST_SHOW_VISIBLE_PROPOSALS, true); store.setDefault(PreferenceConstants.CODEASSIST_CASE_SENSITIVITY, false); store.setDefault(PreferenceConstants.CODEASSIST_ORDER_PROPOSALS, false); store.setDefault(PreferenceConstants.CODEASSIST_ADDIMPORT, true); store.setDefault(PreferenceConstants.CODEASSIST_INSERT_COMPLETION, true); store.setDefault(PreferenceConstants.CODEASSIST_FILL_ARGUMENT_NAMES, false); store.setDefault(PreferenceConstants.CODEASSIST_GUESS_METHOD_ARGUMENTS, true); store.setDefault(PreferenceConstants.EDITOR_SMART_HOME_END, true); store.setDefault(PreferenceConstants.EDITOR_SUB_WORD_NAVIGATION, true); store.setDefault(PreferenceConstants.EDITOR_SMART_PASTE, true); store.setDefault(PreferenceConstants.EDITOR_CLOSE_STRINGS, true); store.setDefault(PreferenceConstants.EDITOR_CLOSE_BRACKETS, true); store.setDefault(PreferenceConstants.EDITOR_CLOSE_BRACES, true); store.setDefault(PreferenceConstants.EDITOR_CLOSE_JAVADOCS, true); store.setDefault(PreferenceConstants.EDITOR_WRAP_STRINGS, true); store.setDefault(PreferenceConstants.EDITOR_ADD_JAVADOC_TAGS, true); store.setDefault(PreferenceConstants.EDITOR_FORMAT_JAVADOCS, false); String mod1Name= Action.findModifierString(SWT.MOD1); // SWT.COMMAND on Mac; SWT.CONTROL elsewhere store.setDefault(PreferenceConstants.EDITOR_TEXT_HOVER_MODIFIERS, "org.eclipse.jdt.ui.BestMatchHover;0;org.eclipse.jdt.ui.JavaSourceHover;" + mod1Name); //$NON-NLS-1$ store.setDefault(PreferenceConstants.EDITOR_TEXT_HOVER_MODIFIER_MASKS, "org.eclipse.jdt.ui.BestMatchHover;0;org.eclipse.jdt.ui.JavaSourceHover;" + SWT.MOD1); //$NON-NLS-1$ store.setDefault(PreferenceConstants.EDITOR_SHOW_TEXT_HOVER_AFFORDANCE, true); store.setDefault(PreferenceConstants.EDITOR_BROWSER_LIKE_LINKS, true); store.setDefault(PreferenceConstants.EDITOR_BROWSER_LIKE_LINKS_KEY_MODIFIER, mod1Name); store.setDefault(PreferenceConstants.EDITOR_BROWSER_LIKE_LINKS_KEY_MODIFIER_MASK, SWT.MOD1); // work in progress WorkInProgressPreferencePage.initDefaults(store); // do more complicated stuff NewJavaProjectPreferencePage.initDefaults(store); } /** * Returns the JDT-UI preference store. * * @return the JDT-UI preference store */ public static IPreferenceStore getPreferenceStore() { return JavaPlugin.getDefault().getPreferenceStore(); } /** * Encodes a JRE library to be used in the named preference <code>NEWPROJECT_JRELIBRARY_LIST</code>. * * @param description a string value describing the JRE library. The description is used * to indentify the JDR library in the UI * @param entries an array of classpath entries to be encoded * * @return the encoded string. */ public static String encodeJRELibrary(String description, IClasspathEntry[] entries) { return NewJavaProjectPreferencePage.encodeJRELibrary(description, entries); } /** * Decodes an encoded JRE library and returns its description string. * * @return the description of an encoded JRE library * * @see #encodeJRELibrary(String, IClasspathEntry[]) */ public static String decodeJRELibraryDescription(String encodedLibrary) { return NewJavaProjectPreferencePage.decodeJRELibraryDescription(encodedLibrary); } /** * Decodes an encoded JRE library and returns its classpath entries. * * @return the array of classpath entries of an encoded JRE library. * * @see #encodeJRELibrary(String, IClasspathEntry[]) */ public static IClasspathEntry[] decodeJRELibraryClasspathEntries(String encodedLibrary) { return NewJavaProjectPreferencePage.decodeJRELibraryClasspathEntries(encodedLibrary); } /** * Returns the current configuration for the JRE to be used as default in new Java projects. * This is a convenience method to access the named preference <code>NEWPROJECT_JRELIBRARY_LIST * </code> with the index defined by <code> NEWPROJECT_JRELIBRARY_INDEX</code>. * * @return the current default set of classpath entries * * @see #NEWPROJECT_JRELIBRARY_LIST * @see #NEWPROJECT_JRELIBRARY_INDEX */ public static IClasspathEntry[] getDefaultJRELibrary() { return NewJavaProjectPreferencePage.getDefaultJRELibrary(); } }
40,772
Bug 40772 [plan item] Smart tab on empty lines
When having the caret on an empty line, pressing tab cleans up the line and sets the caret it the right indentation column.
resolved fixed
adaf274
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2003-09-11T13:25:24Z
2003-07-25T13:33:20Z
org.eclipse.jdt.ui/ui/org/eclipse/jdt/ui/actions/GenerateActionGroup.java
/******************************************************************************* * Copyright (c) 2000, 2003 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Common Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/cpl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.jdt.ui.actions; import java.util.ArrayList; import java.util.Iterator; import java.util.List; import org.eclipse.jface.action.IAction; import org.eclipse.jface.action.IMenuManager; import org.eclipse.jface.action.MenuManager; import org.eclipse.jface.action.Separator; import org.eclipse.jface.util.Assert; import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.ISelectionChangedListener; import org.eclipse.jface.viewers.ISelectionProvider; import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.ui.IActionBars; import org.eclipse.ui.IViewPart; import org.eclipse.ui.IWorkbenchActionConstants; import org.eclipse.ui.IWorkbenchSite; import org.eclipse.ui.actions.ActionGroup; import org.eclipse.ui.actions.AddBookmarkAction; import org.eclipse.ui.editors.text.ITextEditorHelpContextIds; import org.eclipse.ui.part.Page; import org.eclipse.ui.texteditor.ConvertLineDelimitersAction; import org.eclipse.ui.texteditor.IUpdate; import org.eclipse.jdt.ui.IContextMenuConstants; import org.eclipse.jdt.internal.ui.actions.ActionMessages; import org.eclipse.jdt.internal.ui.actions.AddTaskAction; import org.eclipse.jdt.internal.ui.javaeditor.AddImportOnSelectionAction; import org.eclipse.jdt.internal.ui.javaeditor.CompilationUnitEditor; /** * Action group that adds the source and generate actions to a part's context * menu and installs handlers for the corresponding global menu actions. * * <p> * This class may be instantiated; it is not intended to be subclassed. * </p> * * @since 2.0 */ public class GenerateActionGroup extends ActionGroup { private CompilationUnitEditor fEditor; private IWorkbenchSite fSite; private String fGroupName= IContextMenuConstants.GROUP_REORGANIZE; private List fRegisteredSelectionListeners; private AddImportOnSelectionAction fAddImport; private OverrideMethodsAction fOverrideMethods; private AddGetterSetterAction fAddGetterSetter; private AddDelegateMethodsAction fAddDelegateMethods; private AddUnimplementedConstructorsAction fAddUnimplementedConstructors; private GenerateNewConstructorUsingFieldsAction fGenerateConstructorUsingFields; private AddJavaDocStubAction fAddJavaDocStub; private AddBookmarkAction fAddBookmark; private AddTaskAction fAddTaskAction; private ExternalizeStringsAction fExternalizeStrings; private FindStringsToExternalizeAction fFindStringsToExternalize; private SurroundWithTryCatchAction fSurroundWithTryCatch; private AddToClasspathAction fAddToClasspathAction; private RemoveFromClasspathAction fRemoveFromClasspathAction; private OrganizeImportsAction fOrganizeImports; private SortMembersAction fSortMembers; private ConvertLineDelimitersAction fConvertToWindows; private ConvertLineDelimitersAction fConvertToUNIX; private ConvertLineDelimitersAction fConvertToMac; /** * Note: This constructor is for internal use only. Clients should not call this constructor. */ public GenerateActionGroup(CompilationUnitEditor editor, String groupName) { fSite= editor.getSite(); fEditor= editor; fGroupName= groupName; ISelectionProvider provider= fSite.getSelectionProvider(); ISelection selection= provider.getSelection(); fAddImport= new AddImportOnSelectionAction(editor); fAddImport.setActionDefinitionId(IJavaEditorActionDefinitionIds.ADD_IMPORT); fAddImport.update(); editor.setAction("AddImport", fAddImport); //$NON-NLS-1$ fOrganizeImports= new OrganizeImportsAction(editor); fOrganizeImports.setActionDefinitionId(IJavaEditorActionDefinitionIds.ORGANIZE_IMPORTS); editor.setAction("OrganizeImports", fOrganizeImports); //$NON-NLS-1$ fSortMembers= new SortMembersAction(editor); fSortMembers.setActionDefinitionId(IJavaEditorActionDefinitionIds.SORT_MEMBERS); editor.setAction("SortMembers", fSortMembers); //$NON-NLS-1$ fOverrideMethods= new OverrideMethodsAction(editor); fOverrideMethods.setActionDefinitionId(IJavaEditorActionDefinitionIds.OVERRIDE_METHODS); editor.setAction("OverrideMethods", fOverrideMethods); //$NON-NLS-1$ fAddGetterSetter= new AddGetterSetterAction(editor); fAddGetterSetter.setActionDefinitionId(IJavaEditorActionDefinitionIds.CREATE_GETTER_SETTER); editor.setAction("AddGetterSetter", fAddGetterSetter); //$NON-NLS-1$ fAddDelegateMethods= new AddDelegateMethodsAction(editor); fAddDelegateMethods.setActionDefinitionId(IJavaEditorActionDefinitionIds.CREATE_DELEGATE_METHODS); editor.setAction("AddDelegateMethods", fAddDelegateMethods); //$NON-NLS-1$ fAddUnimplementedConstructors= new AddUnimplementedConstructorsAction(editor); fAddUnimplementedConstructors.setActionDefinitionId(IJavaEditorActionDefinitionIds.ADD_UNIMPLEMENTED_CONTRUCTORS); editor.setAction("AddUnimplementedConstructors", fAddUnimplementedConstructors); //$NON-NLS-1$ fGenerateConstructorUsingFields= new GenerateNewConstructorUsingFieldsAction(editor); fGenerateConstructorUsingFields.setActionDefinitionId(IJavaEditorActionDefinitionIds.GENERATE_CONSTRUCTOR_USING_FIELDS); editor.setAction("GenerateConstructorUsingFields", fGenerateConstructorUsingFields); //$NON-NLS-1$ fAddJavaDocStub= new AddJavaDocStubAction(editor); fAddJavaDocStub.setActionDefinitionId(IJavaEditorActionDefinitionIds.ADD_JAVADOC_COMMENT); editor.setAction("AddJavadocComment", fAddJavaDocStub); //$NON-NLS-1$ fSurroundWithTryCatch= new SurroundWithTryCatchAction(editor); fSurroundWithTryCatch.setActionDefinitionId(IJavaEditorActionDefinitionIds.SURROUND_WITH_TRY_CATCH); fSurroundWithTryCatch.update(selection); provider.addSelectionChangedListener(fSurroundWithTryCatch); editor.setAction("SurroundWithTryCatch", fSurroundWithTryCatch); //$NON-NLS-1$ fExternalizeStrings= new ExternalizeStringsAction(editor); fExternalizeStrings.setActionDefinitionId(IJavaEditorActionDefinitionIds.EXTERNALIZE_STRINGS); editor.setAction("ExternalizeStrings", fExternalizeStrings); //$NON-NLS-1$ fConvertToWindows= new ConvertLineDelimitersAction(editor, "\r\n"); //$NON-NLS-1$ fConvertToWindows.setActionDefinitionId(IJavaEditorActionDefinitionIds.CONVERT_LINE_DELIMITERS_TO_WINDOWS); fConvertToWindows.setHelpContextId(ITextEditorHelpContextIds.CONVERT_LINE_DELIMITERS_TO_WINDOWS); editor.setAction("ConvertLineDelimitersToWindows", fConvertToWindows); //$NON-NLS-1$ fConvertToUNIX= new ConvertLineDelimitersAction(editor, "\n"); //$NON-NLS-1$ fConvertToUNIX.setActionDefinitionId(IJavaEditorActionDefinitionIds.CONVERT_LINE_DELIMITERS_TO_UNIX); fConvertToUNIX.setHelpContextId(ITextEditorHelpContextIds.CONVERT_LINE_DELIMITERS_TO_UNIX); editor.setAction("ConvertLineDelimitersToUNIX", fConvertToUNIX); //$NON-NLS-1$ fConvertToMac= new ConvertLineDelimitersAction(editor, "\r"); //$NON-NLS-1$ fConvertToMac.setActionDefinitionId(IJavaEditorActionDefinitionIds.CONVERT_LINE_DELIMITERS_TO_MAC); fConvertToMac.setHelpContextId(ITextEditorHelpContextIds.CONVERT_LINE_DELIMITERS_TO_MAC); editor.setAction("ConvertLineDelimitersToMac", fConvertToMac); //$NON-NLS-1$ } /** * Creates a new <code>GenerateActionGroup</code>. The group * requires that the selection provided by the page's selection provider * is of type <code>org.eclipse.jface.viewers.IStructuredSelection</code>. * * @param page the page that owns this action group */ public GenerateActionGroup(Page page) { this(page.getSite()); } /** * Creates a new <code>GenerateActionGroup</code>. The group * requires that the selection provided by the part's selection provider * is of type <code>org.eclipse.jface.viewers.IStructuredSelection</code>. * * @param part the view part that owns this action group */ public GenerateActionGroup(IViewPart part) { this(part.getSite()); } private GenerateActionGroup(IWorkbenchSite site) { fSite= site; ISelectionProvider provider= fSite.getSelectionProvider(); ISelection selection= provider.getSelection(); fOverrideMethods= new OverrideMethodsAction(site); fAddGetterSetter= new AddGetterSetterAction(site); fAddDelegateMethods= new AddDelegateMethodsAction(site); fAddUnimplementedConstructors= new AddUnimplementedConstructorsAction(site); fGenerateConstructorUsingFields= new GenerateNewConstructorUsingFieldsAction(site); fAddJavaDocStub= new AddJavaDocStubAction(site); fAddBookmark= new AddBookmarkAction(site.getShell()); fAddToClasspathAction= new AddToClasspathAction(site); fRemoveFromClasspathAction= new RemoveFromClasspathAction(site); fAddTaskAction= new AddTaskAction(site); fExternalizeStrings= new ExternalizeStringsAction(site); fFindStringsToExternalize= new FindStringsToExternalizeAction(site); fOrganizeImports= new OrganizeImportsAction(site); fSortMembers= new SortMembersAction(site); fOverrideMethods.update(selection); fAddGetterSetter.update(selection); fAddDelegateMethods.update(selection); fAddUnimplementedConstructors.update(selection); fGenerateConstructorUsingFields.update(selection); fAddJavaDocStub.update(selection); fAddToClasspathAction.update(selection); fRemoveFromClasspathAction.update(selection); fExternalizeStrings.update(selection); fFindStringsToExternalize.update(selection); fAddTaskAction.update(selection); fOrganizeImports.update(selection); fSortMembers.update(selection); if (selection instanceof IStructuredSelection) { IStructuredSelection ss= (IStructuredSelection)selection; fAddBookmark.selectionChanged(ss); } else { fAddBookmark.setEnabled(false); } registerSelectionListener(provider, fOverrideMethods); registerSelectionListener(provider, fAddGetterSetter); registerSelectionListener(provider, fAddDelegateMethods); registerSelectionListener(provider, fAddUnimplementedConstructors); registerSelectionListener(provider, fGenerateConstructorUsingFields); registerSelectionListener(provider, fAddJavaDocStub); registerSelectionListener(provider, fAddBookmark); registerSelectionListener(provider, fAddToClasspathAction); registerSelectionListener(provider, fRemoveFromClasspathAction); registerSelectionListener(provider, fExternalizeStrings); registerSelectionListener(provider, fFindStringsToExternalize); registerSelectionListener(provider, fOrganizeImports); registerSelectionListener(provider, fSortMembers); registerSelectionListener(provider, fAddTaskAction); } private void registerSelectionListener(ISelectionProvider provider, ISelectionChangedListener listener) { if (fRegisteredSelectionListeners == null) fRegisteredSelectionListeners= new ArrayList(20); provider.addSelectionChangedListener(listener); fRegisteredSelectionListeners.add(listener); } /* * The state of the editor owning this action group has changed. * This method does nothing if the group's owner isn't an * editor. */ /** * Note: This method is for internal use only. Clients should not call this method. */ public void editorStateChanged() { Assert.isTrue(isEditorOwner()); // http://dev.eclipse.org/bugs/show_bug.cgi?id=17709 fConvertToMac.update(); fConvertToUNIX.update(); fConvertToWindows.update(); } /* (non-Javadoc) * Method declared in ActionGroup */ public void fillActionBars(IActionBars actionBar) { super.fillActionBars(actionBar); setGlobalActionHandlers(actionBar); } /* (non-Javadoc) * Method declared in ActionGroup */ public void fillContextMenu(IMenuManager menu) { super.fillContextMenu(menu); IMenuManager subMenu= null; if (isEditorOwner()) { subMenu= createEditorSubMenu(menu); } else { subMenu= createViewSubMenu(menu); } if (subMenu != null) menu.appendToGroup(fGroupName, subMenu); } private IMenuManager createEditorSubMenu(IMenuManager mainMenu) { IMenuManager result= new MenuManager(ActionMessages.getString("SourceMenu.label")); //$NON-NLS-1$ int added= 0; added+= addEditorAction(result, "Comment"); //$NON-NLS-1$ added+= addEditorAction(result, "Uncomment"); //$NON-NLS-1$ added+= addEditorAction(result, "AddBlockComment"); //$NON-NLS-1$ added+= addEditorAction(result, "RemoveBlockComment"); //$NON-NLS-1$ added+= addEditorAction(result, "Format"); //$NON-NLS-1$ result.add(new Separator()); added+= addAction(result, fOrganizeImports); added+= addAction(result, fAddImport); result.add(new Separator()); added+= addAction(result, fOverrideMethods); added+= addAction(result, fAddGetterSetter); added+= addAction(result, fAddDelegateMethods); added+= addAction(result, fAddUnimplementedConstructors); added+= addAction(result, fGenerateConstructorUsingFields); added+= addAction(result, fAddJavaDocStub); result.add(new Separator()); added+= addAction(result, fSurroundWithTryCatch); if (added == 0) result= null; return result; } private IMenuManager createViewSubMenu(IMenuManager mainMenu) { IMenuManager result= new MenuManager(ActionMessages.getString("SourceMenu.label")); //$NON-NLS-1$ int added= 0; added+= addAction(result, fSortMembers); result.add(new Separator()); added+= addAction(result, fOrganizeImports); added+= addAction(result, fAddImport); result.add(new Separator()); added+= addAction(result, fOverrideMethods); added+= addAction(result, fAddGetterSetter); added+= addAction(result, fAddDelegateMethods); added+= addAction(result, fAddUnimplementedConstructors); added+= addAction(result, fGenerateConstructorUsingFields); added+= addAction(result, fAddJavaDocStub); added+= addAction(result, fAddToClasspathAction); added+= addAction(result, fRemoveFromClasspathAction); result.add(new Separator()); added+= addAction(result, fSurroundWithTryCatch); added+= addAction(result, fExternalizeStrings); added+= addAction(result, fFindStringsToExternalize); if (added == 0) result= null; return result; } /* (non-Javadoc) * Method declared in ActionGroup */ public void dispose() { if (fRegisteredSelectionListeners != null) { ISelectionProvider provider= fSite.getSelectionProvider(); for (Iterator iter= fRegisteredSelectionListeners.iterator(); iter.hasNext();) { ISelectionChangedListener listener= (ISelectionChangedListener) iter.next(); provider.removeSelectionChangedListener(listener); } } fEditor= null; super.dispose(); } private void setGlobalActionHandlers(IActionBars actionBar) { actionBar.setGlobalActionHandler(JdtActionConstants.ADD_IMPORT, fAddImport); actionBar.setGlobalActionHandler(JdtActionConstants.SURROUND_WITH_TRY_CATCH, fSurroundWithTryCatch); actionBar.setGlobalActionHandler(JdtActionConstants.OVERRIDE_METHODS, fOverrideMethods); actionBar.setGlobalActionHandler(JdtActionConstants.GENERATE_GETTER_SETTER, fAddGetterSetter); actionBar.setGlobalActionHandler(JdtActionConstants.GENERATE_DELEGATE_METHODS, fAddDelegateMethods); actionBar.setGlobalActionHandler(JdtActionConstants.ADD_CONSTRUCTOR_FROM_SUPERCLASS, fAddUnimplementedConstructors); actionBar.setGlobalActionHandler(JdtActionConstants.GENERATE_CONSTRUCTOR_USING_FIELDS, fGenerateConstructorUsingFields); actionBar.setGlobalActionHandler(JdtActionConstants.ADD_JAVA_DOC_COMMENT, fAddJavaDocStub); actionBar.setGlobalActionHandler(JdtActionConstants.EXTERNALIZE_STRINGS, fExternalizeStrings); actionBar.setGlobalActionHandler(JdtActionConstants.FIND_STRINGS_TO_EXTERNALIZE, fFindStringsToExternalize); actionBar.setGlobalActionHandler(JdtActionConstants.ORGANIZE_IMPORTS, fOrganizeImports); actionBar.setGlobalActionHandler(JdtActionConstants.SORT_MEMBERS, fSortMembers); actionBar.setGlobalActionHandler(JdtActionConstants.CONVERT_LINE_DELIMITERS_TO_WINDOWS, fConvertToWindows); actionBar.setGlobalActionHandler(JdtActionConstants.CONVERT_LINE_DELIMITERS_TO_UNIX, fConvertToUNIX); actionBar.setGlobalActionHandler(JdtActionConstants.CONVERT_LINE_DELIMITERS_TO_MAC, fConvertToMac); if (!isEditorOwner()) { // editor provides its own implementation of these actions. actionBar.setGlobalActionHandler(IWorkbenchActionConstants.BOOKMARK, fAddBookmark); actionBar.setGlobalActionHandler(IWorkbenchActionConstants.ADD_TASK, fAddTaskAction); } } private int addAction(IMenuManager menu, IAction action) { if (action != null && action.isEnabled()) { menu.add(action); return 1; } return 0; } private int addEditorAction(IMenuManager menu, String actionID) { if (fEditor == null) return 0; IAction action= fEditor.getAction(actionID); if (action == null) return 0; if (action instanceof IUpdate) ((IUpdate)action).update(); if (action.isEnabled()) { menu.add(action); return 1; } return 0; } private boolean isEditorOwner() { return fEditor != null; } }
40,772
Bug 40772 [plan item] Smart tab on empty lines
When having the caret on an empty line, pressing tab cleans up the line and sets the caret it the right indentation column.
resolved fixed
adaf274
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2003-09-11T13:25:24Z
2003-07-25T13:33:20Z
org.eclipse.jdt.ui/ui/org/eclipse/jdt/ui/actions/IJavaEditorActionDefinitionIds.java
/******************************************************************************* * Copyright (c) 2000, 2003 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Common Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/cpl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.jdt.ui.actions; import org.eclipse.ui.texteditor.ITextEditorActionDefinitionIds; /** * Defines the definition IDs for the Java editor actions. * * <p> * This interface is not intended to be implemented or extended. * </p>. * * @since 2.0 */ public interface IJavaEditorActionDefinitionIds extends ITextEditorActionDefinitionIds { // edit /** * Action definition ID of the edit -> smart typing action * (value <code>"org.eclipse.jdt.smartTyping.toggle"</code>). * * @since 3.0 */ public static final String TOGGLE_SMART_TYPING= "org.eclipse.jdt.smartTyping.toggle"; //$NON-NLS-1$ /** * Action definition ID of the edit -> go to matching bracket action * (value <code>"org.eclipse.jdt.ui.edit.text.java.goto.matching.bracket"</code>). * * @since 2.1 */ public static final String GOTO_MATCHING_BRACKET= "org.eclipse.jdt.ui.edit.text.java.goto.matching.bracket"; //$NON-NLS-1$ /** * Action definition ID of the edit -> go to next member action * (value <code>"org.eclipse.jdt.ui.edit.text.java.goto.next.member"</code>). * * @since 2.1 */ public static final String GOTO_NEXT_MEMBER= "org.eclipse.jdt.ui.edit.text.java.goto.next.member"; //$NON-NLS-1$ /** * Action definition ID of the edit -> go to previous member action * (value <code>"org.eclipse.jdt.ui.edit.text.java.goto.previous.member"</code>). * * @since 2.1 */ public static final String GOTO_PREVIOUS_MEMBER= "org.eclipse.jdt.ui.edit.text.java.goto.previous.member"; //$NON-NLS-1$ /** * Action definition ID of the edit -> select enclosing action * (value <code>"org.eclipse.jdt.ui.edit.text.java.select.enclosing"</code>). */ public static final String SELECT_ENCLOSING= "org.eclipse.jdt.ui.edit.text.java.select.enclosing"; //$NON-NLS-1$ /** * Action definition ID of the edit -> select next action * (value <code>"org.eclipse.jdt.ui.edit.text.java.select.next"</code>). */ public static final String SELECT_NEXT= "org.eclipse.jdt.ui.edit.text.java.select.next"; //$NON-NLS-1$ /** * Action definition ID of the edit -> select previous action * (value <code>"org.eclipse.jdt.ui.edit.text.java.select.previous"</code>). */ public static final String SELECT_PREVIOUS= "org.eclipse.jdt.ui.edit.text.java.select.previous"; //$NON-NLS-1$ /** * Action definition ID of the edit -> select restore last action * (value <code>"org.eclipse.jdt.ui.edit.text.java.select.last"</code>). */ public static final String SELECT_LAST= "org.eclipse.jdt.ui.edit.text.java.select.last"; //$NON-NLS-1$ /** * Action definition ID of the edit -> correction assist proposal action * (value <code>"org.eclipse.jdt.ui.edit.text.java.correction.assist.proposals"</code>). */ public static final String CORRECTION_ASSIST_PROPOSALS= "org.eclipse.jdt.ui.edit.text.java.correction.assist.proposals"; //$NON-NLS-1$ /** * Action definition ID of the edit -> show Javadoc action * (value <code>"org.eclipse.jdt.ui.edit.text.java.show.javadoc"</code>). */ public static final String SHOW_JAVADOC= "org.eclipse.jdt.ui.edit.text.java.show.javadoc"; //$NON-NLS-1$ /** * Action definition ID of the navigate -> Show Outline action * (value <code>"org.eclipse.jdt.ui.edit.text.java.show.outline"</code>). * * @since 2.1 */ public static final String SHOW_OUTLINE= "org.eclipse.jdt.ui.edit.text.java.show.outline"; //$NON-NLS-1$ /** * Action definition ID of the navigate -> Show Hierarchy action * (value <code>"org.eclipse.jdt.ui.edit.text.java.open.hierarchy"</code>). * * @since 3.0 */ public static final String OPEN_HIERARCHY= "org.eclipse.jdt.ui.edit.text.java.open.hierarchy"; //$NON-NLS-1$ /** * Action definition ID of the Navigate -> Open Structure action * (value <code>"org.eclipse.jdt.ui.navigate.java.open.structure"</code>). * * @since 2.1 */ public static final String OPEN_STRUCTURE= "org.eclipse.jdt.ui.navigate.java.open.structure"; //$NON-NLS-1$ // source /** * Action definition ID of the source -> comment action * (value <code>"org.eclipse.jdt.ui.edit.text.java.comment"</code>). */ public static final String COMMENT= "org.eclipse.jdt.ui.edit.text.java.comment"; //$NON-NLS-1$ /** * Action definition ID of the source -> uncomment action * (value <code>"org.eclipse.jdt.ui.edit.text.java.uncomment"</code>). */ public static final String UNCOMMENT= "org.eclipse.jdt.ui.edit.text.java.uncomment"; //$NON-NLS-1$ /** * Action definition ID of the source -> add block comment action * (value <code>"org.eclipse.jdt.ui.edit.text.java.add.block.comment"</code>). * @since 3.0 */ public static final String ADD_BLOCK_COMMENT= "org.eclipse.jdt.ui.edit.text.java.add.block.comment"; //$NON-NLS-1$ /** * Action definition ID of the source -> remove block comment action * (value <code>"org.eclipse.jdt.ui.edit.text.java.remove.block.comment"</code>). * @since 3.0 */ public static final String REMOVE_BLOCK_COMMENT= "org.eclipse.jdt.ui.edit.text.java.remove.block.comment"; //$NON-NLS-1$ /** * Action definition ID of the source -> format action * (value <code>"org.eclipse.jdt.ui.edit.text.java.format"</code>). */ public static final String FORMAT= "org.eclipse.jdt.ui.edit.text.java.format"; //$NON-NLS-1$ /** * Action definition ID of the source -> add import action * (value <code>"org.eclipse.jdt.ui.edit.text.java.add.import"</code>). */ public static final String ADD_IMPORT= "org.eclipse.jdt.ui.edit.text.java.add.import"; //$NON-NLS-1$ /** * Action definition ID of the source -> organize imports action * (value <code>"org.eclipse.jdt.ui.edit.text.java.organize.imports"</code>). */ public static final String ORGANIZE_IMPORTS= "org.eclipse.jdt.ui.edit.text.java.organize.imports"; //$NON-NLS-1$ /** * Action definition ID of the source -> sort order action (value * <code>"org.eclipse.jdt.ui.edit.text.java.sort.members"</code>). * @since 2.1 */ public static final String SORT_MEMBERS= "org.eclipse.jdt.ui.edit.text.java.sort.members"; //$NON-NLS-1$ /** * Action definition ID of the source -> add javadoc comment action (value * <code>"org.eclipse.jdt.ui.edit.text.java.add.javadoc.comment"</code>). * @since 2.1 */ public static final String ADD_JAVADOC_COMMENT= "org.eclipse.jdt.ui.edit.text.java.add.javadoc.comment"; //$NON-NLS-1$ /** * Action definition ID of the source -> surround with try/catch action * (value <code>"org.eclipse.jdt.ui.edit.text.java.surround.with.try.catch"</code>). */ public static final String SURROUND_WITH_TRY_CATCH= "org.eclipse.jdt.ui.edit.text.java.surround.with.try.catch"; //$NON-NLS-1$ /** * Action definition ID of the source -> override methods action * (value <code>"org.eclipse.jdt.ui.edit.text.java.override.methods"</code>). */ public static final String OVERRIDE_METHODS= "org.eclipse.jdt.ui.edit.text.java.override.methods"; //$NON-NLS-1$ /** * Action definition ID of the source -> add unimplemented constructors action * (value <code>"org.eclipse.jdt.ui.edit.text.java.add.unimplemented.constructors"</code>). */ public static final String ADD_UNIMPLEMENTED_CONTRUCTORS= "org.eclipse.jdt.ui.edit.text.java.add.unimplemented.constructors"; //$NON-NLS-1$ /** * Action definition ID of the source ->generate constructor using fields action * (value <code>"org.eclipse.jdt.ui.edit.text.java.generate.constructor.using.fields"</code>). */ public static final String GENERATE_CONSTRUCTOR_USING_FIELDS= "org.eclipse.jdt.ui.edit.text.java.generate.constructor.using.fields"; //$NON-NLS-1$ /** * Action definition ID of the source -> generate setter/getter action * (value <code>"org.eclipse.jdt.ui.edit.text.java.create.getter.setter"</code>). */ public static final String CREATE_GETTER_SETTER= "org.eclipse.jdt.ui.edit.text.java.create.getter.setter"; //$NON-NLS-1$ /** * Action definition ID of the source -> generate delegates action (value * <code>"org.eclipse.jdt.ui.edit.text.java.create.delegate.methods"</code>). * @since 2.1 */ public static final String CREATE_DELEGATE_METHODS= "org.eclipse.jdt.ui.edit.text.java.create.delegate.methods"; //$NON-NLS-1$ /** * Action definition ID of the source -> externalize strings action * (value <code>"org.eclipse.jdt.ui.edit.text.java.externalize.strings"</code>). */ public static final String EXTERNALIZE_STRINGS= "org.eclipse.jdt.ui.edit.text.java.externalize.strings"; //$NON-NLS-1$ /** * Note: this id is for internal use only. * @deprecated as of 3.0 replaced by {@link org.eclipse.ui.texteditor.ITextEditorActionDefinitionIds#GOTO_NEXT_ANNOTATION */ public static final String SHOW_NEXT_PROBLEM= "org.eclipse.jdt.ui.edit.text.java.show.next.problem"; //$NON-NLS-1$ /** * Note: this id is for internal use only. * @deprecated as of 3.0 replaced by {@link org.eclipse.ui.texteditor.ITextEditorActionDefinitionIds#GOTO_PREVIOUS_ANNOTATION */ public static final String SHOW_PREVIOUS_PROBLEM= "org.eclipse.jdt.ui.edit.text.java.show.previous.problem"; //$NON-NLS-1$ // refactor /** * Action definition ID of the refactor -> pull up action * (value <code>"org.eclipse.jdt.ui.edit.text.java.pull.up"</code>). */ public static final String PULL_UP= "org.eclipse.jdt.ui.edit.text.java.pull.up"; //$NON-NLS-1$ /** * Action definition ID of the refactor -> push down action * (value <code>"org.eclipse.jdt.ui.edit.text.java.push.down"</code>). * * @since 2.1 */ public static final String PUSH_DOWN= "org.eclipse.jdt.ui.edit.text.java.push.down"; //$NON-NLS-1$ /** * Action definition ID of the refactor -> rename element action * (value <code>"org.eclipse.jdt.ui.edit.text.java.rename.element"</code>). */ public static final String RENAME_ELEMENT= "org.eclipse.jdt.ui.edit.text.java.rename.element"; //$NON-NLS-1$ /** * Action definition ID of the refactor -> modify method parameters action * (value <code>"org.eclipse.jdt.ui.edit.text.java.modify.method.parameters"</code>). */ public static final String MODIFY_METHOD_PARAMETERS= "org.eclipse.jdt.ui.edit.text.java.modify.method.parameters"; //$NON-NLS-1$ /** * Action definition ID of the refactor -> move element action * (value <code>"org.eclipse.jdt.ui.edit.text.java.move.element"</code>). */ public static final String MOVE_ELEMENT= "org.eclipse.jdt.ui.edit.text.java.move.element"; //$NON-NLS-1$ /** * Action definition ID of the refactor -> extract local variable action * (value <code>"org.eclipse.jdt.ui.edit.text.java.extract.local.variable"</code>). */ public static final String EXTRACT_LOCAL_VARIABLE= "org.eclipse.jdt.ui.edit.text.java.extract.local.variable"; //$NON-NLS-1$ /** * Action definition ID of the refactor -> extract constant action * (value <code>"org.eclipse.jdt.ui.edit.text.java.extract.constant"</code>). * * @since 2.1 */ public static final String EXTRACT_CONSTANT= "org.eclipse.jdt.ui.edit.text.java.extract.constant"; //$NON-NLS-1$ /** * Action definition ID of the refactor -> inline local variable action * (value <code>"org.eclipse.jdt.ui.edit.text.java.inline.local.variable"</code>). * @deprecated Use INLINE */ public static final String INLINE_LOCAL_VARIABLE= "org.eclipse.jdt.ui.edit.text.java.inline.local.variable"; //$NON-NLS-1$ /** * Action definition ID of the refactor -> self encapsulate field action * (value <code>"org.eclipse.jdt.ui.edit.text.java.self.encapsulate.field"</code>). */ public static final String SELF_ENCAPSULATE_FIELD= "org.eclipse.jdt.ui.edit.text.java.self.encapsulate.field"; //$NON-NLS-1$ /** * Action definition ID of the refactor -> extract method action * (value <code>"org.eclipse.jdt.ui.edit.text.java.extract.method"</code>). */ public static final String EXTRACT_METHOD= "org.eclipse.jdt.ui.edit.text.java.extract.method"; //$NON-NLS-1$ /** * Action definition ID of the refactor -> inline action * (value <code>"org.eclipse.jdt.ui.edit.text.java.inline"</code>). * * @since 2.1 */ public static final String INLINE= "org.eclipse.jdt.ui.edit.text.java.inline"; //$NON-NLS-1$ /** * Action definition ID of the refactor -> extract interface action * (value <code>"org.eclipse.jdt.ui.edit.text.java.extract.interface"</code>). * * @since 2.1 */ public static final String EXTRACT_INTERFACE= "org.eclipse.jdt.ui.edit.text.java.extract.interface"; //$NON-NLS-1$ /** * Action definition ID of the refactor -> move inner type to top level action * (value <code>"org.eclipse.jdt.ui.edit.text.java.move.inner.to.top.level"</code>). * * @since 2.1 */ public static final String MOVE_INNER_TO_TOP= "org.eclipse.jdt.ui.edit.text.java.move.inner.to.top.level"; //$NON-NLS-1$ /** * Action definition ID of the refactor -> use supertype action * (value <code>"org.eclipse.jdt.ui.edit.text.java.use.supertype"</code>). * * @since 2.1 */ public static final String USE_SUPERTYPE= "org.eclipse.jdt.ui.edit.text.java.use.supertype"; //$NON-NLS-1$ /** * Action definition ID of the refactor -> promote local variable action * (value <code>"org.eclipse.jdt.ui.edit.text.java.promote.local.variable"</code>). * * @since 2.1 */ public static final String PROMOTE_LOCAL_VARIABLE= "org.eclipse.jdt.ui.edit.text.java.promote.local.variable"; //$NON-NLS-1$ /** * Action definition ID of the refactor -> convert anonynous to nested action * (value <code>"org.eclipse.jdt.ui.edit.text.java.convert.anonymous.to.nested"</code>). * * @since 2.1 */ public static final String CONVERT_ANONYMOUS_TO_NESTED= "org.eclipse.jdt.ui.edit.text.java.convert.anonymous.to.nested"; //$NON-NLS-1$ // navigate /** * Action definition ID of the navigate -> open action * (value <code>"org.eclipse.jdt.ui.edit.text.java.open.editor"</code>). */ public static final String OPEN_EDITOR= "org.eclipse.jdt.ui.edit.text.java.open.editor"; //$NON-NLS-1$ /** * Action definition ID of the navigate -> open super implementation action * (value <code>"org.eclipse.jdt.ui.edit.text.java.open.super.implementation"</code>). */ public static final String OPEN_SUPER_IMPLEMENTATION= "org.eclipse.jdt.ui.edit.text.java.open.super.implementation"; //$NON-NLS-1$ /** * Action definition ID of the navigate -> open external javadoc action * (value <code>"org.eclipse.jdt.ui.edit.text.java.open.external.javadoc"</code>). */ public static final String OPEN_EXTERNAL_JAVADOC= "org.eclipse.jdt.ui.edit.text.java.open.external.javadoc"; //$NON-NLS-1$ /** * Action definition ID of the navigate -> open type hierarchy action * (value <code>"org.eclipse.jdt.ui.edit.text.java.org.eclipse.jdt.ui.edit.text.java.open.type.hierarchy"</code>). */ public static final String OPEN_TYPE_HIERARCHY= "org.eclipse.jdt.ui.edit.text.java.open.type.hierarchy"; //$NON-NLS-1$ /** * Action definition ID of the navigate -> open call hierarchy action * (value <code>"org.eclipse.jdt.ui.edit.text.java.org.eclipse.jdt.ui.edit.text.java.open.call.hierarchy"</code>). * @since 3.0 */ public static final String OPEN_CALL_HIERARCHY= "org.eclipse.jdt.ui.edit.text.java.open.call.hierarchy"; //$NON-NLS-1$ /** * Action definition ID of the navigate -> show in package explorer action * (value <code>"org.eclipse.jdt.ui.edit.text.java.show.in.package.view"</code>). */ public static final String SHOW_IN_PACKAGE_VIEW= "org.eclipse.jdt.ui.edit.text.java.show.in.package.view"; //$NON-NLS-1$ /** * Action definition ID of the navigate -> show in navigator action * (value <code>"org.eclipse.jdt.ui.edit.text.java.show.in.navigator.view"</code>). */ public static final String SHOW_IN_NAVIGATOR_VIEW= "org.eclipse.jdt.ui.edit.text.java.show.in.navigator.view"; //$NON-NLS-1$ // search /** * Action definition ID of the search -> references in workspace action * (value <code>"org.eclipse.jdt.ui.edit.text.java.search.references.in.workspace"</code>). */ public static final String SEARCH_REFERENCES_IN_WORKSPACE= "org.eclipse.jdt.ui.edit.text.java.search.references.in.workspace"; //$NON-NLS-1$ /** * Action definition ID of the search -> references in project action * (value <code>"org.eclipse.jdt.ui.edit.text.java.search.references.in.project"</code>). */ public static final String SEARCH_REFERENCES_IN_PROJECT= "org.eclipse.jdt.ui.edit.text.java.search.references.in.project"; //$NON-NLS-1$ /** * Action definition ID of the search -> references in hierarchy action * (value <code>"org.eclipse.jdt.ui.edit.text.java.search.references.in.hierarchy"</code>). */ public static final String SEARCH_REFERENCES_IN_HIERARCHY= "org.eclipse.jdt.ui.edit.text.java.search.references.in.hierarchy"; //$NON-NLS-1$ /** * Action definition ID of the search -> references in working set action * (value <code>"org.eclipse.jdt.ui.edit.text.java.search.references.in.working.set"</code>). */ public static final String SEARCH_REFERENCES_IN_WORKING_SET= "org.eclipse.jdt.ui.edit.text.java.search.references.in.working.set"; //$NON-NLS-1$ /** * Action definition ID of the search -> read access in workspace action * (value <code>"org.eclipse.jdt.ui.edit.text.java.search.read.access.in.workspace"</code>). */ public static final String SEARCH_READ_ACCESS_IN_WORKSPACE= "org.eclipse.jdt.ui.edit.text.java.search.read.access.in.workspace"; //$NON-NLS-1$ /** * Action definition ID of the search -> read access in project action * (value <code>"org.eclipse.jdt.ui.edit.text.java.search.read.access.in.project"</code>). */ public static final String SEARCH_READ_ACCESS_IN_PROJECT= "org.eclipse.jdt.ui.edit.text.java.search.read.access.in.project"; //$NON-NLS-1$ /** * Action definition ID of the search -> read access in hierarchy action * (value <code>"org.eclipse.jdt.ui.edit.text.java.search.read.access.in.hierarchy"</code>). */ public static final String SEARCH_READ_ACCESS_IN_HIERARCHY= "org.eclipse.jdt.ui.edit.text.java.search.read.access.in.hierarchy"; //$NON-NLS-1$ /** * Action definition ID of the search -> read access in working set action * (value <code>"org.eclipse.jdt.ui.edit.text.java.search.read.access.in.working.set"</code>). */ public static final String SEARCH_READ_ACCESS_IN_WORKING_SET= "org.eclipse.jdt.ui.edit.text.java.search.read.access.in.working.set"; //$NON-NLS-1$ /** * Action definition ID of the search -> write access in workspace action * (value <code>"org.eclipse.jdt.ui.edit.text.java.search.write.access.in.workspace"</code>). */ public static final String SEARCH_WRITE_ACCESS_IN_WORKSPACE= "org.eclipse.jdt.ui.edit.text.java.search.write.access.in.workspace"; //$NON-NLS-1$ /** * Action definition ID of the search -> write access in project action * (value <code>"org.eclipse.jdt.ui.edit.text.java.search.write.access.in.project"</code>). */ public static final String SEARCH_WRITE_ACCESS_IN_PROJECT= "org.eclipse.jdt.ui.edit.text.java.search.write.access.in.project"; //$NON-NLS-1$ /** * Action definition ID of the search -> write access in hierarchy action * (value <code>"org.eclipse.jdt.ui.edit.text.java.search.write.access.in.hierarchy"</code>). */ public static final String SEARCH_WRITE_ACCESS_IN_HIERARCHY= "org.eclipse.jdt.ui.edit.text.java.search.write.access.in.hierarchy"; //$NON-NLS-1$ /** * Action definition ID of the search -> write access in working set action * (value <code>"org.eclipse.jdt.ui.edit.text.java.search.write.access.in.working.set"</code>). */ public static final String SEARCH_WRITE_ACCESS_IN_WORKING_SET= "org.eclipse.jdt.ui.edit.text.java.search.write.access.in.working.set"; //$NON-NLS-1$ /** * Action definition ID of the search -> declarations in workspace action * (value <code>"org.eclipse.jdt.ui.edit.text.java.search.declarations.in.workspace"</code>). */ public static final String SEARCH_DECLARATIONS_IN_WORKSPACE= "org.eclipse.jdt.ui.edit.text.java.search.declarations.in.workspace"; //$NON-NLS-1$ /** * Action definition ID of the search -> declarations in project action * (value <code>"org.eclipse.jdt.ui.edit.text.java.search.declarations.in.project"</code>). */ public static final String SEARCH_DECLARATIONS_IN_PROJECTS= "org.eclipse.jdt.ui.edit.text.java.search.declarations.in.project"; //$NON-NLS-1$ /** * Action definition ID of the search -> declarations in hierarchy action * (value <code>"org.eclipse.jdt.ui.edit.text.java.search.declarations.in.hierarchy"</code>). */ public static final String SEARCH_DECLARATIONS_IN_HIERARCHY= "org.eclipse.jdt.ui.edit.text.java.search.declarations.in.hierarchy"; //$NON-NLS-1$ /** * Action definition ID of the search -> declarations in working set action * (value <code>"org.eclipse.jdt.ui.edit.text.java.search.declarations.in.working.set"</code>). */ public static final String SEARCH_DECLARATIONS_IN_WORKING_SET= "org.eclipse.jdt.ui.edit.text.java.search.declarations.in.working.set"; //$NON-NLS-1$ /** * Action definition ID of the search -> implementors in workspace action * (value <code>"org.eclipse.jdt.ui.edit.text.java.search.implementors.in.workspace"</code>). */ public static final String SEARCH_IMPLEMENTORS_IN_WORKSPACE= "org.eclipse.jdt.ui.edit.text.java.search.implementors.in.workspace"; //$NON-NLS-1$ /** * Action definition ID of the search -> implementors in working set action * (value <code>"org.eclipse.jdt.ui.edit.text.java.seach.implementors.in.working.set"</code>). */ public static final String SEARCH_IMPLEMENTORS_IN_WORKING_SET= "org.eclipse.jdt.ui.edit.text.java.seach.implementors.in.working.set"; //$NON-NLS-1$ // miscellaneous /** * Action definition ID of the toggle presentation toolbar button action * (value <code>"org.eclipse.jdt.ui.edit.text.java.toggle.presentation"</code>). * @deprecated as of 3.0 replaces by {@link org.eclipse.ui.texteditor.ITextEditorActionDefinitionIds#TOGGLE_SHOW_SELECTED_ELEMENT_ONLY */ public static final String TOGGLE_PRESENTATION= "org.eclipse.jdt.ui.edit.text.java.toggle.presentation"; //$NON-NLS-1$ /** * Action definition ID of the toggle text hover toolbar button action * (value <code>"org.eclipse.jdt.ui.edit.text.java.toggle.text.hover"</code>). */ public static final String TOGGLE_TEXT_HOVER= "org.eclipse.jdt.ui.edit.text.java.toggle.text.hover"; //$NON-NLS-1$ /** * Action definition ID of the search -> implementors in project action * (value <code>"org.eclipse.jdt.ui.edit.text.java.seach.implementors.in.project"</code>). */ public static final String SEARCH_IMPLEMENTORS_IN_PROJECT= "org.eclipse.jdt.ui.edit.text.java.seach.implementors.in.project"; //$NON-NLS-1$ }
40,772
Bug 40772 [plan item] Smart tab on empty lines
When having the caret on an empty line, pressing tab cleans up the line and sets the caret it the right indentation column.
resolved fixed
adaf274
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2003-09-11T13:25:24Z
2003-07-25T13:33:20Z
org.eclipse.jdt.ui/ui/org/eclipse/jdt/ui/actions/JdtActionConstants.java
/******************************************************************************* * Copyright (c) 2000, 2003 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Common Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/cpl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.jdt.ui.actions; /** * Action ids for standard actions, for groups in the menu bar, and * for actions in context menus of JDT views. * * <p> * This class may be instantiated; it is not intended to be subclassed. * </p> * * @since 2.0 */ public class JdtActionConstants { // Navigate menu /** * Navigate menu: name of standard Goto Type global action * (value <code>"org.eclipse.jdt.ui.actions.GoToType"</code>). */ public static final String GOTO_TYPE= "org.eclipse.jdt.ui.actions.GoToType"; //$NON-NLS-1$ /** * Navigate menu: name of standard Goto Package global action * (value <code>"org.eclipse.jdt.ui.actions.GoToPackage"</code>). */ public static final String GOTO_PACKAGE= "org.eclipse.jdt.ui.actions.GoToPackage"; //$NON-NLS-1$ /** * Navigate menu: name of standard Open global action * (value <code>"org.eclipse.jdt.ui.actions.Open"</code>). */ public static final String OPEN= "org.eclipse.jdt.ui.actions.Open"; //$NON-NLS-1$ /** * Navigate menu: name of standard Open Super Implementation global action * (value <code>"org.eclipse.jdt.ui.actions.OpenSuperImplementation"</code>). */ public static final String OPEN_SUPER_IMPLEMENTATION= "org.eclipse.jdt.ui.actions.OpenSuperImplementation"; //$NON-NLS-1$ /** * Navigate menu: name of standard Open Type Hierarchy global action * (value <code>"org.eclipse.jdt.ui.actions.OpenTypeHierarchy"</code>). */ public static final String OPEN_TYPE_HIERARCHY= "org.eclipse.jdt.ui.actions.OpenTypeHierarchy"; //$NON-NLS-1$ /** * Navigate menu: name of standard Open Call Hierarchy global action * (value <code>"org.eclipse.jdt.ui.actions.OpenCallHierarchy"</code>). * @since 3.0 */ public static final String OPEN_CALL_HIERARCHY= "org.eclipse.jdt.ui.actions.OpenCallHierarchy"; //$NON-NLS-1$ /** * Navigate menu: name of standard Open External Javadoc global action * (value <code>"org.eclipse.jdt.ui.actions.OpenExternalJavaDoc"</code>). */ public static final String OPEN_EXTERNAL_JAVA_DOC= "org.eclipse.jdt.ui.actions.OpenExternalJavaDoc"; //$NON-NLS-1$ /** * Navigate menu: name of standard Show in Packages View global action * (value <code>"org.eclipse.jdt.ui.actions.ShowInPackagesView"</code>). */ public static final String SHOW_IN_PACKAGE_VIEW= "org.eclipse.jdt.ui.actions.ShowInPackagesView"; //$NON-NLS-1$ /** * Navigate menu: name of standard Show in Navigator View global action * (value <code>"org.eclipse.jdt.ui.actions.ShowInNaviagtorView"</code>). */ public static final String SHOW_IN_NAVIGATOR_VIEW= "org.eclipse.jdt.ui.actions.ShowInNaviagtorView"; //$NON-NLS-1$ // Edit menu /** * Edit menu: name of standard Show Javadoc global action * (value <code>"org.eclipse.jdt.ui.actions.ShowJavaDoc"</code>). */ public static final String SHOW_JAVA_DOC= "org.eclipse.jdt.ui.actions.ShowJavaDoc"; //$NON-NLS-1$ /** * Edit menu: name of standard Code Assist global action * (value <code>"org.eclipse.jdt.ui.actions.ContentAssist"</code>). */ public static final String CONTENT_ASSIST= "org.eclipse.jdt.ui.actions.ContentAssist"; //$NON-NLS-1$ // Source menu /** * Source menu: name of standard Comment global action * (value <code>"org.eclipse.jdt.ui.actions.Comment"</code>). */ public static final String COMMENT= "org.eclipse.jdt.ui.actions.Comment"; //$NON-NLS-1$ /** * Source menu: name of standard Uncomment global action * (value <code>"org.eclipse.jdt.ui.actions.Uncomment"</code>). */ public static final String UNCOMMENT= "org.eclipse.jdt.ui.actions.Uncomment"; //$NON-NLS-1$ /** * Source menu: name of standard Comment global action * (value <code>"org.eclipse.jdt.ui.actions.AddBlockComment"</code>). * * @since 3.0 */ public static final String ADD_BLOCK_COMMENT= "org.eclipse.jdt.ui.actions.AddBlockComment"; //$NON-NLS-1$ /** * Source menu: name of standard Uncomment global action * (value <code>"org.eclipse.jdt.ui.actions.RemoveBlockComment"</code>). * * @since 3.0 */ public static final String REMOVE_BLOCK_COMMENT= "org.eclipse.jdt.ui.actions.RemoveBlockComment"; //$NON-NLS-1$ /** * Source menu: name of standard Shift Rightl action * (value <code>"org.eclipse.jdt.ui.actions.ShiftRight"</code>). */ public static final String SHIFT_RIGHT= "org.eclipse.jdt.ui.actions.ShiftRight"; //$NON-NLS-1$ /** * Source menu: name of standard Shift Left global action * (value <code>"org.eclipse.jdt.ui.actions.ShiftLeft"</code>). */ public static final String SHIFT_LEFT= "org.eclipse.jdt.ui.actions.ShiftLeft"; //$NON-NLS-1$ /** * Source menu: name of standard Format global action * (value <code>"org.eclipse.jdt.ui.actions.Format"</code>). */ public static final String FORMAT= "org.eclipse.jdt.ui.actions.Format"; //$NON-NLS-1$ /** * Source menu: name of standard Add Import global action * (value <code>"org.eclipse.jdt.ui.actions.AddImport"</code>). */ public static final String ADD_IMPORT= "org.eclipse.jdt.ui.actions.AddImport"; //$NON-NLS-1$ /** * Source menu: name of standard Organize Imports global action * (value <code>"org.eclipse.jdt.ui.actions.OrganizeImports"</code>). */ public static final String ORGANIZE_IMPORTS= "org.eclipse.jdt.ui.actions.OrganizeImports"; //$NON-NLS-1$ /** * Source menu: name of standard Sort Members global action (value * <code>"org.eclipse.jdt.ui.actions.SortMembers"</code>). * @since 2.1 */ public static final String SORT_MEMBERS= "org.eclipse.jdt.ui.actions.SortMembers"; //$NON-NLS-1$ /** * Source menu: name of standard Surround with try/catch block global action * (value <code>"org.eclipse.jdt.ui.actions.SurroundWithTryCatch"</code>). */ public static final String SURROUND_WITH_TRY_CATCH= "org.eclipse.jdt.ui.actions.SurroundWithTryCatch"; //$NON-NLS-1$ /** * Source menu: name of standard Override Methods global action * (value <code>"org.eclipse.jdt.ui.actions.OverrideMethods"</code>). */ public static final String OVERRIDE_METHODS= "org.eclipse.jdt.ui.actions.OverrideMethods"; //$NON-NLS-1$ /** * Source menu: name of standard Generate Getter and Setter global action * (value <code>"org.eclipse.jdt.ui.actions.GenerateGetterSetter"</code>). */ public static final String GENERATE_GETTER_SETTER= "org.eclipse.jdt.ui.actions.GenerateGetterSetter"; //$NON-NLS-1$ /** * Source menu: name of standard delegate methdos global action (value * <code>"org.eclipse.jdt.ui.actions.GenerateDelegateMethods"</code>). * @since 2.1 */ public static final String GENERATE_DELEGATE_METHODS= "org.eclipse.jdt.ui.actions.GenerateDelegateMethods"; //$NON-NLS-1$ /** * Source menu: name of standard Add Constructor From Superclass global action * (value <code>"org.eclipse.jdt.ui.actions.AddConstructorFromSuperclass"</code>). */ public static final String ADD_CONSTRUCTOR_FROM_SUPERCLASS= "org.eclipse.jdt.ui.actions.AddConstructorFromSuperclass"; //$NON-NLS-1$ /** * Source menu: name of standard Generate Constructor using Fields global action * (value <code>"org.eclipse.jdt.ui.actions.GenerateConstructorUsingFields"</code>). */ public static final String GENERATE_CONSTRUCTOR_USING_FIELDS= "org.eclipse.jdt.ui.actions.GenerateConstructorUsingFields"; //$NON-NLS-1$ /** * Source menu: name of standard Add Javadoc Comment global action * (value <code>"org.eclipse.jdt.ui.actions.AddJavaDocComment"</code>). */ public static final String ADD_JAVA_DOC_COMMENT= "org.eclipse.jdt.ui.actions.AddJavaDocComment"; //$NON-NLS-1$ /** * Source menu: name of standard Find Strings to Externalize global action * (value <code>"org.eclipse.jdt.ui.actions.FindStringsToExternalize"</code>). */ public static final String FIND_STRINGS_TO_EXTERNALIZE= "org.eclipse.jdt.ui.actions.FindStringsToExternalize"; //$NON-NLS-1$ /** * Source menu: name of standard Externalize Strings global action * (value <code>"org.eclipse.jdt.ui.actions.ExternalizeStrings"</code>). */ public static final String EXTERNALIZE_STRINGS= "org.eclipse.jdt.ui.actions.ExternalizeStrings"; //$NON-NLS-1$ /** * Source menu: name of standard Convert Line Delimiters To Windows global action * (value <code>"org.eclipse.jdt.ui.actions.ConvertLineDelimitersToWindows"</code>). */ public static String CONVERT_LINE_DELIMITERS_TO_WINDOWS= "org.eclipse.jdt.ui.actions.ConvertLineDelimitersToWindows"; //$NON-NLS-1$ /** * Source menu: name of standard Convert Line Delimiters To UNIX global action * (value <code>"org.eclipse.jdt.ui.actions.ConvertLineDelimitersToUNIX"</code>). */ public static String CONVERT_LINE_DELIMITERS_TO_UNIX= "org.eclipse.jdt.ui.actions.ConvertLineDelimitersToUNIX"; //$NON-NLS-1$ /** * Source menu: name of standardConvert Line Delimiters ToMac global action * (value <code>"org.eclipse.jdt.ui.actions.ConvertLineDelimitersToMac"</code>). */ public static String CONVERT_LINE_DELIMITERS_TO_MAC= "org.eclipse.jdt.ui.actions.ConvertLineDelimitersToMac"; //$NON-NLS-1$ // Refactor menu /** * Refactor menu: name of standard Self Encapsulate Field global action * (value <code>"org.eclipse.jdt.ui.actions.SelfEncapsulateField"</code>). */ public static final String SELF_ENCAPSULATE_FIELD= "org.eclipse.jdt.ui.actions.SelfEncapsulateField"; //$NON-NLS-1$ /** * Refactor menu: name of standard Modify Parameters global action * (value <code>"org.eclipse.jdt.ui.actions.ModifyParameters"</code>). */ public static final String MODIFY_PARAMETERS= "org.eclipse.jdt.ui.actions.ModifyParameters"; //$NON-NLS-1$ /** * Refactor menu: name of standard Pull Up global action * (value <code>"org.eclipse.jdt.ui.actions.PullUp"</code>). */ public static final String PULL_UP= "org.eclipse.jdt.ui.actions.PullUp"; //$NON-NLS-1$ /** * Refactor menu: name of standard Push Down global action * (value <code>"org.eclipse.jdt.ui.actions.PushDown"</code>). * * @since 2.1 */ public static final String PUSH_DOWN= "org.eclipse.jdt.ui.actions.PushDown"; //$NON-NLS-1$ /** * Refactor menu: name of standard Move Element global action * (value <code>"org.eclipse.jdt.ui.actions.Move"</code>). */ public static final String MOVE= "org.eclipse.jdt.ui.actions.Move"; //$NON-NLS-1$ /** * Refactor menu: name of standard Rename Element global action * (value <code>"org.eclipse.jdt.ui.actions.Rename"</code>). */ public static final String RENAME= "org.eclipse.jdt.ui.actions.Rename"; //$NON-NLS-1$ /** * Refactor menu: name of standard Inline Temp global action * (value <code>"org.eclipse.jdt.ui.actions.InlineTemp"</code>). * @deprecated Use INLINE */ public static final String INLINE_TEMP= "org.eclipse.jdt.ui.actions.InlineTemp"; //$NON-NLS-1$ /** * Refactor menu: name of standard Extract Temp global action * (value <code>"org.eclipse.jdt.ui.actions.ExtractTemp"</code>). */ public static final String EXTRACT_TEMP= "org.eclipse.jdt.ui.actions.ExtractTemp"; //$NON-NLS-1$ /** * Refactor menu: name of standard Extract Constant global action * (value <code>"org.eclipse.jdt.ui.actions.ExtractConstant"</code>). * * @since 2.1 */ public static final String EXTRACT_CONSTANT= "org.eclipse.jdt.ui.actions.ExtractConstant"; //$NON-NLS-1$ /** * Refactor menu: name of standard Extract Method global action * (value <code>"org.eclipse.jdt.ui.actions.ExtractMethod"</code>). */ public static final String EXTRACT_METHOD= "org.eclipse.jdt.ui.actions.ExtractMethod"; //$NON-NLS-1$ /** * Refactor menu: name of standard Inline global action * (value <code>"org.eclipse.jdt.ui.actions.Inline"</code>). * * @since 2.1 */ public static final String INLINE= "org.eclipse.jdt.ui.actions.Inline"; //$NON-NLS-1$ /** * Refactor menu: name of standard Extract Interface global action * (value <code>"org.eclipse.jdt.ui.actions.ExtractInterface"</code>). * * @since 2.1 */ public static final String EXTRACT_INTERFACE= "org.eclipse.jdt.ui.actions.ExtractInterface"; //$NON-NLS-1$ /** * Refactor menu: name of standard global action to convert a nested type to a top level type * (value <code>"org.eclipse.jdt.ui.actions.MoveInnerToTop"</code>). * * @since 2.1 */ public static final String CONVERT_NESTED_TO_TOP= "org.eclipse.jdt.ui.actions.ConvertNestedToTop"; //$NON-NLS-1$ /** * Refactor menu: name of standard Use Supertype global action * (value <code>"org.eclipse.jdt.ui.actions.UseSupertype"</code>). * * @since 2.1 */ public static final String USE_SUPERTYPE= "org.eclipse.jdt.ui.actions.UseSupertype"; //$NON-NLS-1$ /** * Refactor menu: name of standard global action to convert a local * variable to a field (value <code>"org.eclipse.jdt.ui.actions.ConvertLocalToField"</code>). * * @since 2.1 */ public static final String CONVERT_LOCAL_TO_FIELD= "org.eclipse.jdt.ui.actions.ConvertLocalToField"; //$NON-NLS-1$ /** * Refactor menu: name of standard Covert Anonymous to Nested global action * (value <code>"org.eclipse.jdt.ui.actions.ConvertAnonymousToNested"</code>). * * @since 2.1 */ public static final String CONVERT_ANONYMOUS_TO_NESTED= "org.eclipse.jdt.ui.actions.ConvertAnonymousToNested"; //$NON-NLS-1$ // Search Menu /** * Search menu: name of standard Find References in Workspace global action * (value <code>"org.eclipse.jdt.ui.actions.ReferencesInWorkspace"</code>). */ public static final String FIND_REFERENCES_IN_WORKSPACE= "org.eclipse.jdt.ui.actions.ReferencesInWorkspace"; //$NON-NLS-1$ /** * Search menu: name of standard Find References in Project global action * (value <code>"org.eclipse.jdt.ui.actions.ReferencesInProject"</code>). */ public static final String FIND_REFERENCES_IN_PROJECT= "org.eclipse.jdt.ui.actions.ReferencesInProject"; //$NON-NLS-1$ /** * Search menu: name of standard Find References in Hierarchy global action * (value <code>"org.eclipse.jdt.ui.actions.ReferencesInHierarchy"</code>). */ public static final String FIND_REFERENCES_IN_HIERARCHY= "org.eclipse.jdt.ui.actions.ReferencesInHierarchy"; //$NON-NLS-1$ /** * Search menu: name of standard Find References in Working Set global action * (value <code>"org.eclipse.jdt.ui.actions.ReferencesInWorkingSet"</code>). */ public static final String FIND_REFERENCES_IN_WORKING_SET= "org.eclipse.jdt.ui.actions.ReferencesInWorkingSet"; //$NON-NLS-1$ /** * Search menu: name of standard Find Declarations in Workspace global action * (value <code>"org.eclipse.jdt.ui.actions.DeclarationsInWorkspace"</code>). */ public static final String FIND_DECLARATIONS_IN_WORKSPACE= "org.eclipse.jdt.ui.actions.DeclarationsInWorkspace"; //$NON-NLS-1$ /** * Search menu: name of standard Find Declarations in Project global action * (value <code>"org.eclipse.jdt.ui.actions.DeclarationsInProject"</code>). */ public static final String FIND_DECLARATIONS_IN_PROJECT= "org.eclipse.jdt.ui.actions.DeclarationsInProject"; //$NON-NLS-1$ /** * Search menu: name of standard Find Declarations in Hierarchy global action * (value <code>"org.eclipse.jdt.ui.actions.DeclarationsInHierarchy"</code>). */ public static final String FIND_DECLARATIONS_IN_HIERARCHY= "org.eclipse.jdt.ui.actions.DeclarationsInHierarchy"; //$NON-NLS-1$ /** * Search menu: name of standard Find Declarations in Working Set global action * (value <code>"org.eclipse.jdt.ui.actions.DeclarationsInWorkingSet"</code>). */ public static final String FIND_DECLARATIONS_IN_WORKING_SET= "org.eclipse.jdt.ui.actions.DeclarationsInWorkingSet"; //$NON-NLS-1$ /** * Search menu: name of standard Find Implementors in Workspace global action * (value <code>"org.eclipse.jdt.ui.actions.ImplementorsInWorkspace"</code>). */ public static final String FIND_IMPLEMENTORS_IN_WORKSPACE= "org.eclipse.jdt.ui.actions.ImplementorsInWorkspace"; //$NON-NLS-1$ /** * Search menu: name of standard Find Implementors in Project global action * (value <code>"org.eclipse.jdt.ui.actions.ImplementorsInProject"</code>). */ public static final String FIND_IMPLEMENTORS_IN_PROJECT= "org.eclipse.jdt.ui.actions.ImplementorsInProject"; //$NON-NLS-1$ /** * Search menu: name of standard Find Implementors in Working Set global action * (value <code>"org.eclipse.jdt.ui.actions.ImplementorsInWorkingSet"</code>). */ public static final String FIND_IMPLEMENTORS_IN_WORKING_SET= "org.eclipse.jdt.ui.actions.ImplementorsInWorkingSet"; //$NON-NLS-1$ /** * Search menu: name of standard Find Read Access in Workspace global action * (value <code>"org.eclipse.jdt.ui.actions.ReadAccessInWorkspace"</code>). */ public static final String FIND_READ_ACCESS_IN_WORKSPACE= "org.eclipse.jdt.ui.actions.ReadAccessInWorkspace"; //$NON-NLS-1$ /** * Search menu: name of standard Find Read Access in Project global action * (value <code>"org.eclipse.jdt.ui.actions.ReadAccessInProject"</code>). */ public static final String FIND_READ_ACCESS_IN_PROJECT= "org.eclipse.jdt.ui.actions.ReadAccessInProject"; //$NON-NLS-1$ /** * Search menu: name of standard Find Read Access in Hierarchy global action * (value <code>"org.eclipse.jdt.ui.actions.ReadAccessInHierarchy"</code>). */ public static final String FIND_READ_ACCESS_IN_HIERARCHY= "org.eclipse.jdt.ui.actions.ReadAccessInHierarchy"; //$NON-NLS-1$ /** * Search menu: name of standard Find Read Access in Working Set global action * (value <code>"org.eclipse.jdt.ui.actions.ReadAccessInWorkingSet"</code>). */ public static final String FIND_READ_ACCESS_IN_WORKING_SET= "org.eclipse.jdt.ui.actions.ReadAccessInWorkingSet"; //$NON-NLS-1$ /** * Search menu: name of standard Find Write Access in Workspace global action * (value <code>"org.eclipse.jdt.ui.actions.WriteAccessInWorkspace"</code>). */ public static final String FIND_WRITE_ACCESS_IN_WORKSPACE= "org.eclipse.jdt.ui.actions.WriteAccessInWorkspace"; //$NON-NLS-1$ /** * Search menu: name of standard Find Write Access in Project global action * (value <code>"org.eclipse.jdt.ui.actions.WriteAccessInProject"</code>). */ public static final String FIND_WRITE_ACCESS_IN_PROJECT= "org.eclipse.jdt.ui.actions.WriteAccessInProject"; //$NON-NLS-1$ /** * Search menu: name of standard Find Read Access in Hierarchy global action * (value <code>"org.eclipse.jdt.ui.actions.WriteAccessInHierarchy"</code>). */ public static final String FIND_WRITE_ACCESS_IN_HIERARCHY= "org.eclipse.jdt.ui.actions.WriteAccessInHierarchy"; //$NON-NLS-1$ /** * Search menu: name of standard Find Read Access in Working Set global action * (value <code>"org.eclipse.jdt.ui.actions.WriteAccessInWorkingSet"</code>). */ public static final String FIND_WRITE_ACCESS_IN_WORKING_SET= "org.eclipse.jdt.ui.actions.WriteAccessInWorkingSet"; //$NON-NLS-1$ /** * Search menu: name of standard Occurrences in File global action (value * <code>"org.eclipse.jdt.ui.actions.OccurrencesInFile"</code>). * * @since 2.1 */ public static final String FIND_OCCURRENCES_IN_FILE= "org.eclipse.jdt.ui.actions.OccurrencesInFile"; //$NON-NLS-1$ }
27,005
Bug 27005 [typing] Smart string wrapping
Using1119, I noticed something quite annoying. Consider the following code: String s = ""; If you copy some code like: class A { // comment } And then you paste it between the double-quotes, you will end up with: String s = "public class A { // comment" + "}"; The problem is that this code is not equivalent. I should have a line break at the end of the first line. Otherwise the code contained in my string s doesn't even compile. So the feature is nice, but cannot be used till a line break is added at the end of each part of the string concatenation. So in the above example, I would expect: String s = "public class A { // comment\n" + "}"; or String s = "public class A { // comment\r\n" + "}"; or String s = "public class A { // comment\r" + "}"; The line break could be chosen according to the line breaks in the current file or the platform line delimiter.
resolved fixed
c2cedc9
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2003-09-11T17:16:57Z
2002-11-22T18:33:20Z
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/JavaEditorPreferencePage.java
/******************************************************************************* * Copyright (c) 2000, 2003 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Common Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/cpl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.jdt.internal.ui.preferences; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.HashMap; import java.util.Iterator; import java.util.Map; import java.util.StringTokenizer; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Preferences; import org.eclipse.swt.SWT; import org.eclipse.swt.custom.StyledText; import org.eclipse.swt.events.KeyEvent; import org.eclipse.swt.events.KeyListener; import org.eclipse.swt.events.ModifyEvent; import org.eclipse.swt.events.ModifyListener; 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.Point; import org.eclipse.swt.graphics.RGB; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.layout.RowLayout; import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Control; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Group; import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.List; import org.eclipse.swt.widgets.TabFolder; import org.eclipse.swt.widgets.TabItem; import org.eclipse.swt.widgets.Text; import org.eclipse.jface.action.Action; import org.eclipse.jface.dialogs.Dialog; import org.eclipse.jface.preference.IPreferenceStore; import org.eclipse.jface.preference.PreferenceConverter; import org.eclipse.jface.preference.PreferencePage; import org.eclipse.jface.resource.JFaceResources; import org.eclipse.jface.util.IPropertyChangeListener; import org.eclipse.jface.util.PropertyChangeEvent; import org.eclipse.jface.text.Document; import org.eclipse.jface.text.IDocument; import org.eclipse.jface.text.source.ISourceViewer; import org.eclipse.jface.text.source.SourceViewer; import org.eclipse.ui.IWorkbench; import org.eclipse.ui.IWorkbenchPreferencePage; import org.eclipse.ui.help.WorkbenchHelp; import org.eclipse.ui.texteditor.AnnotationPreference; import org.eclipse.ui.texteditor.ExtendedTextEditorPreferenceConstants; import org.eclipse.ui.texteditor.MarkerAnnotationPreferences; import org.eclipse.jdt.core.JavaCore; import org.eclipse.jdt.ui.PreferenceConstants; import org.eclipse.jdt.ui.text.JavaSourceViewerConfiguration; import org.eclipse.jdt.ui.text.JavaTextTools; import org.eclipse.jdt.internal.ui.IJavaHelpContextIds; import org.eclipse.jdt.internal.ui.JavaPlugin; import org.eclipse.jdt.internal.ui.dialogs.StatusInfo; import org.eclipse.jdt.internal.ui.dialogs.StatusUtil; import org.eclipse.jdt.internal.ui.javaeditor.EditorUtility; import org.eclipse.jdt.internal.ui.util.TabFolderLayout; /* * The page for setting the editor options. */ public class JavaEditorPreferencePage extends PreferencePage implements IWorkbenchPreferencePage { private static final String BOLD= PreferenceConstants.EDITOR_BOLD_SUFFIX; private static final String COMPILER_TASK_TAGS= JavaCore.COMPILER_TASK_TAGS; private static final String DELIMITER= PreferencesMessages.getString("JavaEditorPreferencePage.navigation.delimiter"); //$NON-NLS-1$ public final OverlayPreferenceStore.OverlayKey[] fKeys; private final String[][] fSyntaxColorListModel= new String[][] { { PreferencesMessages.getString("JavaEditorPreferencePage.multiLineComment"), PreferenceConstants.EDITOR_MULTI_LINE_COMMENT_COLOR }, //$NON-NLS-1$ { PreferencesMessages.getString("JavaEditorPreferencePage.singleLineComment"), PreferenceConstants.EDITOR_SINGLE_LINE_COMMENT_COLOR }, //$NON-NLS-1$ { PreferencesMessages.getString("JavaEditorPreferencePage.keywords"), PreferenceConstants.EDITOR_JAVA_KEYWORD_COLOR }, //$NON-NLS-1$ { PreferencesMessages.getString("JavaEditorPreferencePage.strings"), PreferenceConstants.EDITOR_STRING_COLOR }, //$NON-NLS-1$ { PreferencesMessages.getString("JavaEditorPreferencePage.methodNames"), PreferenceConstants.EDITOR_JAVA_METHOD_NAME_COLOR }, //$NON-NLS-1$ { PreferencesMessages.getString("JavaEditorPreferencePage.operators"), PreferenceConstants.EDITOR_JAVA_OPERATOR_COLOR }, //$NON-NLS-1$ { PreferencesMessages.getString("JavaEditorPreferencePage.others"), PreferenceConstants.EDITOR_JAVA_DEFAULT_COLOR }, //$NON-NLS-1$ { PreferencesMessages.getString("JavaEditorPreferencePage.javaCommentTaskTags"), PreferenceConstants.EDITOR_TASK_TAG_COLOR }, //$NON-NLS-1$ { PreferencesMessages.getString("JavaEditorPreferencePage.javaDocKeywords"), PreferenceConstants.EDITOR_JAVADOC_KEYWORD_COLOR }, //$NON-NLS-1$ { PreferencesMessages.getString("JavaEditorPreferencePage.javaDocHtmlTags"), PreferenceConstants.EDITOR_JAVADOC_TAG_COLOR }, //$NON-NLS-1$ { PreferencesMessages.getString("JavaEditorPreferencePage.javaDocLinks"), PreferenceConstants.EDITOR_JAVADOC_LINKS_COLOR }, //$NON-NLS-1$ { PreferencesMessages.getString("JavaEditorPreferencePage.javaDocOthers"), PreferenceConstants.EDITOR_JAVADOC_DEFAULT_COLOR } //$NON-NLS-1$ }; private final String[][] fAppearanceColorListModel= new String[][] { {PreferencesMessages.getString("JavaEditorPreferencePage.lineNumberForegroundColor"), ExtendedTextEditorPreferenceConstants.EDITOR_LINE_NUMBER_RULER_COLOR}, //$NON-NLS-1$ {PreferencesMessages.getString("JavaEditorPreferencePage.matchingBracketsHighlightColor2"), PreferenceConstants.EDITOR_MATCHING_BRACKETS_COLOR}, //$NON-NLS-1$ {PreferencesMessages.getString("JavaEditorPreferencePage.currentLineHighlighColor"), ExtendedTextEditorPreferenceConstants.EDITOR_CURRENT_LINE_COLOR}, //$NON-NLS-1$ {PreferencesMessages.getString("JavaEditorPreferencePage.printMarginColor2"), ExtendedTextEditorPreferenceConstants.EDITOR_PRINT_MARGIN_COLOR}, //$NON-NLS-1$ {PreferencesMessages.getString("JavaEditorPreferencePage.findScopeColor2"), PreferenceConstants.EDITOR_FIND_SCOPE_COLOR}, //$NON-NLS-1$ {PreferencesMessages.getString("JavaEditorPreferencePage.linkedPositionColor2"), PreferenceConstants.EDITOR_LINKED_POSITION_COLOR}, //$NON-NLS-1$ {PreferencesMessages.getString("JavaEditorPreferencePage.linkColor2"), PreferenceConstants.EDITOR_LINK_COLOR}, //$NON-NLS-1$ }; private final String[][] fAnnotationColorListModel; private final String[][] fContentAssistColorListModel= new String[][] { {PreferencesMessages.getString("JavaEditorPreferencePage.backgroundForCompletionProposals"), PreferenceConstants.CODEASSIST_PROPOSALS_BACKGROUND }, //$NON-NLS-1$ {PreferencesMessages.getString("JavaEditorPreferencePage.foregroundForCompletionProposals"), PreferenceConstants.CODEASSIST_PROPOSALS_FOREGROUND }, //$NON-NLS-1$ {PreferencesMessages.getString("JavaEditorPreferencePage.backgroundForMethodParameters"), PreferenceConstants.CODEASSIST_PARAMETERS_BACKGROUND }, //$NON-NLS-1$ {PreferencesMessages.getString("JavaEditorPreferencePage.foregroundForMethodParameters"), PreferenceConstants.CODEASSIST_PARAMETERS_FOREGROUND }, //$NON-NLS-1$ {PreferencesMessages.getString("JavaEditorPreferencePage.backgroundForCompletionReplacement"), PreferenceConstants.CODEASSIST_REPLACEMENT_BACKGROUND }, //$NON-NLS-1$ {PreferencesMessages.getString("JavaEditorPreferencePage.foregroundForCompletionReplacement"), PreferenceConstants.CODEASSIST_REPLACEMENT_FOREGROUND } //$NON-NLS-1$ }; private OverlayPreferenceStore fOverlayStore; private JavaTextTools fJavaTextTools; private JavaEditorHoverConfigurationBlock fJavaEditorHoverConfigurationBlock; private Map fColorButtons= new HashMap(); private Map fCheckBoxes= new HashMap(); private SelectionListener fCheckBoxListener= new SelectionListener() { public void widgetDefaultSelected(SelectionEvent e) { } public void widgetSelected(SelectionEvent e) { Button button= (Button) e.widget; fOverlayStore.setValue((String) fCheckBoxes.get(button), button.getSelection()); } }; private Map fTextFields= new HashMap(); private ModifyListener fTextFieldListener= new ModifyListener() { public void modifyText(ModifyEvent e) { Text text= (Text) e.widget; fOverlayStore.setValue((String) fTextFields.get(text), text.getText()); } }; private ArrayList fNumberFields= new ArrayList(); private ModifyListener fNumberFieldListener= new ModifyListener() { public void modifyText(ModifyEvent e) { numberFieldChanged((Text) e.widget); } }; private List fSyntaxColorList; private List fAppearanceColorList; private List fContentAssistColorList; private List fAnnotationList; private ColorEditor fSyntaxForegroundColorEditor; private ColorEditor fAppearanceColorEditor; private ColorEditor fAnnotationForegroundColorEditor; private ColorEditor fContentAssistColorEditor; private ColorEditor fBackgroundColorEditor; private Button fBackgroundDefaultRadioButton; private Button fBackgroundCustomRadioButton; private Button fBackgroundColorButton; private Button fBoldCheckBox; private Button fAddJavaDocTagsButton; private Button fGuessMethodArgumentsButton; private SourceViewer fPreviewViewer; private Color fBackgroundColor; private Control fAutoInsertDelayText; private Control fAutoInsertJavaTriggerText; private Control fAutoInsertJavaDocTriggerText; private Label fAutoInsertDelayLabel; private Label fAutoInsertJavaTriggerLabel; private Label fAutoInsertJavaDocTriggerLabel; private Button fShowInTextCheckBox; private Button fShowInOverviewRulerCheckBox; private Text fBrowserLikeLinksKeyModifierText; private Button fBrowserLikeLinksCheckBox; private StatusInfo fBrowserLikeLinksKeyModifierStatus; private Button fCompletionInsertsRadioButton; private Button fCompletionOverwritesRadioButton; public JavaEditorPreferencePage() { setDescription(PreferencesMessages.getString("JavaEditorPreferencePage.description")); //$NON-NLS-1$ setPreferenceStore(JavaPlugin.getDefault().getPreferenceStore()); MarkerAnnotationPreferences markerAnnotationPreferences= new MarkerAnnotationPreferences(); fKeys= createOverlayStoreKeys(markerAnnotationPreferences); fOverlayStore= new OverlayPreferenceStore(getPreferenceStore(), fKeys); fAnnotationColorListModel= createAnnotationTypeListModel(markerAnnotationPreferences); } private OverlayPreferenceStore.OverlayKey[] createOverlayStoreKeys(MarkerAnnotationPreferences preferences) { ArrayList overlayKeys= new ArrayList(); Iterator e= preferences.getAnnotationPreferences().iterator(); overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_FOREGROUND_COLOR)); overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_FOREGROUND_DEFAULT_COLOR)); overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_BACKGROUND_COLOR)); overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_BACKGROUND_DEFAULT_COLOR)); overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.INT, PreferenceConstants.EDITOR_TAB_WIDTH)); overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_MULTI_LINE_COMMENT_COLOR)); overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_MULTI_LINE_COMMENT_BOLD)); overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_SINGLE_LINE_COMMENT_COLOR)); overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_SINGLE_LINE_COMMENT_BOLD)); overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_JAVA_KEYWORD_COLOR)); overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_JAVA_KEYWORD_BOLD)); overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_STRING_COLOR)); overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_STRING_BOLD)); overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_JAVA_DEFAULT_COLOR)); overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_JAVA_DEFAULT_BOLD)); overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_TASK_TAG_COLOR)); overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_TASK_TAG_BOLD)); overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_JAVA_METHOD_NAME_COLOR)); overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_JAVA_METHOD_NAME_BOLD)); overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_JAVA_OPERATOR_COLOR)); overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_JAVA_OPERATOR_BOLD)); overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_JAVADOC_KEYWORD_COLOR)); overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_JAVADOC_KEYWORD_BOLD)); overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_JAVADOC_TAG_COLOR)); overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_JAVADOC_TAG_BOLD)); overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_JAVADOC_LINKS_COLOR)); overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_JAVADOC_LINKS_BOLD)); overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_JAVADOC_DEFAULT_COLOR)); overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_JAVADOC_DEFAULT_BOLD)); overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_MATCHING_BRACKETS_COLOR)); overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_MATCHING_BRACKETS)); overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, ExtendedTextEditorPreferenceConstants.EDITOR_CURRENT_LINE_COLOR)); overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, ExtendedTextEditorPreferenceConstants.EDITOR_CURRENT_LINE)); overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, ExtendedTextEditorPreferenceConstants.EDITOR_PRINT_MARGIN_COLOR)); overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.INT, ExtendedTextEditorPreferenceConstants.EDITOR_PRINT_MARGIN_COLUMN)); overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, ExtendedTextEditorPreferenceConstants.EDITOR_PRINT_MARGIN)); overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_FIND_SCOPE_COLOR)); overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_LINKED_POSITION_COLOR)); overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_LINK_COLOR)); overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_CORRECTION_INDICATION)); overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_EVALUTE_TEMPORARY_PROBLEMS)); overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, ExtendedTextEditorPreferenceConstants.EDITOR_OVERVIEW_RULER)); overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, ExtendedTextEditorPreferenceConstants.EDITOR_LINE_NUMBER_RULER_COLOR)); overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, ExtendedTextEditorPreferenceConstants.EDITOR_LINE_NUMBER_RULER)); overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_SPACES_FOR_TABS)); overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.CODEASSIST_AUTOACTIVATION)); overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.INT, PreferenceConstants.CODEASSIST_AUTOACTIVATION_DELAY)); overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.CODEASSIST_AUTOINSERT)); overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.CODEASSIST_PROPOSALS_BACKGROUND)); overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.CODEASSIST_PROPOSALS_FOREGROUND)); overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.CODEASSIST_PARAMETERS_BACKGROUND)); overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.CODEASSIST_PARAMETERS_FOREGROUND)); overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.CODEASSIST_REPLACEMENT_BACKGROUND)); overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.CODEASSIST_REPLACEMENT_FOREGROUND)); overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.CODEASSIST_AUTOACTIVATION_TRIGGERS_JAVA)); overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.CODEASSIST_AUTOACTIVATION_TRIGGERS_JAVADOC)); overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.CODEASSIST_SHOW_VISIBLE_PROPOSALS)); overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.CODEASSIST_ORDER_PROPOSALS)); overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.CODEASSIST_CASE_SENSITIVITY)); overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.CODEASSIST_ADDIMPORT)); overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.CODEASSIST_INSERT_COMPLETION)); overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.CODEASSIST_FILL_ARGUMENT_NAMES)); overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.CODEASSIST_GUESS_METHOD_ARGUMENTS)); overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_SMART_PASTE)); overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_CLOSE_STRINGS)); overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_CLOSE_BRACKETS)); overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_CLOSE_BRACES)); overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_CLOSE_JAVADOCS)); overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_WRAP_STRINGS)); overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_ADD_JAVADOC_TAGS)); // overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_FORMAT_JAVADOCS)); overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_SMART_HOME_END)); overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_SUB_WORD_NAVIGATION)); overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_SHOW_TEXT_HOVER_AFFORDANCE)); overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_TEXT_HOVER_MODIFIERS)); overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_TEXT_HOVER_MODIFIER_MASKS)); overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_BROWSER_LIKE_LINKS)); overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_BROWSER_LIKE_LINKS_KEY_MODIFIER)); overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_BROWSER_LIKE_LINKS_KEY_MODIFIER_MASK)); while (e.hasNext()) { AnnotationPreference info= (AnnotationPreference) e.next(); overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, info.getColorPreferenceKey())); overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, info.getTextPreferenceKey())); overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, info.getOverviewRulerPreferenceKey())); } OverlayPreferenceStore.OverlayKey[] keys= new OverlayPreferenceStore.OverlayKey[overlayKeys.size()]; overlayKeys.toArray(keys); return keys; } /* * @see IWorkbenchPreferencePage#init() */ public void init(IWorkbench workbench) { } /* * @see PreferencePage#createControl(Composite) */ public void createControl(Composite parent) { super.createControl(parent); WorkbenchHelp.setHelp(getControl(), IJavaHelpContextIds.JAVA_EDITOR_PREFERENCE_PAGE); } private void handleSyntaxColorListSelection() { int i= fSyntaxColorList.getSelectionIndex(); String key= fSyntaxColorListModel[i][1]; RGB rgb= PreferenceConverter.getColor(fOverlayStore, key); fSyntaxForegroundColorEditor.setColorValue(rgb); fBoldCheckBox.setSelection(fOverlayStore.getBoolean(key + BOLD)); } private void handleAppearanceColorListSelection() { int i= fAppearanceColorList.getSelectionIndex(); String key= fAppearanceColorListModel[i][1]; RGB rgb= PreferenceConverter.getColor(fOverlayStore, key); fAppearanceColorEditor.setColorValue(rgb); } private void handleContentAssistColorListSelection() { int i= fContentAssistColorList.getSelectionIndex(); String key= fContentAssistColorListModel[i][1]; RGB rgb= PreferenceConverter.getColor(fOverlayStore, key); fContentAssistColorEditor.setColorValue(rgb); } private void handleAnnotationListSelection() { int i= fAnnotationList.getSelectionIndex(); String key= fAnnotationColorListModel[i][1]; RGB rgb= PreferenceConverter.getColor(fOverlayStore, key); fAnnotationForegroundColorEditor.setColorValue(rgb); key= fAnnotationColorListModel[i][2]; fShowInTextCheckBox.setSelection(fOverlayStore.getBoolean(key)); key= fAnnotationColorListModel[i][3]; fShowInOverviewRulerCheckBox.setSelection(fOverlayStore.getBoolean(key)); } private Control createSyntaxPage(Composite parent) { Composite colorComposite= new Composite(parent, SWT.NULL); colorComposite.setLayout(new GridLayout()); Group backgroundComposite= new Group(colorComposite, SWT.SHADOW_ETCHED_IN); backgroundComposite.setLayout(new RowLayout()); backgroundComposite.setText(PreferencesMessages.getString("JavaEditorPreferencePage.backgroundColor"));//$NON-NLS-1$ SelectionListener backgroundSelectionListener= new SelectionListener() { public void widgetSelected(SelectionEvent e) { boolean custom= fBackgroundCustomRadioButton.getSelection(); fBackgroundColorButton.setEnabled(custom); fOverlayStore.setValue(PreferenceConstants.EDITOR_BACKGROUND_DEFAULT_COLOR, !custom); } public void widgetDefaultSelected(SelectionEvent e) {} }; fBackgroundDefaultRadioButton= new Button(backgroundComposite, SWT.RADIO | SWT.LEFT); fBackgroundDefaultRadioButton.setText(PreferencesMessages.getString("JavaEditorPreferencePage.systemDefault")); //$NON-NLS-1$ fBackgroundDefaultRadioButton.addSelectionListener(backgroundSelectionListener); fBackgroundCustomRadioButton= new Button(backgroundComposite, SWT.RADIO | SWT.LEFT); fBackgroundCustomRadioButton.setText(PreferencesMessages.getString("JavaEditorPreferencePage.custom")); //$NON-NLS-1$ fBackgroundCustomRadioButton.addSelectionListener(backgroundSelectionListener); fBackgroundColorEditor= new ColorEditor(backgroundComposite); fBackgroundColorButton= fBackgroundColorEditor.getButton(); Label label= new Label(colorComposite, SWT.LEFT); label.setText(PreferencesMessages.getString("JavaEditorPreferencePage.foreground")); //$NON-NLS-1$ label.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); Composite editorComposite= new Composite(colorComposite, SWT.NONE); GridLayout layout= new GridLayout(); layout.numColumns= 2; layout.marginHeight= 0; layout.marginWidth= 0; editorComposite.setLayout(layout); GridData gd= new GridData(GridData.FILL_BOTH); editorComposite.setLayoutData(gd); fSyntaxColorList= new List(editorComposite, SWT.SINGLE | SWT.V_SCROLL | SWT.BORDER); gd= new GridData(GridData.FILL_BOTH); gd.heightHint= convertHeightInCharsToPixels(5); fSyntaxColorList.setLayoutData(gd); Composite stylesComposite= new Composite(editorComposite, SWT.NONE); layout= new GridLayout(); layout.marginHeight= 0; layout.marginWidth= 0; layout.numColumns= 2; stylesComposite.setLayout(layout); stylesComposite.setLayoutData(new GridData(GridData.FILL_BOTH)); label= new Label(stylesComposite, SWT.LEFT); label.setText(PreferencesMessages.getString("JavaEditorPreferencePage.color")); //$NON-NLS-1$ gd= new GridData(); gd.horizontalAlignment= GridData.BEGINNING; label.setLayoutData(gd); fSyntaxForegroundColorEditor= new ColorEditor(stylesComposite); Button foregroundColorButton= fSyntaxForegroundColorEditor.getButton(); gd= new GridData(GridData.FILL_HORIZONTAL); gd.horizontalAlignment= GridData.BEGINNING; foregroundColorButton.setLayoutData(gd); fBoldCheckBox= new Button(stylesComposite, SWT.CHECK); fBoldCheckBox.setText(PreferencesMessages.getString("JavaEditorPreferencePage.bold")); //$NON-NLS-1$ gd= new GridData(GridData.FILL_HORIZONTAL); gd.horizontalAlignment= GridData.BEGINNING; gd.horizontalSpan= 2; fBoldCheckBox.setLayoutData(gd); label= new Label(colorComposite, SWT.LEFT); label.setText(PreferencesMessages.getString("JavaEditorPreferencePage.preview")); //$NON-NLS-1$ label.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); Control previewer= createPreviewer(colorComposite); gd= new GridData(GridData.FILL_BOTH); gd.widthHint= convertWidthInCharsToPixels(20); gd.heightHint= convertHeightInCharsToPixels(5); previewer.setLayoutData(gd); fSyntaxColorList.addSelectionListener(new SelectionListener() { public void widgetDefaultSelected(SelectionEvent e) { // do nothing } public void widgetSelected(SelectionEvent e) { handleSyntaxColorListSelection(); } }); foregroundColorButton.addSelectionListener(new SelectionListener() { public void widgetDefaultSelected(SelectionEvent e) { // do nothing } public void widgetSelected(SelectionEvent e) { int i= fSyntaxColorList.getSelectionIndex(); String key= fSyntaxColorListModel[i][1]; PreferenceConverter.setValue(fOverlayStore, key, fSyntaxForegroundColorEditor.getColorValue()); } }); fBackgroundColorButton.addSelectionListener(new SelectionListener() { public void widgetDefaultSelected(SelectionEvent e) { // do nothing } public void widgetSelected(SelectionEvent e) { PreferenceConverter.setValue(fOverlayStore, PreferenceConstants.EDITOR_BACKGROUND_COLOR, fBackgroundColorEditor.getColorValue()); } }); fBoldCheckBox.addSelectionListener(new SelectionListener() { public void widgetDefaultSelected(SelectionEvent e) { // do nothing } public void widgetSelected(SelectionEvent e) { int i= fSyntaxColorList.getSelectionIndex(); String key= fSyntaxColorListModel[i][1]; fOverlayStore.setValue(key + BOLD, fBoldCheckBox.getSelection()); } }); return colorComposite; } private Control createPreviewer(Composite parent) { Preferences coreStore= createTemporaryCorePreferenceStore(); fJavaTextTools= new JavaTextTools(fOverlayStore, coreStore, false); fPreviewViewer= new SourceViewer(parent, null, SWT.V_SCROLL | SWT.H_SCROLL | SWT.BORDER); fPreviewViewer.configure(new JavaSourceViewerConfiguration(fJavaTextTools, null)); fPreviewViewer.getTextWidget().setFont(JFaceResources.getFontRegistry().get(JFaceResources.TEXT_FONT)); fPreviewViewer.setEditable(false); initializeViewerColors(fPreviewViewer); String content= loadPreviewContentFromFile("ColorSettingPreviewCode.txt"); //$NON-NLS-1$ IDocument document= new Document(content); fJavaTextTools.setupJavaDocumentPartitioner(document); fPreviewViewer.setDocument(document); fOverlayStore.addPropertyChangeListener(new IPropertyChangeListener() { public void propertyChange(PropertyChangeEvent event) { String p= event.getProperty(); if (p.equals(PreferenceConstants.EDITOR_BACKGROUND_COLOR) || p.equals(PreferenceConstants.EDITOR_BACKGROUND_DEFAULT_COLOR)) { initializeViewerColors(fPreviewViewer); } fPreviewViewer.invalidateTextPresentation(); } }); return fPreviewViewer.getControl(); } private Preferences createTemporaryCorePreferenceStore() { Preferences result= new Preferences(); result.setValue(COMPILER_TASK_TAGS, "TASK"); //$NON-NLS-1$ return result; } /** * Initializes the given viewer's colors. * * @param viewer the viewer to be initialized */ private void initializeViewerColors(ISourceViewer viewer) { IPreferenceStore store= fOverlayStore; if (store != null) { StyledText styledText= viewer.getTextWidget(); // ---------- background color ---------------------- Color color= store.getBoolean(PreferenceConstants.EDITOR_BACKGROUND_DEFAULT_COLOR) ? null : createColor(store, PreferenceConstants.EDITOR_BACKGROUND_COLOR, styledText.getDisplay()); styledText.setBackground(color); if (fBackgroundColor != null) fBackgroundColor.dispose(); fBackgroundColor= color; } } /** * Creates a color from the information stored in the given preference store. * Returns <code>null</code> if there is no such information available. */ private Color createColor(IPreferenceStore store, String key, Display display) { RGB rgb= null; if (store.contains(key)) { if (store.isDefault(key)) rgb= PreferenceConverter.getDefaultColor(store, key); else rgb= PreferenceConverter.getColor(store, key); if (rgb != null) return new Color(display, rgb); } return null; } private Control createAppearancePage(Composite parent) { Composite appearanceComposite= new Composite(parent, SWT.NONE); GridLayout layout= new GridLayout(); layout.numColumns= 2; appearanceComposite.setLayout(layout); String label= PreferencesMessages.getString("JavaEditorPreferencePage.displayedTabWidth"); //$NON-NLS-1$ addTextField(appearanceComposite, label, PreferenceConstants.EDITOR_TAB_WIDTH, 3, 0, true); label= PreferencesMessages.getString("JavaEditorPreferencePage.printMarginColumn"); //$NON-NLS-1$ addTextField(appearanceComposite, label, ExtendedTextEditorPreferenceConstants.EDITOR_PRINT_MARGIN_COLUMN, 3, 0, true); label= PreferencesMessages.getString("JavaEditorPreferencePage.showOverviewRuler"); //$NON-NLS-1$ addCheckBox(appearanceComposite, label, ExtendedTextEditorPreferenceConstants.EDITOR_OVERVIEW_RULER, 0); label= PreferencesMessages.getString("JavaEditorPreferencePage.showLineNumbers"); //$NON-NLS-1$ addCheckBox(appearanceComposite, label, ExtendedTextEditorPreferenceConstants.EDITOR_LINE_NUMBER_RULER, 0); label= PreferencesMessages.getString("JavaEditorPreferencePage.highlightMatchingBrackets"); //$NON-NLS-1$ addCheckBox(appearanceComposite, label, PreferenceConstants.EDITOR_MATCHING_BRACKETS, 0); label= PreferencesMessages.getString("JavaEditorPreferencePage.highlightCurrentLine"); //$NON-NLS-1$ addCheckBox(appearanceComposite, label, ExtendedTextEditorPreferenceConstants.EDITOR_CURRENT_LINE, 0); label= PreferencesMessages.getString("JavaEditorPreferencePage.showPrintMargin"); //$NON-NLS-1$ addCheckBox(appearanceComposite, label, ExtendedTextEditorPreferenceConstants.EDITOR_PRINT_MARGIN, 0); Label l= new Label(appearanceComposite, SWT.LEFT ); GridData gd= new GridData(GridData.HORIZONTAL_ALIGN_FILL); gd.horizontalSpan= 2; gd.heightHint= convertHeightInCharsToPixels(1) / 2; l.setLayoutData(gd); l= new Label(appearanceComposite, SWT.LEFT); l.setText(PreferencesMessages.getString("JavaEditorPreferencePage.appearanceOptions")); //$NON-NLS-1$ gd= new GridData(GridData.HORIZONTAL_ALIGN_FILL); gd.horizontalSpan= 2; l.setLayoutData(gd); Composite editorComposite= new Composite(appearanceComposite, SWT.NONE); layout= new GridLayout(); layout.numColumns= 2; layout.marginHeight= 0; layout.marginWidth= 0; editorComposite.setLayout(layout); gd= new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.FILL_VERTICAL); gd.horizontalSpan= 2; editorComposite.setLayoutData(gd); fAppearanceColorList= new List(editorComposite, SWT.SINGLE | SWT.V_SCROLL | SWT.BORDER); gd= new GridData(GridData.VERTICAL_ALIGN_BEGINNING | GridData.FILL_HORIZONTAL); gd.heightHint= convertHeightInCharsToPixels(8); fAppearanceColorList.setLayoutData(gd); Composite stylesComposite= new Composite(editorComposite, SWT.NONE); layout= new GridLayout(); layout.marginHeight= 0; layout.marginWidth= 0; layout.numColumns= 2; stylesComposite.setLayout(layout); stylesComposite.setLayoutData(new GridData(GridData.FILL_BOTH)); l= new Label(stylesComposite, SWT.LEFT); l.setText(PreferencesMessages.getString("JavaEditorPreferencePage.color")); //$NON-NLS-1$ gd= new GridData(); gd.horizontalAlignment= GridData.BEGINNING; l.setLayoutData(gd); fAppearanceColorEditor= new ColorEditor(stylesComposite); Button foregroundColorButton= fAppearanceColorEditor.getButton(); gd= new GridData(GridData.FILL_HORIZONTAL); gd.horizontalAlignment= GridData.BEGINNING; foregroundColorButton.setLayoutData(gd); fAppearanceColorList.addSelectionListener(new SelectionListener() { public void widgetDefaultSelected(SelectionEvent e) { // do nothing } public void widgetSelected(SelectionEvent e) { handleAppearanceColorListSelection(); } }); foregroundColorButton.addSelectionListener(new SelectionListener() { public void widgetDefaultSelected(SelectionEvent e) { // do nothing } public void widgetSelected(SelectionEvent e) { int i= fAppearanceColorList.getSelectionIndex(); String key= fAppearanceColorListModel[i][1]; PreferenceConverter.setValue(fOverlayStore, key, fAppearanceColorEditor.getColorValue()); } }); return appearanceComposite; } private Control createAnnotationsPage(Composite parent) { Composite composite= new Composite(parent, SWT.NULL); GridLayout layout= new GridLayout(); layout.numColumns= 2; composite.setLayout(layout); String text= PreferencesMessages.getString("JavaEditorPreferencePage.analyseAnnotationsWhileTyping"); //$NON-NLS-1$ addCheckBox(composite, text, PreferenceConstants.EDITOR_EVALUTE_TEMPORARY_PROBLEMS, 0); text= PreferencesMessages.getString("JavaEditorPreferencePage.showQuickFixables"); //$NON-NLS-1$ addCheckBox(composite, text, PreferenceConstants.EDITOR_CORRECTION_INDICATION, 0); addFiller(composite); Label label= new Label(composite, SWT.LEFT); label.setText(PreferencesMessages.getString("JavaEditorPreferencePage.annotationPresentationOptions")); //$NON-NLS-1$ GridData gd= new GridData(GridData.HORIZONTAL_ALIGN_FILL); gd.horizontalSpan= 2; label.setLayoutData(gd); Composite editorComposite= new Composite(composite, SWT.NONE); layout= new GridLayout(); layout.numColumns= 2; layout.marginHeight= 0; layout.marginWidth= 0; editorComposite.setLayout(layout); gd= new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.FILL_VERTICAL); gd.horizontalSpan= 2; editorComposite.setLayoutData(gd); fAnnotationList= new List(editorComposite, SWT.SINGLE | SWT.V_SCROLL | SWT.BORDER); gd= new GridData(GridData.VERTICAL_ALIGN_BEGINNING | GridData.FILL_HORIZONTAL); gd.heightHint= convertHeightInCharsToPixels(10); fAnnotationList.setLayoutData(gd); Composite optionsComposite= new Composite(editorComposite, SWT.NONE); layout= new GridLayout(); layout.marginHeight= 0; layout.marginWidth= 0; layout.numColumns= 2; optionsComposite.setLayout(layout); optionsComposite.setLayoutData(new GridData(GridData.FILL_BOTH)); fShowInTextCheckBox= new Button(optionsComposite, SWT.CHECK); fShowInTextCheckBox.setText(PreferencesMessages.getString("JavaEditorPreferencePage.annotations.showInText")); //$NON-NLS-1$ gd= new GridData(GridData.FILL_HORIZONTAL); gd.horizontalAlignment= GridData.BEGINNING; gd.horizontalSpan= 2; fShowInTextCheckBox.setLayoutData(gd); fShowInOverviewRulerCheckBox= new Button(optionsComposite, SWT.CHECK); fShowInOverviewRulerCheckBox.setText(PreferencesMessages.getString("JavaEditorPreferencePage.annotations.showInOverviewRuler")); //$NON-NLS-1$ gd= new GridData(GridData.FILL_HORIZONTAL); gd.horizontalAlignment= GridData.BEGINNING; gd.horizontalSpan= 2; fShowInOverviewRulerCheckBox.setLayoutData(gd); label= new Label(optionsComposite, SWT.LEFT); label.setText(PreferencesMessages.getString("JavaEditorPreferencePage.annotations.color")); //$NON-NLS-1$ gd= new GridData(); gd.horizontalAlignment= GridData.BEGINNING; label.setLayoutData(gd); fAnnotationForegroundColorEditor= new ColorEditor(optionsComposite); Button foregroundColorButton= fAnnotationForegroundColorEditor.getButton(); gd= new GridData(GridData.FILL_HORIZONTAL); gd.horizontalAlignment= GridData.BEGINNING; foregroundColorButton.setLayoutData(gd); fAnnotationList.addSelectionListener(new SelectionListener() { public void widgetDefaultSelected(SelectionEvent e) { // do nothing } public void widgetSelected(SelectionEvent e) { handleAnnotationListSelection(); } }); fShowInTextCheckBox.addSelectionListener(new SelectionListener() { public void widgetDefaultSelected(SelectionEvent e) { // do nothing } public void widgetSelected(SelectionEvent e) { int i= fAnnotationList.getSelectionIndex(); String key= fAnnotationColorListModel[i][2]; fOverlayStore.setValue(key, fShowInTextCheckBox.getSelection()); } }); fShowInOverviewRulerCheckBox.addSelectionListener(new SelectionListener() { public void widgetDefaultSelected(SelectionEvent e) { // do nothing } public void widgetSelected(SelectionEvent e) { int i= fAnnotationList.getSelectionIndex(); String key= fAnnotationColorListModel[i][3]; fOverlayStore.setValue(key, fShowInOverviewRulerCheckBox.getSelection()); } }); foregroundColorButton.addSelectionListener(new SelectionListener() { public void widgetDefaultSelected(SelectionEvent e) { // do nothing } public void widgetSelected(SelectionEvent e) { int i= fAnnotationList.getSelectionIndex(); String key= fAnnotationColorListModel[i][1]; PreferenceConverter.setValue(fOverlayStore, key, fAnnotationForegroundColorEditor.getColorValue()); } }); return composite; } private String[][] createAnnotationTypeListModel(MarkerAnnotationPreferences preferences) { ArrayList listModelItems= new ArrayList(); Iterator e= preferences.getAnnotationPreferences().iterator(); while (e.hasNext()) { AnnotationPreference info= (AnnotationPreference) e.next(); listModelItems.add(new String[] { info.getPreferenceLabel(), info.getColorPreferenceKey(), info.getTextPreferenceKey(), info.getOverviewRulerPreferenceKey()}); } String[][] items= new String[listModelItems.size()][]; listModelItems.toArray(items); return items; } private Control createTypingPage(Composite parent) { Composite composite= new Composite(parent, SWT.NONE); GridLayout layout= new GridLayout(); layout.numColumns= 1; composite.setLayout(layout); String label= PreferencesMessages.getString("JavaEditorPreferencePage.smartHomeEnd"); //$NON-NLS-1$ addCheckBox(composite, label, PreferenceConstants.EDITOR_SMART_HOME_END, 1); label= PreferencesMessages.getString("JavaEditorPreferencePage.subWordNavigation"); //$NON-NLS-1$ addCheckBox(composite, label, PreferenceConstants.EDITOR_SUB_WORD_NAVIGATION, 1); addFiller(composite); Group group= new Group(composite, SWT.NONE); layout= new GridLayout(); layout.numColumns= 2; group.setLayout(layout); group.setText(PreferencesMessages.getString("JavaEditorPreferencePage.typing.description")); //$NON-NLS-1$ label= PreferencesMessages.getString("JavaEditorPreferencePage.wrapStrings"); //$NON-NLS-1$ addCheckBox(group, label, PreferenceConstants.EDITOR_WRAP_STRINGS, 1); label= PreferencesMessages.getString("JavaEditorPreferencePage.smartPaste"); //$NON-NLS-1$ addCheckBox(group, label, PreferenceConstants.EDITOR_SMART_PASTE, 1); label= PreferencesMessages.getString("JavaEditorPreferencePage.insertSpaceForTabs"); //$NON-NLS-1$ addCheckBox(group, label, PreferenceConstants.EDITOR_SPACES_FOR_TABS, 1); label= PreferencesMessages.getString("JavaEditorPreferencePage.closeStrings"); //$NON-NLS-1$ addCheckBox(group, label, PreferenceConstants.EDITOR_CLOSE_STRINGS, 1); label= PreferencesMessages.getString("JavaEditorPreferencePage.closeBrackets"); //$NON-NLS-1$ addCheckBox(group, label, PreferenceConstants.EDITOR_CLOSE_BRACKETS, 1); label= PreferencesMessages.getString("JavaEditorPreferencePage.closeBraces"); //$NON-NLS-1$ addCheckBox(group, label, PreferenceConstants.EDITOR_CLOSE_BRACES, 1); label= PreferencesMessages.getString("JavaEditorPreferencePage.closeJavaDocs"); //$NON-NLS-1$ Button button= addCheckBox(group, label, PreferenceConstants.EDITOR_CLOSE_JAVADOCS, 1); label= PreferencesMessages.getString("JavaEditorPreferencePage.addJavaDocTags"); //$NON-NLS-1$ fAddJavaDocTagsButton= addCheckBox(group, label, PreferenceConstants.EDITOR_ADD_JAVADOC_TAGS, 1); createDependency(button, fAddJavaDocTagsButton); // label= PreferencesMessages.getString("JavaEditorPreferencePage.formatJavaDocs"); //$NON-NLS-1$ // addCheckBox(group, label, PreferenceConstants.EDITOR_FORMAT_JAVADOCS, 1); return composite; } private void addFiller(Composite composite) { Label filler= new Label(composite, SWT.LEFT ); GridData gd= new GridData(GridData.HORIZONTAL_ALIGN_FILL); gd.horizontalSpan= 2; gd.heightHint= convertHeightInCharsToPixels(1) / 2; filler.setLayoutData(gd); } private static void indent(Control control) { GridData gridData= new GridData(); gridData.horizontalIndent= 20; control.setLayoutData(gridData); } private static void createDependency(final Button master, final Control slave) { indent(slave); master.addSelectionListener(new SelectionListener() { public void widgetSelected(SelectionEvent e) { slave.setEnabled(master.getSelection()); } public void widgetDefaultSelected(SelectionEvent e) {} }); } private Control createContentAssistPage(Composite parent) { Composite contentAssistComposite= new Composite(parent, SWT.NULL); GridLayout layout= new GridLayout(); layout.numColumns= 2; contentAssistComposite.setLayout(layout); addCompletionRadioButtons(contentAssistComposite); String label; label= PreferencesMessages.getString("JavaEditorPreferencePage.insertSingleProposalsAutomatically"); //$NON-NLS-1$ addCheckBox(contentAssistComposite, label, PreferenceConstants.CODEASSIST_AUTOINSERT, 0); label= PreferencesMessages.getString("JavaEditorPreferencePage.showOnlyProposalsVisibleInTheInvocationContext"); //$NON-NLS-1$ addCheckBox(contentAssistComposite, label, PreferenceConstants.CODEASSIST_SHOW_VISIBLE_PROPOSALS, 0); label= PreferencesMessages.getString("JavaEditorPreferencePage.presentProposalsInAlphabeticalOrder"); //$NON-NLS-1$ addCheckBox(contentAssistComposite, label, PreferenceConstants.CODEASSIST_ORDER_PROPOSALS, 0); label= PreferencesMessages.getString("JavaEditorPreferencePage.automaticallyAddImportInsteadOfQualifiedName"); //$NON-NLS-1$ addCheckBox(contentAssistComposite, label, PreferenceConstants.CODEASSIST_ADDIMPORT, 0); label= PreferencesMessages.getString("JavaEditorPreferencePage.fillArgumentNamesOnMethodCompletion"); //$NON-NLS-1$ Button button= addCheckBox(contentAssistComposite, label, PreferenceConstants.CODEASSIST_FILL_ARGUMENT_NAMES, 0); label= PreferencesMessages.getString("JavaEditorPreferencePage.guessArgumentNamesOnMethodCompletion"); //$NON-NLS-1$ fGuessMethodArgumentsButton= addCheckBox(contentAssistComposite, label, PreferenceConstants.CODEASSIST_GUESS_METHOD_ARGUMENTS, 0); createDependency(button, fGuessMethodArgumentsButton); label= PreferencesMessages.getString("JavaEditorPreferencePage.enableAutoActivation"); //$NON-NLS-1$ final Button autoactivation= addCheckBox(contentAssistComposite, label, PreferenceConstants.CODEASSIST_AUTOACTIVATION, 0); autoactivation.addSelectionListener(new SelectionAdapter(){ public void widgetSelected(SelectionEvent e) { updateAutoactivationControls(); } }); Control[] labelledTextField; label= PreferencesMessages.getString("JavaEditorPreferencePage.autoActivationDelay"); //$NON-NLS-1$ labelledTextField= addLabelledTextField(contentAssistComposite, label, PreferenceConstants.CODEASSIST_AUTOACTIVATION_DELAY, 4, 0, true); fAutoInsertDelayLabel= getLabelControl(labelledTextField); fAutoInsertDelayText= getTextControl(labelledTextField); label= PreferencesMessages.getString("JavaEditorPreferencePage.autoActivationTriggersForJava"); //$NON-NLS-1$ labelledTextField= addLabelledTextField(contentAssistComposite, label, PreferenceConstants.CODEASSIST_AUTOACTIVATION_TRIGGERS_JAVA, 4, 0, false); fAutoInsertJavaTriggerLabel= getLabelControl(labelledTextField); fAutoInsertJavaTriggerText= getTextControl(labelledTextField); label= PreferencesMessages.getString("JavaEditorPreferencePage.autoActivationTriggersForJavaDoc"); //$NON-NLS-1$ labelledTextField= addLabelledTextField(contentAssistComposite, label, PreferenceConstants.CODEASSIST_AUTOACTIVATION_TRIGGERS_JAVADOC, 4, 0, false); fAutoInsertJavaDocTriggerLabel= getLabelControl(labelledTextField); fAutoInsertJavaDocTriggerText= getTextControl(labelledTextField); Label l= new Label(contentAssistComposite, SWT.LEFT); l.setText(PreferencesMessages.getString("JavaEditorPreferencePage.codeAssist.colorOptions")); //$NON-NLS-1$ GridData gd= new GridData(GridData.HORIZONTAL_ALIGN_FILL); gd.horizontalSpan= 2; l.setLayoutData(gd); Composite editorComposite= new Composite(contentAssistComposite, SWT.NONE); layout= new GridLayout(); layout.numColumns= 2; layout.marginHeight= 0; layout.marginWidth= 0; editorComposite.setLayout(layout); gd= new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.FILL_VERTICAL); gd.horizontalSpan= 2; editorComposite.setLayoutData(gd); fContentAssistColorList= new List(editorComposite, SWT.SINGLE | SWT.V_SCROLL | SWT.BORDER); gd= new GridData(GridData.VERTICAL_ALIGN_BEGINNING | GridData.FILL_HORIZONTAL); gd.heightHint= convertHeightInCharsToPixels(8); fContentAssistColorList.setLayoutData(gd); Composite stylesComposite= new Composite(editorComposite, SWT.NONE); layout= new GridLayout(); layout.marginHeight= 0; layout.marginWidth= 0; layout.numColumns= 2; stylesComposite.setLayout(layout); stylesComposite.setLayoutData(new GridData(GridData.FILL_BOTH)); l= new Label(stylesComposite, SWT.LEFT); l.setText(PreferencesMessages.getString("JavaEditorPreferencePage.codeAssist.color")); //$NON-NLS-1$ gd= new GridData(); gd.horizontalAlignment= GridData.BEGINNING; l.setLayoutData(gd); fContentAssistColorEditor= new ColorEditor(stylesComposite); Button colorButton= fContentAssistColorEditor.getButton(); gd= new GridData(GridData.FILL_HORIZONTAL); gd.horizontalAlignment= GridData.BEGINNING; colorButton.setLayoutData(gd); fContentAssistColorList.addSelectionListener(new SelectionListener() { public void widgetDefaultSelected(SelectionEvent e) { // do nothing } public void widgetSelected(SelectionEvent e) { handleContentAssistColorListSelection(); } }); colorButton.addSelectionListener(new SelectionListener() { public void widgetDefaultSelected(SelectionEvent e) { // do nothing } public void widgetSelected(SelectionEvent e) { int i= fContentAssistColorList.getSelectionIndex(); String key= fContentAssistColorListModel[i][1]; PreferenceConverter.setValue(fOverlayStore, key, fContentAssistColorEditor.getColorValue()); } }); return contentAssistComposite; } private void addCompletionRadioButtons(Composite contentAssistComposite) { Composite completionComposite= new Composite(contentAssistComposite, SWT.NONE); GridData ccgd= new GridData(); ccgd.horizontalSpan= 2; completionComposite.setLayoutData(ccgd); GridLayout ccgl= new GridLayout(); ccgl.marginWidth= 0; ccgl.numColumns= 2; completionComposite.setLayout(ccgl); SelectionListener completionSelectionListener= new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { boolean insert= fCompletionInsertsRadioButton.getSelection(); fOverlayStore.setValue(PreferenceConstants.CODEASSIST_INSERT_COMPLETION, insert); } }; fCompletionInsertsRadioButton= new Button(completionComposite, SWT.RADIO | SWT.LEFT); fCompletionInsertsRadioButton.setText(PreferencesMessages.getString("JavaEditorPreferencePage.completionInserts")); //$NON-NLS-1$ fCompletionInsertsRadioButton.setLayoutData(new GridData()); fCompletionInsertsRadioButton.addSelectionListener(completionSelectionListener); fCompletionOverwritesRadioButton= new Button(completionComposite, SWT.RADIO | SWT.LEFT); fCompletionOverwritesRadioButton.setText(PreferencesMessages.getString("JavaEditorPreferencePage.completionOverwrites")); //$NON-NLS-1$ fCompletionOverwritesRadioButton.setLayoutData(new GridData()); fCompletionOverwritesRadioButton.addSelectionListener(completionSelectionListener); } private Control createNavigationPage(Composite parent) { Composite composite= new Composite(parent, SWT.NULL); GridLayout layout= new GridLayout(); layout.numColumns= 2; composite.setLayout(layout); String text= PreferencesMessages.getString("JavaEditorPreferencePage.navigation.browserLikeLinks"); //$NON-NLS-1$ fBrowserLikeLinksCheckBox= addCheckBox(composite, text, PreferenceConstants.EDITOR_BROWSER_LIKE_LINKS, 0); fBrowserLikeLinksCheckBox.addSelectionListener(new SelectionListener() { public void widgetSelected(SelectionEvent e) { boolean state= fBrowserLikeLinksCheckBox.getSelection(); fBrowserLikeLinksKeyModifierText.setEnabled(state); handleBrowserLikeLinksKeyModifierModified(); } public void widgetDefaultSelected(SelectionEvent e) { } }); // Text field for modifier string text= PreferencesMessages.getString("JavaEditorPreferencePage.navigation.browserLikeLinksKeyModifier"); //$NON-NLS-1$ fBrowserLikeLinksKeyModifierText= addTextField(composite, text, PreferenceConstants.EDITOR_BROWSER_LIKE_LINKS_KEY_MODIFIER, 20, 0, false); fBrowserLikeLinksKeyModifierText.setTextLimit(Text.LIMIT); if (computeStateMask(fOverlayStore.getString(PreferenceConstants.EDITOR_BROWSER_LIKE_LINKS_KEY_MODIFIER)) == -1) { // Fix possible illegal modifier string int stateMask= fOverlayStore.getInt(PreferenceConstants.EDITOR_BROWSER_LIKE_LINKS_KEY_MODIFIER_MASK); if (stateMask == -1) fBrowserLikeLinksKeyModifierText.setText(""); //$NON-NLS-1$ else fBrowserLikeLinksKeyModifierText.setText(EditorUtility.getModifierString(stateMask)); } fBrowserLikeLinksKeyModifierText.addKeyListener(new KeyListener() { private boolean isModifierCandidate; public void keyPressed(KeyEvent e) { isModifierCandidate= e.keyCode > 0 && e.character == 0 && e.stateMask == 0; } public void keyReleased(KeyEvent e) { if (isModifierCandidate && e.stateMask > 0 && e.stateMask == e.stateMask && e.character == 0) {// && e.time -time < 1000) { String modifierString= fBrowserLikeLinksKeyModifierText.getText(); Point selection= fBrowserLikeLinksKeyModifierText.getSelection(); int i= selection.x - 1; while (i > -1 && Character.isWhitespace(modifierString.charAt(i))) { i--; } boolean needsPrefixDelimiter= i > -1 && !String.valueOf(modifierString.charAt(i)).equals(DELIMITER); i= selection.y; while (i < modifierString.length() && Character.isWhitespace(modifierString.charAt(i))) { i++; } boolean needsPostfixDelimiter= i < modifierString.length() && !String.valueOf(modifierString.charAt(i)).equals(DELIMITER); String insertString; if (needsPrefixDelimiter && needsPostfixDelimiter) insertString= PreferencesMessages.getFormattedString("JavaEditorPreferencePage.navigation.insertDelimiterAndModifierAndDelimiter", new String[] {Action.findModifierString(e.stateMask)}); //$NON-NLS-1$ else if (needsPrefixDelimiter) insertString= PreferencesMessages.getFormattedString("JavaEditorPreferencePage.navigation.insertDelimiterAndModifier", new String[] {Action.findModifierString(e.stateMask)}); //$NON-NLS-1$ else if (needsPostfixDelimiter) insertString= PreferencesMessages.getFormattedString("JavaEditorPreferencePage.navigation.insertModifierAndDelimiter", new String[] {Action.findModifierString(e.stateMask)}); //$NON-NLS-1$ else insertString= Action.findModifierString(e.stateMask); fBrowserLikeLinksKeyModifierText.insert(insertString); } } }); fBrowserLikeLinksKeyModifierText.addModifyListener(new ModifyListener() { public void modifyText(ModifyEvent e) { handleBrowserLikeLinksKeyModifierModified(); } }); return composite; } private void handleBrowserLikeLinksKeyModifierModified() { String modifiers= fBrowserLikeLinksKeyModifierText.getText(); int stateMask= computeStateMask(modifiers); if (fBrowserLikeLinksCheckBox.getSelection() && (stateMask == -1 || (stateMask & SWT.SHIFT) != 0)) { if (stateMask == -1) fBrowserLikeLinksKeyModifierStatus= new StatusInfo(IStatus.ERROR, PreferencesMessages.getFormattedString("JavaEditorPreferencePage.navigation.modifierIsNotValid", modifiers)); //$NON-NLS-1$ else fBrowserLikeLinksKeyModifierStatus= new StatusInfo(IStatus.ERROR, PreferencesMessages.getString("JavaEditorPreferencePage.navigation.shiftIsDisabled")); //$NON-NLS-1$ setValid(false); StatusUtil.applyToStatusLine(this, fBrowserLikeLinksKeyModifierStatus); } else { fBrowserLikeLinksKeyModifierStatus= new StatusInfo(); updateStatus(fBrowserLikeLinksKeyModifierStatus); } } private IStatus getBrowserLikeLinksKeyModifierStatus() { if (fBrowserLikeLinksKeyModifierStatus == null) fBrowserLikeLinksKeyModifierStatus= new StatusInfo(); return fBrowserLikeLinksKeyModifierStatus; } /** * Computes the state mask for the given modifier string. * * @param modifiers the string with the modifiers, separated by '+', '-', ';', ',' or '.' * @return the state mask or -1 if the input is invalid */ private int computeStateMask(String modifiers) { if (modifiers == null) return -1; if (modifiers.length() == 0) return SWT.NONE; int stateMask= 0; StringTokenizer modifierTokenizer= new StringTokenizer(modifiers, ",;.:+-* "); //$NON-NLS-1$ while (modifierTokenizer.hasMoreTokens()) { int modifier= EditorUtility.findLocalizedModifier(modifierTokenizer.nextToken()); if (modifier == 0 || (stateMask & modifier) == modifier) return -1; stateMask= stateMask | modifier; } return stateMask; } /* * @see PreferencePage#createContents(Composite) */ protected Control createContents(Composite parent) { initializeDefaultColors(); fOverlayStore.load(); fOverlayStore.start(); TabFolder folder= new TabFolder(parent, SWT.NONE); folder.setLayout(new TabFolderLayout()); folder.setLayoutData(new GridData(GridData.FILL_BOTH)); TabItem item= new TabItem(folder, SWT.NONE); item.setText(PreferencesMessages.getString("JavaEditorPreferencePage.general")); //$NON-NLS-1$ item.setControl(createAppearancePage(folder)); item= new TabItem(folder, SWT.NONE); item.setText(PreferencesMessages.getString("JavaEditorPreferencePage.colors")); //$NON-NLS-1$ item.setControl(createSyntaxPage(folder)); item= new TabItem(folder, SWT.NONE); item.setText(PreferencesMessages.getString("JavaEditorPreferencePage.codeAssist")); //$NON-NLS-1$ item.setControl(createContentAssistPage(folder)); item= new TabItem(folder, SWT.NONE); item.setText(PreferencesMessages.getString("JavaEditorPreferencePage.annotationsTab.title")); //$NON-NLS-1$ item.setControl(createAnnotationsPage(folder)); item= new TabItem(folder, SWT.NONE); item.setText(PreferencesMessages.getString("JavaEditorPreferencePage.typing.tabTitle")); //$NON-NLS-1$ item.setControl(createTypingPage(folder)); item= new TabItem(folder, SWT.NONE); item.setText(PreferencesMessages.getString("JavaEditorPreferencePage.hoverTab.title")); //$NON-NLS-1$ fJavaEditorHoverConfigurationBlock= new JavaEditorHoverConfigurationBlock(this, fOverlayStore); item.setControl(fJavaEditorHoverConfigurationBlock.createControl(folder)); item= new TabItem(folder, SWT.NONE); item.setText(PreferencesMessages.getString("JavaEditorPreferencePage.navigationTab.title")); //$NON-NLS-1$ item.setControl(createNavigationPage(folder)); initialize(); Dialog.applyDialogFont(folder); return folder; } private void initialize() { initializeFields(); for (int i= 0; i < fSyntaxColorListModel.length; i++) fSyntaxColorList.add(fSyntaxColorListModel[i][0]); fSyntaxColorList.getDisplay().asyncExec(new Runnable() { public void run() { if (fSyntaxColorList != null && !fSyntaxColorList.isDisposed()) { fSyntaxColorList.select(0); handleSyntaxColorListSelection(); } } }); for (int i= 0; i < fAppearanceColorListModel.length; i++) fAppearanceColorList.add(fAppearanceColorListModel[i][0]); fAppearanceColorList.getDisplay().asyncExec(new Runnable() { public void run() { if (fAppearanceColorList != null && !fAppearanceColorList.isDisposed()) { fAppearanceColorList.select(0); handleAppearanceColorListSelection(); } } }); for (int i= 0; i < fAnnotationColorListModel.length; i++) fAnnotationList.add(fAnnotationColorListModel[i][0]); fAnnotationList.getDisplay().asyncExec(new Runnable() { public void run() { if (fAnnotationList != null && !fAnnotationList.isDisposed()) { fAnnotationList.select(0); handleAnnotationListSelection(); } } }); for (int i= 0; i < fContentAssistColorListModel.length; i++) fContentAssistColorList.add(fContentAssistColorListModel[i][0]); fContentAssistColorList.getDisplay().asyncExec(new Runnable() { public void run() { if (fContentAssistColorList != null && !fContentAssistColorList.isDisposed()) { fContentAssistColorList.select(0); handleContentAssistColorListSelection(); } } }); } private void initializeFields() { Iterator e= fColorButtons.keySet().iterator(); while (e.hasNext()) { ColorEditor c= (ColorEditor) e.next(); String key= (String) fColorButtons.get(c); RGB rgb= PreferenceConverter.getColor(fOverlayStore, key); c.setColorValue(rgb); } e= fCheckBoxes.keySet().iterator(); while (e.hasNext()) { Button b= (Button) e.next(); String key= (String) fCheckBoxes.get(b); b.setSelection(fOverlayStore.getBoolean(key)); } e= fTextFields.keySet().iterator(); while (e.hasNext()) { Text t= (Text) e.next(); String key= (String) fTextFields.get(t); t.setText(fOverlayStore.getString(key)); } RGB rgb= PreferenceConverter.getColor(fOverlayStore, PreferenceConstants.EDITOR_BACKGROUND_COLOR); fBackgroundColorEditor.setColorValue(rgb); boolean default_= fOverlayStore.getBoolean(PreferenceConstants.EDITOR_BACKGROUND_DEFAULT_COLOR); fBackgroundDefaultRadioButton.setSelection(default_); fBackgroundCustomRadioButton.setSelection(!default_); fBackgroundColorButton.setEnabled(!default_); boolean closeJavaDocs= fOverlayStore.getBoolean(PreferenceConstants.EDITOR_CLOSE_JAVADOCS); fAddJavaDocTagsButton.setEnabled(closeJavaDocs); boolean fillMethodArguments= fOverlayStore.getBoolean(PreferenceConstants.CODEASSIST_FILL_ARGUMENT_NAMES); fGuessMethodArgumentsButton.setEnabled(fillMethodArguments); boolean completionInserts= fOverlayStore.getBoolean(PreferenceConstants.CODEASSIST_INSERT_COMPLETION); fCompletionInsertsRadioButton.setSelection(completionInserts); fCompletionOverwritesRadioButton.setSelection(! completionInserts); fBrowserLikeLinksKeyModifierText.setEnabled(fBrowserLikeLinksCheckBox.getSelection()); updateAutoactivationControls(); } private void initializeDefaultColors() { if (!getPreferenceStore().contains(PreferenceConstants.EDITOR_BACKGROUND_COLOR)) { RGB rgb= getControl().getDisplay().getSystemColor(SWT.COLOR_LIST_BACKGROUND).getRGB(); PreferenceConverter.setDefault(fOverlayStore, PreferenceConstants.EDITOR_BACKGROUND_COLOR, rgb); PreferenceConverter.setDefault(getPreferenceStore(), PreferenceConstants.EDITOR_BACKGROUND_COLOR, rgb); } if (!getPreferenceStore().contains(PreferenceConstants.EDITOR_FOREGROUND_COLOR)) { RGB rgb= getControl().getDisplay().getSystemColor(SWT.COLOR_LIST_FOREGROUND).getRGB(); PreferenceConverter.setDefault(fOverlayStore, PreferenceConstants.EDITOR_FOREGROUND_COLOR, rgb); PreferenceConverter.setDefault(getPreferenceStore(), PreferenceConstants.EDITOR_FOREGROUND_COLOR, rgb); } } private void updateAutoactivationControls() { boolean autoactivation= fOverlayStore.getBoolean(PreferenceConstants.CODEASSIST_AUTOACTIVATION); fAutoInsertDelayText.setEnabled(autoactivation); fAutoInsertDelayLabel.setEnabled(autoactivation); fAutoInsertJavaTriggerText.setEnabled(autoactivation); fAutoInsertJavaTriggerLabel.setEnabled(autoactivation); fAutoInsertJavaDocTriggerText.setEnabled(autoactivation); fAutoInsertJavaDocTriggerLabel.setEnabled(autoactivation); } /* * @see PreferencePage#performOk() */ public boolean performOk() { fJavaEditorHoverConfigurationBlock.performOk(); fOverlayStore.setValue(PreferenceConstants.EDITOR_BROWSER_LIKE_LINKS_KEY_MODIFIER_MASK, computeStateMask(fBrowserLikeLinksKeyModifierText.getText())); fOverlayStore.propagate(); JavaPlugin.getDefault().savePluginPreferences(); return true; } /* * @see PreferencePage#performDefaults() */ protected void performDefaults() { fOverlayStore.loadDefaults(); initializeFields(); handleSyntaxColorListSelection(); handleAppearanceColorListSelection(); handleAnnotationListSelection(); handleContentAssistColorListSelection(); fJavaEditorHoverConfigurationBlock.performDefaults(); super.performDefaults(); fPreviewViewer.invalidateTextPresentation(); } /* * @see DialogPage#dispose() */ public void dispose() { if (fJavaTextTools != null) { fJavaTextTools.dispose(); fJavaTextTools= null; } if (fOverlayStore != null) { fOverlayStore.stop(); fOverlayStore= null; } if (fBackgroundColor != null && !fBackgroundColor.isDisposed()) fBackgroundColor.dispose(); super.dispose(); } private Button addCheckBox(Composite parent, String label, String key, int indentation) { Button checkBox= new Button(parent, SWT.CHECK); checkBox.setText(label); GridData gd= new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING); gd.horizontalIndent= indentation; gd.horizontalSpan= 2; checkBox.setLayoutData(gd); checkBox.addSelectionListener(fCheckBoxListener); fCheckBoxes.put(checkBox, key); return checkBox; } private Text addTextField(Composite composite, String label, String key, int textLimit, int indentation, boolean isNumber) { return getTextControl(addLabelledTextField(composite, label, key, textLimit, indentation, isNumber)); } private static Label getLabelControl(Control[] labelledTextField){ return (Label)labelledTextField[0]; } private static Text getTextControl(Control[] labelledTextField){ return (Text)labelledTextField[1]; } /** * Returns an array of size 2: * - first element is of type <code>Label</code> * - second element is of type <code>Text</code> * Use <code>getLabelControl</code> and <code>getTextControl</code> to get the 2 controls. */ private Control[] addLabelledTextField(Composite composite, String label, String key, int textLimit, int indentation, boolean isNumber) { Label labelControl= new Label(composite, SWT.NONE); labelControl.setText(label); GridData gd= new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING); gd.horizontalIndent= indentation; labelControl.setLayoutData(gd); Text textControl= new Text(composite, SWT.BORDER | SWT.SINGLE); gd= new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING); gd.widthHint= convertWidthInCharsToPixels(textLimit + 1); textControl.setLayoutData(gd); textControl.setTextLimit(textLimit); fTextFields.put(textControl, key); if (isNumber) { fNumberFields.add(textControl); textControl.addModifyListener(fNumberFieldListener); } else { textControl.addModifyListener(fTextFieldListener); } return new Control[]{labelControl, textControl}; } private String loadPreviewContentFromFile(String filename) { String line; String separator= System.getProperty("line.separator"); //$NON-NLS-1$ StringBuffer buffer= new StringBuffer(512); BufferedReader reader= null; try { reader= new BufferedReader(new InputStreamReader(getClass().getResourceAsStream(filename))); while ((line= reader.readLine()) != null) { buffer.append(line); buffer.append(separator); } } catch (IOException io) { JavaPlugin.log(io); } finally { if (reader != null) { try { reader.close(); } catch (IOException e) {} } } return buffer.toString(); } private void numberFieldChanged(Text textControl) { String number= textControl.getText(); IStatus status= validatePositiveNumber(number); if (!status.matches(IStatus.ERROR)) fOverlayStore.setValue((String) fTextFields.get(textControl), number); updateStatus(status); } private IStatus validatePositiveNumber(String number) { StatusInfo status= new StatusInfo(); if (number.length() == 0) { status.setError(PreferencesMessages.getString("JavaEditorPreferencePage.empty_input")); //$NON-NLS-1$ } else { try { int value= Integer.parseInt(number); if (value < 0) status.setError(PreferencesMessages.getFormattedString("JavaEditorPreferencePage.invalid_input", number)); //$NON-NLS-1$ } catch (NumberFormatException e) { status.setError(PreferencesMessages.getFormattedString("JavaEditorPreferencePage.invalid_input", number)); //$NON-NLS-1$ } } return status; } void updateStatus(IStatus status) { if (!status.matches(IStatus.ERROR)) { for (int i= 0; i < fNumberFields.size(); i++) { Text text= (Text) fNumberFields.get(i); IStatus s= validatePositiveNumber(text.getText()); status= StatusUtil.getMoreSevere(s, status); } } status= StatusUtil.getMoreSevere(fJavaEditorHoverConfigurationBlock.getStatus(), status); status= StatusUtil.getMoreSevere(getBrowserLikeLinksKeyModifierStatus(), status); setValid(!status.matches(IStatus.ERROR)); StatusUtil.applyToStatusLine(this, status); } }
27,005
Bug 27005 [typing] Smart string wrapping
Using1119, I noticed something quite annoying. Consider the following code: String s = ""; If you copy some code like: class A { // comment } And then you paste it between the double-quotes, you will end up with: String s = "public class A { // comment" + "}"; The problem is that this code is not equivalent. I should have a line break at the end of the first line. Otherwise the code contained in my string s doesn't even compile. So the feature is nice, but cannot be used till a line break is added at the end of each part of the string concatenation. So in the above example, I would expect: String s = "public class A { // comment\n" + "}"; or String s = "public class A { // comment\r\n" + "}"; or String s = "public class A { // comment\r" + "}"; The line break could be chosen according to the line breaks in the current file or the platform line delimiter.
resolved fixed
c2cedc9
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2003-09-11T17:16:57Z
2002-11-22T18:33:20Z
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/java/JavaStringAutoIndentStrategy.java
/******************************************************************************* * Copyright (c) 2000, 2003 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Common Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/cpl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.jdt.internal.ui.text.java; import org.eclipse.jface.preference.IPreferenceStore; import org.eclipse.jface.text.BadLocationException; import org.eclipse.jface.text.DefaultAutoIndentStrategy; import org.eclipse.jface.text.Document; import org.eclipse.jface.text.DocumentCommand; import org.eclipse.jface.text.IDocument; import org.eclipse.jface.text.IRegion; import org.eclipse.jface.text.ITypedRegion; import org.eclipse.jface.text.TextUtilities; import org.eclipse.ui.IEditorPart; import org.eclipse.ui.IWorkbenchPage; import org.eclipse.ui.texteditor.ITextEditorExtension3; import org.eclipse.jdt.ui.PreferenceConstants; import org.eclipse.jdt.internal.ui.JavaPlugin; /** * Auto indent strategy for java strings */ public class JavaStringAutoIndentStrategy extends DefaultAutoIndentStrategy { private String fPartitioning; /** * Creates a new Java string auto indent strategy for the given document partitioning. * * @param partitioning the document partitioning */ public JavaStringAutoIndentStrategy(String partitioning) { super(); fPartitioning= partitioning; } private boolean isLineDelimiter(IDocument document, String text) { String[] delimiters= document.getLegalLineDelimiters(); if (delimiters != null) return TextUtilities.equals(delimiters, text) > -1; return false; } private String getLineIndentation(IDocument document, int offset) throws BadLocationException { // find start of line int adjustedOffset= (offset == document.getLength() ? offset - 1 : offset); IRegion line= document.getLineInformationOfOffset(adjustedOffset); int start= line.getOffset(); // find white spaces int end= findEndOfWhiteSpace(document, start, offset); return document.get(start, end - start); } private String getModifiedText(String string, String lineDelimiter, String indentation) throws BadLocationException { String indentedLine= lineDelimiter + indentation; IDocument document= new Document(string); StringBuffer buffer= new StringBuffer(); IRegion line= document.getLineInformation(0); buffer.append(document.get(line.getOffset(), line.getLength())); buffer.append("\" +"); //$NON-NLS-1$ int lineCount= document.getNumberOfLines(); for (int i= 1; i < lineCount - 1; i++) { line= document.getLineInformation(i); buffer.append(indentedLine); buffer.append('\"'); buffer.append(document.get(line.getOffset(), line.getLength())); buffer.append("\" +"); //$NON-NLS-1$ } line= document.getLineInformation(lineCount - 1); buffer.append(indentedLine); buffer.append('\"'); buffer.append(document.get(line.getOffset(), line.getLength())); return buffer.toString(); } private void javaStringIndentAfterNewLine(IDocument document, DocumentCommand command) throws BadLocationException { ITypedRegion partition= TextUtilities.getPartition(document, fPartitioning, command.offset); int offset= partition.getOffset(); int length= partition.getLength(); if (command.offset == offset) return; if (command.offset == offset + length && document.getChar(offset + length - 1) == '\"') return; String[] legalLineDelimiters= document.getLegalLineDelimiters(); String lineDelimiter= legalLineDelimiters[0]; String indentation= getLineIndentation(document, command.offset); IRegion line= document.getLineInformationOfOffset(offset); String string= document.get(line.getOffset(), offset - line.getOffset()); if (string.trim().length() != 0) indentation += String.valueOf("\t\t"); //$NON-NLS-1$ command.text= getModifiedText(command.text, lineDelimiter, indentation); } private boolean isSmartMode() { IWorkbenchPage page= JavaPlugin.getActivePage(); if (page != null) { IEditorPart part= page.getActiveEditor(); if (part instanceof ITextEditorExtension3) { ITextEditorExtension3 extension= (ITextEditorExtension3) part; return extension.getInsertMode() == ITextEditorExtension3.SMART_INSERT; } } return false; } /* * @see org.eclipse.jface.text.IAutoIndentStrategy#customizeDocumentCommand(IDocument, DocumentCommand) */ public void customizeDocumentCommand(IDocument document, DocumentCommand command) { try { if (command.length != 0 || command.text == null) return; IPreferenceStore preferenceStore= JavaPlugin.getDefault().getPreferenceStore(); if (preferenceStore.getBoolean(PreferenceConstants.EDITOR_WRAP_STRINGS) && isLineDelimiter(document, command.text) && isSmartMode()) javaStringIndentAfterNewLine(document, command); } catch (BadLocationException e) { } } }
27,005
Bug 27005 [typing] Smart string wrapping
Using1119, I noticed something quite annoying. Consider the following code: String s = ""; If you copy some code like: class A { // comment } And then you paste it between the double-quotes, you will end up with: String s = "public class A { // comment" + "}"; The problem is that this code is not equivalent. I should have a line break at the end of the first line. Otherwise the code contained in my string s doesn't even compile. So the feature is nice, but cannot be used till a line break is added at the end of each part of the string concatenation. So in the above example, I would expect: String s = "public class A { // comment\n" + "}"; or String s = "public class A { // comment\r\n" + "}"; or String s = "public class A { // comment\r" + "}"; The line break could be chosen according to the line breaks in the current file or the platform line delimiter.
resolved fixed
c2cedc9
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2003-09-11T17:16:57Z
2002-11-22T18:33:20Z
org.eclipse.jdt.ui/ui/org/eclipse/jdt/ui/PreferenceConstants.java
/******************************************************************************* * Copyright (c) 2000, 2003 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Common Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/cpl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.jdt.ui; import org.eclipse.swt.SWT; import org.eclipse.swt.graphics.RGB; import org.eclipse.jface.action.Action; import org.eclipse.jface.preference.IPreferenceStore; import org.eclipse.jface.preference.PreferenceConverter; import org.eclipse.ui.texteditor.AbstractTextEditor; import org.eclipse.ui.texteditor.ExtendedTextEditorPreferenceConstants; import org.eclipse.jdt.core.IClasspathEntry; import org.eclipse.jdt.core.JavaCore; import org.eclipse.jdt.ui.text.IJavaColorConstants; import org.eclipse.jdt.internal.ui.JavaPlugin; import org.eclipse.jdt.internal.ui.preferences.NewJavaProjectPreferencePage; import org.eclipse.jdt.internal.ui.preferences.WorkInProgressPreferencePage; /** * Preference constants used in the JDT-UI preference store. Clients should only read the * JDT-UI preference store using these values. Clients are not allowed to modify the * preference store programmatically. * * @since 2.0 */ public class PreferenceConstants { private PreferenceConstants() { } /** * A named preference that controls return type rendering of methods in the UI. * <p> * Value is of type <code>Boolean</code>: if <code>true</code> return types * are rendered * </p> */ public static final String APPEARANCE_METHOD_RETURNTYPE= "org.eclipse.jdt.ui.methodreturntype";//$NON-NLS-1$ /** * A named preference that controls if override indicators are rendered in the UI. * <p> * Value is of type <code>Boolean</code>: if <code>true</code> override * indicators are rendered * </p> */ public static final String APPEARANCE_OVERRIDE_INDICATOR= "org.eclipse.jdt.ui.overrideindicator";//$NON-NLS-1$ /** * A named preference that controls if quick assist light bulbs are shown. * <p> * Value is of type <code>Boolean</code>: if <code>true</code> light bulbs are shown * for quick assists. * </p> */ public static final String APPEARANCE_QUICKASSIST_LIGHTBULB="org.eclipse.jdt.quickassist.lightbulb"; //$NON-NLS-1$ /** * A named preference that defines the pattern used for package name compression. * <p> * Value is of type <code>String</code>. For example foe the given package name 'org.eclipse.jdt' pattern * '.' will compress it to '..jdt', '1~' to 'o~.e~.jdt'. * </p> */ public static final String APPEARANCE_PKG_NAME_PATTERN_FOR_PKG_VIEW= "PackagesView.pkgNamePatternForPackagesView";//$NON-NLS-1$ /** * A named preference that controls if package name compression is turned on or off. * <p> * Value is of type <code>Boolean</code>. * </p> * * @see #APPEARANCE_PKG_NAME_PATTERN_FOR_PKG_VIEW */ public static final String APPEARANCE_COMPRESS_PACKAGE_NAMES= "org.eclipse.jdt.ui.compresspackagenames";//$NON-NLS-1$ /** * A named preference that controls if empty inner packages are folded in * the hierarchical mode of the package explorer. * <p> * Value is of type <code>Boolean</code>: if <code>true</code> empty * inner packages are folded. * </p> * @since 2.1 */ public static final String APPEARANCE_FOLD_PACKAGES_IN_PACKAGE_EXPLORER= "org.eclipse.jdt.ui.flatPackagesInPackageExplorer";//$NON-NLS-1$ /** * A named preference that defines how member elements are ordered by the * Java views using the <code>JavaElementSorter</code>. * <p> * Value is of type <code>String</code>: A comma separated list of the * following entries. Each entry must be in the list, no duplication. List * order defines the sort order. * <ul> * <li><b>T</b>: Types</li> * <li><b>C</b>: Constructors</li> * <li><b>I</b>: Initializers</li> * <li><b>M</b>: Methods</li> * <li><b>F</b>: Fields</li> * <li><b>SI</b>: Static Initializers</li> * <li><b>SM</b>: Static Methods</li> * <li><b>SF</b>: Static Fields</li> * </ul> * </p> * @since 2.1 */ public static final String APPEARANCE_MEMBER_SORT_ORDER= "outlinesortoption"; //$NON-NLS-1$ /** * A named preference that controls if prefix removal during setter/getter generation is turned on or off. * <p> * Value is of type <code>Boolean</code>. * </p> * @deprecated Use JavaCore preference store (key JavaCore. * CODEASSIST_FIELD_PREFIXES and CODEASSIST_STATIC_FIELD_PREFIXES) */ public static final String CODEGEN_USE_GETTERSETTER_PREFIX= "org.eclipse.jdt.ui.gettersetter.prefix.enable";//$NON-NLS-1$ /** * A named preference that holds a list of prefixes to be removed from a local variable to compute setter * and gettter names. * <p> * Value is of type <code>String</code>: comma separated list of prefixed * </p> * * @deprecated Use JavaCore preference store (key JavaCore. * CODEASSIST_FIELD_PREFIXES and CODEASSIST_STATIC_FIELD_PREFIXES) */ public static final String CODEGEN_GETTERSETTER_PREFIX= "org.eclipse.jdt.ui.gettersetter.prefix.list";//$NON-NLS-1$ /** * A named preference that controls if suffix removal during setter/getter generation is turned on or off. * <p> * Value is of type <code>Boolean</code>. * </p> * @deprecated Use JavaCore preference store (key JavaCore. * CODEASSIST_FIELD_PREFIXES and CODEASSIST_STATIC_FIELD_PREFIXES) */ public static final String CODEGEN_USE_GETTERSETTER_SUFFIX= "org.eclipse.jdt.ui.gettersetter.suffix.enable";//$NON-NLS-1$ /** * A named preference that holds a list of suffixes to be removed from a local variable to compute setter * and getter names. * <p> * Value is of type <code>String</code>: comma separated list of suffixes * </p> * @deprecated Use setting from JavaCore preference store (key JavaCore. * CODEASSIST_FIELD_SUFFIXES and CODEASSIST_STATIC_FIELD_SUFFIXES) */ public static final String CODEGEN_GETTERSETTER_SUFFIX= "org.eclipse.jdt.ui.gettersetter.suffix.list"; //$NON-NLS-1$ /** * A named preference that controls whether the keyword "this" will be added * automatically to field accesses in autogenerated methods. * <p> * Value is of type <code>Boolean</code>. * </p> * @since 3.0 */ public static final String CODEGEN_KEYWORD_THIS= "org.eclipse.jdt.ui.keywordthis"; //$NON-NLS-1$ /** * A named preference that controls whether to use the prefix "is" or the prefix "get" for * automatically created getters which return a boolean field. * <p> * Value is of type <code>Boolean</code>. * </p> * @since 3.0 */ public static final String CODEGEN_IS_FOR_GETTERS= "org.eclipse.jdt.ui.gettersetter.use.is"; //$NON-NLS-1$ /** * A named preference that controls if comment stubs will be added * automatically to newly created types and methods. * <p> * Value is of type <code>Boolean</code>. * </p> * @since 2.1 */ public static final String CODEGEN_ADD_COMMENTS= "org.eclipse.jdt.ui.javadoc"; //$NON-NLS-1$ /** * A named preference that controls if a comment stubs will be added * automatocally to newly created types and methods. * <p> * Value is of type <code>Boolean</code>. * </p> * @deprecated Use CODEGEN_ADD_COMMENTS instead (Name is more precice). */ public static final String CODEGEN__JAVADOC_STUBS= CODEGEN_ADD_COMMENTS; /** * A named preference that controls if a non-javadoc comment gets added to methods generated via the * "Override Methods" operation. * <p> * Value is of type <code>Boolean</code>. * </p> * @deprecated New code template story: user can * specify the overriding method comment. */ public static final String CODEGEN__NON_JAVADOC_COMMENTS= "org.eclipse.jdt.ui.seecomments"; //$NON-NLS-1$ /** * A named preference that controls if a file comment gets added to newly created files. * <p> * Value is of type <code>Boolean</code>. * </p> * @deprecated New code template story: user can * specify the new type code template. */ public static final String CODEGEN__FILE_COMMENTS= "org.eclipse.jdt.ui.filecomments"; //$NON-NLS-1$ /** * A named preference that holds a list of comma separated package names. The list specifies the import order used by * the "Organize Imports" opeation. * <p> * Value is of type <code>String</code>: semicolon separated list of package * names * </p> */ public static final String ORGIMPORTS_IMPORTORDER= "org.eclipse.jdt.ui.importorder"; //$NON-NLS-1$ /** * A named preference that specifies the number of imports added before a star-import declaration is used. * <p> * Value is of type <code>Int</code>: positive value specifing the number of non star-import is used * </p> */ public static final String ORGIMPORTS_ONDEMANDTHRESHOLD= "org.eclipse.jdt.ui.ondemandthreshold"; //$NON-NLS-1$ /** * A named preferences that controls if types that start with a lower case letters get added by the * "Organize Import" operation. * <p> * Value is of type <code>Boolean</code>. * </p> */ public static final String ORGIMPORTS_IGNORELOWERCASE= "org.eclipse.jdt.ui.ignorelowercasenames"; //$NON-NLS-1$ /** * A named preference that speficies whether children of a compilation unit are shown in the package explorer. * <p> * Value is of type <code>Boolean</code>. * </p> */ public static final String SHOW_CU_CHILDREN= "org.eclipse.jdt.ui.packages.cuchildren"; //$NON-NLS-1$ /** * A named preference that controls whether the package explorer's selection is linked to the active editor. * <p> * Value is of type <code>Boolean</code>. * </p> */ public static final String LINK_PACKAGES_TO_EDITOR= "org.eclipse.jdt.ui.packages.linktoeditor"; //$NON-NLS-1$ /** * A named preference that controls whether the hierarchy view's selection is linked to the active editor. * <p> * Value is of type <code>Boolean</code>. * </p> */ public static final String LINK_TYPEHIERARCHY_TO_EDITOR= "org.eclipse.jdt.ui.packages.linktypehierarchytoeditor"; //$NON-NLS-1$ /** * A named preference that controls whether the projects view's selection is * linked to the active editor. * <p> * Value is of type <code>Boolean</code>. * </p> * @since 2.1 */ public static final String LINK_BROWSING_PROJECTS_TO_EDITOR= "org.eclipse.jdt.ui.browsing.projectstoeditor"; //$NON-NLS-1$ /** * A named preference that controls whether the packages view's selection is * linked to the active editor. * <p> * Value is of type <code>Boolean</code>. * </p> * @since 2.1 */ public static final String LINK_BROWSING_PACKAGES_TO_EDITOR= "org.eclipse.jdt.ui.browsing.packagestoeditor"; //$NON-NLS-1$ /** * A named preference that controls whether the types view's selection is * linked to the active editor. * <p> * Value is of type <code>Boolean</code>. * </p> * @since 2.1 */ public static final String LINK_BROWSING_TYPES_TO_EDITOR= "org.eclipse.jdt.ui.browsing.typestoeditor"; //$NON-NLS-1$ /** * A named preference that controls whether the members view's selection is * linked to the active editor. * <p> * Value is of type <code>Boolean</code>. * </p> * @since 2.1 */ public static final String LINK_BROWSING_MEMBERS_TO_EDITOR= "org.eclipse.jdt.ui.browsing.memberstoeditor"; //$NON-NLS-1$ /** * A named preference that controls whether new projects are generated using source and output folder. * <p> * Value is of type <code>Boolean</code>. if <code>true</code> new projects are created with a source and * output folder. If <code>false</code> source and output folder equals to the project. * </p> */ public static final String SRCBIN_FOLDERS_IN_NEWPROJ= "org.eclipse.jdt.ui.wizards.srcBinFoldersInNewProjects"; //$NON-NLS-1$ /** * A named preference that specifies the source folder name used when creating a new Java project. Value is inactive * if <code>SRCBIN_FOLDERS_IN_NEWPROJ</code> is set to <code>false</code>. * <p> * Value is of type <code>String</code>. * </p> * * @see #SRCBIN_FOLDERS_IN_NEWPROJ */ public static final String SRCBIN_SRCNAME= "org.eclipse.jdt.ui.wizards.srcBinFoldersSrcName"; //$NON-NLS-1$ /** * A named preference that specifies the output folder name used when creating a new Java project. Value is inactive * if <code>SRCBIN_FOLDERS_IN_NEWPROJ</code> is set to <code>false</code>. * <p> * Value is of type <code>String</code>. * </p> * * @see #SRCBIN_FOLDERS_IN_NEWPROJ */ public static final String SRCBIN_BINNAME= "org.eclipse.jdt.ui.wizards.srcBinFoldersBinName"; //$NON-NLS-1$ /** * A named preference that holds a list of possible JRE libraries used by the New Java Project wizard. An library * consists of a description and an arbitrary number of <code>IClasspathEntry</code>s, that will represent the * JRE on the new project's classpath. * <p> * Value is of type <code>String</code>: a semicolon separated list of encoded JRE libraries. * <code>NEWPROJECT_JRELIBRARY_INDEX</code> defines the currently used library. Clients * should use the method <code>encodeJRELibrary</code> to encode a JRE library into a string * and the methods <code>decodeJRELibraryDescription(String)</code> and <code> * decodeJRELibraryClasspathEntries(String)</code> to decode the description and the array * of classpath entries from an encoded string. * </p> * * @see #NEWPROJECT_JRELIBRARY_INDEX * @see #encodeJRELibrary(String, IClasspathEntry[]) * @see #decodeJRELibraryDescription(String) * @see #decodeJRELibraryClasspathEntries(String) */ public static final String NEWPROJECT_JRELIBRARY_LIST= "org.eclipse.jdt.ui.wizards.jre.list"; //$NON-NLS-1$ /** * A named preferences that specifies the current active JRE library. * <p> * Value is of type <code>Int</code>: an index into the list of possible JRE libraries. * </p> * * @see #NEWPROJECT_JRELIBRARY_LIST */ public static final String NEWPROJECT_JRELIBRARY_INDEX= "org.eclipse.jdt.ui.wizards.jre.index"; //$NON-NLS-1$ /** * A named preference that controls if a new type hierarchy gets opened in a * new type hierarchy perspective or inside the type hierarchy view part. * <p> * Value is of type <code>String</code>: possible values are <code> * OPEN_TYPE_HIERARCHY_IN_PERSPECTIVE</code> or <code> * OPEN_TYPE_HIERARCHY_IN_VIEW_PART</code>. * </p> * * @see #OPEN_TYPE_HIERARCHY_IN_PERSPECTIVE * @see #OPEN_TYPE_HIERARCHY_IN_VIEW_PART */ public static final String OPEN_TYPE_HIERARCHY= "org.eclipse.jdt.ui.openTypeHierarchy"; //$NON-NLS-1$ /** * A string value used by the named preference <code>OPEN_TYPE_HIERARCHY</code>. * * @see #OPEN_TYPE_HIERARCHY */ public static final String OPEN_TYPE_HIERARCHY_IN_PERSPECTIVE= "perspective"; //$NON-NLS-1$ /** * A string value used by the named preference <code>OPEN_TYPE_HIERARCHY</code>. * * @see #OPEN_TYPE_HIERARCHY */ public static final String OPEN_TYPE_HIERARCHY_IN_VIEW_PART= "viewPart"; //$NON-NLS-1$ /** * A named preference that controls the behaviour when double clicking on a container in the packages view. * <p> * Value is of type <code>String</code>: possible values are <code> * DOUBLE_CLICK_GOES_INTO</code> or <code> * DOUBLE_CLICK_EXPANDS</code>. * </p> * * @see #DOUBLE_CLICK_EXPANDS * @see #DOUBLE_CLICK_GOES_INTO */ public static final String DOUBLE_CLICK= "packageview.doubleclick"; //$NON-NLS-1$ /** * A string value used by the named preference <code>DOUBLE_CLICK</code>. * * @see #DOUBLE_CLICK */ public static final String DOUBLE_CLICK_GOES_INTO= "packageview.gointo"; //$NON-NLS-1$ /** * A string value used by the named preference <code>DOUBLE_CLICK</code>. * * @see #DOUBLE_CLICK */ public static final String DOUBLE_CLICK_EXPANDS= "packageview.doubleclick.expands"; //$NON-NLS-1$ /** * A named preference that controls whether Java views update their presentation while editing or when saving the * content of an editor. * <p> * Value is of type <code>String</code>: possible values are <code> * UPDATE_ON_SAVE</code> or <code> * UPDATE_WHILE_EDITING</code>. * </p> * * @see #UPDATE_ON_SAVE * @see #UPDATE_WHILE_EDITING */ public static final String UPDATE_JAVA_VIEWS= "JavaUI.update"; //$NON-NLS-1$ /** * A string value used by the named preference <code>UPDATE_JAVA_VIEWS</code> * * @see #UPDATE_JAVA_VIEWS */ public static final String UPDATE_ON_SAVE= "JavaUI.update.onSave"; //$NON-NLS-1$ /** * A string value used by the named preference <code>UPDATE_JAVA_VIEWS</code> * * @see #UPDATE_JAVA_VIEWS */ public static final String UPDATE_WHILE_EDITING= "JavaUI.update.whileEditing"; //$NON-NLS-1$ /** * A named preference that holds the path of the Javadoc command used by the Javadoc creation wizard. * <p> * Value is of type <code>String</code>. * </p> */ public static final String JAVADOC_COMMAND= "command"; //$NON-NLS-1$ /** * A named preference that defines whether hint to make hover sticky should be shown. * * @see JavaUI * @since 3.0 */ public static String EDITOR_SHOW_TEXT_HOVER_AFFORDANCE= "PreferenceConstants.EDITOR_SHOW_TEXT_HOVER_AFFORDANCE"; //$NON-NLS-1$ /** * A named preference that defines the key for the hover modifiers. * * @see JavaUI * @since 2.1 */ public static final String EDITOR_TEXT_HOVER_MODIFIERS= "hoverModifiers"; //$NON-NLS-1$ /** * A named preference that defines the key for the hover modifier state masks. * The value is only used if the value of <code>EDITOR_TEXT_HOVER_MODIFIERS</code> * cannot be resolved to valid SWT modifier bits. * * @see JavaUI * @see #EDITOR_TEXT_HOVER_MODIFIERS * @since 2.1.1 */ public static final String EDITOR_TEXT_HOVER_MODIFIER_MASKS= "hoverModifierMasks"; //$NON-NLS-1$ /** * The id of the best match hover contributed for extension point * <code>javaEditorTextHovers</code>. * * @since 2.1 */ public static String ID_BESTMATCH_HOVER= "org.eclipse.jdt.ui.BestMatchHover"; //$NON-NLS-1$ /** * The id of the source code hover contributed for extension point * <code>javaEditorTextHovers</code>. * * @since 2.1 */ public static String ID_SOURCE_HOVER= "org.eclipse.jdt.ui.JavaSourceHover"; //$NON-NLS-1$ /** * The id of the javadoc hover contributed for extension point * <code>javaEditorTextHovers</code>. * * @since 2.1 */ public static String ID_JAVADOC_HOVER= "org.eclipse.jdt.ui.JavadocHover"; //$NON-NLS-1$ /** * The id of the problem hover contributed for extension point * <code>javaEditorTextHovers</code>. * * @since 2.1 */ public static String ID_PROBLEM_HOVER= "org.eclipse.jdt.ui.ProblemHover"; //$NON-NLS-1$ /** * A named preference that controls whether bracket matching highlighting is turned on or off. * <p> * Value is of type <code>Boolean</code>. * </p> */ public final static String EDITOR_MATCHING_BRACKETS= "matchingBrackets"; //$NON-NLS-1$ /** * A named preference that holds the color used to highlight matching brackets. * <p> * Value is of type <code>String</code>. A RGB color value encoded as a string * using class <code>PreferenceConverter</code> * </p> * * @see org.eclipse.jface.resource.StringConverter * @see org.eclipse.jface.preference.PreferenceConverter */ public final static String EDITOR_MATCHING_BRACKETS_COLOR= "matchingBracketsColor"; //$NON-NLS-1$ /** * A named preference that controls whether the current line highlighting is turned on or off. * <p> * Value is of type <code>Boolean</code>. * </p> * @deprecated as of 3.0 replaced by {@link org.eclipse.ui.texteditor.ExtendedTextEditorPreferenceConstants} */ public final static String EDITOR_CURRENT_LINE= "currentLine"; //$NON-NLS-1$ /** * A named preference that holds the color used to highlight the current line. * <p> * Value is of type <code>String</code>. A RGB color value encoded as a string * using class <code>PreferenceConverter</code> * </p> * * @see org.eclipse.jface.resource.StringConverter * @see org.eclipse.jface.preference.PreferenceConverter * @deprecated as of 3.0 replaced by {@link org.eclipse.ui.texteditor.ExtendedTextEditorPreferenceConstants} */ public final static String EDITOR_CURRENT_LINE_COLOR= "currentLineColor"; //$NON-NLS-1$ /** * A named preference that controls whether the print margin is turned on or off. * <p> * Value is of type <code>Boolean</code>. * </p> * @deprecated as of 3.0 replaced by {@link org.eclipse.ui.texteditor.ExtendedTextEditorPreferenceConstants} */ public final static String EDITOR_PRINT_MARGIN= "printMargin"; //$NON-NLS-1$ /** * A named preference that holds the color used to render the print margin. * <p> * Value is of type <code>String</code>. A RGB color value encoded as a string * using class <code>PreferenceConverter</code> * </p> * * @see org.eclipse.jface.resource.StringConverter * @see org.eclipse.jface.preference.PreferenceConverter * @deprecated as of 3.0 replaced by {@link org.eclipse.ui.texteditor.ExtendedTextEditorPreferenceConstants} */ public final static String EDITOR_PRINT_MARGIN_COLOR= "printMarginColor"; //$NON-NLS-1$ /** * Print margin column. Int value. * @deprecated as of 3.0 replaced by {@link org.eclipse.ui.texteditor.ExtendedTextEditorPreferenceConstants} */ public final static String EDITOR_PRINT_MARGIN_COLUMN= "printMarginColumn"; //$NON-NLS-1$ /** * A named preference that holds the color used for the find/replace scope. * <p> * Value is of type <code>String</code>. A RGB color value encoded as a string * using class <code>PreferenceConverter</code> * </p> * * @see org.eclipse.jface.resource.StringConverter * @see org.eclipse.jface.preference.PreferenceConverter */ public final static String EDITOR_FIND_SCOPE_COLOR= AbstractTextEditor.PREFERENCE_COLOR_FIND_SCOPE; /** * A named preference that specifies if the editor uses spaces for tabs. * <p> * Value is of type <code>Boolean</code>. If <code>true</code>spaces instead of tabs are used * in the editor. If <code>false</code> the editor inserts a tab character when pressing the tab * key. * </p> */ public final static String EDITOR_SPACES_FOR_TABS= "spacesForTabs"; //$NON-NLS-1$ /** * A named preference that holds the number of spaces used per tab in the editor. * <p> * Value is of type <code>Int</code>: positive int value specifying the number of * spaces per tab. * </p> */ public final static String EDITOR_TAB_WIDTH= "org.eclipse.jdt.ui.editor.tab.width"; //$NON-NLS-1$ /** * A named preference that controls whether the outline view selection * should stay in sync with with the element at the current cursor position. * <p> * Value is of type <code>Boolean</code>. * </p> * @since 2.1 */ public final static String EDITOR_SYNC_OUTLINE_ON_CURSOR_MOVE= "JavaEditor.SyncOutlineOnCursorMove"; //$NON-NLS-1$ /** * A named preference that controls if correction indicators are shown in the UI. * <p> * Value is of type <code>Boolean</code>. * </p> */ public final static String EDITOR_CORRECTION_INDICATION= "JavaEditor.ShowTemporaryProblem"; //$NON-NLS-1$ /** * A named preference that controls whether the editor shows problem indicators in text (squiggly lines). * <p> * Value is of type <code>Boolean</code>. * </p> * * @deprecated as of 3.0 replaced by {@link org.eclipse.ui.texteditor.MarkerAnnotationPreferences} */ public final static String EDITOR_PROBLEM_INDICATION= "problemIndication"; //$NON-NLS-1$ /** * A named preference that holds the color used to render problem indicators. * <p> * Value is of type <code>String</code>. A RGB color value encoded as a string * using class <code>PreferenceConverter</code> * </p> * * @see #EDITOR_PROBLEM_INDICATION * @see org.eclipse.jface.resource.StringConverter * @see org.eclipse.jface.preference.PreferenceConverter * @deprecated as of 3.0 replaced by {@link org.eclipse.ui.texteditor.MarkerAnnotationPreferences} */ public final static String EDITOR_PROBLEM_INDICATION_COLOR= "problemIndicationColor"; //$NON-NLS-1$ /** * A named preference that controls whether the editor shows warning indicators in text (squiggly lines). * <p> * Value is of type <code>Boolean</code>. * </p> * @since 2.1 * @deprecated as of 3.0 replaced by {@link org.eclipse.ui.texteditor.MarkerAnnotationPreferences} */ public final static String EDITOR_WARNING_INDICATION= "warningIndication"; //$NON-NLS-1$ /** * A named preference that holds the color used to render warning indicators. * <p> * Value is of type <code>String</code>. A RGB color value encoded as a string * using class <code>PreferenceConverter</code> * </p> * * @see #EDITOR_WARNING_INDICATION * @see org.eclipse.jface.resource.StringConverter * @see org.eclipse.jface.preference.PreferenceConverter * @since 2.1 * @deprecated as of 3.0 replaced by {@link org.eclipse.ui.texteditor.MarkerAnnotationPreferences} */ public final static String EDITOR_WARNING_INDICATION_COLOR= "warningIndicationColor"; //$NON-NLS-1$ /** * A named preference that controls whether the editor shows task indicators in text (squiggly lines). * <p> * Value is of type <code>Boolean</code>. * </p> * @since 2.1 * @deprecated as of 3.0 replaced by {@link org.eclipse.ui.texteditor.MarkerAnnotationPreferences} */ public final static String EDITOR_TASK_INDICATION= "taskIndication"; //$NON-NLS-1$ /** * A named preference that holds the color used to render task indicators. * <p> * Value is of type <code>String</code>. A RGB color value encoded as a string * using class <code>PreferenceConverter</code> * </p> * * @see #EDITOR_TASK_INDICATION * @see org.eclipse.jface.resource.StringConverter * @see org.eclipse.jface.preference.PreferenceConverter * @since 2.1 * @deprecated as of 3.0 replaced by {@link org.eclipse.ui.texteditor.MarkerAnnotationPreferences} */ public final static String EDITOR_TASK_INDICATION_COLOR= "taskIndicationColor"; //$NON-NLS-1$ /** * A named preference that controls whether the editor shows bookmark * indicators in text (squiggly lines). * <p> * Value is of type <code>Boolean</code>. * </p> * @since 2.1 * @deprecated as of 3.0 replaced by {@link org.eclipse.ui.texteditor.MarkerAnnotationPreferences} */ public final static String EDITOR_BOOKMARK_INDICATION= "bookmarkIndication"; //$NON-NLS-1$ /** * A named preference that holds the color used to render bookmark indicators. * <p> * Value is of type <code>String</code>. A RGB color value encoded as a string * using class <code>PreferenceConverter</code> * </p> * * @see #EDITOR_BOOKMARK_INDICATION * @see org.eclipse.jface.resource.StringConverter * @see org.eclipse.jface.preference.PreferenceConverter * @since 2.1 * @deprecated as of 3.0 replaced by {@link org.eclipse.ui.texteditor.MarkerAnnotationPreferences} */ public final static String EDITOR_BOOKMARK_INDICATION_COLOR= "bookmarkIndicationColor"; //$NON-NLS-1$ /** * A named preference that controls whether the editor shows search * indicators in text (squiggly lines). * <p> * Value is of type <code>Boolean</code>. * </p> * @since 2.1 * @deprecated as of 3.0 replaced by {@link org.eclipse.ui.texteditor.MarkerAnnotationPreferences} */ public final static String EDITOR_SEARCH_RESULT_INDICATION= "searchResultIndication"; //$NON-NLS-1$ /** * A named preference that holds the color used to render search indicators. * <p> * Value is of type <code>String</code>. A RGB color value encoded as a string * using class <code>PreferenceConverter</code> * </p> * * @see #EDITOR_SEARCH_RESULT_INDICATION * @see org.eclipse.jface.resource.StringConverter * @see org.eclipse.jface.preference.PreferenceConverter * @since 2.1 * @deprecated as of 3.0 replaced by {@link org.eclipse.ui.texteditor.MarkerAnnotationPreferences} */ public final static String EDITOR_SEARCH_RESULT_INDICATION_COLOR= "searchResultIndicationColor"; //$NON-NLS-1$ /** * A named preference that controls whether the editor shows unknown * indicators in text (squiggly lines). * <p> * Value is of type <code>Boolean</code>. * </p> * @since 2.1 * @deprecated as of 3.0 replaced by {@link org.eclipse.ui.texteditor.MarkerAnnotationPreferences} */ public final static String EDITOR_UNKNOWN_INDICATION= "othersIndication"; //$NON-NLS-1$ /** * A named preference that holds the color used to render unknown * indicators. * <p> * Value is of type <code>String</code>. A RGB color value encoded as a string * using class <code>PreferenceConverter</code> * </p> * * @see #EDITOR_UNKNOWN_INDICATION * @see org.eclipse.jface.resource.StringConverter * @see org.eclipse.jface.preference.PreferenceConverter * @since 2.1 * @deprecated * @deprecated as of 3.0 replaced by {@link org.eclipse.ui.texteditor.MarkerAnnotationPreferences} */ public final static String EDITOR_UNKNOWN_INDICATION_COLOR= "othersIndicationColor"; //$NON-NLS-1$ /** * A named preference that controls whether the overview ruler shows error * indicators. * <p> * Value is of type <code>Boolean</code>. * </p> * @since 2.1 * @deprecated as of 3.0 replaced by {@link org.eclipse.ui.texteditor.MarkerAnnotationPreferences} */ public final static String EDITOR_ERROR_INDICATION_IN_OVERVIEW_RULER= "errorIndicationInOverviewRuler"; //$NON-NLS-1$ /** * A named preference that controls whether the overview ruler shows warning * indicators. * <p> * Value is of type <code>Boolean</code>. * </p> * @since 2.1 * @deprecated as of 3.0 replaced by {@link org.eclipse.ui.texteditor.MarkerAnnotationPreferences} */ public final static String EDITOR_WARNING_INDICATION_IN_OVERVIEW_RULER= "warningIndicationInOverviewRuler"; //$NON-NLS-1$ /** * A named preference that controls whether the overview ruler shows task * indicators. * <p> * Value is of type <code>Boolean</code>. * </p> * @since 2.1 * @deprecated as of 3.0 replaced by {@link org.eclipse.ui.texteditor.MarkerAnnotationPreferences} */ public final static String EDITOR_TASK_INDICATION_IN_OVERVIEW_RULER= "taskIndicationInOverviewRuler"; //$NON-NLS-1$ /** * A named preference that controls whether the overview ruler shows * bookmark indicators. * <p> * Value is of type <code>Boolean</code>. * </p> * @since 2.1 * @deprecated as of 3.0 replaced by {@link org.eclipse.ui.texteditor.MarkerAnnotationPreferences} */ public final static String EDITOR_BOOKMARK_INDICATION_IN_OVERVIEW_RULER= "bookmarkIndicationInOverviewRuler"; //$NON-NLS-1$ /** * A named preference that controls whether the overview ruler shows * search result indicators. * <p> * Value is of type <code>Boolean</code>. * </p> * @since 2.1 * @deprecated as of 3.0 replaced by {@link org.eclipse.ui.texteditor.MarkerAnnotationPreferences} */ public final static String EDITOR_SEARCH_RESULT_INDICATION_IN_OVERVIEW_RULER= "searchResultIndicationInOverviewRuler"; //$NON-NLS-1$ /** * A named preference that controls whether the overview ruler shows * unknown indicators. * <p> * Value is of type <code>Boolean</code>. * </p> * @since 2.1 * @deprecated as of 3.0 replaced by {@link org.eclipse.ui.texteditor.MarkerAnnotationPreferences} */ public final static String EDITOR_UNKNOWN_INDICATION_IN_OVERVIEW_RULER= "othersIndicationInOverviewRuler"; //$NON-NLS-1$ /** * A named preference that controls whether the 'close strings' feature * is enabled. * <p> * Value is of type <code>Boolean</code>. * </p> * @since 2.1 */ public final static String EDITOR_CLOSE_STRINGS= "closeStrings"; //$NON-NLS-1$ /** * A named preference that controls whether the 'wrap strings' feature is * enabled. * <p> * Value is of type <code>Boolean</code>. * </p> * @since 2.1 */ public final static String EDITOR_WRAP_STRINGS= "wrapStrings"; //$NON-NLS-1$ /** * A named preference that controls whether the 'close brackets' feature is * enabled. * <p> * Value is of type <code>Boolean</code>. * </p> * @since 2.1 */ public final static String EDITOR_CLOSE_BRACKETS= "closeBrackets"; //$NON-NLS-1$ /** * A named preference that controls whether the 'close braces' feature is * enabled. * <p> * Value is of type <code>Boolean</code>. * </p> * @since 2.1 */ public final static String EDITOR_CLOSE_BRACES= "closeBraces"; //$NON-NLS-1$ /** * A named preference that controls whether the 'close java docs' feature is * enabled. * <p> * Value is of type <code>Boolean</code>. * </p> * @since 2.1 */ public final static String EDITOR_CLOSE_JAVADOCS= "closeJavaDocs"; //$NON-NLS-1$ /** * A named preference that controls whether the 'add JavaDoc tags' feature * is enabled. * <p> * Value is of type <code>Boolean</code>. * </p> * @since 2.1 */ public final static String EDITOR_ADD_JAVADOC_TAGS= "addJavaDocTags"; //$NON-NLS-1$ /** * A named preference that controls whether the 'format Javadoc tags' * feature is enabled. * <p> * Value is of type <code>Boolean</code>. * </p> * @since 2.1 */ public final static String EDITOR_FORMAT_JAVADOCS= "autoFormatJavaDocs"; //$NON-NLS-1$ /** * A named preference that controls whether the 'smart paste' feature is * enabled. * <p> * Value is of type <code>Boolean</code>. * </p> * @since 2.1 */ public final static String EDITOR_SMART_PASTE= "smartPaste"; //$NON-NLS-1$ /** * A named preference that controls whether the 'smart home-end' feature is * enabled. * <p> * Value is of type <code>Boolean</code>. * </p> * @since 2.1 */ public final static String EDITOR_SMART_HOME_END= AbstractTextEditor.PREFERENCE_NAVIGATION_SMART_HOME_END; /** * A named preference that controls whether the 'sub-word navigation' feature is * enabled. * <p> * Value is of type <code>Boolean</code>. * </p> * @since 2.1 */ public final static String EDITOR_SUB_WORD_NAVIGATION= "subWordNavigation"; //$NON-NLS-1$ /** * A named preference that controls if temporary problems are evaluated and shown in the UI. * <p> * Value is of type <code>Boolean</code>. * </p> */ public final static String EDITOR_EVALUTE_TEMPORARY_PROBLEMS= "handleTemporaryProblems"; //$NON-NLS-1$ /** * A named preference that controls if the overview ruler is shown in the UI. * <p> * Value is of type <code>Boolean</code>. * </p> * @deprecated as of 3.0 replaced by {@link org.eclipse.ui.texteditor.ExtendedTextEditorPreferenceConstants} */ public final static String EDITOR_OVERVIEW_RULER= "overviewRuler"; //$NON-NLS-1$ /** * A named preference that controls if the line number ruler is shown in the UI. * <p> * Value is of type <code>Boolean</code>. * </p> * @deprecated as of 3.0 replaced by {@link org.eclipse.ui.texteditor.ExtendedTextEditorPreferenceConstants} */ public final static String EDITOR_LINE_NUMBER_RULER= "lineNumberRuler"; //$NON-NLS-1$ /** * A named preference that holds the color used to render line numbers inside the line number ruler. * <p> * Value is of type <code>String</code>. A RGB color value encoded as a string * using class <code>PreferenceConverter</code> * </p> * * @see org.eclipse.jface.resource.StringConverter * @see org.eclipse.jface.preference.PreferenceConverter * @see #EDITOR_LINE_NUMBER_RULER * @deprecated as of 3.0 replaced by {@link org.eclipse.ui.texteditor.ExtendedTextEditorPreferenceConstants} */ public final static String EDITOR_LINE_NUMBER_RULER_COLOR= "lineNumberColor"; //$NON-NLS-1$ /** * A named preference that holds the color used to render linked positions inside code templates. * <p> * Value is of type <code>String</code>. A RGB color value encoded as a string * using class <code>PreferenceConverter</code> * </p> * * @see org.eclipse.jface.resource.StringConverter * @see org.eclipse.jface.preference.PreferenceConverter */ public final static String EDITOR_LINKED_POSITION_COLOR= "linkedPositionColor"; //$NON-NLS-1$ /** * A named preference that holds the color used as the text foreground. * This value has not effect if the system default color is used. * <p> * Value is of type <code>String</code>. A RGB color value encoded as a string * using class <code>PreferenceConverter</code> * </p> * * @see org.eclipse.jface.resource.StringConverter * @see org.eclipse.jface.preference.PreferenceConverter */ public final static String EDITOR_FOREGROUND_COLOR= AbstractTextEditor.PREFERENCE_COLOR_FOREGROUND; /** * A named preference that describes if the system default foreground color * is used as the text foreground. * <p> * Value is of type <code>Boolean</code>. * </p> */ public final static String EDITOR_FOREGROUND_DEFAULT_COLOR= AbstractTextEditor.PREFERENCE_COLOR_FOREGROUND_SYSTEM_DEFAULT; /** * A named preference that holds the color used as the text background. * This value has not effect if the system default color is used. * <p> * Value is of type <code>String</code>. A RGB color value encoded as a string * using class <code>PreferenceConverter</code> * </p> * * @see org.eclipse.jface.resource.StringConverter * @see org.eclipse.jface.preference.PreferenceConverter */ public final static String EDITOR_BACKGROUND_COLOR= AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND; /** * A named preference that describes if the system default background color * is used as the text background. * <p> * Value is of type <code>Boolean</code>. * </p> */ public final static String EDITOR_BACKGROUND_DEFAULT_COLOR= AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND_SYSTEM_DEFAULT; /** * Preference key suffix for bold text style preference keys. * * @since 2.1 */ public static final String EDITOR_BOLD_SUFFIX= "_bold"; //$NON-NLS-1$ /** * A named preference that holds the color used to render multi line comments. * <p> * Value is of type <code>String</code>. A RGB color value encoded as a string * using class <code>PreferenceConverter</code> * </p> * * @see org.eclipse.jface.resource.StringConverter * @see org.eclipse.jface.preference.PreferenceConverter */ public final static String EDITOR_MULTI_LINE_COMMENT_COLOR= IJavaColorConstants.JAVA_MULTI_LINE_COMMENT; /** * The symbolic font name for the Java editor text font * (value <code>"org.eclipse.jdt.ui.editors.textfont"</code>). * * @since 2.1 */ public final static String EDITOR_TEXT_FONT= "org.eclipse.jdt.ui.editors.textfont"; //$NON-NLS-1$ /** * A named preference that controls whether multi line comments are rendered in bold. * <p> * Value is of type <code>Boolean</code>. If <code>true</code> multi line comments are rendered * in bold. If <code>false</code> the are rendered using no font style attribute. * </p> */ public final static String EDITOR_MULTI_LINE_COMMENT_BOLD= IJavaColorConstants.JAVA_MULTI_LINE_COMMENT + EDITOR_BOLD_SUFFIX; /** * A named preference that holds the color used to render single line comments. * <p> * Value is of type <code>String</code>. A RGB color value encoded as a string * using class <code>PreferenceConverter</code> * </p> * * @see org.eclipse.jface.resource.StringConverter * @see org.eclipse.jface.preference.PreferenceConverter */ public final static String EDITOR_SINGLE_LINE_COMMENT_COLOR= IJavaColorConstants.JAVA_SINGLE_LINE_COMMENT; /** * A named preference that controls whether sinle line comments are rendered in bold. * <p> * Value is of type <code>Boolean</code>. If <code>true</code> single line comments are rendered * in bold. If <code>false</code> the are rendered using no font style attribute. * </p> */ public final static String EDITOR_SINGLE_LINE_COMMENT_BOLD= IJavaColorConstants.JAVA_SINGLE_LINE_COMMENT + EDITOR_BOLD_SUFFIX; /** * A named preference that holds the color used to render java keywords. * <p> * Value is of type <code>String</code>. A RGB color value encoded as a string * using class <code>PreferenceConverter</code> * </p> * * @see org.eclipse.jface.resource.StringConverter * @see org.eclipse.jface.preference.PreferenceConverter */ public final static String EDITOR_JAVA_KEYWORD_COLOR= IJavaColorConstants.JAVA_KEYWORD; /** * A named preference that controls whether keywords are rendered in bold. * <p> * Value is of type <code>Boolean</code>. * </p> */ public final static String EDITOR_JAVA_KEYWORD_BOLD= IJavaColorConstants.JAVA_KEYWORD + EDITOR_BOLD_SUFFIX; /** * A named preference that holds the color used to render string constants. * <p> * Value is of type <code>String</code>. A RGB color value encoded as a string * using class <code>PreferenceConverter</code> * </p> * * @see org.eclipse.jface.resource.StringConverter * @see org.eclipse.jface.preference.PreferenceConverter */ public final static String EDITOR_STRING_COLOR= IJavaColorConstants.JAVA_STRING; /** * A named preference that controls whether string constants are rendered in bold. * <p> * Value is of type <code>Boolean</code>. * </p> */ public final static String EDITOR_STRING_BOLD= IJavaColorConstants.JAVA_STRING + EDITOR_BOLD_SUFFIX; /** * A named preference that holds the color used to render method names. * <p> * Value is of type <code>String</code>. A RGB color value encoded as a string * using class <code>PreferenceConverter</code> * </p> * * @see org.eclipse.jface.resource.StringConverter * @see org.eclipse.jface.preference.PreferenceConverter * @since 3.0 */ public final static String EDITOR_JAVA_METHOD_NAME_COLOR= IJavaColorConstants.JAVA_METHOD_NAME; /** * A named preference that controls whether method names are rendered in bold. * <p> * Value is of type <code>Boolean</code>. * </p> * * @since 3.0 */ public final static String EDITOR_JAVA_METHOD_NAME_BOLD= IJavaColorConstants.JAVA_METHOD_NAME + EDITOR_BOLD_SUFFIX; /** * A named preference that holds the color used to render operators and brackets. * <p> * Value is of type <code>String</code>. A RGB color value encoded as a string * using class <code>PreferenceConverter</code> * </p> * * @see org.eclipse.jface.resource.StringConverter * @see org.eclipse.jface.preference.PreferenceConverter * @since 3.0 */ public final static String EDITOR_JAVA_OPERATOR_COLOR= IJavaColorConstants.JAVA_OPERATOR; /** * A named preference that controls whether operators and brackets are rendered in bold. * <p> * Value is of type <code>Boolean</code>. * </p> * * @since 3.0 */ public final static String EDITOR_JAVA_OPERATOR_BOLD= IJavaColorConstants.JAVA_OPERATOR + EDITOR_BOLD_SUFFIX; /** * A named preference that holds the color used to render java default text. * <p> * Value is of type <code>String</code>. A RGB color value encoded as a string * using class <code>PreferenceConverter</code> * </p> * * @see org.eclipse.jface.resource.StringConverter * @see org.eclipse.jface.preference.PreferenceConverter */ public final static String EDITOR_JAVA_DEFAULT_COLOR= IJavaColorConstants.JAVA_DEFAULT; /** * A named preference that controls whether Java default text is rendered in bold. * <p> * Value is of type <code>Boolean</code>. * </p> */ public final static String EDITOR_JAVA_DEFAULT_BOLD= IJavaColorConstants.JAVA_DEFAULT + EDITOR_BOLD_SUFFIX; /** * A named preference that holds the color used to render task tags. * <p> * Value is of type <code>String</code>. A RGB color value encoded as a string * using class <code>PreferenceConverter</code> * </p> * * @see org.eclipse.jface.resource.StringConverter * @see org.eclipse.jface.preference.PreferenceConverter * @since 2.1 */ public final static String EDITOR_TASK_TAG_COLOR= IJavaColorConstants.TASK_TAG; /** * A named preference that controls whether task tags are rendered in bold. * <p> * Value is of type <code>Boolean</code>. * </p> * @since 2.1 */ public final static String EDITOR_TASK_TAG_BOLD= IJavaColorConstants.TASK_TAG + EDITOR_BOLD_SUFFIX; /** * A named preference that holds the color used to render javadoc keywords. * <p> * Value is of type <code>String</code>. A RGB color value encoded as a string * using class <code>PreferenceConverter</code> * </p> * * @see org.eclipse.jface.resource.StringConverter * @see org.eclipse.jface.preference.PreferenceConverter */ public final static String EDITOR_JAVADOC_KEYWORD_COLOR= IJavaColorConstants.JAVADOC_KEYWORD; /** * A named preference that controls whether javadoc keywords are rendered in bold. * <p> * Value is of type <code>Boolean</code>. * </p> */ public final static String EDITOR_JAVADOC_KEYWORD_BOLD= IJavaColorConstants.JAVADOC_KEYWORD + EDITOR_BOLD_SUFFIX; /** * A named preference that holds the color used to render javadoc tags. * <p> * Value is of type <code>String</code>. A RGB color value encoded as a string * using class <code>PreferenceConverter</code> * </p> * * @see org.eclipse.jface.resource.StringConverter * @see org.eclipse.jface.preference.PreferenceConverter */ public final static String EDITOR_JAVADOC_TAG_COLOR= IJavaColorConstants.JAVADOC_TAG; /** * A named preference that controls whether javadoc tags are rendered in bold. * <p> * Value is of type <code>Boolean</code>. * </p> */ public final static String EDITOR_JAVADOC_TAG_BOLD= IJavaColorConstants.JAVADOC_TAG + EDITOR_BOLD_SUFFIX; /** * A named preference that holds the color used to render javadoc links. * <p> * Value is of type <code>String</code>. A RGB color value encoded as a string * using class <code>PreferenceConverter</code> * </p> * * @see org.eclipse.jface.resource.StringConverter * @see org.eclipse.jface.preference.PreferenceConverter */ public final static String EDITOR_JAVADOC_LINKS_COLOR= IJavaColorConstants.JAVADOC_LINK; /** * A named preference that controls whether javadoc links are rendered in bold. * <p> * Value is of type <code>Boolean</code>. * </p> */ public final static String EDITOR_JAVADOC_LINKS_BOLD= IJavaColorConstants.JAVADOC_LINK + EDITOR_BOLD_SUFFIX; /** * A named preference that holds the color used to render javadoc default text. * <p> * Value is of type <code>String</code>. A RGB color value encoded as a string * using class <code>PreferenceConverter</code> * </p> * * @see org.eclipse.jface.resource.StringConverter * @see org.eclipse.jface.preference.PreferenceConverter */ public final static String EDITOR_JAVADOC_DEFAULT_COLOR= IJavaColorConstants.JAVADOC_DEFAULT; /** * A named preference that controls whether javadoc default text is rendered in bold. * <p> * Value is of type <code>Boolean</code>. * </p> */ public final static String EDITOR_JAVADOC_DEFAULT_BOLD= IJavaColorConstants.JAVADOC_DEFAULT + EDITOR_BOLD_SUFFIX; /** * A named preference that holds the color used for 'linked-mode' underline. * <p> * Value is of type <code>String</code>. A RGB color value encoded as a string * using class <code>PreferenceConverter</code> * </p> * * @see org.eclipse.jface.resource.StringConverter * @see org.eclipse.jface.preference.PreferenceConverter * @since 2.1 */ public final static String EDITOR_LINK_COLOR= "linkColor"; //$NON-NLS-1$ /** * A named preference that controls whether hover tooltips in the editor are turned on or off. * <p> * Value is of type <code>Boolean</code>. * </p> */ public static final String EDITOR_SHOW_HOVER= "org.eclipse.jdt.ui.editor.showHover"; //$NON-NLS-1$ /** * A named preference that defines the hover shown when no control key is * pressed. * <p>Value is of type <code>String</code>: possible values are <code> * EDITOR_NO_HOVER_CONFIGURED_ID</code> or * <code>EDITOR_DEFAULT_HOVER_CONFIGURED_ID</code> or the hover id of a hover * contributed as <code>javaEditorTextHovers</code>. * </p> * @see #EDITOR_NO_HOVER_CONFIGURED_ID * @see #EDITOR_DEFAULT_HOVER_CONFIGURED_ID * @see JavaUI * @since 2.1 * @deprecated Will soon be removed - replaced by {@link #EDITOR_TEXT_HOVER_MODIFIERS} */ public static final String EDITOR_NONE_HOVER= "noneHover"; //$NON-NLS-1$ /** * A named preference that defines the hover shown when the * <code>CTRL</code> modifier key is pressed. * <p>Value is of type <code>String</code>: possible values are <code> * EDITOR_NO_HOVER_CONFIGURED_ID</code> or * <code>EDITOR_DEFAULT_HOVER_CONFIGURED_ID</code> or the hover id of a * hover contributed as <code>javaEditorTextHovers</code>. * </p> * @see #EDITOR_NO_HOVER_CONFIGURED_ID * @see #EDITOR_DEFAULT_HOVER_CONFIGURED_ID * @see JavaUI * @since 2.1 * @deprecated Will soon be removed - replaced by {@link #EDITOR_TEXT_HOVER_MODIFIERS} */ public static final String EDITOR_CTRL_HOVER= "ctrlHover"; //$NON-NLS-1$ /** * A named preference that defines the hover shown when the * <code>SHIFT</code> modifier key is pressed. * <p>Value is of type <code>String</code>: possible values are <code> * EDITOR_NO_HOVER_CONFIGURED_ID</code> or * <code>EDITOR_DEFAULT_HOVER_CONFIGURED_ID</code> or the hover id of a * hover contributed as <code>javaEditorTextHovers</code>. * </p> * @see #EDITOR_NO_HOVER_CONFIGURED_ID * @see #EDITOR_DEFAULT_HOVER_CONFIGURED_ID * @see JavaUI ID_*_HOVER * @since 2.1 * @deprecated Will soon be removed - replaced by {@link #EDITOR_TEXT_HOVER_MODIFIERS} */ public static final String EDITOR_SHIFT_HOVER= "shiftHover"; //$NON-NLS-1$ /** * A named preference that defines the hover shown when the * <code>CTRL + ALT</code> modifier keys is pressed. * <p>Value is of type <code>String</code>: possible values are <code> * EDITOR_NO_HOVER_CONFIGURED_ID</code> or * <code>EDITOR_DEFAULT_HOVER_CONFIGURED_ID</code> or the hover id of a * hover contributed as <code>javaEditorTextHovers</code>. * </p> * @see #EDITOR_NO_HOVER_CONFIGURED_ID * @see #EDITOR_DEFAULT_HOVER_CONFIGURED_ID * @see JavaUI ID_*_HOVER * @since 2.1 */ public static final String EDITOR_CTRL_ALT_HOVER= "ctrlAltHover"; //$NON-NLS-1$ /** * A named preference that defines the hover shown when the * <code>CTRL + ALT + SHIFT</code> modifier keys is pressed. * <p>Value is of type <code>String</code>: possible values are <code> * EDITOR_NO_HOVER_CONFIGURED_ID</code> or * <code>EDITOR_DEFAULT_HOVER_CONFIGURED_ID</code> or the hover id of a * hover contributed as <code>javaEditorTextHovers</code>. * </p> * @see #EDITOR_NO_HOVER_CONFIGURED_ID * @see #EDITOR_DEFAULT_HOVER_CONFIGURED_ID * @see JavaUI ID_*_HOVER * @since 2.1 */ public static final String EDITOR_CTRL_ALT_SHIFT_HOVER= "ctrlAltShiftHover"; //$NON-NLS-1$ /** * A named preference that defines the hover shown when the * <code>CTRL + SHIFT</code> modifier keys is pressed. * <p>Value is of type <code>String</code>: possible values are <code> * EDITOR_NO_HOVER_CONFIGURED_ID</code> or * <code>EDITOR_DEFAULT_HOVER_CONFIGURED_ID</code> or the hover id of a * hover contributed as <code>javaEditorTextHovers</code>. * </p> * @see #EDITOR_NO_HOVER_CONFIGURED_ID * @see #EDITOR_DEFAULT_HOVER_CONFIGURED_ID * @see JavaUI ID_*_HOVER * @since 2.1 * @deprecated Will be removed in one of the next builds. */ public static final String EDITOR_CTRL_SHIFT_HOVER= "ctrlShiftHover"; //$NON-NLS-1$ /** * A named preference that defines the hover shown when the * <code>ALT</code> modifier key is pressed. * <p>Value is of type <code>String</code>: possible values are <code> * EDITOR_NO_HOVER_CONFIGURED_ID</code>, * <code>EDITOR_DEFAULT_HOVER_CONFIGURED_ID</code> or the hover id of a * hover contributed as <code>javaEditorTextHovers</code>. * </p> * @see #EDITOR_NO_HOVER_CONFIGURED_ID * @see #EDITOR_DEFAULT_HOVER_CONFIGURED_ID * @see JavaUI ID_*_HOVER * @deprecated Will soon be removed - replaced by {@link #EDITOR_TEXT_HOVER_MODIFIERS} * @since 2.1 */ public static final String EDITOR_ALT_SHIFT_HOVER= "altShiftHover"; //$NON-NLS-1$ /** * A string value used by the named preferences for hover configuration to * descibe that no hover should be shown for the given key modifiers. * @deprecated Will soon be removed - replaced by {@link #EDITOR_TEXT_HOVER_MODIFIERS} * @since 2.1 */ public static final String EDITOR_NO_HOVER_CONFIGURED_ID= "noHoverConfiguredId"; //$NON-NLS-1$ /** * A string value used by the named preferences for hover configuration to * descibe that the default hover should be shown for the given key * modifiers. The default hover is described by the * <code>EDITOR_DEFAULT_HOVER</code> property. * @since 2.1 * @deprecated Will soon be removed - replaced by {@link #EDITOR_TEXT_HOVER_MODIFIERS} */ public static final String EDITOR_DEFAULT_HOVER_CONFIGURED_ID= "defaultHoverConfiguredId"; //$NON-NLS-1$ /** * A named preference that defines the hover named the 'default hover'. * Value is of type <code>String</code>: possible values are <code> * EDITOR_NO_HOVER_CONFIGURED_ID</code> or <code> the hover id of a hover * contributed as <code>javaEditorTextHovers</code>. * </p> * @since 2.1 * @deprecated Will soon be removed - replaced by {@link #EDITOR_TEXT_HOVER_MODIFIERS} */ public static final String EDITOR_DEFAULT_HOVER= "defaultHover"; //$NON-NLS-1$ /** * A named preference that controls if segmented view (show selected element only) is turned on or off. * <p> * Value is of type <code>Boolean</code>. * </p> */ public static final String EDITOR_SHOW_SEGMENTS= "org.eclipse.jdt.ui.editor.showSegments"; //$NON-NLS-1$ /** * A named preference that controls if browser like links are turned on or off. * <p> * Value is of type <code>Boolean</code>. * </p> * * @since 2.1 */ public static final String EDITOR_BROWSER_LIKE_LINKS= "browserLikeLinks"; //$NON-NLS-1$ /** * A named preference that controls the key modifier for browser like links. * <p> * Value is of type <code>String</code>. * </p> * * @since 2.1 */ public static final String EDITOR_BROWSER_LIKE_LINKS_KEY_MODIFIER= "browserLikeLinksKeyModifier"; //$NON-NLS-1$ /** * A named preference that controls the key modifier mask for browser like links. * The value is only used if the value of <code>EDITOR_BROWSER_LIKE_LINKS</code> * cannot be resolved to valid SWT modifier bits. * <p> * Value is of type <code>String</code>. * </p> * * @see #EDITOR_BROWSER_LIKE_LINKS_KEY_MODIFIER * @since 2.1.1 */ public static final String EDITOR_BROWSER_LIKE_LINKS_KEY_MODIFIER_MASK= "browserLikeLinksKeyModifierMask"; //$NON-NLS-1$ /** * A named preference that controls disabling of the overwrite mode. * <p> * Value is of type <code>Boolean</code>. * </p> * * @since 3.0 */ public static final String EDITOR_DISABLE_OVERWRITE_MODE= "disable_overwrite_mode"; //$NON-NLS-1$ /** * A named preference that controls the "smart semicolon" smart typing handler * <p> * Value is of type <code>Boolean</code>. * </p> * * @since 3.0 */ public static final String EDITOR_SMART_SEMICOLON= "smart_semicolon"; //$NON-NLS-1$ /** * A named preference that controls the "smart opening brace" smart typing handler * <p> * Value is of type <code>Boolean</code>. * </p> * * @since 3.0 */ public static final String EDITOR_SMART_OPENING_BRACE= "smart_opening_brace"; //$NON-NLS-1$ /** * A named preference that controls the smart tab behaviour. * <p> * Value is of type <code>Boolean</code>. * * @since 3.0 */ public static final String EDITOR_SMART_TAB= "smart_tab"; //$NON-NLS-1$ /** * A named preference that controls if the Java code assist gets auto activated. * <p> * Value is of type <code>Boolean</code>. * </p> */ public final static String CODEASSIST_AUTOACTIVATION= "content_assist_autoactivation"; //$NON-NLS-1$ /** * A name preference that holds the auto activation delay time in milli seconds. * <p> * Value is of type <code>Int</code>. * </p> */ public final static String CODEASSIST_AUTOACTIVATION_DELAY= "content_assist_autoactivation_delay"; //$NON-NLS-1$ /** * A named preference that controls if code assist contains only visible proposals. * <p> * Value is of type <code>Boolean</code>. if <code>true<code> code assist only contains visible members. If * <code>false</code> all members are included. * </p> */ public final static String CODEASSIST_SHOW_VISIBLE_PROPOSALS= "content_assist_show_visible_proposals"; //$NON-NLS-1$ /** * A named preference that controls if the Java code assist inserts a * proposal automatically if only one proposal is available. * <p> * Value is of type <code>Boolean</code>. * </p> * @since 2.1 */ public final static String CODEASSIST_AUTOINSERT= "content_assist_autoinsert"; //$NON-NLS-1$ /** * A named preference that controls if the Java code assist adds import * statements. * <p> * Value is of type <code>Boolean</code>. * </p> * @since 2.1 */ public final static String CODEASSIST_ADDIMPORT= "content_assist_add_import"; //$NON-NLS-1$ /** * A named preference that controls if the Java code assist only inserts * completions. If set to false the proposals can also _replace_ code. * <p> * Value is of type <code>Boolean</code>. * </p> * @since 2.1 */ public final static String CODEASSIST_INSERT_COMPLETION= "content_assist_insert_completion"; //$NON-NLS-1$ /** * A named preference that controls whether code assist proposals filtering is case sensitive or not. * <p> * Value is of type <code>Boolean</code>. * </p> */ public final static String CODEASSIST_CASE_SENSITIVITY= "content_assist_case_sensitivity"; //$NON-NLS-1$ /** * A named preference that defines if code assist proposals are sorted in alphabetical order. * <p> * Value is of type <code>Boolean</code>. If <code>true</code> that are sorted in alphabetical * order. If <code>false</code> that are unsorted. * </p> */ public final static String CODEASSIST_ORDER_PROPOSALS= "content_assist_order_proposals"; //$NON-NLS-1$ /** * A named preference that controls if argument names are filled in when a method is selected from as list * of code assist proposal. * <p> * Value is of type <code>Boolean</code>. * </p> */ public final static String CODEASSIST_FILL_ARGUMENT_NAMES= "content_assist_fill_method_arguments"; //$NON-NLS-1$ /** * A named preference that controls if method arguments are guessed when a * method is selected from as list of code assist proposal. * <p> * Value is of type <code>Boolean</code>. * </p> * @since 2.1 */ public final static String CODEASSIST_GUESS_METHOD_ARGUMENTS= "content_assist_guess_method_arguments"; //$NON-NLS-1$ /** * A named preference that holds the characters that auto activate code assist in Java code. * <p> * Value is of type <code>Sring</code>. All characters that trigger auto code assist in Java code. * </p> */ public final static String CODEASSIST_AUTOACTIVATION_TRIGGERS_JAVA= "content_assist_autoactivation_triggers_java"; //$NON-NLS-1$ /** * A named preference that holds the characters that auto activate code assist in Javadoc. * <p> * Value is of type <code>Sring</code>. All characters that trigger auto code assist in Javadoc. * </p> */ public final static String CODEASSIST_AUTOACTIVATION_TRIGGERS_JAVADOC= "content_assist_autoactivation_triggers_javadoc"; //$NON-NLS-1$ /** * A named preference that holds the background color used in the code assist selection dialog. * <p> * Value is of type <code>String</code>. A RGB color value encoded as a string * using class <code>PreferenceConverter</code> * </p> * * @see org.eclipse.jface.resource.StringConverter * @see org.eclipse.jface.preference.PreferenceConverter */ public final static String CODEASSIST_PROPOSALS_BACKGROUND= "content_assist_proposals_background"; //$NON-NLS-1$ /** * A named preference that holds the foreground color used in the code assist selection dialog. * <p> * Value is of type <code>String</code>. A RGB color value encoded as a string * using class <code>PreferenceConverter</code> * </p> * * @see org.eclipse.jface.resource.StringConverter * @see org.eclipse.jface.preference.PreferenceConverter */ public final static String CODEASSIST_PROPOSALS_FOREGROUND= "content_assist_proposals_foreground"; //$NON-NLS-1$ /** * A named preference that holds the background color used for parameter hints. * <p> * Value is of type <code>String</code>. A RGB color value encoded as a string * using class <code>PreferenceConverter</code> * </p> * * @see org.eclipse.jface.resource.StringConverter * @see org.eclipse.jface.preference.PreferenceConverter */ public final static String CODEASSIST_PARAMETERS_BACKGROUND= "content_assist_parameters_background"; //$NON-NLS-1$ /** * A named preference that holds the foreground color used in the code assist selection dialog. * <p> * Value is of type <code>String</code>. A RGB color value encoded as a string * using class <code>PreferenceConverter</code> * </p> * * @see org.eclipse.jface.resource.StringConverter * @see org.eclipse.jface.preference.PreferenceConverter */ public final static String CODEASSIST_PARAMETERS_FOREGROUND= "content_assist_parameters_foreground"; //$NON-NLS-1$ /** * A named preference that holds the background color used in the code * assist selection dialog to mark replaced code. * <p> * Value is of type <code>String</code>. A RGB color value encoded as a string * using class <code>PreferenceConverter</code> * </p> * * @see org.eclipse.jface.resource.StringConverter * @see org.eclipse.jface.preference.PreferenceConverter * @since 2.1 */ public final static String CODEASSIST_REPLACEMENT_BACKGROUND= "content_assist_completion_replacement_background"; //$NON-NLS-1$ /** * A named preference that holds the foreground color used in the code * assist selection dialog to mark replaced code. * <p> * Value is of type <code>String</code>. A RGB color value encoded as a string * using class <code>PreferenceConverter</code> * </p> * * @see org.eclipse.jface.resource.StringConverter * @see org.eclipse.jface.preference.PreferenceConverter * @since 2.1 */ public final static String CODEASSIST_REPLACEMENT_FOREGROUND= "content_assist_completion_replacement_foreground"; //$NON-NLS-1$ /** * A named preference that controls the behaviour of the refactoring wizard for showing the error page. * <p> * Value is of type <code>String</code>. Valid values are: * <code>REFACTOR_FATAL_SEVERITY</code>, * <code>REFACTOR_ERROR_SEVERITY</code>, * <code>REFACTOR_WARNING_SEVERITY</code> * <code>REFACTOR_INFO_SEVERITY</code>, * <code>REFACTOR_OK_SEVERITY</code>. * </p> * * @see #REFACTOR_FATAL_SEVERITY * @see #REFACTOR_ERROR_SEVERITY * @see #REFACTOR_WARNING_SEVERITY * @see #REFACTOR_INFO_SEVERITY * @see #REFACTOR_OK_SEVERITY */ public static final String REFACTOR_ERROR_PAGE_SEVERITY_THRESHOLD= "Refactoring.ErrorPage.severityThreshold"; //$NON-NLS-1$ /** * A string value used by the named preference <code>REFACTOR_ERROR_PAGE_SEVERITY_THRESHOLD</code>. * * @see #REFACTOR_ERROR_PAGE_SEVERITY_THRESHOLD */ public static final String REFACTOR_FATAL_SEVERITY= "4"; //$NON-NLS-1$ /** * A string value used by the named preference <code>REFACTOR_ERROR_PAGE_SEVERITY_THRESHOLD</code>. * * @see #REFACTOR_ERROR_PAGE_SEVERITY_THRESHOLD */ public static final String REFACTOR_ERROR_SEVERITY= "3"; //$NON-NLS-1$ /** * A string value used by the named preference <code>REFACTOR_ERROR_PAGE_SEVERITY_THRESHOLD</code>. * * @see #REFACTOR_ERROR_PAGE_SEVERITY_THRESHOLD */ public static final String REFACTOR_WARNING_SEVERITY= "2"; //$NON-NLS-1$ /** * A string value used by the named preference <code>REFACTOR_ERROR_PAGE_SEVERITY_THRESHOLD</code>. * * @see #REFACTOR_ERROR_PAGE_SEVERITY_THRESHOLD */ public static final String REFACTOR_INFO_SEVERITY= "1"; //$NON-NLS-1$ /** * A string value used by the named preference <code>REFACTOR_ERROR_PAGE_SEVERITY_THRESHOLD</code>. * * @see #REFACTOR_ERROR_PAGE_SEVERITY_THRESHOLD */ public static final String REFACTOR_OK_SEVERITY= "0"; //$NON-NLS-1$ /** * A named preference thet controls whether all dirty editors are automatically saved before a refactoring is * executed. * <p> * Value is of type <code>Boolean</code>. * </p> */ public static final String REFACTOR_SAVE_ALL_EDITORS= "Refactoring.savealleditors"; //$NON-NLS-1$ /** * A named preference that controls if the Java Browsing views are linked to the active editor. * <p> * Value is of type <code>Boolean</code>. * </p> * * @see #LINK_PACKAGES_TO_EDITOR */ public static final String BROWSING_LINK_VIEW_TO_EDITOR= "org.eclipse.jdt.ui.browsing.linktoeditor"; //$NON-NLS-1$ /** * A named preference that controls the layout of the Java Browsing views vertically. Boolean value. * <p> * Value is of type <code>Boolean</code>. If <code>true<code> the views are stacked vertical. * If <code>false</code> they are stacked horizontal. * </p> */ public static final String BROWSING_STACK_VERTICALLY= "org.eclipse.jdt.ui.browsing.stackVertically"; //$NON-NLS-1$ /** * A named preference that controls if templates are formatted when applied. * <p> * Value is of type <code>Boolean</code>. * </p> * * @since 2.1 */ public static final String TEMPLATES_USE_CODEFORMATTER= "org.eclipse.jdt.ui.template.format"; //$NON-NLS-1$ /** * Initializes the given preference store with the default values. * * @param store the preference store to be initialized * * @since 2.1 */ public static void initializeDefaultValues(IPreferenceStore store) { // set the default values from ExtendedTextEditor ExtendedTextEditorPreferenceConstants.initializeDefaultValues(store); store.setDefault(PreferenceConstants.EDITOR_SHOW_SEGMENTS, false); // JavaBasePreferencePage store.setDefault(PreferenceConstants.LINK_PACKAGES_TO_EDITOR, false); store.setDefault(PreferenceConstants.LINK_TYPEHIERARCHY_TO_EDITOR, false); store.setDefault(PreferenceConstants.OPEN_TYPE_HIERARCHY, PreferenceConstants.OPEN_TYPE_HIERARCHY_IN_VIEW_PART); store.setDefault(PreferenceConstants.DOUBLE_CLICK, PreferenceConstants.DOUBLE_CLICK_EXPANDS); store.setDefault(PreferenceConstants.UPDATE_JAVA_VIEWS, PreferenceConstants.UPDATE_WHILE_EDITING); store.setDefault(PreferenceConstants.LINK_BROWSING_PROJECTS_TO_EDITOR, true); store.setDefault(PreferenceConstants.LINK_BROWSING_PACKAGES_TO_EDITOR, true); store.setDefault(PreferenceConstants.LINK_BROWSING_TYPES_TO_EDITOR, true); store.setDefault(PreferenceConstants.LINK_BROWSING_MEMBERS_TO_EDITOR, true); // AppearancePreferencePage store.setDefault(PreferenceConstants.APPEARANCE_COMPRESS_PACKAGE_NAMES, false); store.setDefault(PreferenceConstants.APPEARANCE_METHOD_RETURNTYPE, false); store.setDefault(PreferenceConstants.SHOW_CU_CHILDREN, true); store.setDefault(PreferenceConstants.APPEARANCE_OVERRIDE_INDICATOR, true); store.setDefault(PreferenceConstants.BROWSING_STACK_VERTICALLY, false); store.setDefault(PreferenceConstants.APPEARANCE_PKG_NAME_PATTERN_FOR_PKG_VIEW, ""); //$NON-NLS-1$ store.setDefault(PreferenceConstants.APPEARANCE_FOLD_PACKAGES_IN_PACKAGE_EXPLORER, true); // ImportOrganizePreferencePage store.setDefault(PreferenceConstants.ORGIMPORTS_IMPORTORDER, "java;javax;org;com"); //$NON-NLS-1$ store.setDefault(PreferenceConstants.ORGIMPORTS_ONDEMANDTHRESHOLD, 99); store.setDefault(PreferenceConstants.ORGIMPORTS_IGNORELOWERCASE, true); // ClasspathVariablesPreferencePage // CodeFormatterPreferencePage // CompilerPreferencePage // no initialization needed // RefactoringPreferencePage store.setDefault(PreferenceConstants.REFACTOR_ERROR_PAGE_SEVERITY_THRESHOLD, PreferenceConstants.REFACTOR_ERROR_SEVERITY); store.setDefault(PreferenceConstants.REFACTOR_SAVE_ALL_EDITORS, false); // TemplatePreferencePage store.setDefault(PreferenceConstants.TEMPLATES_USE_CODEFORMATTER, true); // CodeGenerationPreferencePage // compatibility code if (store.getBoolean(PreferenceConstants.CODEGEN_USE_GETTERSETTER_PREFIX)) { String prefix= store.getString(PreferenceConstants.CODEGEN_GETTERSETTER_PREFIX); if (prefix.length() > 0) { JavaCore.getPlugin().getPluginPreferences().setValue(JavaCore.CODEASSIST_FIELD_PREFIXES, prefix); store.setToDefault(PreferenceConstants.CODEGEN_USE_GETTERSETTER_PREFIX); store.setToDefault(PreferenceConstants.CODEGEN_GETTERSETTER_PREFIX); } } if (store.getBoolean(PreferenceConstants.CODEGEN_USE_GETTERSETTER_SUFFIX)) { String suffix= store.getString(PreferenceConstants.CODEGEN_GETTERSETTER_SUFFIX); if (suffix.length() > 0) { JavaCore.getPlugin().getPluginPreferences().setValue(JavaCore.CODEASSIST_FIELD_SUFFIXES, suffix); store.setToDefault(PreferenceConstants.CODEGEN_USE_GETTERSETTER_SUFFIX); store.setToDefault(PreferenceConstants.CODEGEN_GETTERSETTER_SUFFIX); } } store.setDefault(PreferenceConstants.CODEGEN_KEYWORD_THIS, false); store.setDefault(PreferenceConstants.CODEGEN_IS_FOR_GETTERS, true); store.setDefault(PreferenceConstants.CODEGEN_ADD_COMMENTS, true); // MembersOrderPreferencePage store.setDefault(PreferenceConstants.APPEARANCE_MEMBER_SORT_ORDER, "T,SI,SF,SM,I,F,C,M"); //$NON-NLS-1$ // must add here to guarantee that it is the first in the listener list store.addPropertyChangeListener(JavaPlugin.getDefault().getMemberOrderPreferenceCache()); // JavaEditorPreferencePage store.setDefault(PreferenceConstants.EDITOR_MATCHING_BRACKETS, true); PreferenceConverter.setDefault(store, PreferenceConstants.EDITOR_MATCHING_BRACKETS_COLOR, new RGB(192, 192,192)); store.setDefault(PreferenceConstants.EDITOR_CURRENT_LINE, true); PreferenceConverter.setDefault(store, PreferenceConstants.EDITOR_CURRENT_LINE_COLOR, new RGB(225, 235, 224)); store.setDefault(PreferenceConstants.EDITOR_PRINT_MARGIN, false); store.setDefault(PreferenceConstants.EDITOR_PRINT_MARGIN_COLUMN, 80); PreferenceConverter.setDefault(store, PreferenceConstants.EDITOR_PRINT_MARGIN_COLOR, new RGB(176, 180 , 185)); PreferenceConverter.setDefault(store, PreferenceConstants.EDITOR_FIND_SCOPE_COLOR, new RGB(185, 176 , 180)); store.setDefault(PreferenceConstants.EDITOR_CORRECTION_INDICATION, true); store.setDefault(PreferenceConstants.EDITOR_SYNC_OUTLINE_ON_CURSOR_MOVE, true); store.setDefault(PreferenceConstants.EDITOR_EVALUTE_TEMPORARY_PROBLEMS, true); store.setDefault(PreferenceConstants.EDITOR_OVERVIEW_RULER, true); store.setDefault(PreferenceConstants.EDITOR_LINE_NUMBER_RULER, false); PreferenceConverter.setDefault(store, PreferenceConstants.EDITOR_LINE_NUMBER_RULER_COLOR, new RGB(0, 0, 0)); PreferenceConverter.setDefault(store, PreferenceConstants.EDITOR_LINKED_POSITION_COLOR, new RGB(0, 200 , 100)); PreferenceConverter.setDefault(store, PreferenceConstants.EDITOR_LINK_COLOR, new RGB(0, 0, 255)); store.setDefault(PreferenceConstants.EDITOR_FOREGROUND_DEFAULT_COLOR, true); store.setDefault(PreferenceConstants.EDITOR_BACKGROUND_DEFAULT_COLOR, true); store.setDefault(PreferenceConstants.EDITOR_TAB_WIDTH, 4); store.setDefault(PreferenceConstants.EDITOR_SPACES_FOR_TABS, false); PreferenceConverter.setDefault(store, PreferenceConstants.EDITOR_MULTI_LINE_COMMENT_COLOR, new RGB(63, 127, 95)); store.setDefault(PreferenceConstants.EDITOR_MULTI_LINE_COMMENT_BOLD, false); PreferenceConverter.setDefault(store, PreferenceConstants.EDITOR_SINGLE_LINE_COMMENT_COLOR, new RGB(63, 127, 95)); store.setDefault(PreferenceConstants.EDITOR_SINGLE_LINE_COMMENT_BOLD, false); PreferenceConverter.setDefault(store, PreferenceConstants.EDITOR_JAVA_KEYWORD_COLOR, new RGB(127, 0, 85)); store.setDefault(PreferenceConstants.EDITOR_JAVA_KEYWORD_BOLD, true); PreferenceConverter.setDefault(store, PreferenceConstants.EDITOR_STRING_COLOR, new RGB(42, 0, 255)); store.setDefault(PreferenceConstants.EDITOR_STRING_BOLD, false); PreferenceConverter.setDefault(store, PreferenceConstants.EDITOR_JAVA_DEFAULT_COLOR, new RGB(0, 0, 0)); store.setDefault(PreferenceConstants.EDITOR_JAVA_DEFAULT_BOLD, false); PreferenceConverter.setDefault(store, PreferenceConstants.EDITOR_JAVA_METHOD_NAME_COLOR, new RGB(0, 0, 0)); store.setDefault(PreferenceConstants.EDITOR_JAVA_METHOD_NAME_BOLD, false); PreferenceConverter.setDefault(store, PreferenceConstants.EDITOR_JAVA_OPERATOR_COLOR, new RGB(0, 0, 0)); store.setDefault(PreferenceConstants.EDITOR_JAVA_OPERATOR_BOLD, false); PreferenceConverter.setDefault(store, PreferenceConstants.EDITOR_TASK_TAG_COLOR, new RGB(127, 159, 191)); store.setDefault(PreferenceConstants.EDITOR_TASK_TAG_BOLD, true); PreferenceConverter.setDefault(store, PreferenceConstants.EDITOR_JAVADOC_KEYWORD_COLOR, new RGB(127, 159, 191)); store.setDefault(PreferenceConstants.EDITOR_JAVADOC_KEYWORD_BOLD, true); PreferenceConverter.setDefault(store, PreferenceConstants.EDITOR_JAVADOC_TAG_COLOR, new RGB(127, 127, 159)); store.setDefault(PreferenceConstants.EDITOR_JAVADOC_TAG_BOLD, false); PreferenceConverter.setDefault(store, PreferenceConstants.EDITOR_JAVADOC_LINKS_COLOR, new RGB(63, 63, 191)); store.setDefault(PreferenceConstants.EDITOR_JAVADOC_LINKS_BOLD, false); PreferenceConverter.setDefault(store, PreferenceConstants.EDITOR_JAVADOC_DEFAULT_COLOR, new RGB(63, 95, 191)); store.setDefault(PreferenceConstants.EDITOR_JAVADOC_DEFAULT_BOLD, false); store.setDefault(PreferenceConstants.CODEASSIST_AUTOACTIVATION, true); store.setDefault(PreferenceConstants.CODEASSIST_AUTOACTIVATION_DELAY, 500); store.setDefault(PreferenceConstants.CODEASSIST_AUTOINSERT, true); PreferenceConverter.setDefault(store, PreferenceConstants.CODEASSIST_PROPOSALS_BACKGROUND, new RGB(254, 241, 233)); PreferenceConverter.setDefault(store, PreferenceConstants.CODEASSIST_PROPOSALS_FOREGROUND, new RGB(0, 0, 0)); PreferenceConverter.setDefault(store, PreferenceConstants.CODEASSIST_PARAMETERS_BACKGROUND, new RGB(254, 241, 233)); PreferenceConverter.setDefault(store, PreferenceConstants.CODEASSIST_PARAMETERS_FOREGROUND, new RGB(0, 0, 0)); PreferenceConverter.setDefault(store, PreferenceConstants.CODEASSIST_REPLACEMENT_BACKGROUND, new RGB(255, 255, 0)); PreferenceConverter.setDefault(store, PreferenceConstants.CODEASSIST_REPLACEMENT_FOREGROUND, new RGB(255, 0, 0)); store.setDefault(PreferenceConstants.CODEASSIST_AUTOACTIVATION_TRIGGERS_JAVA, "."); //$NON-NLS-1$ store.setDefault(PreferenceConstants.CODEASSIST_AUTOACTIVATION_TRIGGERS_JAVADOC, "@"); //$NON-NLS-1$ store.setDefault(PreferenceConstants.CODEASSIST_SHOW_VISIBLE_PROPOSALS, true); store.setDefault(PreferenceConstants.CODEASSIST_CASE_SENSITIVITY, false); store.setDefault(PreferenceConstants.CODEASSIST_ORDER_PROPOSALS, false); store.setDefault(PreferenceConstants.CODEASSIST_ADDIMPORT, true); store.setDefault(PreferenceConstants.CODEASSIST_INSERT_COMPLETION, true); store.setDefault(PreferenceConstants.CODEASSIST_FILL_ARGUMENT_NAMES, false); store.setDefault(PreferenceConstants.CODEASSIST_GUESS_METHOD_ARGUMENTS, true); store.setDefault(PreferenceConstants.EDITOR_SMART_HOME_END, true); store.setDefault(PreferenceConstants.EDITOR_SUB_WORD_NAVIGATION, true); store.setDefault(PreferenceConstants.EDITOR_SMART_PASTE, true); store.setDefault(PreferenceConstants.EDITOR_CLOSE_STRINGS, true); store.setDefault(PreferenceConstants.EDITOR_CLOSE_BRACKETS, true); store.setDefault(PreferenceConstants.EDITOR_CLOSE_BRACES, true); store.setDefault(PreferenceConstants.EDITOR_CLOSE_JAVADOCS, true); store.setDefault(PreferenceConstants.EDITOR_WRAP_STRINGS, true); store.setDefault(PreferenceConstants.EDITOR_ADD_JAVADOC_TAGS, true); store.setDefault(PreferenceConstants.EDITOR_FORMAT_JAVADOCS, false); String mod1Name= Action.findModifierString(SWT.MOD1); // SWT.COMMAND on Mac; SWT.CONTROL elsewhere store.setDefault(PreferenceConstants.EDITOR_TEXT_HOVER_MODIFIERS, "org.eclipse.jdt.ui.BestMatchHover;0;org.eclipse.jdt.ui.JavaSourceHover;" + mod1Name); //$NON-NLS-1$ store.setDefault(PreferenceConstants.EDITOR_TEXT_HOVER_MODIFIER_MASKS, "org.eclipse.jdt.ui.BestMatchHover;0;org.eclipse.jdt.ui.JavaSourceHover;" + SWT.MOD1); //$NON-NLS-1$ store.setDefault(PreferenceConstants.EDITOR_SHOW_TEXT_HOVER_AFFORDANCE, true); store.setDefault(PreferenceConstants.EDITOR_BROWSER_LIKE_LINKS, true); store.setDefault(PreferenceConstants.EDITOR_BROWSER_LIKE_LINKS_KEY_MODIFIER, mod1Name); store.setDefault(PreferenceConstants.EDITOR_BROWSER_LIKE_LINKS_KEY_MODIFIER_MASK, SWT.MOD1); store.setDefault(PreferenceConstants.EDITOR_SMART_TAB, true); // work in progress WorkInProgressPreferencePage.initDefaults(store); // do more complicated stuff NewJavaProjectPreferencePage.initDefaults(store); } /** * Returns the JDT-UI preference store. * * @return the JDT-UI preference store */ public static IPreferenceStore getPreferenceStore() { return JavaPlugin.getDefault().getPreferenceStore(); } /** * Encodes a JRE library to be used in the named preference <code>NEWPROJECT_JRELIBRARY_LIST</code>. * * @param description a string value describing the JRE library. The description is used * to indentify the JDR library in the UI * @param entries an array of classpath entries to be encoded * * @return the encoded string. */ public static String encodeJRELibrary(String description, IClasspathEntry[] entries) { return NewJavaProjectPreferencePage.encodeJRELibrary(description, entries); } /** * Decodes an encoded JRE library and returns its description string. * * @return the description of an encoded JRE library * * @see #encodeJRELibrary(String, IClasspathEntry[]) */ public static String decodeJRELibraryDescription(String encodedLibrary) { return NewJavaProjectPreferencePage.decodeJRELibraryDescription(encodedLibrary); } /** * Decodes an encoded JRE library and returns its classpath entries. * * @return the array of classpath entries of an encoded JRE library. * * @see #encodeJRELibrary(String, IClasspathEntry[]) */ public static IClasspathEntry[] decodeJRELibraryClasspathEntries(String encodedLibrary) { return NewJavaProjectPreferencePage.decodeJRELibraryClasspathEntries(encodedLibrary); } /** * Returns the current configuration for the JRE to be used as default in new Java projects. * This is a convenience method to access the named preference <code>NEWPROJECT_JRELIBRARY_LIST * </code> with the index defined by <code> NEWPROJECT_JRELIBRARY_INDEX</code>. * * @return the current default set of classpath entries * * @see #NEWPROJECT_JRELIBRARY_LIST * @see #NEWPROJECT_JRELIBRARY_INDEX */ public static IClasspathEntry[] getDefaultJRELibrary() { return NewJavaProjectPreferencePage.getDefaultJRELibrary(); } }
43,035
Bug 43035 Smart Tab ends up at offset 0
Have a line that has an indent greater than it is required. Place cursor at the correct indent position. Press Tab. => Cursor ends up at the beginning of the document.
resolved fixed
e3b7077
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2003-09-15T07:47:11Z
2003-09-12T18:06:40Z
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/actions/IndentAction.java
/******************************************************************************* * Copyright (c) 2000, 2003 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Common Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/cpl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.jdt.internal.ui.actions; import java.util.ResourceBundle; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Status; import org.eclipse.swt.custom.BusyIndicator; import org.eclipse.swt.widgets.Display; import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.ISelectionProvider; import org.eclipse.jface.text.Assert; import org.eclipse.jface.text.BadLocationException; import org.eclipse.jface.text.DocumentCommand; import org.eclipse.jface.text.IDocument; import org.eclipse.jface.text.IRegion; import org.eclipse.jface.text.IRewriteTarget; import org.eclipse.jface.text.ITextSelection; import org.eclipse.jface.text.ITypedRegion; import org.eclipse.jface.text.Position; import org.eclipse.jface.text.TextSelection; import org.eclipse.jface.text.TextUtilities; import org.eclipse.ui.IEditorInput; import org.eclipse.ui.texteditor.IDocumentProvider; import org.eclipse.ui.texteditor.ITextEditor; import org.eclipse.ui.texteditor.ITextEditorExtension3; import org.eclipse.ui.texteditor.TextEditorAction; import org.eclipse.jdt.internal.ui.JavaPlugin; import org.eclipse.jdt.internal.ui.text.IJavaPartitions; import org.eclipse.jdt.internal.ui.text.JavaHeuristicScanner; import org.eclipse.jdt.internal.ui.text.JavaIndenter; import org.eclipse.jdt.internal.ui.text.javadoc.JavaDocAutoIndentStrategy; /** * Indents a line or range of lines in a Java document to its correct position. No complete * AST must be present, the indentation is computed using heuristics. The algorith used is fast for * single lines, but does not store any information and therefore not so efficient for large line * ranges. * * @see org.eclipse.jdt.internal.ui.text.JavaHeuristicScanner * @see org.eclipse.jdt.internal.ui.text.JavaIndenter * @since 3.0 */ public class IndentAction extends TextEditorAction { /** * Creates a new instance. * * @param bundle the resource bundle * @param prefix the prefix to use for keys in <code>bundle</code> * @param editor the text editor */ public IndentAction(ResourceBundle bundle, String prefix, ITextEditor editor) { super(bundle, prefix, editor); } /* * @see org.eclipse.jface.action.Action#run() */ public void run() { // update has been called by the framework if (!isEnabled()) return; ITextSelection selection= getSelection(); final IDocument document= getDocument(); if (document != null) { final int offset= selection.getOffset(); final int length= selection.getLength(); final Position end= new Position(offset + length); final int firstLine, nLines; try { document.addPosition(end); firstLine= document.getLineOfOffset(offset); // check for marginal (zero-length) lines int minusOne= length == 0 ? 0 : 1; nLines= document.getLineOfOffset(offset + length - minusOne) - firstLine + 1; } catch (BadLocationException e) { // will only happen on concurrent modification JavaPlugin.log(new Status(IStatus.ERROR, JavaPlugin.getPluginId(), IStatus.OK, null, e)); return; } Runnable runnable= new Runnable() { public void run() { IRewriteTarget target= (IRewriteTarget)getTextEditor().getAdapter(IRewriteTarget.class); if (target != null) { target.beginCompoundChange(); target.setRedraw(false); } try { JavaHeuristicScanner scanner= new JavaHeuristicScanner(document); JavaIndenter indenter= new JavaIndenter(document, scanner); int newOffset= offset; for (int i= 0; i < nLines; i++) { newOffset= indentLine(document, firstLine + i, indenter, scanner); } // update caret position: move to new position when indenting just one line // keep selection when indenting multiple int newLength= 0; if (nLines > 1) { newOffset= offset; newLength= end.getOffset() - offset; } Assert.isTrue(newLength >= 0); Assert.isTrue(newOffset >= 0); // only change the selection if it really changes if (offset != newOffset || length != newLength) // TODO: be less intrusive than selectAndReveal getTextEditor().selectAndReveal(newOffset, newLength); document.removePosition(end); } catch (BadLocationException e) { // will only happen on concurrent modification JavaPlugin.log(new Status(IStatus.ERROR, JavaPlugin.getPluginId(), IStatus.OK, null, e)); } finally { if (target != null) { target.endCompoundChange(); target.setRedraw(true); } } } }; if (nLines > 50) { Display display= getTextEditor().getEditorSite().getWorkbenchWindow().getShell().getDisplay(); BusyIndicator.showWhile(display, runnable); } else runnable.run(); } } /** * Indents a single line using the java heuristic scanner. Javadoc and multiline comments are * indented as specified by the <code>JavaDocAutoIndentStrategy</code>. * * @param document the document * @param line the line to be indented * @param indenter the java indenter * @param scanner the heuristic scanner * @return the position in document after the indentation * @throws BadLocationException if the document got changed concurrently */ private int indentLine(IDocument document, int line, JavaIndenter indenter, JavaHeuristicScanner scanner) throws BadLocationException { IRegion currentLine= document.getLineInformation(line); int offset= currentLine.getOffset(); String indent= null; if (offset < document.getLength()) { ITypedRegion partition= TextUtilities.getPartition(document, IJavaPartitions.JAVA_PARTITIONING, offset); String type= partition.getType(); if (partition.getOffset() < offset && type.equals(IJavaPartitions.JAVA_DOC) || type.equals(IJavaPartitions.JAVA_MULTI_LINE_COMMENT)) { // TODO this is a hack // what I want to do // new JavaDocAutoIndentStrategy().indentLineAtOffset(document, offset); // return; IRegion previousLine= document.getLineInformation(line - 1); DocumentCommand command= new DocumentCommand() { }; command.text= "\n"; //$NON-NLS-1$ command.offset= previousLine.getOffset() + previousLine.getLength(); new JavaDocAutoIndentStrategy(IJavaPartitions.JAVA_PARTITIONING).customizeDocumentCommand(document, command); int i= command.text.indexOf('*'); if (i != -1) indent= command.text.substring(1, i); else indent= command.text.substring(1); } } // standard java indentation if (indent == null) indent= indenter.computeIndentation(offset); // default is no indentation if (indent == null) indent= new String(); // change document: // get current white space int lineLength= currentLine.getLength(); int end= scanner.findNonWhitespaceForwardInAnyPartition(offset, offset + lineLength); int length; if (end == JavaHeuristicScanner.NOT_FOUND) length= lineLength; else length= end - offset; // only change the document if it is a real change if (!indent.equals(document.get(offset, length))) document.replace(offset, length, indent); return offset + indent.length(); } /** * Returns the editor's selection provider. * * @return the editor's selection provider or <code>null</code> */ private ISelectionProvider getSelectionProvider() { ITextEditor editor= getTextEditor(); if (editor != null) { return editor.getSelectionProvider(); } return null; } /* * @see org.eclipse.ui.texteditor.IUpdate#update() */ public void update() { super.update(); if (isEnabled()) setEnabled(!getSelection().isEmpty()); } /** * Enablement when tab key is pressed - the current selection has to be empty and in the * whitespace in the beginning of a line. */ protected void updateForTab() { super.update(); if (isEnabled()) setEnabled(isSmartMode() && isValidSelection()); } /** * Returns if the current selection is valid, i.e. whether it is empty and the caret in the * whitespace at the start of a line, or covers multiple lines. * * @return <code>true</code> if the selection is valid for an indent operation */ private boolean isValidSelection() { ITextSelection selection= getSelection(); if (selection.isEmpty()) return false; int offset= selection.getOffset(); int length= selection.getLength(); IDocument document= getDocument(); if (document == null) return false; try { IRegion firstLine= document.getLineInformationOfOffset(offset); int lineOffset= firstLine.getOffset(); // either the selection has to be empty and the caret in the WS at the line start // or the selection has to extend over multiple lines if (length == 0) return document.get(lineOffset, offset - lineOffset).trim().length() == 0; else // return lineOffset + firstLine.getLength() < offset + length; return false; // only enable for empty selections for now } catch (BadLocationException e) { } return false; } /** * Returns the smart preference state. * * @return <code>true</code> if smart mode is on, <code>false</code> otherwise */ private boolean isSmartMode() { ITextEditor editor= getTextEditor(); if (editor instanceof ITextEditorExtension3) return ((ITextEditorExtension3) editor).getInsertMode() == ITextEditorExtension3.SMART_INSERT; return false; } /** * Returns the document currently displayed in the editor, or <code>null</code> if none can be * obtained. * * @return the current document or <code>null</code> */ private IDocument getDocument() { ITextEditor editor= getTextEditor(); if (editor != null) { IDocumentProvider provider= editor.getDocumentProvider(); IEditorInput input= editor.getEditorInput(); if (provider != null && input != null) return provider.getDocument(input); } return null; } /** * Returns the selection on the editor or an invalid selection if none can be obtained. Returns * never <code>null</code>. * * @return the current selection, never <code>null</code> */ private ITextSelection getSelection() { ISelectionProvider provider= getSelectionProvider(); if (provider != null) { ISelection selection= provider.getSelection(); if (selection instanceof ITextSelection) return (ITextSelection) selection; } // null object return TextSelection.emptySelection(); } }
43,032
Bug 43032 Autoindent/Smart Tab in case statement
... case label: { <press Enter here> I <new cursor position> Indentation level should be one less.
resolved fixed
3fa626d
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2003-09-15T07:47:38Z
2003-09-12T18:06:40Z
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/JavaIndenter.java
/******************************************************************************* * Copyright (c) 2000, 2003 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Common Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/cpl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.jdt.internal.ui.text; import org.eclipse.jface.text.Assert; import org.eclipse.jface.text.BadLocationException; import org.eclipse.jface.text.IDocument; import org.eclipse.jface.text.IRegion; import org.eclipse.jdt.internal.corext.util.CodeFormatterUtil; import org.eclipse.jdt.internal.ui.JavaPlugin; /** * Uses the {@link org.eclipse.jdt.internal.ui.text.JavaHeuristicScanner} to get the indentation * level for a certain position in a document. * * <p>An instance holds some internal position in the document and is therefore not threadsafe.</p> * * @since 3.0 */ public class JavaIndenter { /** The document being scanned. */ private IDocument fDocument; /** The indentation accumulated by <code>findPreviousIndenationUnit</code>. */ private int fIndent; /** The absolute (character-counted) indentation offset for special cases (method defs, array initializers) */ private int fAlign; /** Whether to add one space to the absolute indentation. */ private boolean fAlignPlusOne; /** The stateful scanpositionf or the indentation methods. */ private int fPosition; /** The previous position. */ private int fPreviousPos; /** The most recent token. */ private int fToken; /** * The scanner we will use to scan the document. It has to be installed on the same document * as the one we get. */ private JavaHeuristicScanner fScanner; /** * Creates a new instance. * * @param document the document to scan */ public JavaIndenter(IDocument document, JavaHeuristicScanner scanner) { Assert.isNotNull(document); Assert.isNotNull(scanner); fDocument= document; fScanner= scanner; } /** * Computes the indentation at the reference point of <code>position</code>. * * @param position the position in the document, either at the beginning of a line or in the * whitespace at the beginning of a line * @return a String which reflects the indentation at the line in which the reference position * to <code>position</code> resides, or <code>null</code> if it cannot be determined. */ public String getReferenceIndentation(int position) { try { // account for unindenation characters already typed in, but after position // also account for a dangling else boolean danglingElse= false; boolean matchBrace= false; if (position < fDocument.getLength()) { IRegion line= fDocument.getLineInformationOfOffset(position); int next= fScanner.nextToken(position, line.getOffset() + line.getLength()); switch (next) { case Symbols.TokenEOF: case Symbols.TokenELSE: danglingElse= true; break; case Symbols.TokenRBRACE: // closing braces get unindented matchBrace= true; } } else { danglingElse= true; } // find the base position int unit= findReferencePosition(position, danglingElse, matchBrace); // if we were unable to find anything, return null if (unit == JavaHeuristicScanner.NOT_FOUND) return null; //$NON-NLS-1$ // get base indent at the reference location IRegion line= fDocument.getLineInformationOfOffset(unit); int offset= line.getOffset(); int nonWS= fScanner.findNonWhitespaceForwardInAnyPartition(offset, offset + line.getLength()); StringBuffer indent= new StringBuffer(fDocument.get(offset, nonWS - offset)); return indent.toString(); } catch (BadLocationException e) { } return null; } /** * Computes the indentation at <code>position</code>. * * @param position the position in the document, either at the beginning of a line or in the * whitespace at the beginning of a line * @return a String which reflects the correct indentation for the line in which position * resides, or <code>null</code> if it cannot be determined.. */ public String computeIndentation(int position) { try { // account for unindenation characters already typed in, but after position // also account for a dangling else boolean danglingElse= false; boolean unindent= false; boolean matchBrace= false; if (position < fDocument.getLength()) { IRegion line= fDocument.getLineInformationOfOffset(position); int next= fScanner.nextToken(position, line.getOffset() + line.getLength()); int prevPos= Math.max(position - 1, 0); switch (next) { case Symbols.TokenEOF: case Symbols.TokenELSE: danglingElse= true; break; case Symbols.TokenCASE: case Symbols.TokenDEFAULT: // only if not right after the brace! if (prefAlignCaseWithSwitch() || fScanner.previousToken(prevPos, JavaHeuristicScanner.UNBOUND) != Symbols.TokenLBRACE) unindent= true; break; case Symbols.TokenLBRACE: // for opening-brace-on-new-line style if (fScanner.isBracelessBlockStart(prevPos, JavaHeuristicScanner.UNBOUND)) unindent= true; break; case Symbols.TokenRBRACE: // closing braces get unindented matchBrace= true; } } else { danglingElse= true; } // find the base position int unit= findReferencePosition(position, danglingElse, matchBrace); // handle special alignment if (fAlign != JavaHeuristicScanner.NOT_FOUND) { // a special case has been detected. IRegion line= fDocument.getLineInformationOfOffset(fAlign); int offset= line.getOffset(); return createIndent(offset, fAlign); } // if we were unable to find anything, return null if (unit == JavaHeuristicScanner.NOT_FOUND) return null; //$NON-NLS-1$ // get base indent at the reference location IRegion line= fDocument.getLineInformationOfOffset(unit); int offset= line.getOffset(); int nonWS= fScanner.findNonWhitespaceForwardInAnyPartition(offset, offset + line.getLength()); StringBuffer indent= new StringBuffer(fDocument.get(offset, nonWS - offset)); // add additional indent indent.append(createIndent(fIndent)); if (unindent) unindent(indent); return indent.toString(); } catch (BadLocationException e) { } return null; //$NON-NLS-1$ } /** * Reduces indentation in <code>indent</code> by one. * * @param indent the indentation to be modified */ private void unindent(StringBuffer indent) { String oneIndent= createIndent(1); int i= indent.lastIndexOf(oneIndent); //$NON-NLS-1$ if (i != -1) { indent.deleteCharAt(i); } } /** * Creates an indentation string of the length indent - start + 1, consisting of the content * in <code>fDocument</code> in the range [start, indent), with every character replaced by * a space except for tabs, which are kept as such. * * @return the indentation corresponding to the document content specified by <code>start</code> * and <code>indent</code> */ private String createIndent(int start, int indent) { int tabLen; if (JavaPlugin.getDefault() != null) tabLen= CodeFormatterUtil.getTabWidth(); else tabLen= 4; StringBuffer ret= new StringBuffer(); try { int spaces= 0; while (start < indent) { char ch= fDocument.getChar(start); if (ch == '\t') { ret.append('\t'); spaces= 0; } else { spaces++; if (spaces == tabLen) { ret.append('\t'); spaces= 0; } } start++; } if (fAlignPlusOne) spaces++; if (spaces == tabLen) ret.append('\t'); else while (spaces-- > 0) ret.append(' '); } catch (BadLocationException e) { } return ret.toString(); } /** * Creates a string that represents the given number of indents (can be spaces or tabs..) * @param indent the requested indentation level. * * @return the indentation specified by <code>indent</code> */ private String createIndent(int indent) { // get a sensible default when running without the infrastructure for testing if (JavaPlugin.getDefault() == null) { StringBuffer ret= new StringBuffer(); while (indent-- > 0) ret.append('\t'); return ret.toString(); } return CodeFormatterUtil.createIndentString(indent); } /** * Returns the reference position regarding to indentation for <code>position</code>, or * <code>NOT_FOUND</code>. <code>fIndent</code> will contain the relative indentation (in * indentation units, not characters) after the call. If there is a special alignment (e.g. for * a method declaration where parameters should be aligned), <code>fAlign</code> will contain the absolute * position of the alignment reference in <code>fDocument</code>, otherwise <code>fAlign</code> * is set to <code>JavaHeuristicScanner.NOT_FOUND</code>. * * @param position the position for which the reference is computed * @return the reference statement relative to which <code>position</code> should be indented. */ public int findReferencePosition(int position) { return findReferencePosition(position, false, false); } /** * Returns the reference position regarding to indentation for <code>position</code>, or * <code>NOT_FOUND</code>. <code>fIndent</code> will contain the relative indentation (in * indentation units, not characters) after the call. If there is a special alignment (e.g. for * a method declaration where parameters should be aligned), <code>fAlign</code> will contain the absolute * position of the alignment reference in <code>fDocument</code>, otherwise <code>fAlign</code> * is set to <code>JavaHeuristicScanner.NOT_FOUND</code>. * * @param position the position for which the reference is computed * @param danglingElse whether a dangling else should be assumed at <code>position</code> * @param matchBrace whether the position of the matching brace should be returned instead of doing code analysis * @return the reference statement relative to which <code>position</code> should be indented. */ private int findReferencePosition(int position, boolean danglingElse, boolean matchBrace) { fIndent= 0; // the indentation modification fAlign= JavaHeuristicScanner.NOT_FOUND; fPosition= position; boolean indentBlockLess= true; // whether to indent after an if / while / for without block (set false by semicolons and braces) boolean takeNextExit= true; // whether the next possible exit should be taken (instead of looking for the base; see blockless stuff) boolean found= false; // whether we have found anything at all. If we have, we'll trace back to it once we have a hoist point boolean hasBrace= false; if (matchBrace) { if (!skipScope(Symbols.TokenLBRACE, Symbols.TokenRBRACE)) fPosition= position; else { indentBlockLess= false; hasBrace= true; } } nextToken(); while (true) { switch (fToken) { // skip all scopes introduced by parenthesis' or brackets: case Symbols.TokenRBRACKET: skipScope(Symbols.TokenLBRACKET, Symbols.TokenRBRACKET); nextToken(); break; case Symbols.TokenRPAREN: skipScope(Symbols.TokenLPAREN, Symbols.TokenRPAREN); // handle special indentations: non-block conditionals nextToken(); int pos= fPosition; switch (fToken) { case Symbols.TokenWHILE: if (hasMatchingDo()) { nextToken(); break; } else { nextToken(pos); } case Symbols.TokenIF: if (danglingElse && fToken == Symbols.TokenIF) takeNextExit= true; case Symbols.TokenFOR: if (indentBlockLess) fIndent++; if (takeNextExit) return pos; } break; case Symbols.TokenDO: // do blockless special if (indentBlockLess) fIndent++; else // after a do, there has to come a while, on the same indentation as the do fIndent= 0; return fPosition; case Symbols.TokenELSE: // else blockless special if (indentBlockLess) fIndent++; if (takeNextExit) return fPosition; // else if (!searchIfForElse()) return JavaHeuristicScanner.NOT_FOUND; nextToken(); break; case Symbols.TokenCOLON: // switch statements and labels if (searchCaseGotoDefault()) { fIndent++; return fPosition; } break; case Symbols.TokenQUESTIONMARK: // ternary expressions if (takeNextExit && prefTenaryDeepAlign()) fAlign= fPosition; nextToken(); break; // When we find a semi or lbrace, we have found a hoist point // Take the first start to the right from it. If there is only whitespace // up to position, search one step more. case Symbols.TokenLBRACE: int searchPos= fPreviousPos; // special array handling nextToken(); if (fToken == Symbols.TokenEQUAL || skipBrackets()) { int first= fScanner.findNonWhitespaceForwardInAnyPartition(searchPos, position); // ... with a first element already defined - take its offset if (prefArrayDeepIndent() && first != JavaHeuristicScanner.NOT_FOUND) { fAlign= first; } else fIndent += prefArrayIndent(); } hasBrace= true; if (found) return fScanner.findNonWhitespaceForward(searchPos, position); // search start of code forward or continue takeNextExit= true; indentBlockLess= false; // indent when searching over an LBRACE fIndent++; break; case Symbols.TokenSEMICOLON: // search start of code forward or continue if (found) return fScanner.findNonWhitespaceForward(fPreviousPos, position); takeNextExit= false; // search to the bottom of blockless statements indentBlockLess= false; // don't indent at the next blockless introducer nextToken(); break; case Symbols.TokenEOF: if (found) return fScanner.findNonWhitespaceForward(0, position); return JavaHeuristicScanner.NOT_FOUND; // RBRACE is either the end of a statement as SEMICOLON, // or - if no statement start can be found - must be skipped as RPAREN and RBRACKET case Symbols.TokenRBRACE: if (found) return fScanner.findNonWhitespaceForward(fPreviousPos, position); skipScope(Symbols.TokenLBRACE, Symbols.TokenRBRACE); takeNextExit= false; // search to the bottom of blockless statements indentBlockLess= false; // don't indent at the next blockless introducer nextToken(); break; // use double indentation inside conditions and calls // handle method definitions separately case Symbols.TokenLPAREN: // TODO differentiate between conditional continuation and calls if (!hasBrace) fIndent += prefCallContinuationIndent(); searchPos= fPreviousPos; if (prefMethodDeclDeepIndent() && looksLikeMethodDecl() && found) { fAlign= fScanner.findNonWhitespaceForward(searchPos, position); } break; // array dimensions case Symbols.TokenLBRACKET: if (prefArrayDimensionsDeepIndent() && found) fAlign= fScanner.findNonWhitespaceForward(fPreviousPos, position); fIndent+= prefArrayDimensionIndent(); nextToken(); break; default: nextToken(); } found= true; } } /** * Searches for a case, goto, or default after a scanned colon. * * @return <code>true</code> if one of the above keywords can be scanned, possibly separated * by an identifier or constant. */ private boolean searchCaseGotoDefault() { // after a colon while (true) { nextToken(); switch (fToken) { // number or char literals won't bother us, no scopes allowed case Symbols.TokenOTHER: case Symbols.TokenIDENT: break; case Symbols.TokenEOF: return false; case Symbols.TokenCASE: case Symbols.TokenDEFAULT: case Symbols.TokenGOTO: return true; default: return false; } } } /** * while(condition); is ambiguous when parsed backwardly, as it is a valid statement by its own, * so we have to check whether there is a matching do. A <code>do</code> can either be separated * from the while by a block, or by a single statement, which limits our search distance. * * @return <code>true</code> if the <code>while</code> currently in <code>fToken</code> has a matching <code>do</code>. */ private boolean hasMatchingDo() { Assert.isTrue(fToken == Symbols.TokenWHILE); return skipStatementOrBlock() && fToken == Symbols.TokenDO; } /** * Skips a statement or block, the token being the next token after it. * * @return <code>true</code> if a statement or block could be parsed, <code>false</code> otherwise. */ private boolean skipStatementOrBlock() { nextToken(); switch (fToken) { case Symbols.TokenRBRACE: // do { BLOCK } while if (skipScope(Symbols.TokenLBRACE, Symbols.TokenRBRACE)) { nextToken(); return true; } break; case Symbols.TokenSEMICOLON: // do statement; while nextToken(); while (true) { switch (fToken) { case Symbols.TokenRBRACE: // array definition skipScope(Symbols.TokenLBRACE, Symbols.TokenRBRACE); nextToken(); if (skipBrackets()) break; else return false; case Symbols.TokenRBRACKET: // array index skipScope(Symbols.TokenLBRACKET, Symbols.TokenRBRACKET); break; case Symbols.TokenRPAREN: // call, if , for, ..., step over skipScope(Symbols.TokenLPAREN, Symbols.TokenRPAREN); break; case Symbols.TokenSEMICOLON: return true; case Symbols.TokenLBRACE: return true; case Symbols.TokenLPAREN: return false; case Symbols.TokenLBRACKET: return false; case Symbols.TokenDO: return true; case Symbols.TokenIF: return true; case Symbols.TokenFOR: return true; case Symbols.TokenWHILE: return true; case Symbols.TokenEOF: return false; } nextToken(); } } return false; } /** * Skips brackets if the current token is a RBRACKET. There can be nothing in between, this is * only to be used for <code>[]</code> elements. * * @return <code>true</code> if a <code>[]</code> could be scanned, the current token is left at * the LBRACKET. */ private boolean skipBrackets() { if (fToken == Symbols.TokenRBRACKET) { nextToken(); if (fToken == Symbols.TokenLBRACKET) { return true; } } return false; } /** * Searches for the <code>if</code> matching a just scanned else. * * @return <code>true</code> if the matching if can be found, <code>false</code> otherwise */ private boolean searchIfForElse() { int depth= 1; while (true) { nextToken(); switch (fToken) { case Symbols.TokenRBRACE: skipScope(Symbols.TokenLBRACE, Symbols.TokenRBRACE); break; case Symbols.TokenIF: depth--; if (depth == 0) return true; break; case Symbols.TokenELSE: depth++; break; case Symbols.TokenEOF: return false; } } } /** * Reads the next token in backward direction from the heuristic scanner and sets the fields * <code>fToken, fPreviousPosition</code> and <code>fPosition</code> accordingly. */ private void nextToken() { nextToken(fPosition); } /** * Reads the next token in backward direction of <code>start</code> from the heuristic scanner and sets the fields * <code>fToken, fPreviousPosition</code> and <code>fPosition</code> accordingly. */ private void nextToken(int start) { fToken= fScanner.previousToken(start - 1, JavaHeuristicScanner.UNBOUND); fPreviousPos= start; fPosition= fScanner.getPosition() + 1; } /** * Returns <code>true</code> if the current tokens look like a method declaration header * (i.e. only the return type and method name). * * @return <code>true</code> if the current position looks like a method header. */ private boolean looksLikeMethodDecl() { nextToken(); if (fToken == Symbols.TokenIDENT) { // method name do nextToken(); while (skipBrackets()); // optional brackets for array valued return types return fToken == Symbols.TokenIDENT; // type name } return false; } /** * Scans tokens for the matching parenthesis. * * @return <code>true</code> if a matching token was found, <code>false</code> otherwise */ private boolean skipScope(int openToken, int closeToken) { int depth= 1; while (true) { nextToken(); if (fToken == closeToken) { depth++; } else if (fToken == openToken) { depth--; if (depth == 0) return true; } else if (fToken == Symbols.TokenEOF) { return false; } } } private boolean prefAlignCaseWithSwitch() { // TODO preference lookup return false; } private int prefArrayDimensionIndent() { // TODO preference lookup return 2; } private boolean prefArrayDimensionsDeepIndent() { // TODO preference lookup return true; } private boolean prefMethodDeclDeepIndent() { // TODO preference lookup return true; } private int prefCallContinuationIndent() { // TODO preference lookup return 2; } private int prefArrayIndent() { // TODO preference lookup return 2; } private boolean prefArrayDeepIndent() { // TODO preference lookup return false; } private boolean prefTenaryDeepAlign() { // TODO preference lookup return true; } }
40,952
Bug 40952 Generate getter and setter: set field name as default return value
Unfortunately, the new Eclipse version does not create a get/set method in the form of /** * Description. * * @return string */ public String getName() { return name; } anymore but it leaves out the value of the @return param: /** * Description. * * @return */ public String getName() { return name; } But this has the bad side effect that generating javadoc generates warnings for each method that was automatically generated via "Generate getter and setter" function of eclipse. To get a clean javadoc creation back again, you have to fill in the @return value by hand which makes all the nice automatic stuff rather useless. i suggest to set the field name as the default return value: /** * Description. * * @return name */ public String getName() { return name; } which should be quite easy to implement as each get/set method is created based on this field name!
resolved fixed
6aee354
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2003-09-15T12:55:53Z
2003-07-30T15:46:40Z
org.eclipse.jdt.ui/core
40,952
Bug 40952 Generate getter and setter: set field name as default return value
Unfortunately, the new Eclipse version does not create a get/set method in the form of /** * Description. * * @return string */ public String getName() { return name; } anymore but it leaves out the value of the @return param: /** * Description. * * @return */ public String getName() { return name; } But this has the bad side effect that generating javadoc generates warnings for each method that was automatically generated via "Generate getter and setter" function of eclipse. To get a clean javadoc creation back again, you have to fill in the @return value by hand which makes all the nice automatic stuff rather useless. i suggest to set the field name as the default return value: /** * Description. * * @return name */ public String getName() { return name; } which should be quite easy to implement as each get/set method is created based on this field name!
resolved fixed
6aee354
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2003-09-15T12:55:53Z
2003-07-30T15:46:40Z
extension/org/eclipse/jdt/internal/corext/codemanipulation/AddGetterSetterOperation.java
40,952
Bug 40952 Generate getter and setter: set field name as default return value
Unfortunately, the new Eclipse version does not create a get/set method in the form of /** * Description. * * @return string */ public String getName() { return name; } anymore but it leaves out the value of the @return param: /** * Description. * * @return */ public String getName() { return name; } But this has the bad side effect that generating javadoc generates warnings for each method that was automatically generated via "Generate getter and setter" function of eclipse. To get a clean javadoc creation back again, you have to fill in the @return value by hand which makes all the nice automatic stuff rather useless. i suggest to set the field name as the default return value: /** * Description. * * @return name */ public String getName() { return name; } which should be quite easy to implement as each get/set method is created based on this field name!
resolved fixed
6aee354
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2003-09-15T12:55:53Z
2003-07-30T15:46:40Z
org.eclipse.jdt.ui/core
40,952
Bug 40952 Generate getter and setter: set field name as default return value
Unfortunately, the new Eclipse version does not create a get/set method in the form of /** * Description. * * @return string */ public String getName() { return name; } anymore but it leaves out the value of the @return param: /** * Description. * * @return */ public String getName() { return name; } But this has the bad side effect that generating javadoc generates warnings for each method that was automatically generated via "Generate getter and setter" function of eclipse. To get a clean javadoc creation back again, you have to fill in the @return value by hand which makes all the nice automatic stuff rather useless. i suggest to set the field name as the default return value: /** * Description. * * @return name */ public String getName() { return name; } which should be quite easy to implement as each get/set method is created based on this field name!
resolved fixed
6aee354
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2003-09-15T12:55:53Z
2003-07-30T15:46:40Z
extension/org/eclipse/jdt/internal/corext/codemanipulation/StubUtility.java
40,952
Bug 40952 Generate getter and setter: set field name as default return value
Unfortunately, the new Eclipse version does not create a get/set method in the form of /** * Description. * * @return string */ public String getName() { return name; } anymore but it leaves out the value of the @return param: /** * Description. * * @return */ public String getName() { return name; } But this has the bad side effect that generating javadoc generates warnings for each method that was automatically generated via "Generate getter and setter" function of eclipse. To get a clean javadoc creation back again, you have to fill in the @return value by hand which makes all the nice automatic stuff rather useless. i suggest to set the field name as the default return value: /** * Description. * * @return name */ public String getName() { return name; } which should be quite easy to implement as each get/set method is created based on this field name!
resolved fixed
6aee354
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2003-09-15T12:55:53Z
2003-07-30T15:46:40Z
org.eclipse.jdt.ui/core
40,952
Bug 40952 Generate getter and setter: set field name as default return value
Unfortunately, the new Eclipse version does not create a get/set method in the form of /** * Description. * * @return string */ public String getName() { return name; } anymore but it leaves out the value of the @return param: /** * Description. * * @return */ public String getName() { return name; } But this has the bad side effect that generating javadoc generates warnings for each method that was automatically generated via "Generate getter and setter" function of eclipse. To get a clean javadoc creation back again, you have to fill in the @return value by hand which makes all the nice automatic stuff rather useless. i suggest to set the field name as the default return value: /** * Description. * * @return name */ public String getName() { return name; } which should be quite easy to implement as each get/set method is created based on this field name!
resolved fixed
6aee354
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2003-09-15T12:55:53Z
2003-07-30T15:46:40Z
extension/org/eclipse/jdt/internal/corext/template/CodeTemplates.java
40,952
Bug 40952 Generate getter and setter: set field name as default return value
Unfortunately, the new Eclipse version does not create a get/set method in the form of /** * Description. * * @return string */ public String getName() { return name; } anymore but it leaves out the value of the @return param: /** * Description. * * @return */ public String getName() { return name; } But this has the bad side effect that generating javadoc generates warnings for each method that was automatically generated via "Generate getter and setter" function of eclipse. To get a clean javadoc creation back again, you have to fill in the @return value by hand which makes all the nice automatic stuff rather useless. i suggest to set the field name as the default return value: /** * Description. * * @return name */ public String getName() { return name; } which should be quite easy to implement as each get/set method is created based on this field name!
resolved fixed
6aee354
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2003-09-15T12:55:53Z
2003-07-30T15:46:40Z
org.eclipse.jdt.ui/core
40,952
Bug 40952 Generate getter and setter: set field name as default return value
Unfortunately, the new Eclipse version does not create a get/set method in the form of /** * Description. * * @return string */ public String getName() { return name; } anymore but it leaves out the value of the @return param: /** * Description. * * @return */ public String getName() { return name; } But this has the bad side effect that generating javadoc generates warnings for each method that was automatically generated via "Generate getter and setter" function of eclipse. To get a clean javadoc creation back again, you have to fill in the @return value by hand which makes all the nice automatic stuff rather useless. i suggest to set the field name as the default return value: /** * Description. * * @return name */ public String getName() { return name; } which should be quite easy to implement as each get/set method is created based on this field name!
resolved fixed
6aee354
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2003-09-15T12:55:53Z
2003-07-30T15:46:40Z
extension/org/eclipse/jdt/internal/corext/template/java/CodeTemplateContextType.java
40,952
Bug 40952 Generate getter and setter: set field name as default return value
Unfortunately, the new Eclipse version does not create a get/set method in the form of /** * Description. * * @return string */ public String getName() { return name; } anymore but it leaves out the value of the @return param: /** * Description. * * @return */ public String getName() { return name; } But this has the bad side effect that generating javadoc generates warnings for each method that was automatically generated via "Generate getter and setter" function of eclipse. To get a clean javadoc creation back again, you have to fill in the @return value by hand which makes all the nice automatic stuff rather useless. i suggest to set the field name as the default return value: /** * Description. * * @return name */ public String getName() { return name; } which should be quite easy to implement as each get/set method is created based on this field name!
resolved fixed
6aee354
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2003-09-15T12:55:53Z
2003-07-30T15:46:40Z
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/CodeTemplateBlock.java
/******************************************************************************* * Copyright (c) 2000, 2003 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Common Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/cpl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.jdt.internal.ui.preferences; import java.io.File; import java.io.FileNotFoundException; import java.util.ArrayList; import java.util.List; import org.eclipse.core.runtime.CoreException; import org.eclipse.jdt.internal.corext.template.CodeTemplates; import org.eclipse.jdt.internal.corext.template.Template; import org.eclipse.jdt.internal.corext.template.TemplateSet; import org.eclipse.jdt.internal.ui.IJavaStatusConstants; import org.eclipse.jdt.internal.ui.JavaPlugin; import org.eclipse.jdt.internal.ui.util.ExceptionHandler; import org.eclipse.jdt.internal.ui.util.PixelConverter; import org.eclipse.jdt.internal.ui.wizards.dialogfields.DialogField; import org.eclipse.jdt.internal.ui.wizards.dialogfields.IDialogFieldListener; import org.eclipse.jdt.internal.ui.wizards.dialogfields.ITreeListAdapter; import org.eclipse.jdt.internal.ui.wizards.dialogfields.LayoutUtil; import org.eclipse.jdt.internal.ui.wizards.dialogfields.SelectionButtonDialogField; import org.eclipse.jdt.internal.ui.wizards.dialogfields.TreeListDialogField; import org.eclipse.jdt.ui.PreferenceConstants; import org.eclipse.jdt.ui.text.JavaSourceViewerConfiguration; import org.eclipse.jdt.ui.text.JavaTextTools; import org.eclipse.jface.dialogs.MessageDialog; import org.eclipse.jface.preference.IPreferenceStore; import org.eclipse.jface.resource.JFaceResources; import org.eclipse.jface.text.Document; import org.eclipse.jface.text.IDocument; import org.eclipse.jface.text.source.SourceViewer; import org.eclipse.jface.viewers.LabelProvider; import org.eclipse.jface.viewers.StructuredSelection; import org.eclipse.jface.window.Window; import org.eclipse.swt.SWT; import org.eclipse.swt.events.KeyEvent; import org.eclipse.swt.graphics.Font; import org.eclipse.swt.graphics.Image; 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.FileDialog; import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.Shell; /** */ public class CodeTemplateBlock { private class CodeTemplateAdapter implements ITreeListAdapter, IDialogFieldListener { private final Object[] NO_CHILDREN= new Object[0]; public CodeTemplateAdapter(CodeTemplates templates) { } public void customButtonPressed(TreeListDialogField field, int index) { doButtonPressed(index, field.getSelectedElements()); } public void selectionChanged(TreeListDialogField field) { List selected= field.getSelectedElements(); field.enableButton(IDX_EDIT, canEdit(selected)); field.enableButton(IDX_EXPORT, !selected.isEmpty()); updateSourceViewerInput(selected); } public void doubleClicked(TreeListDialogField field) { List selected= field.getSelectedElements(); if (canEdit(selected)) { doButtonPressed(IDX_EDIT, selected); } } public Object[] getChildren(TreeListDialogField field, Object element) { if (element == COMMENT_NODE || element == CODE_NODE) { return getTemplateOfCategory(element == COMMENT_NODE); } return NO_CHILDREN; } public Object getParent(TreeListDialogField field, Object element) { if (element instanceof Template) { Template template= (Template) element; if (template.getName().endsWith(CodeTemplates.COMMENT_SUFFIX)) { return COMMENT_NODE; } return CODE_NODE; } return null; } public boolean hasChildren(TreeListDialogField field, Object element) { return (element == COMMENT_NODE || element == CODE_NODE); } public void dialogFieldChanged(DialogField field) { } public void keyPressed(TreeListDialogField field, KeyEvent event) { } } private static class CodeTemplateLabelProvider extends LabelProvider { /* (non-Javadoc) * @see org.eclipse.jface.viewers.ILabelProvider#getImage(java.lang.Object) */ public Image getImage(Object element) { /* if (element == COMMENT_NODE) { return JavaPluginImages.get(JavaPluginImages.IMG_OBJS_JAVADOCTAG); } if (element == CODE_NODE) { return JavaPluginImages.get(JavaPluginImages.IMG_OBJS_IMPCONT); } Template template = (Template) element; String name= template.getName(); if (CodeTemplates.CATCHBLOCK.equals(name)) { return JavaPluginImages.get(JavaPluginImages.IMG_OBJS_EXCEPTION); } else if (CodeTemplates.METHODSTUB.equals(name)) { return JavaPluginImages.get(JavaPluginImages.IMG_MISC_DEFAULT); } else if (CodeTemplates.CONSTRUCTORSTUB.equals(name)) { ImageDescriptorRegistry registry= JavaPlugin.getImageDescriptorRegistry(); return registry.get(new JavaElementImageDescriptor(JavaPluginImages.DESC_MISC_PUBLIC, JavaElementImageDescriptor.CONSTRUCTOR, JavaElementImageProvider.SMALL_SIZE)); } else if (CodeTemplates.NEWTYPE.equals(name)) { return JavaPluginImages.get(JavaPluginImages.IMG_OBJS_CUNIT); } else if (CodeTemplates.TYPECOMMENT.equals(name)) { return JavaPluginImages.get(JavaPluginImages.IMG_OBJS_CLASS); } else if (CodeTemplates.METHODCOMMENT.equals(name)) { return JavaPluginImages.get(JavaPluginImages.IMG_MISC_PROTECTED); } else if (CodeTemplates.OVERRIDECOMMENT.equals(name)) { ImageDescriptorRegistry registry= JavaPlugin.getImageDescriptorRegistry(); return registry.get(new JavaElementImageDescriptor(JavaPluginImages.DESC_MISC_PROTECTED, JavaElementImageDescriptor.OVERRIDES, JavaElementImageProvider.SMALL_SIZE)); } else if (CodeTemplates.CONSTRUCTORCOMMENT.equals(name)) { ImageDescriptorRegistry registry= JavaPlugin.getImageDescriptorRegistry(); return registry.get(new JavaElementImageDescriptor(JavaPluginImages.DESC_MISC_PUBLIC, JavaElementImageDescriptor.CONSTRUCTOR, JavaElementImageProvider.SMALL_SIZE)); }*/ return null; } /* (non-Javadoc) * @see org.eclipse.jface.viewers.ILabelProvider#getText(java.lang.Object) */ public String getText(Object element) { if (element == COMMENT_NODE || element == CODE_NODE) { return (String) element; } Template template = (Template) element; String name= template.getName(); if (CodeTemplates.CATCHBLOCK.equals(name)) { return PreferencesMessages.getString("CodeTemplateBlock.catchblock.label"); //$NON-NLS-1$ } else if (CodeTemplates.METHODSTUB.equals(name)) { return PreferencesMessages.getString("CodeTemplateBlock.methodstub.label"); //$NON-NLS-1$ } else if (CodeTemplates.CONSTRUCTORSTUB.equals(name)) { return PreferencesMessages.getString("CodeTemplateBlock.constructorstub.label"); //$NON-NLS-1$ } else if (CodeTemplates.GETTERSTUB.equals(name)) { return PreferencesMessages.getString("CodeTemplateBlock.getterstub.label"); //$NON-NLS-1$ } else if (CodeTemplates.SETTERSTUB.equals(name)) { return PreferencesMessages.getString("CodeTemplateBlock.setterstub.label"); //$NON-NLS-1$ } else if (CodeTemplates.NEWTYPE.equals(name)) { return PreferencesMessages.getString("CodeTemplateBlock.newtype.label"); //$NON-NLS-1$ } else if (CodeTemplates.TYPECOMMENT.equals(name)) { return PreferencesMessages.getString("CodeTemplateBlock.typecomment.label"); //$NON-NLS-1$ } else if (CodeTemplates.METHODCOMMENT.equals(name)) { return PreferencesMessages.getString("CodeTemplateBlock.methodcomment.label"); //$NON-NLS-1$ } else if (CodeTemplates.OVERRIDECOMMENT.equals(name)) { return PreferencesMessages.getString("CodeTemplateBlock.overridecomment.label"); //$NON-NLS-1$ } else if (CodeTemplates.CONSTRUCTORCOMMENT.equals(name)) { return PreferencesMessages.getString("CodeTemplateBlock.constructorcomment.label"); //$NON-NLS-1$ } return template.getDescription(); } } private final static int IDX_EDIT= 0; private final static int IDX_IMPORT= 2; private final static int IDX_EXPORT= 3; private final static int IDX_EXPORTALL= 4; protected final static Object COMMENT_NODE= PreferencesMessages.getString("CodeTemplateBlock.templates.comment.node"); //$NON-NLS-1$ protected final static Object CODE_NODE= PreferencesMessages.getString("CodeTemplateBlock.templates.code.node"); //$NON-NLS-1$ private static final String PREF_JAVADOC_STUBS= PreferenceConstants.CODEGEN_ADD_COMMENTS; private TreeListDialogField fCodeTemplateTree; private SelectionButtonDialogField fCreateJavaDocComments; protected CodeTemplates fTemplates; private PixelConverter fPixelConverter; private SourceViewer fPatternViewer; private Control fSWTWidget; public CodeTemplateBlock() { fTemplates= CodeTemplates.getInstance(); CodeTemplateAdapter adapter= new CodeTemplateAdapter(fTemplates); String[] buttonLabels= new String[] { /* IDX_EDIT*/ PreferencesMessages.getString("CodeTemplateBlock.templates.edit.button"), //$NON-NLS-1$ /* */ null, /* IDX_IMPORT */ PreferencesMessages.getString("CodeTemplateBlock.templates.import.button"), //$NON-NLS-1$ /* IDX_EXPORT */ PreferencesMessages.getString("CodeTemplateBlock.templates.export.button"), //$NON-NLS-1$ /* IDX_EXPORTALL */ PreferencesMessages.getString("CodeTemplateBlock.templates.exportall.button") //$NON-NLS-1$ }; fCodeTemplateTree= new TreeListDialogField(adapter, buttonLabels, new CodeTemplateLabelProvider()); fCodeTemplateTree.setDialogFieldListener(adapter); fCodeTemplateTree.setLabelText(PreferencesMessages.getString("CodeTemplateBlock.templates.label")); //$NON-NLS-1$ fCodeTemplateTree.enableButton(IDX_EXPORT, false); fCodeTemplateTree.enableButton(IDX_EDIT, false); fCodeTemplateTree.addElement(COMMENT_NODE); fCodeTemplateTree.addElement(CODE_NODE); fCreateJavaDocComments= new SelectionButtonDialogField(SWT.CHECK | SWT.WRAP); fCreateJavaDocComments.setLabelText(PreferencesMessages.getString("CodeTemplateBlock.createcomment.label")); //$NON-NLS-1$ fCreateJavaDocComments.setSelection(PreferenceConstants.getPreferenceStore().getBoolean(PREF_JAVADOC_STUBS)); fCodeTemplateTree.selectFirstElement(); } protected Control createContents(Composite parent) { fPixelConverter= new PixelConverter(parent); fSWTWidget= parent; Composite composite= new Composite(parent, SWT.NONE); GridLayout layout= new GridLayout(); //layout.marginHeight= 0; //layout.marginWidth= 0; layout.numColumns= 2; composite.setLayout(layout); fCodeTemplateTree.doFillIntoGrid(composite, 3); LayoutUtil.setHorizontalSpan(fCodeTemplateTree.getLabelControl(null), 2); LayoutUtil.setHorizontalGrabbing(fCodeTemplateTree.getTreeControl(null)); fPatternViewer= createViewer(composite, 2); fCreateJavaDocComments.doFillIntoGrid(composite, 2); DialogField label= new DialogField(); label.setLabelText(PreferencesMessages.getString("CodeTemplateBlock.createcomment.description")); //$NON-NLS-1$ label.doFillIntoGrid(composite, 2); return composite; } private Shell getShell() { if (fSWTWidget != null) { return fSWTWidget.getShell(); } return JavaPlugin.getActiveWorkbenchShell(); } private SourceViewer createViewer(Composite parent, int nColumns) { Label label= new Label(parent, SWT.NONE); label.setText(PreferencesMessages.getString("CodeTemplateBlock.preview")); //$NON-NLS-1$ GridData data= new GridData(); data.horizontalSpan= nColumns; label.setLayoutData(data); SourceViewer viewer= new SourceViewer(parent, null, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL); IDocument document= new Document(); JavaTextTools tools= JavaPlugin.getDefault().getJavaTextTools(); tools.setupJavaDocumentPartitioner(document); viewer.configure(new JavaSourceViewerConfiguration(tools, null)); viewer.setEditable(false); viewer.setDocument(document); viewer.getTextWidget().setBackground(parent.getDisplay().getSystemColor(SWT.COLOR_WIDGET_BACKGROUND)); Font font= JFaceResources.getFont(PreferenceConstants.EDITOR_TEXT_FONT); viewer.getTextWidget().setFont(font); Control control= viewer.getControl(); data= new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.FILL_VERTICAL); data.horizontalSpan= nColumns; data.heightHint= fPixelConverter.convertHeightInCharsToPixels(5); control.setLayoutData(data); return viewer; } protected Template[] getTemplateOfCategory(boolean isComment) { ArrayList res= new ArrayList(); Template[] templates= fTemplates.getTemplates(); for (int i= 0; i < templates.length; i++) { Template curr= templates[i]; if (isComment == curr.getName().endsWith(CodeTemplates.COMMENT_SUFFIX)) { res.add(curr); } } return (Template[]) res.toArray(new Template[res.size()]); } protected static boolean canEdit(List selected) { return selected.size() == 1 && (selected.get(0) instanceof Template); } protected void updateSourceViewerInput(List selection) { if (fPatternViewer == null || fPatternViewer.getTextWidget().isDisposed()) { return; } if (selection.size() == 1 && selection.get(0) instanceof Template) { Template template= (Template) selection.get(0); fPatternViewer.getDocument().set(template.getPattern()); } else { fPatternViewer.getDocument().set(""); //$NON-NLS-1$ } } protected void doButtonPressed(int buttonIndex, List selected) { if (buttonIndex == IDX_EDIT) { edit((Template) selected.get(0)); } else if (buttonIndex == IDX_EXPORT) { export(selected); } else if (buttonIndex == IDX_EXPORTALL) { exportAll(); } else if (buttonIndex == IDX_IMPORT) { import_(); } } private void edit(Template template) { Template newTemplate= new Template(template); EditTemplateDialog dialog= new EditTemplateDialog(getShell(), newTemplate, true, false, new String[0]); if (dialog.open() == Window.OK) { // changed template.setDescription(newTemplate.getDescription()); template.setPattern(newTemplate.getPattern()); fCodeTemplateTree.refresh(template); fCodeTemplateTree.selectElements(new StructuredSelection(template)); } } private void import_() { FileDialog dialog= new FileDialog(getShell()); dialog.setText(PreferencesMessages.getString("CodeTemplateBlock.import.title")); //$NON-NLS-1$ dialog.setFilterExtensions(new String[] {PreferencesMessages.getString("CodeTemplateBlock.import.extension")}); //$NON-NLS-1$ String path= dialog.open(); if (path != null) { try { fTemplates.addFromFile(new File(path), false); } catch (CoreException e) { openReadErrorDialog(e); } fCodeTemplateTree.refresh(); } } private void exportAll() { export(fTemplates); } private void export(List selected) { TemplateSet templateSet= new TemplateSet(fTemplates.getTemplateTag()); for (int i= 0; i < selected.size(); i++) { Object curr= selected.get(i); if (curr instanceof Template) { addToTemplateSet(templateSet, (Template) curr); } else { Template[] templates= getTemplateOfCategory(curr == COMMENT_NODE); for (int k= 0; k < templates.length; k++) { addToTemplateSet(templateSet, templates[k]); } } } export(templateSet); } private void addToTemplateSet(TemplateSet set, Template template) { if (set.getFirstTemplate(template.getName()) == null) { set.add(template); } } private void export(TemplateSet templateSet) { FileDialog dialog= new FileDialog(getShell(), SWT.SAVE); dialog.setText(PreferencesMessages.getFormattedString("CodeTemplateBlock.export.title", String.valueOf(templateSet.getTemplates().length))); //$NON-NLS-1$ dialog.setFilterExtensions(new String[] {PreferencesMessages.getString("CodeTemplateBlock.export.extension")}); //$NON-NLS-1$ dialog.setFileName(PreferencesMessages.getString("CodeTemplateBlock.export.filename")); //$NON-NLS-1$ String path= dialog.open(); if (path == null) return; File file= new File(path); if (file.isHidden()) { String title= PreferencesMessages.getString("CodeTemplateBlock.export.error.title"); //$NON-NLS-1$ String message= PreferencesMessages.getFormattedString("CodeTemplateBlock.export.error.hidden", file.getAbsolutePath()); //$NON-NLS-1$ MessageDialog.openError(getShell(), title, message); return; } if (file.exists() && !file.canWrite()) { String title= PreferencesMessages.getString("CodeTemplateBlock.export.error.title"); //$NON-NLS-1$ String message= PreferencesMessages.getFormattedString("CodeTemplateBlock.export.error.canNotWrite", file.getAbsolutePath()); //$NON-NLS-1$ MessageDialog.openError(getShell(), title, message); return; } if (!file.exists() || confirmOverwrite(file)) { try { templateSet.saveToFile(file); } catch (CoreException e) { if (e.getStatus().getException() instanceof FileNotFoundException) { String title= PreferencesMessages.getString("CodeTemplateBlock.export.error.title"); //$NON-NLS-1$ String message= PreferencesMessages.getFormattedString("CodeTemplateBlock.export.error.fileNotFound", e.getStatus().getException().getLocalizedMessage()); //$NON-NLS-1$ MessageDialog.openError(getShell(), title, message); return; } JavaPlugin.log(e); openWriteErrorDialog(e); } } } private boolean confirmOverwrite(File file) { return MessageDialog.openQuestion(getShell(), PreferencesMessages.getString("CodeTemplateBlock.export.exists.title"), //$NON-NLS-1$ PreferencesMessages.getFormattedString("CodeTemplateBlock.export.exists.message", file.getAbsolutePath())); //$NON-NLS-1$ } public void performDefaults() { IPreferenceStore prefs= JavaPlugin.getDefault().getPreferenceStore(); fCreateJavaDocComments.setSelection(prefs.getDefaultBoolean(PREF_JAVADOC_STUBS)); try { fTemplates.restoreDefaults(); } catch (CoreException e) { JavaPlugin.log(e); openReadErrorDialog(e); } // refresh fCodeTemplateTree.refresh(); } public boolean performOk(boolean enabled) { IPreferenceStore prefs= PreferenceConstants.getPreferenceStore(); prefs.setValue(PREF_JAVADOC_STUBS, fCreateJavaDocComments.isSelected()); JavaPlugin.getDefault().savePluginPreferences(); try { fTemplates.save(); } catch (CoreException e) { JavaPlugin.log(e); openWriteErrorDialog(e); } return true; } public void performCancel() { try { fTemplates.reset(); } catch (CoreException e) { openReadErrorDialog(e); } } private void openReadErrorDialog(CoreException e) { String title= PreferencesMessages.getString("CodeTemplateBlock.error.read.title"); //$NON-NLS-1$ // Show parse error in a user dialog without logging if (e.getStatus().getCode() == IJavaStatusConstants.TEMPLATE_PARSE_EXCEPTION) { String message= e.getStatus().getException().getLocalizedMessage(); if (message != null) message= PreferencesMessages.getFormattedString("CodeTemplateBlock.error.parse.message", message); //$NON-NLS-1$ else message= PreferencesMessages.getString("CodeTemplateBlock.error.read.message"); //$NON-NLS-1$ MessageDialog.openError(getShell(), title, message); } else { String message= PreferencesMessages.getString("CodeTemplateBlock.error.read.message"); //$NON-NLS-1$ ExceptionHandler.handle(e, getShell(), title, message); } } private void openWriteErrorDialog(CoreException e) { String title= PreferencesMessages.getString("CodeTemplateBlock.error.write.title"); //$NON-NLS-1$ String message= PreferencesMessages.getString("CodeTemplateBlock.error.write.message"); //$NON-NLS-1$ ExceptionHandler.handle(e, getShell(), title, message); } }
40,952
Bug 40952 Generate getter and setter: set field name as default return value
Unfortunately, the new Eclipse version does not create a get/set method in the form of /** * Description. * * @return string */ public String getName() { return name; } anymore but it leaves out the value of the @return param: /** * Description. * * @return */ public String getName() { return name; } But this has the bad side effect that generating javadoc generates warnings for each method that was automatically generated via "Generate getter and setter" function of eclipse. To get a clean javadoc creation back again, you have to fill in the @return value by hand which makes all the nice automatic stuff rather useless. i suggest to set the field name as the default return value: /** * Description. * * @return name */ public String getName() { return name; } which should be quite easy to implement as each get/set method is created based on this field name!
resolved fixed
6aee354
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2003-09-15T12:55:53Z
2003-07-30T15:46:40Z
org.eclipse.jdt.ui/ui/org/eclipse/jdt/ui/CodeGeneration.java
/******************************************************************************* * Copyright (c) 2000, 2003 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Common Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/cpl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.jdt.ui; import org.eclipse.core.runtime.CoreException; import org.eclipse.jdt.core.ICompilationUnit; import org.eclipse.jdt.core.IMethod; import org.eclipse.jdt.core.dom.IMethodBinding; import org.eclipse.jdt.core.dom.MethodDeclaration; import org.eclipse.jdt.internal.corext.codemanipulation.StubUtility; /** * Class that offers access to the templates contained in the 'code generation' preference page. * * @since 2.1 */ public class CodeGeneration { private CodeGeneration() { } /** * Returns the content for a new compilation unit using the 'new Java file' code template. * @param cu The compilation to create the source for. The compilation unit does not need to exist. * @param typeComment The comment for the type to created. Used when the code template contains a ${typecomment} variable. Can be <code>null</code> if * no comment should be added. * @param typeContent The code of the type, including type declaration and body. * @param lineDelimiter The line delimiter to be used. * @return Returns the new content or <code>null</code> if the template is undefined or empty. * @throws CoreException */ public static String getCompilationUnitContent(ICompilationUnit cu, String typeComment, String typeContent, String lineDelimiter) throws CoreException { return StubUtility.getCompilationUnitContent(cu, typeComment, typeContent, lineDelimiter); } /** * Returns the content for a new type comment using the 'typecomment' code template. The returned content is unformatted and is not indented. * @param cu The compilation where the type is contained. The compilation unit does not need to exist. * @param typeQualifiedName The name of the type to which the comment is added. For inner types the name must be qualified and include the outer * types names (dot separated). See {@link org.eclipse.jdt.core.IType#getTypeQualifiedName(char)}. * @param lineDelimiter The line delimiter to be used. * @return Returns the new content or <code>null</code> if the code template is undefined or empty. The returned content is unformatted and is not indented. * @throws CoreException */ public static String getTypeComment(ICompilationUnit cu, String typeQualifiedName, String lineDelimiter) throws CoreException { return StubUtility.getTypeComment(cu, typeQualifiedName, lineDelimiter); } /** * Returns the comment for a method or constructor using the comment code templates (constructor / method / overriding method). * <code>null</code> is returned if the template is empty. * @param cu The compilation unit to which the method belongs. The compilation unit does not need to exist. * @param declaringTypeName Name of the type to which the method belongs. For inner types the name must be qualified and include the outer * types names (dot separated). See {@link org.eclipse.jdt.core.IType#getTypeQualifiedName(char)} * @param decl The MethodDeclaration AST node that will be added as new * method. The node does not need to exist in an AST (no parent needed) and does not need to resolve. * See {@link org.eclipse.jdt.core.dom.AST#newMethodDeclaration()} fo how to create such a node. * @param overridden The binding of the method that will be overridden by the created * method or <code>null</code> if no method is overridden. * @param lineDelimiter The line delimiter to be used. * @return Returns the generated method comment or <code>null</code> if the * code template is empty. The returned content is unformatted and not indented (formatting required). * @throws CoreException */ public static String getMethodComment(ICompilationUnit cu, String declaringTypeName, MethodDeclaration decl, IMethodBinding overridden, String lineDelimiter) throws CoreException { return StubUtility.getMethodComment(cu, declaringTypeName, decl, overridden, lineDelimiter); } /** * Returns the comment for a method or constructor using the comment code templates (constructor / method / overriding method). * <code>null</code> is returned if the template is empty. * <p>The returned string is unformatted and not indented. * <p>Exception types and return type are in signature notation. e.g. a source method declared as <code>public void foo(String text, int length)</code> * would return the array <code>{"QString;","I"}</code> as parameter types. See {@link org.eclipse.jdt.core.Signature} * * @param cu The compilation unit to which the method belongs. The compilation unit does not need to exist. * @param declaringTypeName Name of the type to which the method belongs. For inner types the name must be qualified and include the outer * types names (dot separated). * @param methodName Name of the method. * @param paramNames Names of the parameters for the method. * @param excTypeSig Throwns exceptions (Signature notation) * @param retTypeSig Return type (Signature notation) or <code>null</code> * for constructors. * @param overridden The method that will be overridden by the created method or * <code>null</code> for non-overriding methods. If not <code>null</code>, the method must exist. * @param lineDelimiter The line delimiter to be used * @return Returns the constructed comment or <code>null</code> if * the comment code template is empty. The returned content is unformatted and not indented (formatting required). * @throws CoreException */ public static String getMethodComment(ICompilationUnit cu, String declaringTypeName, String methodName, String[] paramNames, String[] excTypeSig, String retTypeSig, IMethod overridden, String lineDelimiter) throws CoreException { return StubUtility.getMethodComment(cu, declaringTypeName, methodName, paramNames, excTypeSig, retTypeSig, overridden, lineDelimiter); } /** * Returns the comment for a method or constructor using the comment code templates (constructor / method / overriding method). * <code>null</code> is returned if the template is empty. * <p>The returned string is unformatted and not indented. * * @param method The method to be documented. The method must exist. * @param overridden The method that will be overridden by the created method or * <code>null</code> for non-overriding methods. If not <code>null</code>, the method must exist. * @param lineDelimiter The line delimiter to be used * @return String Returns the constructed comment or <code>null</code> if * the comment code template is empty. The returned string is unformatted and and has no indent (formatting required). * @throws CoreException */ public static String getMethodComment(IMethod method, IMethod overridden, String lineDelimiter) throws CoreException { return StubUtility.getMethodComment(method, overridden, lineDelimiter); } /** * Returns the content of body for a method or constructor using the method body templates. * <code>null</code> is returned if the template is empty. * <p>The returned string is unformatted and not indented. * * @param cu The compilation unit to which the method belongs. The compilation unit does not need to exist. * @param declaringTypeName Name of the type to which the method belongs. For inner types the name must be qualified and include the outer * types names (dot separated). * @param methodName Name of the method. * @param isConstructor Defines if the created body is for a constructor * @param bodyStatement The code to be entered at the place of the variable ${body_statement}. * @return String Returns the constructed body contnet or <code>null</code> if * the comment code template is empty. The returned string is unformatted and and has no indent (formatting required). * @throws CoreException */ public static String getMethodBodyContent(ICompilationUnit cu, String declaringTypeName, String methodName, boolean isConstructor, String bodyStatement, String lineDelimiter) throws CoreException { return StubUtility.getMethodBodyContent(isConstructor, cu.getJavaProject(), declaringTypeName, methodName, bodyStatement, lineDelimiter); } /** * Returns the content of body for a getter method using the getter method body template. * <code>null</code> is returned if the template is empty. * <p>The returned string is unformatted and not indented. * * @param cu The compilation unit to which the method belongs. The compilation unit does not need to exist. * @param declaringTypeName Name of the type to which the method belongs. For inner types the name must be qualified and include the outer * types names (dot separated). * @param methodName The name of the getter method. * @param fieldName The name of the field to be set in the setter method, corresponding to the template variable for ${field}. * @return String Returns the constructed body content or <code>null</code> if * the comment code template is empty. The returned string is unformatted and and has no indent (formatting required). * @throws CoreException */ public static String getGetterMethodBodyContent(ICompilationUnit cu, String declaringTypeName, String methodName, String fieldName, String lineDelimiter) throws CoreException { return StubUtility.getGetterMethodBodyContent(cu.getJavaProject(), declaringTypeName, methodName, fieldName, lineDelimiter); } /** * Returns the content of body for a setter method using the setter method body template. * <code>null</code> is returned if the template is empty. * <p>The returned string is unformatted and not indented. * * @param cu The compilation unit to which the method belongs. The compilation unit does not need to exist. * @param declaringTypeName Name of the type to which the method belongs. For inner types the name must be qualified and include the outer * types names (dot separated). * @param methodName The name of the setter method. * @param fieldName The name of the field to be set in the setter method, corresponding to the template variable for ${field}. * @param paramName The parameter passed to the setter method, corresponding to the template variable for $(param). * @return String Returns the constructed body content or <code>null</code> if * the comment code template is empty. The returned string is unformatted and and has no indent (formatting required). * @throws CoreException */ public static String getSetterMethodBodyContent(ICompilationUnit cu, String declaringTypeName, String methodName, String fieldName, String paramName, String lineDelimiter) throws CoreException { return StubUtility.getSetterMethodBodyContent(cu.getJavaProject(), declaringTypeName, methodName, fieldName, paramName, lineDelimiter); } }
42,998
Bug 42998 Search in project does not work for NLS search page
I20030910 1. select SearchMessages.properties (in search plug-in) in the Navigator 2. press Ctrl+H 3. select Enclosing Project scope 4. click the search button Observe: the list contains too many entries.
resolved fixed
a6d7b25
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2003-09-15T13:06:30Z
2003-09-12T09:46:40Z
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/search/JavaSearchScopeFactory.java
/******************************************************************************* * Copyright (c) 2000, 2003 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Common Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/cpl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.jdt.internal.ui.search; import java.util.HashSet; import java.util.Iterator; import java.util.Set; import org.eclipse.core.resources.IFolder; import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IResource; import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IAdaptable; import org.eclipse.core.runtime.IPath; import org.eclipse.swt.widgets.Shell; import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.jface.window.Window; import org.eclipse.ui.IWorkingSet; import org.eclipse.ui.PlatformUI; import org.eclipse.ui.dialogs.IWorkingSetSelectionDialog; import org.eclipse.search.ui.ISearchResultViewEntry; import org.eclipse.jdt.core.IJavaElement; import org.eclipse.jdt.core.IJavaProject; import org.eclipse.jdt.core.IPackageFragment; import org.eclipse.jdt.core.JavaModelException; import org.eclipse.jdt.core.search.IJavaSearchScope; import org.eclipse.jdt.core.search.SearchEngine; import org.eclipse.jdt.internal.ui.JavaPlugin; import org.eclipse.jdt.internal.ui.browsing.LogicalPackage; public class JavaSearchScopeFactory { private static JavaSearchScopeFactory fgInstance; private static final IJavaSearchScope EMPTY_SCOPE= SearchEngine.createJavaSearchScope(new IJavaElement[] {}); private static final Set EMPTY_SET= new HashSet(0); private JavaSearchScopeFactory() { } public static JavaSearchScopeFactory getInstance() { if (fgInstance == null) fgInstance= new JavaSearchScopeFactory(); return fgInstance; } public IWorkingSet[] queryWorkingSets() throws JavaModelException { Shell shell= JavaPlugin.getActiveWorkbenchShell(); if (shell == null) return null; IWorkingSetSelectionDialog dialog= PlatformUI.getWorkbench().getWorkingSetManager().createWorkingSetSelectionDialog(shell, true); if (dialog.open() == Window.OK) { IWorkingSet[] workingSets= dialog.getSelection(); if (workingSets.length > 0) return workingSets; } return null; } public IJavaSearchScope createJavaSearchScope(IWorkingSet[] workingSets) { if (workingSets == null || workingSets.length < 1) return EMPTY_SCOPE; Set javaElements= new HashSet(workingSets.length * 10); for (int i= 0; i < workingSets.length; i++) addJavaElements(javaElements, workingSets[i]); return createJavaSearchScope(javaElements); } public IJavaSearchScope createJavaSearchScope(IWorkingSet workingSet) { Set javaElements= new HashSet(10); addJavaElements(javaElements, workingSet); return createJavaSearchScope(javaElements); } public IJavaSearchScope createJavaSearchScope(IResource[] resources) { if (resources == null) return EMPTY_SCOPE; Set javaElements= new HashSet(resources.length); addJavaElements(javaElements, resources); return createJavaSearchScope(javaElements); } public IJavaSearchScope createJavaSearchScope(ISelection selection) { return createJavaSearchScope(getJavaElements(selection)); } public IJavaSearchScope createJavaProjectSearchScope(ISelection selection) { Set javaElements= getJavaElements(selection); Set javaProjects= new HashSet(javaElements.size()); Iterator elements= javaElements.iterator(); while (elements.hasNext()) { IJavaProject jp= ((IJavaElement)elements.next()).getJavaProject(); if (jp != null) javaProjects.add(jp); } return createJavaSearchScope(javaProjects); } public IProject[] getJavaProjects(IJavaSearchScope scope) { IPath[] paths= scope.enclosingProjectsAndJars(); HashSet temp= new HashSet(); for (int i= 0; i < paths.length; i++) { IResource resource= ResourcesPlugin.getWorkspace().getRoot().findMember(paths[i]); if (resource != null && resource.getType() == IResource.PROJECT) temp.add(resource); } return (IProject[]) temp.toArray(new IProject[temp.size()]); } private Set getJavaElements(ISelection selection) { Set javaElements; if (selection instanceof IStructuredSelection && !selection.isEmpty()) { Iterator iter= ((IStructuredSelection) selection).iterator(); javaElements= new HashSet(((IStructuredSelection) selection).size()); while (iter.hasNext()) { Object selectedElement= iter.next(); // Unpack search result view entry if (selectedElement instanceof ISearchResultViewEntry) selectedElement= ((ISearchResultViewEntry) selectedElement).getGroupByKey(); if (selectedElement instanceof IJavaElement) addJavaElements(javaElements, (IJavaElement) selectedElement); else if (selectedElement instanceof IResource) addJavaElements(javaElements, (IResource) selectedElement); else if (selectedElement instanceof LogicalPackage) addJavaElements(javaElements, (LogicalPackage) selectedElement); else if (selectedElement instanceof IAdaptable) { IResource resource= (IResource) ((IAdaptable) selectedElement).getAdapter(IResource.class); if (resource != null) addJavaElements(javaElements, resource); } } } else { javaElements= EMPTY_SET; } return javaElements; } private IJavaSearchScope createJavaSearchScope(Set javaElements) { if (javaElements.isEmpty()) return EMPTY_SCOPE; return SearchEngine.createJavaSearchScope((IJavaElement[])javaElements.toArray(new IJavaElement[javaElements.size()]), false); } private void addJavaElements(Set javaElements, IResource[] resources) { for (int i= 0; i < resources.length; i++) addJavaElements(javaElements, resources[i]); } private void addJavaElements(Set javaElements, IResource resource) { IJavaElement javaElement= (IJavaElement)resource.getAdapter(IJavaElement.class); if (javaElement == null) // not a Java resource return; if (javaElement.getElementType() == IJavaElement.PACKAGE_FRAGMENT) { // add other possible package fragments try { addJavaElements(javaElements, ((IFolder)resource).members()); } catch (CoreException ex) { // don't add elements } } javaElements.add(javaElement); } private void addJavaElements(Set javaElements, IJavaElement javaElement) { javaElements.add(javaElement); } private void addJavaElements(Set javaElements, IWorkingSet workingSet) { if (workingSet == null) return; IAdaptable[] elements= workingSet.getElements(); for (int i= 0; i < elements.length; i++) { IJavaElement javaElement=(IJavaElement) elements[i].getAdapter(IJavaElement.class); if (javaElement != null) { addJavaElements(javaElements, javaElement); continue; } IResource resource= (IResource)elements[i].getAdapter(IResource.class); if (resource != null) { addJavaElements(javaElements, resource); } // else we don't know what to do with it, ignore. } } public void addJavaElements(Set javaElements, LogicalPackage selectedElement) { IPackageFragment[] packages= selectedElement.getFragments(); for (int i= 0; i < packages.length; i++) addJavaElements(javaElements, packages[i]); } }
42,625
Bug 42625 Default for compiler compliance level
From a mail from Philippe: In order to reflect the migration to 1.4, compiler settings for JDT/Core projects should be: - compiler compliance 1.4 - source compatibility 1.3 - generated classfile compatibility 1.2 These are 1.4 compilers defaults anyway. JDT/UI got informed that their defaults in 1.4 compliant mode do not match expectation. Martin, can you please change our defaults.
verified fixed
1c904f1
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2003-09-15T13:20:05Z
2003-09-05T16:40:00Z
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/CompilerConfigurationBlock.java
/******************************************************************************* * Copyright (c) 2000, 2003 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Common Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/cpl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.jdt.internal.ui.preferences; import java.util.ArrayList; import java.util.Arrays; import java.util.Map; import org.eclipse.core.resources.IResource; import org.eclipse.core.resources.IWorkspace; import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.core.runtime.IStatus; import org.eclipse.swt.SWT; 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; import org.eclipse.swt.widgets.TabFolder; import org.eclipse.swt.widgets.TabItem; import org.eclipse.swt.widgets.Text; import org.eclipse.jdt.core.IJavaProject; import org.eclipse.jdt.core.JavaCore; import org.eclipse.jdt.internal.ui.dialogs.StatusInfo; import org.eclipse.jdt.internal.ui.dialogs.StatusUtil; import org.eclipse.jdt.internal.ui.util.PixelConverter; import org.eclipse.jdt.internal.ui.util.TabFolderLayout; import org.eclipse.jdt.internal.ui.wizards.IStatusChangeListener; /** */ public class CompilerConfigurationBlock extends OptionsConfigurationBlock { // Preference store keys, see JavaCore.getOptions private static final String PREF_LOCAL_VARIABLE_ATTR= JavaCore.COMPILER_LOCAL_VARIABLE_ATTR; private static final String PREF_LINE_NUMBER_ATTR= JavaCore.COMPILER_LINE_NUMBER_ATTR; private static final String PREF_SOURCE_FILE_ATTR= JavaCore.COMPILER_SOURCE_FILE_ATTR; private static final String PREF_CODEGEN_UNUSED_LOCAL= JavaCore.COMPILER_CODEGEN_UNUSED_LOCAL; private static final String PREF_CODEGEN_TARGET_PLATFORM= JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM; //private static final String PREF_PB_UNREACHABLE_CODE= JavaCore.COMPILER_PB_UNREACHABLE_CODE; //private static final String PREF_PB_INVALID_IMPORT= JavaCore.COMPILER_PB_INVALID_IMPORT; private static final String PREF_PB_OVERRIDING_PACKAGE_DEFAULT_METHOD= JavaCore.COMPILER_PB_OVERRIDING_PACKAGE_DEFAULT_METHOD; private static final String PREF_PB_METHOD_WITH_CONSTRUCTOR_NAME= JavaCore.COMPILER_PB_METHOD_WITH_CONSTRUCTOR_NAME; private static final String PREF_PB_DEPRECATION= JavaCore.COMPILER_PB_DEPRECATION; private static final String PREF_PB_HIDDEN_CATCH_BLOCK= JavaCore.COMPILER_PB_HIDDEN_CATCH_BLOCK; private static final String PREF_PB_UNUSED_LOCAL= JavaCore.COMPILER_PB_UNUSED_LOCAL; private static final String PREF_PB_UNUSED_PARAMETER= JavaCore.COMPILER_PB_UNUSED_PARAMETER; private static final String PREF_PB_SIGNAL_PARAMETER_IN_OVERRIDING= JavaCore.COMPILER_PB_UNUSED_PARAMETER_WHEN_OVERRIDING_CONCRETE; private static final String PREF_PB_SIGNAL_PARAMETER_IN_ABSTRACT= JavaCore.COMPILER_PB_UNUSED_PARAMETER_WHEN_IMPLEMENTING_ABSTRACT; private static final String PREF_PB_SYNTHETIC_ACCESS_EMULATION= JavaCore.COMPILER_PB_SYNTHETIC_ACCESS_EMULATION; private static final String PREF_PB_NON_EXTERNALIZED_STRINGS= JavaCore.COMPILER_PB_NON_NLS_STRING_LITERAL; private static final String PREF_PB_ASSERT_AS_IDENTIFIER= JavaCore.COMPILER_PB_ASSERT_IDENTIFIER; private static final String PREF_PB_MAX_PER_UNIT= JavaCore.COMPILER_PB_MAX_PER_UNIT; private static final String PREF_PB_UNUSED_IMPORT= JavaCore.COMPILER_PB_UNUSED_IMPORT; private static final String PREF_PB_UNUSED_PRIVATE= JavaCore.COMPILER_PB_UNUSED_PRIVATE_MEMBER; private static final String PREF_PB_STATIC_ACCESS_RECEIVER= JavaCore.COMPILER_PB_STATIC_ACCESS_RECEIVER; private static final String PREF_PB_NO_EFFECT_ASSIGNMENT= JavaCore.COMPILER_PB_NO_EFFECT_ASSIGNMENT; private static final String PREF_PB_CHAR_ARRAY_IN_CONCAT= JavaCore.COMPILER_PB_CHAR_ARRAY_IN_STRING_CONCATENATION; private static final String PREF_PB_POSSIBLE_ACCIDENTAL_BOOLEAN_ASSIGNMENT= JavaCore.COMPILER_PB_POSSIBLE_ACCIDENTAL_BOOLEAN_ASSIGNMENT; private static final String PREF_PB_LOCAL_VARIABLE_HIDING= JavaCore.COMPILER_PB_LOCAL_VARIABLE_HIDING; private static final String PREF_PB_FIELD_HIDING= JavaCore.COMPILER_PB_FIELD_HIDING; private static final String PREF_PB_SPECIAL_PARAMETER_HIDING_FIELD= JavaCore.COMPILER_PB_SPECIAL_PARAMETER_HIDING_FIELD; private static final String PREF_PB_INDIRECT_STATIC_ACCESS= JavaCore.COMPILER_PB_INDIRECT_STATIC_ACCESS; private static final String PREF_PB_SUPERFLUOUS_SEMICOLON= JavaCore.COMPILER_PB_SUPERFLUOUS_SEMICOLON; private static final String PREF_PB_UNNECESSARY_TYPE_CHECK= JavaCore.COMPILER_PB_UNNECESSARY_TYPE_CHECK; private static final String PREF_SOURCE_COMPATIBILITY= JavaCore.COMPILER_SOURCE; private static final String PREF_COMPLIANCE= JavaCore.COMPILER_COMPLIANCE; private static final String PREF_RESOURCE_FILTER= JavaCore.CORE_JAVA_BUILD_RESOURCE_COPY_FILTER; private static final String PREF_BUILD_INVALID_CLASSPATH= JavaCore.CORE_JAVA_BUILD_INVALID_CLASSPATH; private static final String PREF_BUILD_CLEAN_OUTPUT_FOLDER= JavaCore.CORE_JAVA_BUILD_CLEAN_OUTPUT_FOLDER; private static final String PREF_ENABLE_EXCLUSION_PATTERNS= JavaCore.CORE_ENABLE_CLASSPATH_EXCLUSION_PATTERNS; private static final String PREF_ENABLE_MULTIPLE_OUTPUT_LOCATIONS= JavaCore.CORE_ENABLE_CLASSPATH_MULTIPLE_OUTPUT_LOCATIONS; private static final String PREF_PB_INCOMPLETE_BUILDPATH= JavaCore.CORE_INCOMPLETE_CLASSPATH; private static final String PREF_PB_CIRCULAR_BUILDPATH= JavaCore.CORE_CIRCULAR_CLASSPATH; private static final String PREF_PB_INCOMPATIBLE_JDK_LEVEL= JavaCore.CORE_INCOMPATIBLE_JDK_LEVEL; private static final String PREF_PB_DEPRECATION_IN_DEPRECATED_CODE= JavaCore.COMPILER_PB_DEPRECATION_IN_DEPRECATED_CODE; private static final String PREF_PB_DUPLICATE_RESOURCE= JavaCore.CORE_JAVA_BUILD_DUPLICATE_RESOURCE; private static final String PREF_PB_INCOMPATIBLE_INTERFACE_METHOD= JavaCore.COMPILER_PB_INCOMPATIBLE_NON_INHERITED_INTERFACE_METHOD; private static final String INTR_DEFAULT_COMPLIANCE= "internal.default.compliance"; //$NON-NLS-1$ // values private static final String GENERATE= JavaCore.GENERATE; private static final String DO_NOT_GENERATE= JavaCore.DO_NOT_GENERATE; private static final String PRESERVE= JavaCore.PRESERVE; private static final String OPTIMIZE_OUT= JavaCore.OPTIMIZE_OUT; private static final String VERSION_1_1= JavaCore.VERSION_1_1; private static final String VERSION_1_2= JavaCore.VERSION_1_2; private static final String VERSION_1_3= JavaCore.VERSION_1_3; private static final String VERSION_1_4= JavaCore.VERSION_1_4; private static final String ERROR= JavaCore.ERROR; private static final String WARNING= JavaCore.WARNING; private static final String IGNORE= JavaCore.IGNORE; private static final String ABORT= JavaCore.ABORT; private static final String CLEAN= JavaCore.CLEAN; private static final String ENABLED= JavaCore.ENABLED; private static final String DISABLED= JavaCore.DISABLED; private static final String DEFAULT= "default"; //$NON-NLS-1$ private static final String USER= "user"; //$NON-NLS-1$ private ArrayList fComplianceControls; private PixelConverter fPixelConverter; private IStatus fComplianceStatus, fMaxNumberProblemsStatus, fResourceFilterStatus; public CompilerConfigurationBlock(IStatusChangeListener context, IJavaProject project) { super(context, project); fComplianceControls= new ArrayList(); fComplianceStatus= new StatusInfo(); fMaxNumberProblemsStatus= new StatusInfo(); fResourceFilterStatus= new StatusInfo(); } private final String[] KEYS= new String[] { PREF_LOCAL_VARIABLE_ATTR, PREF_LINE_NUMBER_ATTR, PREF_SOURCE_FILE_ATTR, PREF_CODEGEN_UNUSED_LOCAL, PREF_CODEGEN_TARGET_PLATFORM, PREF_PB_OVERRIDING_PACKAGE_DEFAULT_METHOD, PREF_PB_METHOD_WITH_CONSTRUCTOR_NAME, PREF_PB_DEPRECATION, PREF_PB_HIDDEN_CATCH_BLOCK, PREF_PB_UNUSED_LOCAL, PREF_PB_UNUSED_PARAMETER, PREF_PB_SYNTHETIC_ACCESS_EMULATION, PREF_PB_NON_EXTERNALIZED_STRINGS, PREF_PB_ASSERT_AS_IDENTIFIER, PREF_PB_UNUSED_IMPORT, PREF_PB_MAX_PER_UNIT, PREF_SOURCE_COMPATIBILITY, PREF_COMPLIANCE, PREF_RESOURCE_FILTER, PREF_BUILD_INVALID_CLASSPATH, PREF_PB_STATIC_ACCESS_RECEIVER, PREF_PB_INCOMPLETE_BUILDPATH, PREF_PB_CIRCULAR_BUILDPATH, PREF_PB_DEPRECATION_IN_DEPRECATED_CODE, PREF_BUILD_CLEAN_OUTPUT_FOLDER, PREF_PB_DUPLICATE_RESOURCE, PREF_PB_NO_EFFECT_ASSIGNMENT, PREF_PB_INCOMPATIBLE_INTERFACE_METHOD, PREF_PB_UNUSED_PRIVATE, PREF_PB_CHAR_ARRAY_IN_CONCAT, PREF_ENABLE_EXCLUSION_PATTERNS, PREF_ENABLE_MULTIPLE_OUTPUT_LOCATIONS, PREF_PB_POSSIBLE_ACCIDENTAL_BOOLEAN_ASSIGNMENT, PREF_PB_LOCAL_VARIABLE_HIDING, PREF_PB_FIELD_HIDING, PREF_PB_SPECIAL_PARAMETER_HIDING_FIELD, PREF_PB_INCOMPATIBLE_JDK_LEVEL, PREF_PB_INDIRECT_STATIC_ACCESS, PREF_PB_SUPERFLUOUS_SEMICOLON, PREF_PB_SIGNAL_PARAMETER_IN_OVERRIDING, PREF_PB_SIGNAL_PARAMETER_IN_ABSTRACT, PREF_PB_UNNECESSARY_TYPE_CHECK }; protected String[] getAllKeys() { return KEYS; } protected final Map getOptions(boolean inheritJavaCoreOptions) { Map map= super.getOptions(inheritJavaCoreOptions); map.put(INTR_DEFAULT_COMPLIANCE, getCurrentCompliance(map)); return map; } protected final Map getDefaultOptions() { Map map= super.getDefaultOptions(); map.put(INTR_DEFAULT_COMPLIANCE, getCurrentCompliance(map)); return map; } /* * @see org.eclipse.jface.preference.PreferencePage#createContents(Composite) */ protected Control createContents(Composite parent) { fPixelConverter= new PixelConverter(parent); setShell(parent.getShell()); TabFolder folder= new TabFolder(parent, SWT.NONE); folder.setLayout(new TabFolderLayout()); folder.setLayoutData(new GridData(GridData.FILL_BOTH)); Composite commonComposite= createStyleTabContent(folder); Composite unusedComposite= createUnusedCodeTabContent(folder); Composite advancedComposite= createAdvancedTabContent(folder); Composite complianceComposite= createComplianceTabContent(folder); Composite othersComposite= createBuildPathTabContent(folder); TabItem item= new TabItem(folder, SWT.NONE); item.setText(PreferencesMessages.getString("CompilerConfigurationBlock.common.tabtitle")); //$NON-NLS-1$ item.setControl(commonComposite); item= new TabItem(folder, SWT.NONE); item.setText(PreferencesMessages.getString("CompilerConfigurationBlock.advanced.tabtitle")); //$NON-NLS-1$ item.setControl(advancedComposite); item= new TabItem(folder, SWT.NONE); item.setText(PreferencesMessages.getString("CompilerConfigurationBlock.unused.tabtitle")); //$NON-NLS-1$ item.setControl(unusedComposite); item= new TabItem(folder, SWT.NONE); item.setText(PreferencesMessages.getString("CompilerConfigurationBlock.compliance.tabtitle")); //$NON-NLS-1$ item.setControl(complianceComposite); item= new TabItem(folder, SWT.NONE); item.setText(PreferencesMessages.getString("CompilerConfigurationBlock.others.tabtitle")); //$NON-NLS-1$ item.setControl(othersComposite); validateSettings(null, null); return folder; } private Composite createStyleTabContent(Composite folder) { String[] errorWarningIgnore= new String[] { ERROR, WARNING, IGNORE }; String[] errorWarningIgnoreLabels= new String[] { PreferencesMessages.getString("CompilerConfigurationBlock.error"), //$NON-NLS-1$ PreferencesMessages.getString("CompilerConfigurationBlock.warning"), //$NON-NLS-1$ PreferencesMessages.getString("CompilerConfigurationBlock.ignore") //$NON-NLS-1$ }; int nColumns= 3; GridLayout layout= new GridLayout(); layout.numColumns= nColumns; Composite composite= new Composite(folder, SWT.NULL); composite.setLayout(layout); Label description= new Label(composite, SWT.WRAP); description.setText(PreferencesMessages.getString("CompilerConfigurationBlock.common.description")); //$NON-NLS-1$ GridData gd= new GridData(); gd.horizontalSpan= nColumns; gd.widthHint= fPixelConverter.convertWidthInCharsToPixels(50); description.setLayoutData(gd); String label= PreferencesMessages.getString("CompilerConfigurationBlock.pb_overriding_pkg_dflt.label"); //$NON-NLS-1$ addComboBox(composite, label, PREF_PB_OVERRIDING_PACKAGE_DEFAULT_METHOD, errorWarningIgnore, errorWarningIgnoreLabels, 0); label= PreferencesMessages.getString("CompilerConfigurationBlock.pb_method_naming.label"); //$NON-NLS-1$ addComboBox(composite, label, PREF_PB_METHOD_WITH_CONSTRUCTOR_NAME, errorWarningIgnore, errorWarningIgnoreLabels, 0); label= PreferencesMessages.getString("CompilerConfigurationBlock.pb_hidden_catchblock.label"); //$NON-NLS-1$ addComboBox(composite, label, PREF_PB_HIDDEN_CATCH_BLOCK, errorWarningIgnore, errorWarningIgnoreLabels, 0); label= PreferencesMessages.getString("CompilerConfigurationBlock.pb_static_access_receiver.label"); //$NON-NLS-1$ addComboBox(composite, label, PREF_PB_STATIC_ACCESS_RECEIVER, errorWarningIgnore, errorWarningIgnoreLabels, 0); label= PreferencesMessages.getString("CompilerConfigurationBlock.pb_no_effect_assignment.label"); //$NON-NLS-1$ addComboBox(composite, label, PREF_PB_NO_EFFECT_ASSIGNMENT, errorWarningIgnore, errorWarningIgnoreLabels, 0); label= PreferencesMessages.getString("CompilerConfigurationBlock.pb_indirect_access_to_static.label"); //$NON-NLS-1$ addComboBox(composite, label, PREF_PB_INDIRECT_STATIC_ACCESS, errorWarningIgnore, errorWarningIgnoreLabels, 0); label= PreferencesMessages.getString("CompilerConfigurationBlock.pb_accidential_assignement.label"); //$NON-NLS-1$ addComboBox(composite, label, PREF_PB_POSSIBLE_ACCIDENTAL_BOOLEAN_ASSIGNMENT, errorWarningIgnore, errorWarningIgnoreLabels, 0); return composite; } private Composite createAdvancedTabContent(TabFolder folder) { String[] errorWarningIgnore= new String[] { ERROR, WARNING, IGNORE }; String[] errorWarningIgnoreLabels= new String[] { PreferencesMessages.getString("CompilerConfigurationBlock.error"), //$NON-NLS-1$ PreferencesMessages.getString("CompilerConfigurationBlock.warning"), //$NON-NLS-1$ PreferencesMessages.getString("CompilerConfigurationBlock.ignore") //$NON-NLS-1$ }; String[] enabledDisabled= new String[] { ENABLED, DISABLED }; int nColumns= 3; GridLayout layout= new GridLayout(); layout.numColumns= nColumns; Composite composite= new Composite(folder, SWT.NULL); composite.setLayout(layout); Label description= new Label(composite, SWT.WRAP); description.setText(PreferencesMessages.getString("CompilerConfigurationBlock.advanced.description")); //$NON-NLS-1$ GridData gd= new GridData(); gd.horizontalSpan= nColumns; gd.widthHint= fPixelConverter.convertWidthInCharsToPixels(50); description.setLayoutData(gd); String label= PreferencesMessages.getString("CompilerConfigurationBlock.pb_synth_access_emul.label"); //$NON-NLS-1$ addComboBox(composite, label, PREF_PB_SYNTHETIC_ACCESS_EMULATION, errorWarningIgnore, errorWarningIgnoreLabels, 0); label= PreferencesMessages.getString("CompilerConfigurationBlock.pb_local_variable_hiding.label"); //$NON-NLS-1$ addComboBox(composite, label, PREF_PB_LOCAL_VARIABLE_HIDING, errorWarningIgnore, errorWarningIgnoreLabels, 0); int indent= fPixelConverter.convertWidthInCharsToPixels(2); label= PreferencesMessages.getString("CompilerConfigurationBlock.pb_special_param_hiding.label"); //$NON-NLS-1$ addCheckBox(composite, label, PREF_PB_SPECIAL_PARAMETER_HIDING_FIELD, enabledDisabled, indent); label= PreferencesMessages.getString("CompilerConfigurationBlock.pb_field_hiding.label"); //$NON-NLS-1$ addComboBox(composite, label, PREF_PB_FIELD_HIDING, errorWarningIgnore, errorWarningIgnoreLabels, 0); label= PreferencesMessages.getString("CompilerConfigurationBlock.pb_non_externalized_strings.label"); //$NON-NLS-1$ addComboBox(composite, label, PREF_PB_NON_EXTERNALIZED_STRINGS, errorWarningIgnore, errorWarningIgnoreLabels, 0); label= PreferencesMessages.getString("CompilerConfigurationBlock.pb_incompatible_interface_method.label"); //$NON-NLS-1$ addComboBox(composite, label, PREF_PB_INCOMPATIBLE_INTERFACE_METHOD, errorWarningIgnore, errorWarningIgnoreLabels, 0); label= PreferencesMessages.getString("CompilerConfigurationBlock.pb_char_array_in_concat.label"); //$NON-NLS-1$ addComboBox(composite, label, PREF_PB_CHAR_ARRAY_IN_CONCAT, errorWarningIgnore, errorWarningIgnoreLabels, 0); gd= new GridData(); gd.widthHint= fPixelConverter.convertWidthInCharsToPixels(6); label= PreferencesMessages.getString("CompilerConfigurationBlock.pb_max_per_unit.label"); //$NON-NLS-1$ Text text= addTextField(composite, label, PREF_PB_MAX_PER_UNIT, 0, 0); text.setTextLimit(6); text.setLayoutData(gd); return composite; } private Composite createUnusedCodeTabContent(TabFolder folder) { String[] errorWarningIgnore= new String[] { ERROR, WARNING, IGNORE }; String[] errorWarningIgnoreLabels= new String[] { PreferencesMessages.getString("CompilerConfigurationBlock.error"), //$NON-NLS-1$ PreferencesMessages.getString("CompilerConfigurationBlock.warning"), //$NON-NLS-1$ PreferencesMessages.getString("CompilerConfigurationBlock.ignore") //$NON-NLS-1$ }; String[] enabledDisabled= new String[] { ENABLED, DISABLED }; int nColumns= 3; GridLayout layout= new GridLayout(); layout.numColumns= nColumns; Composite composite= new Composite(folder, SWT.NULL); composite.setLayout(layout); Label description= new Label(composite, SWT.WRAP); description.setText(PreferencesMessages.getString("CompilerConfigurationBlock.unused.description")); //$NON-NLS-1$ GridData gd= new GridData(); gd.horizontalSpan= nColumns; gd.widthHint= fPixelConverter.convertWidthInCharsToPixels(50); description.setLayoutData(gd); Composite combos= composite; String label= PreferencesMessages.getString("CompilerConfigurationBlock.pb_unused_local.label"); //$NON-NLS-1$ addComboBox(combos, label, PREF_PB_UNUSED_LOCAL, errorWarningIgnore, errorWarningIgnoreLabels, 0); label= PreferencesMessages.getString("CompilerConfigurationBlock.pb_unused_parameter.label"); //$NON-NLS-1$ addComboBox(combos, label, PREF_PB_UNUSED_PARAMETER, errorWarningIgnore, errorWarningIgnoreLabels, 0); int indent= fPixelConverter.convertWidthInCharsToPixels(2); label= PreferencesMessages.getString("CompilerConfigurationBlock.pb_signal_param_in_overriding.label"); //$NON-NLS-1$ addCheckBox(combos, label, PREF_PB_SIGNAL_PARAMETER_IN_OVERRIDING, enabledDisabled, indent); label= PreferencesMessages.getString("CompilerConfigurationBlock.pb_signal_param_in_abstract.label"); //$NON-NLS-1$ addCheckBox(combos, label, PREF_PB_SIGNAL_PARAMETER_IN_ABSTRACT, enabledDisabled, indent); label= PreferencesMessages.getString("CompilerConfigurationBlock.pb_unused_imports.label"); //$NON-NLS-1$ addComboBox(combos, label, PREF_PB_UNUSED_IMPORT, errorWarningIgnore, errorWarningIgnoreLabels, 0); label= PreferencesMessages.getString("CompilerConfigurationBlock.pb_unused_private.label"); //$NON-NLS-1$ addComboBox(combos, label, PREF_PB_UNUSED_PRIVATE, errorWarningIgnore, errorWarningIgnoreLabels, 0); label= PreferencesMessages.getString("CompilerConfigurationBlock.pb_deprecation.label"); //$NON-NLS-1$ addComboBox(combos, label, PREF_PB_DEPRECATION, errorWarningIgnore, errorWarningIgnoreLabels, 0); label= PreferencesMessages.getString("CompilerConfigurationBlock.pb_deprecation_in_deprecation.label"); //$NON-NLS-1$ addCheckBox(composite, label, PREF_PB_DEPRECATION_IN_DEPRECATED_CODE, enabledDisabled, indent); label= PreferencesMessages.getString("CompilerConfigurationBlock.pb_superfluous_semicolon.label"); //$NON-NLS-1$ addComboBox(composite, label, PREF_PB_SUPERFLUOUS_SEMICOLON, errorWarningIgnore, errorWarningIgnoreLabels, 0); label= PreferencesMessages.getString("CompilerConfigurationBlock.pb_unnecessary_type_check.label"); //$NON-NLS-1$ addComboBox(composite, label, PREF_PB_UNNECESSARY_TYPE_CHECK, errorWarningIgnore, errorWarningIgnoreLabels, 0); return composite; } private Composite createBuildPathTabContent(TabFolder folder) { String[] abortIgnoreValues= new String[] { ABORT, IGNORE }; String[] cleanIgnoreValues= new String[] { CLEAN, IGNORE }; String[] enableDisableValues= new String[] { ENABLED, DISABLED }; String[] errorWarning= new String[] { ERROR, WARNING }; String[] errorWarningLabels= new String[] { PreferencesMessages.getString("CompilerConfigurationBlock.error"), //$NON-NLS-1$ PreferencesMessages.getString("CompilerConfigurationBlock.warning") //$NON-NLS-1$ }; int nColumns= 3; GridLayout layout= new GridLayout(); layout.numColumns= nColumns; Composite othersComposite= new Composite(folder, SWT.NULL); othersComposite.setLayout(layout); Label description= new Label(othersComposite, SWT.WRAP); description.setText(PreferencesMessages.getString("CompilerConfigurationBlock.build_warnings.description")); //$NON-NLS-1$ GridData gd= new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL); gd.horizontalSpan= nColumns; description.setLayoutData(gd); String label= PreferencesMessages.getString("CompilerConfigurationBlock.pb_incomplete_build_path.label"); //$NON-NLS-1$ addComboBox(othersComposite, label, PREF_PB_INCOMPLETE_BUILDPATH, errorWarning, errorWarningLabels, 0); label= PreferencesMessages.getString("CompilerConfigurationBlock.pb_build_path_cycles.label"); //$NON-NLS-1$ addComboBox(othersComposite, label, PREF_PB_CIRCULAR_BUILDPATH, errorWarning, errorWarningLabels, 0); label= PreferencesMessages.getString("CompilerConfigurationBlock.pb_duplicate_resources.label"); //$NON-NLS-1$ addComboBox(othersComposite, label, PREF_PB_DUPLICATE_RESOURCE, errorWarning, errorWarningLabels, 0); String[] errorWarningIgnore= new String[] { ERROR, WARNING, IGNORE }; String[] errorWarningIgnoreLabels= new String[] { PreferencesMessages.getString("CompilerConfigurationBlock.error"), //$NON-NLS-1$ PreferencesMessages.getString("CompilerConfigurationBlock.warning"), //$NON-NLS-1$ PreferencesMessages.getString("CompilerConfigurationBlock.ignore") //$NON-NLS-1$ }; label= PreferencesMessages.getString("CompilerConfigurationBlock.pb_check_prereq_binary_level.label"); //$NON-NLS-1$ addComboBox(othersComposite, label, PREF_PB_INCOMPATIBLE_JDK_LEVEL, errorWarningIgnore, errorWarningIgnoreLabels, 0); label= PreferencesMessages.getString("CompilerConfigurationBlock.build_invalid_classpath.label"); //$NON-NLS-1$ addCheckBox(othersComposite, label, PREF_BUILD_INVALID_CLASSPATH, abortIgnoreValues, 0); label= PreferencesMessages.getString("CompilerConfigurationBlock.build_clean_outputfolder.label"); //$NON-NLS-1$ addCheckBox(othersComposite, label, PREF_BUILD_CLEAN_OUTPUT_FOLDER, cleanIgnoreValues, 0); label= PreferencesMessages.getString("CompilerConfigurationBlock.enable_exclusion_patterns.label"); //$NON-NLS-1$ addCheckBox(othersComposite, label, PREF_ENABLE_EXCLUSION_PATTERNS, enableDisableValues, 0); label= PreferencesMessages.getString("CompilerConfigurationBlock.enable_multiple_outputlocations.label"); //$NON-NLS-1$ addCheckBox(othersComposite, label, PREF_ENABLE_MULTIPLE_OUTPUT_LOCATIONS, enableDisableValues, 0); description= new Label(othersComposite, SWT.WRAP); description.setText(PreferencesMessages.getString("CompilerConfigurationBlock.resource_filter.description")); //$NON-NLS-1$ gd= new GridData(GridData.FILL); gd.horizontalSpan= nColumns; gd.widthHint= fPixelConverter.convertWidthInCharsToPixels(60); description.setLayoutData(gd); label= PreferencesMessages.getString("CompilerConfigurationBlock.resource_filter.label"); //$NON-NLS-1$ Text text= addTextField(othersComposite, label, PREF_RESOURCE_FILTER, 0, 0); gd= (GridData) text.getLayoutData(); gd.grabExcessHorizontalSpace= true; gd.widthHint= fPixelConverter.convertWidthInCharsToPixels(10); return othersComposite; } private Composite createComplianceTabContent(Composite folder) { GridLayout layout= new GridLayout(); layout.numColumns= 1; String[] values34= new String[] { VERSION_1_3, VERSION_1_4 }; String[] values34Labels= new String[] { PreferencesMessages.getString("CompilerConfigurationBlock.version13"), //$NON-NLS-1$ PreferencesMessages.getString("CompilerConfigurationBlock.version14") //$NON-NLS-1$ }; Composite compComposite= new Composite(folder, SWT.NULL); compComposite.setLayout(layout); int nColumns= 3; layout= new GridLayout(); layout.numColumns= nColumns; Group group= new Group(compComposite, SWT.NONE); group.setText(PreferencesMessages.getString("CompilerConfigurationBlock.compliance.group.label")); //$NON-NLS-1$ group.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); group.setLayout(layout); String label= PreferencesMessages.getString("CompilerConfigurationBlock.compiler_compliance.label"); //$NON-NLS-1$ addComboBox(group, label, PREF_COMPLIANCE, values34, values34Labels, 0); label= PreferencesMessages.getString("CompilerConfigurationBlock.default_settings.label"); //$NON-NLS-1$ addCheckBox(group, label, INTR_DEFAULT_COMPLIANCE, new String[] { DEFAULT, USER }, 0); int indent= fPixelConverter.convertWidthInCharsToPixels(2); Control[] otherChildren= group.getChildren(); String[] values14= new String[] { VERSION_1_1, VERSION_1_2, VERSION_1_3, VERSION_1_4 }; String[] values14Labels= new String[] { PreferencesMessages.getString("CompilerConfigurationBlock.version11"), //$NON-NLS-1$ PreferencesMessages.getString("CompilerConfigurationBlock.version12"), //$NON-NLS-1$ PreferencesMessages.getString("CompilerConfigurationBlock.version13"), //$NON-NLS-1$ PreferencesMessages.getString("CompilerConfigurationBlock.version14") //$NON-NLS-1$ }; label= PreferencesMessages.getString("CompilerConfigurationBlock.codegen_targetplatform.label"); //$NON-NLS-1$ addComboBox(group, label, PREF_CODEGEN_TARGET_PLATFORM, values14, values14Labels, indent); label= PreferencesMessages.getString("CompilerConfigurationBlock.source_compatibility.label"); //$NON-NLS-1$ addComboBox(group, label, PREF_SOURCE_COMPATIBILITY, values34, values34Labels, indent); String[] errorWarningIgnore= new String[] { ERROR, WARNING, IGNORE }; String[] errorWarningIgnoreLabels= new String[] { PreferencesMessages.getString("CompilerConfigurationBlock.error"), //$NON-NLS-1$ PreferencesMessages.getString("CompilerConfigurationBlock.warning"), //$NON-NLS-1$ PreferencesMessages.getString("CompilerConfigurationBlock.ignore") //$NON-NLS-1$ }; label= PreferencesMessages.getString("CompilerConfigurationBlock.pb_assert_as_identifier.label"); //$NON-NLS-1$ addComboBox(group, label, PREF_PB_ASSERT_AS_IDENTIFIER, errorWarningIgnore, errorWarningIgnoreLabels, indent); Control[] allChildren= group.getChildren(); fComplianceControls.addAll(Arrays.asList(allChildren)); fComplianceControls.removeAll(Arrays.asList(otherChildren)); layout= new GridLayout(); layout.numColumns= nColumns; group= new Group(compComposite, SWT.NONE); group.setText(PreferencesMessages.getString("CompilerConfigurationBlock.classfiles.group.label")); //$NON-NLS-1$ group.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); group.setLayout(layout); String[] generateValues= new String[] { GENERATE, DO_NOT_GENERATE }; label= PreferencesMessages.getString("CompilerConfigurationBlock.variable_attr.label"); //$NON-NLS-1$ addCheckBox(group, label, PREF_LOCAL_VARIABLE_ATTR, generateValues, 0); label= PreferencesMessages.getString("CompilerConfigurationBlock.line_number_attr.label"); //$NON-NLS-1$ addCheckBox(group, label, PREF_LINE_NUMBER_ATTR, generateValues, 0); label= PreferencesMessages.getString("CompilerConfigurationBlock.source_file_attr.label"); //$NON-NLS-1$ addCheckBox(group, label, PREF_SOURCE_FILE_ATTR, generateValues, 0); label= PreferencesMessages.getString("CompilerConfigurationBlock.codegen_unused_local.label"); //$NON-NLS-1$ addCheckBox(group, label, PREF_CODEGEN_UNUSED_LOCAL, new String[] { PRESERVE, OPTIMIZE_OUT }, 0); return compComposite; } /* (non-javadoc) * Update fields and validate. * @param changedKey Key that changed, or null, if all changed. */ protected void validateSettings(String changedKey, String newValue) { if (changedKey != null) { if (INTR_DEFAULT_COMPLIANCE.equals(changedKey)) { updateComplianceEnableState(); if (DEFAULT.equals(newValue)) { updateComplianceDefaultSettings(); } fComplianceStatus= validateCompliance(); } else if (PREF_COMPLIANCE.equals(changedKey)) { if (checkValue(INTR_DEFAULT_COMPLIANCE, DEFAULT)) { updateComplianceDefaultSettings(); } fComplianceStatus= validateCompliance(); } else if (PREF_SOURCE_COMPATIBILITY.equals(changedKey) || PREF_CODEGEN_TARGET_PLATFORM.equals(changedKey) || PREF_PB_ASSERT_AS_IDENTIFIER.equals(changedKey)) { fComplianceStatus= validateCompliance(); } else if (PREF_PB_MAX_PER_UNIT.equals(changedKey)) { fMaxNumberProblemsStatus= validateMaxNumberProblems(); } else if (PREF_RESOURCE_FILTER.equals(changedKey)) { fResourceFilterStatus= validateResourceFilters(); } else if (PREF_PB_UNUSED_PARAMETER.equals(changedKey) || PREF_PB_DEPRECATION.equals(changedKey) || PREF_PB_LOCAL_VARIABLE_HIDING.equals(changedKey)) { updateEnableStates(); } else { return; } } else { updateEnableStates(); updateComplianceEnableState(); fComplianceStatus= validateCompliance(); fMaxNumberProblemsStatus= validateMaxNumberProblems(); fResourceFilterStatus= validateResourceFilters(); } IStatus status= StatusUtil.getMostSevere(new IStatus[] { fComplianceStatus, fMaxNumberProblemsStatus, fResourceFilterStatus }); fContext.statusChanged(status); } private void updateEnableStates() { boolean enableUnusedParams= !checkValue(PREF_PB_UNUSED_PARAMETER, IGNORE); getCheckBox(PREF_PB_SIGNAL_PARAMETER_IN_OVERRIDING).setEnabled(enableUnusedParams); getCheckBox(PREF_PB_SIGNAL_PARAMETER_IN_ABSTRACT).setEnabled(enableUnusedParams); boolean enableDeprecation= !checkValue(PREF_PB_DEPRECATION, IGNORE); getCheckBox(PREF_PB_DEPRECATION_IN_DEPRECATED_CODE).setEnabled(enableDeprecation); boolean enableHiding= !checkValue(PREF_PB_LOCAL_VARIABLE_HIDING, IGNORE); getCheckBox(PREF_PB_SPECIAL_PARAMETER_HIDING_FIELD).setEnabled(enableHiding); } private IStatus validateCompliance() { StatusInfo status= new StatusInfo(); if (checkValue(PREF_COMPLIANCE, VERSION_1_3)) { if (checkValue(PREF_SOURCE_COMPATIBILITY, VERSION_1_4)) { status.setError(PreferencesMessages.getString("CompilerConfigurationBlock.cpl13src14.error")); //$NON-NLS-1$ return status; } else if (checkValue(PREF_CODEGEN_TARGET_PLATFORM, VERSION_1_4)) { status.setError(PreferencesMessages.getString("CompilerConfigurationBlock.cpl13trg14.error")); //$NON-NLS-1$ return status; } } if (checkValue(PREF_SOURCE_COMPATIBILITY, VERSION_1_4)) { if (!checkValue(PREF_PB_ASSERT_AS_IDENTIFIER, ERROR)) { status.setError(PreferencesMessages.getString("CompilerConfigurationBlock.src14asrterr.error")); //$NON-NLS-1$ return status; } } if (checkValue(PREF_SOURCE_COMPATIBILITY, VERSION_1_4)) { if (!checkValue(PREF_CODEGEN_TARGET_PLATFORM, VERSION_1_4)) { status.setError(PreferencesMessages.getString("CompilerConfigurationBlock.src14tgt14.error")); //$NON-NLS-1$ return status; } } return status; } private IStatus validateMaxNumberProblems() { String number= (String) fWorkingValues.get(PREF_PB_MAX_PER_UNIT); StatusInfo status= new StatusInfo(); if (number.length() == 0) { status.setError(PreferencesMessages.getString("CompilerConfigurationBlock.empty_input")); //$NON-NLS-1$ } else { try { int value= Integer.parseInt(number); if (value <= 0) { status.setError(PreferencesMessages.getFormattedString("CompilerConfigurationBlock.invalid_input", number)); //$NON-NLS-1$ } } catch (NumberFormatException e) { status.setError(PreferencesMessages.getFormattedString("CompilerConfigurationBlock.invalid_input", number)); //$NON-NLS-1$ } } return status; } private IStatus validateResourceFilters() { String text= (String) fWorkingValues.get(PREF_RESOURCE_FILTER); IWorkspace workspace= ResourcesPlugin.getWorkspace(); String[] filters= getTokens(text, ","); //$NON-NLS-1$ for (int i= 0; i < filters.length; i++) { String fileName= filters[i].replace('*', 'x'); int resourceType= IResource.FILE; int lastCharacter= fileName.length() - 1; if (lastCharacter >= 0 && fileName.charAt(lastCharacter) == '/') { fileName= fileName.substring(0, lastCharacter); resourceType= IResource.FOLDER; } IStatus status= workspace.validateName(fileName, resourceType); if (status.matches(IStatus.ERROR)) { String message= PreferencesMessages.getFormattedString("CompilerConfigurationBlock.filter.invalidsegment.error", status.getMessage()); //$NON-NLS-1$ return new StatusInfo(IStatus.ERROR, message); } } return new StatusInfo(); } /* * Update the compliance controls' enable state */ private void updateComplianceEnableState() { boolean enabled= checkValue(INTR_DEFAULT_COMPLIANCE, USER); for (int i= fComplianceControls.size() - 1; i >= 0; i--) { Control curr= (Control) fComplianceControls.get(i); curr.setEnabled(enabled); } } /* * Set the default compliance values derived from the chosen level */ private void updateComplianceDefaultSettings() { Object complianceLevel= fWorkingValues.get(PREF_COMPLIANCE); if (VERSION_1_3.equals(complianceLevel)) { fWorkingValues.put(PREF_PB_ASSERT_AS_IDENTIFIER, IGNORE); fWorkingValues.put(PREF_SOURCE_COMPATIBILITY, VERSION_1_3); fWorkingValues.put(PREF_CODEGEN_TARGET_PLATFORM, VERSION_1_1); } else if (VERSION_1_4.equals(complianceLevel)) { fWorkingValues.put(PREF_PB_ASSERT_AS_IDENTIFIER, ERROR); fWorkingValues.put(PREF_SOURCE_COMPATIBILITY, VERSION_1_4); fWorkingValues.put(PREF_CODEGEN_TARGET_PLATFORM, VERSION_1_4); } updateControls(); } /* * Evaluate if the current compliance setting correspond to a default setting */ private static String getCurrentCompliance(Map map) { Object complianceLevel= map.get(PREF_COMPLIANCE); if ((VERSION_1_3.equals(complianceLevel) && IGNORE.equals(map.get(PREF_PB_ASSERT_AS_IDENTIFIER)) && VERSION_1_3.equals(map.get(PREF_SOURCE_COMPATIBILITY)) && VERSION_1_1.equals(map.get(PREF_CODEGEN_TARGET_PLATFORM))) || (VERSION_1_4.equals(complianceLevel) && ERROR.equals(map.get(PREF_PB_ASSERT_AS_IDENTIFIER)) && VERSION_1_4.equals(map.get(PREF_SOURCE_COMPATIBILITY)) && VERSION_1_4.equals(map.get(PREF_CODEGEN_TARGET_PLATFORM)))) { return DEFAULT; } return USER; } protected String[] getFullBuildDialogStrings(boolean workspaceSettings) { String title= PreferencesMessages.getString("CompilerConfigurationBlock.needsbuild.title"); //$NON-NLS-1$ String message; if (workspaceSettings) { message= PreferencesMessages.getString("CompilerConfigurationBlock.needsfullbuild.message"); //$NON-NLS-1$ } else { message= PreferencesMessages.getString("CompilerConfigurationBlock.needsprojectbuild.message"); //$NON-NLS-1$ } return new String[] { title, message }; } }
42,587
Bug 42587 Left over from content assist
M3 - set preference that content assist should overwrite - open content assist on some word so that the rest of the word is indicated to be overwritten - transfer focus to the content assist widget using TAB - Esc -> overwrite indication is still there
resolved fixed
a226d37
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2003-09-15T15:11:04Z
2003-09-05T11:06:40Z
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/link/contentassist/CompletionProposalPopup2.java
/******************************************************************************* * Copyright (c) 2000, 2003 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Common Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/cpl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.jdt.internal.ui.text.link.contentassist; import java.util.ArrayList; import java.util.List; import org.eclipse.swt.SWT; import org.eclipse.swt.custom.BusyIndicator; import org.eclipse.swt.custom.StyledText; import org.eclipse.swt.events.ControlEvent; import org.eclipse.swt.events.ControlListener; import org.eclipse.swt.events.KeyEvent; import org.eclipse.swt.events.KeyListener; import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.events.SelectionListener; import org.eclipse.swt.events.VerifyEvent; import org.eclipse.swt.graphics.Color; import org.eclipse.swt.graphics.Point; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Control; import org.eclipse.swt.widgets.Shell; import org.eclipse.swt.widgets.Table; import org.eclipse.swt.widgets.TableItem; import org.eclipse.jface.resource.JFaceResources; import org.eclipse.jface.text.BadLocationException; import org.eclipse.jface.text.DocumentEvent; import org.eclipse.jface.text.IDocument; import org.eclipse.jface.text.IDocumentListener; import org.eclipse.jface.text.IRewriteTarget; import org.eclipse.jface.text.ITextViewer; import org.eclipse.jface.text.ITextViewerExtension; import org.eclipse.jface.text.TextUtilities; import org.eclipse.jface.text.contentassist.ICompletionProposal; import org.eclipse.jface.text.contentassist.ICompletionProposalExtension; import org.eclipse.jface.text.contentassist.ICompletionProposalExtension2; import org.eclipse.jface.text.contentassist.IContextInformation; /** * This class is used to present proposals to the user. If additional * information exists for a proposal, then selecting that proposal * will result in the information being displayed in a secondary * window. * * @see org.eclipse.jface.text.contentassist.ICompletionProposal * @see org.eclipse.jface.text.contentassist.AdditionalInfoController */ class CompletionProposalPopup2 implements IContentAssistListener2 { /** The associated text viewer */ private ITextViewer fViewer; /** The associated content assistant */ private ContentAssistant2 fContentAssistant; /** The used additional info controller */ private AdditionalInfoController2 fAdditionalInfoController; /** The closing strategy for this completion proposal popup */ private PopupCloser2 fPopupCloser= new PopupCloser2(); /** The popup shell */ private Shell fProposalShell; /** The proposal table */ private Table fProposalTable; /** Indicates whether a completion proposal is being inserted */ private boolean fInserting= false; /** The key listener to control navigation */ private KeyListener fKeyListener; /** List of document events used for filtering proposals */ private List fDocumentEvents= new ArrayList(); /** Listener filling the document event queue */ private IDocumentListener fDocumentListener; /** Reentrance count for <code>filterProposals</code> */ private long fInvocationCounter= 0; /** The filter list of proposals */ private ICompletionProposal[] fFilteredProposals; /** The computed list of proposals */ private ICompletionProposal[] fComputedProposals; /** The offset for which the proposals have been computed */ private int fInvocationOffset; /** The offset for which the computed proposaks have been filtered */ private int fFilterOffset; /** The default line delimiter of the viewer's widget */ private String fLineDelimiter; /** * Creates a new completion proposal popup for the given elements. * * @param contentAssistant the content assistant feeding this popup * @param viewer the viewer on top of which this popup appears * @param infoController the info control collaborating with this popup * @since 2.0 */ public CompletionProposalPopup2(ContentAssistant2 contentAssistant, ITextViewer viewer, AdditionalInfoController2 infoController) { fContentAssistant= contentAssistant; fViewer= viewer; fAdditionalInfoController= infoController; } /** * Computes and presents completion proposals. The flag indicates whether this call has * be made out of an auto activation context. * * @param autoActivated <code>true</code> if auto activation context * @return an error message or <code>null</code> in case of no error */ public String showProposals(final boolean autoActivated) { if (fKeyListener == null) { fKeyListener= new KeyListener() { public void keyPressed(KeyEvent e) { if (!Helper2.okToUse(fProposalShell)) return; if (e.character == 0 && e.keyCode == SWT.MOD1) { // http://dev.eclipse.org/bugs/show_bug.cgi?id=34754 int index= fProposalTable.getSelectionIndex(); if (index >= 0) selectProposal(index, true); } } public void keyReleased(KeyEvent e) { if (!Helper2.okToUse(fProposalShell)) return; if (e.character == 0 && e.keyCode == SWT.MOD1) { // http://dev.eclipse.org/bugs/show_bug.cgi?id=34754 int index= fProposalTable.getSelectionIndex(); if (index >= 0) selectProposal(index, false); } } }; } final StyledText styledText= fViewer.getTextWidget(); if (styledText != null && !styledText.isDisposed()) styledText.addKeyListener(fKeyListener); BusyIndicator.showWhile(styledText.getDisplay(), new Runnable() { public void run() { fInvocationOffset= fViewer.getSelectedRange().x; // lazily compute proposals // if (fComputedProposals == null) fComputedProposals= computeProposals(fContentAssistant.getCompletionPosition()); fComputedProposals= computeProposals(fInvocationOffset); int count= (fComputedProposals == null ? 0 : fComputedProposals.length); if (count == 0) { if (!autoActivated) styledText.getDisplay().beep(); } else { if (count == 1 && !autoActivated && fContentAssistant.isAutoInserting()) insertProposal(fComputedProposals[0], (char) 0, 0, fInvocationOffset); else { if (fLineDelimiter == null) fLineDelimiter= styledText.getLineDelimiter(); createProposalSelector(); setProposals(fComputedProposals); resizeProposalSelector(true); displayProposals(); } } } }); return getErrorMessage(); } /** * Returns the completion proposal available at the given offset of the * viewer's document. Delegates the work to the content assistant. * * @param offset the offset * @return the completion proposals available at this offset */ private ICompletionProposal[] computeProposals(int offset) { return fContentAssistant.computeCompletionProposals(fViewer, offset); } /** * Returns the error message. * * @return the error message */ private String getErrorMessage() { return fContentAssistant.getErrorMessage(); } /** * Creates the proposal selector. */ private void createProposalSelector() { if (Helper2.okToUse(fProposalShell)) return; Control control= fViewer.getTextWidget(); fProposalShell= new Shell(control.getShell(), SWT.ON_TOP); // fProposalShell= new Shell(control.getShell(), SWT.ON_TOP | SWT.RESIZE ); fProposalTable= new Table(fProposalShell, SWT.H_SCROLL | SWT.V_SCROLL); // fProposalTable= new Table(fProposalShell, SWT.H_SCROLL | SWT.V_SCROLL); fProposalTable.setLocation(0, 0); if (fAdditionalInfoController != null) fAdditionalInfoController.setSizeConstraints(50, 10, true, false); GridLayout layout= new GridLayout(); layout.marginWidth= 0; layout.marginHeight= 0; fProposalShell.setLayout(layout); GridData data= new GridData(GridData.FILL_BOTH); fProposalTable.setLayoutData(data); fProposalShell.pack(); // set location Point currentLocation= fProposalShell.getLocation(); Point newLocation= getLocation(); if ((newLocation.x < currentLocation.x && newLocation.y == currentLocation.y) || newLocation.y < currentLocation.y) fProposalShell.setLocation(newLocation); if (fAdditionalInfoController != null) { fProposalShell.addControlListener(new ControlListener() { public void controlMoved(ControlEvent e) {} public void controlResized(ControlEvent e) { // resets the cached resize constraints fAdditionalInfoController.setSizeConstraints(50, 10, true, false); } }); } fProposalShell.setBackground(control.getDisplay().getSystemColor(SWT.COLOR_BLACK)); Color c= fContentAssistant.getProposalSelectorBackground(); if (c == null) c= control.getDisplay().getSystemColor(SWT.COLOR_INFO_BACKGROUND); fProposalTable.setBackground(c); c= fContentAssistant.getProposalSelectorForeground(); if (c == null) c= control.getDisplay().getSystemColor(SWT.COLOR_INFO_FOREGROUND); fProposalTable.setForeground(c); fProposalTable.addSelectionListener(new SelectionListener() { public void widgetSelected(SelectionEvent e) {} public void widgetDefaultSelected(SelectionEvent e) { selectProposalWithMask(e.stateMask); } }); fPopupCloser.install(fContentAssistant, fProposalTable); fProposalTable.setHeaderVisible(false); fContentAssistant.addToLayout(this, fProposalShell, ContentAssistant2.LayoutManager.LAYOUT_PROPOSAL_SELECTOR, fContentAssistant.getSelectionOffset()); } /** * Returns the proposal selected in the proposal selector. * * @return the selected proposal * @since 2.0 */ private ICompletionProposal getSelectedProposal() { int i= fProposalTable.getSelectionIndex(); if (i < 0 || i >= fFilteredProposals.length) return null; return fFilteredProposals[i]; } /** * Takes the selected proposal and applies it. * * @param stateMask the state mask * @since 2.1 */ private void selectProposalWithMask(int stateMask) { ICompletionProposal p= getSelectedProposal(); hide(); if (p != null) insertProposal(p, (char) 0, stateMask, fViewer.getSelectedRange().x); } /** * Applies the given proposal at the given offset. The given character is the * one that triggered the insertion of this proposal. * * @param p the completion proposal * @param trigger the trigger character * @param offset the offset * @since 2.1 */ private void insertProposal(ICompletionProposal p, char trigger, int stateMask, int offset) { fInserting= true; IRewriteTarget target= null; try { IDocument document= fViewer.getDocument(); if (fViewer instanceof ITextViewerExtension) { ITextViewerExtension extension= (ITextViewerExtension) fViewer; target= extension.getRewriteTarget(); } if (target != null) target.beginCompoundChange(); if (p instanceof ICompletionProposalExtension2) { ICompletionProposalExtension2 e= (ICompletionProposalExtension2) p; e.apply(fViewer, trigger, stateMask, offset); } else if (p instanceof ICompletionProposalExtension) { ICompletionProposalExtension e= (ICompletionProposalExtension) p; e.apply(document, trigger, offset); } else { p.apply(document); } Point selection= p.getSelection(document); if (selection != null) { fViewer.setSelectedRange(selection.x, selection.y); fViewer.revealRange(selection.x, selection.y); } IContextInformation info= p.getContextInformation(); if (info != null) { int position; if (p instanceof ICompletionProposalExtension) { ICompletionProposalExtension e= (ICompletionProposalExtension) p; position= e.getContextInformationPosition(); } else { if (selection == null) selection= fViewer.getSelectedRange(); position= selection.x + selection.y; } fContentAssistant.showContextInformation(info, position); } fContentAssistant.setProposalChosen(true); } finally { if (target != null) target.endCompoundChange(); fInserting= false; } } /** * Returns whether this popup has the focus. * * @return <code>true</code> if the popup has the focus */ public boolean hasFocus() { if (Helper2.okToUse(fProposalShell)) return (fProposalShell.isFocusControl() || fProposalTable.isFocusControl()); return false; } /** * Hides this popup. */ public void hide() { if (fDocumentListener != null) { IDocument document= fViewer.getDocument(); if (document != null) document.removeDocumentListener(fDocumentListener); fDocumentListener= null; } fDocumentEvents.clear(); StyledText styledText= fViewer.getTextWidget(); if (fKeyListener != null && styledText != null && !styledText.isDisposed()) styledText.removeKeyListener(fKeyListener); if (Helper2.okToUse(fProposalTable)) { ICompletionProposal proposal= getSelectedProposal(); if (proposal instanceof ICompletionProposalExtension2) { ICompletionProposalExtension2 extension= (ICompletionProposalExtension2) proposal; extension.unselected(fViewer); } } if (Helper2.okToUse(fProposalShell)) { fContentAssistant.removeContentAssistListener(this, ContentAssistant2.PROPOSAL_SELECTOR); fPopupCloser.uninstall(); fProposalShell.setVisible(false); fProposalShell.dispose(); fProposalShell= null; } if (fAdditionalInfoController != null) { fAdditionalInfoController.dispose(); } fFilteredProposals= null; fContentAssistant.possibleCompletionsClosed(); } /** *Returns whether this popup is active. It is active if the propsal selector is visible. * * @return <code>true</code> if this popup is active */ public boolean isActive() { return fProposalShell != null && !fProposalShell.isDisposed(); } /** * Initializes the proposal selector with these given proposals. * * @param proposals the proposals */ private void setProposals(ICompletionProposal[] proposals) { if (Helper2.okToUse(fProposalTable)) { ICompletionProposal oldProposal= getSelectedProposal(); if (oldProposal instanceof ICompletionProposalExtension2) ((ICompletionProposalExtension2) oldProposal).unselected(fViewer); fFilteredProposals= proposals; fProposalTable.setRedraw(false); fProposalTable.removeAll(); Point selection= fViewer.getSelectedRange(); int endOffset; endOffset= selection.x + selection.y; IDocument document= fViewer.getDocument(); boolean validate= false; if (selection.y != 0 && document != null) validate= true; int selectionIndex= 0; TableItem item; ICompletionProposal p; for (int i= 0; i < proposals.length; i++) { p= proposals[i]; item= new TableItem(fProposalTable, SWT.NULL); if (p.getImage() != null) item.setImage(p.getImage()); item.setText(p.getDisplayString()); item.setData(p); if (validate && validateProposal(document, p, endOffset, null)) { selectionIndex= i; validate= false; } } resizeProposalSelector(false); selectProposal(selectionIndex, false); fProposalTable.setRedraw(true); } } private void resizeProposalSelector(boolean adjustWidth) { // in order to fill in the table items so size computation works correctly // will cause flicker, though fProposalTable.setRedraw(true); int width= adjustWidth ? SWT.DEFAULT : ((GridData)fProposalTable.getLayoutData()).widthHint; Point size= fProposalTable.computeSize(width, SWT.DEFAULT, true); GridData data= new GridData(GridData.FILL_BOTH); data.widthHint= adjustWidth ? Math.min(size.x, 300) : width; data.heightHint= Math.min(getTableHeightHint(fProposalTable, fProposalTable.getItemCount() - 1), getTableHeightHint(fProposalTable, 9)); fProposalTable.setLayoutData(data); fProposalShell.layout(true); fProposalShell.pack(); } /** * Computes the table hight hint for <code>table</code>. * * @param table the table to compute the height for * @param rows the number of rows to compute the height for * @return the height hint for <code>table</code> */ private int getTableHeightHint(Table table, int rows) { if (table.getFont().equals(JFaceResources.getDefaultFont())) table.setFont(JFaceResources.getDialogFont()); int result= table.getItemHeight() * rows; if (table.getLinesVisible()) result+= table.getGridLineWidth() * (rows - 1); // TODO adjustment might just work on windows return result + 4; } private boolean validateProposal(IDocument document, ICompletionProposal p, int offset, DocumentEvent event) { // detect selected if (p instanceof ICompletionProposalExtension2) { ICompletionProposalExtension2 e= (ICompletionProposalExtension2) p; if (e.validate(document, offset, event)) return true; } else if (p instanceof ICompletionProposalExtension) { ICompletionProposalExtension e= (ICompletionProposalExtension) p; if (e.isValidFor(document, offset)) return true; } return false; } /** * Returns the graphical location at which this popup should be made visible. * * @return the location of this popup */ private Point getLocation() { StyledText text= fViewer.getTextWidget(); Point selection= text.getSelection(); Point p= text.getLocationAtOffset(selection.x); // TODO subtract border width! p.x -= fProposalShell.getBorderWidth(); if (p.x < 0) p.x= 0; if (p.y < 0) p.y= 0; p= new Point(p.x, p.y + text.getLineHeight()); p= text.toDisplay(p); if (p.x < 0) p.x= 0; if (p.y < 0) p.y= 0; return p; } /** *Displays this popup and install the additional info controller, so that additional info * is displayed when a proposal is selected and additional info is available. */ private void displayProposals() { if (fContentAssistant.addContentAssistListener(this, ContentAssistant2.PROPOSAL_SELECTOR)) { if (fDocumentListener == null) fDocumentListener= new IDocumentListener() { public void documentAboutToBeChanged(DocumentEvent event) { if (!fInserting) fDocumentEvents.add(event); } public void documentChanged(DocumentEvent event) { if (!fInserting) filterProposals(); } }; IDocument document= fViewer.getDocument(); if (document != null) document.addDocumentListener(fDocumentListener); fProposalShell.setVisible(true); if (fAdditionalInfoController != null) { fAdditionalInfoController.install(fProposalTable); fAdditionalInfoController.handleTableSelectionChanged(); } } } /* * @see IContentAssistListener#verifyKey(VerifyEvent) */ public boolean verifyKey(VerifyEvent e) { if (!Helper2.okToUse(fProposalShell)) return true; char key= e.character; if (key == 0) { int newSelection= fProposalTable.getSelectionIndex(); int visibleRows= (fProposalTable.getSize().y / fProposalTable.getItemHeight()) - 1; boolean smartToggle= false; switch (e.keyCode) { case SWT.ARROW_LEFT : case SWT.ARROW_RIGHT : filterProposals(); return true; case SWT.ARROW_UP : newSelection -= 1; if (newSelection < 0) newSelection= fProposalTable.getItemCount() - 1; break; case SWT.ARROW_DOWN : newSelection += 1; if (newSelection > fProposalTable.getItemCount() - 1) newSelection= 0; break; case SWT.PAGE_DOWN : newSelection += visibleRows; if (newSelection >= fProposalTable.getItemCount()) newSelection= fProposalTable.getItemCount() - 1; break; case SWT.PAGE_UP : newSelection -= visibleRows; if (newSelection < 0) newSelection= 0; break; case SWT.HOME : newSelection= 0; break; case SWT.END : newSelection= fProposalTable.getItemCount() - 1; break; default : if (e.keyCode != SWT.MOD1 && e.keyCode != SWT.MOD2 && e.keyCode != SWT.MOD3 && e.keyCode != SWT.MOD4) hide(); return true; } selectProposal(newSelection, smartToggle); e.doit= false; return false; } else { switch (key) { case 0x1B: // Esc e.doit= false; hide(); break; case '\n': // Ctrl-Enter on w2k case '\r': // Enter // e.doit= false; selectProposalWithMask(e.stateMask); break; // in linked mode: hide popup // plus: don't invalidate the event in order to give LinkedUI a chance to handle it case '\t': hide(); break; default: ICompletionProposal p= getSelectedProposal(); if (p instanceof ICompletionProposalExtension) { ICompletionProposalExtension t= (ICompletionProposalExtension) p; char[] triggers= t.getTriggerCharacters(); if (contains(triggers, key)) { hide(); if (key == ';') { e.doit= true; insertProposal(p, (char) 0, e.stateMask, fViewer.getSelectedRange().x); } else { e.doit= false; insertProposal(p, key, e.stateMask, fViewer.getSelectedRange().x); } } } } } return true; } /** * Selects the entry with the given index in the proposal selector and feeds * the selection to the additional info controller. * * @param index the index in the list * @param smartToggle <code>true</code> if the smart toogle key has been pressed * @since 2.1 */ private void selectProposal(int index, boolean smartToggle) { ICompletionProposal oldProposal= getSelectedProposal(); if (oldProposal instanceof ICompletionProposalExtension2) ((ICompletionProposalExtension2) oldProposal).unselected(fViewer); ICompletionProposal proposal= fFilteredProposals[index]; if (proposal instanceof ICompletionProposalExtension2) ((ICompletionProposalExtension2) proposal).selected(fViewer, smartToggle); fProposalTable.setSelection(index); fProposalTable.showSelection(); if (fAdditionalInfoController != null) fAdditionalInfoController.handleTableSelectionChanged(); } /** * Returns whether the given character is contained in the given array of * characters. * * @param characters the list of characters * @param c the character to look for in the list * @return <code>true</code> if character belongs to the list * @since 2.0 */ private boolean contains(char[] characters, char c) { if (characters == null) return false; for (int i= 0; i < characters.length; i++) { if (c == characters[i]) return true; } return false; } /* * @see IEventConsumer#processEvent(VerifyEvent) */ public void processEvent(VerifyEvent e) { } /** * Filters the displayed proposal based on the given cursor position and the * offset of the original invocation of the content assistant. */ private void filterProposals() { ++ fInvocationCounter; Control control= fViewer.getTextWidget(); control.getDisplay().asyncExec(new Runnable() { long fCounter= fInvocationCounter; public void run() { if (fCounter != fInvocationCounter) return; int offset= fViewer.getSelectedRange().x; ICompletionProposal[] proposals= null; try { if (offset > -1) { DocumentEvent event= TextUtilities.mergeProcessedDocumentEvents(fDocumentEvents); proposals= computeFilteredProposals(offset, event); } } catch (BadLocationException x) { } finally { fDocumentEvents.clear(); } fFilterOffset= offset; if (proposals != null && proposals.length > 0) setProposals(proposals); else hide(); } }); } /** * Computes the subset of already computed propsals that are still valid for * the given offset. * * @param offset the offset * @param event the merged document event * @return the set of filtered proposals * @since 2.0 */ private ICompletionProposal[] computeFilteredProposals(int offset, DocumentEvent event) { if (offset == fInvocationOffset && event == null) return fComputedProposals; if (offset < fInvocationOffset) { return null; } ICompletionProposal[] proposals= fComputedProposals; if (offset > fFilterOffset) proposals= fFilteredProposals; if (proposals == null) return null; IDocument document= fViewer.getDocument(); int length= proposals.length; List filtered= new ArrayList(length); for (int i= 0; i < length; i++) { if (proposals[i] instanceof ICompletionProposalExtension2) { ICompletionProposalExtension2 p= (ICompletionProposalExtension2) proposals[i]; if (p.validate(document, offset, event)) filtered.add(p); } else if (proposals[i] instanceof ICompletionProposalExtension) { ICompletionProposalExtension p= (ICompletionProposalExtension) proposals[i]; if (p.isValidFor(document, offset)) filtered.add(p); } else { // restore original behavior fInvocationOffset= offset; fComputedProposals= computeProposals(fInvocationOffset); return fComputedProposals; } } ICompletionProposal[] p= new ICompletionProposal[filtered.size()]; filtered.toArray(p); return p; } /** * Requests the proposal shell to take focus. * * @since 3.0 */ public void setFocus() { if (Helper2.okToUse(fProposalShell)) fProposalShell.setFocus(); } }
42,587
Bug 42587 Left over from content assist
M3 - set preference that content assist should overwrite - open content assist on some word so that the rest of the word is indicated to be overwritten - transfer focus to the content assist widget using TAB - Esc -> overwrite indication is still there
resolved fixed
a226d37
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2003-09-15T15:11:04Z
2003-09-05T11:06:40Z
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/link/contentassist/PopupCloser2.java
/******************************************************************************* * Copyright (c) 2000, 2003 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Common Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/cpl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.jdt.internal.ui.text.link.contentassist; import org.eclipse.swt.events.FocusEvent; import org.eclipse.swt.events.FocusListener; import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.events.SelectionListener; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.ScrollBar; import org.eclipse.swt.widgets.Table; /** * A generic closer class used to monitor various * interface events in order to determine whether * a content assistant should be terminated and all * associated windows be closed. */ class PopupCloser2 implements FocusListener, SelectionListener { /** The content assistant to be monitored */ private ContentAssistant2 fContentAssistant; /** The table of a selector popup opened by the content assistant */ private Table fTable; /** The scrollbar of the table for the selector popup */ private ScrollBar fScrollbar; /** Indicates whether the scrollbar thumb has been grabed */ private boolean fScrollbarClicked= false; /** * Installs this closer on the given table opened by the given content assistant. * * @param contentAssistant the content assistant * @param table the table to be tracked */ public void install(ContentAssistant2 contentAssistant, Table table) { fContentAssistant= contentAssistant; fTable= table; if (Helper2.okToUse(fTable)) { fTable.addFocusListener(this); fScrollbar= fTable.getVerticalBar(); if (fScrollbar != null) fScrollbar.addSelectionListener(this); } } /** * Uninstalls this closer if previously installed. */ public void uninstall() { if (Helper2.okToUse(fTable)) { fTable.removeFocusListener(this); if (fScrollbar != null) fScrollbar.removeSelectionListener(this); } } /* * @see org.eclipse.swt.events.SelectionListener#widgetSelected(org.eclipse.swt.events.SelectionEvent) */ public void widgetSelected(SelectionEvent e) { fScrollbarClicked= true; } /* * @see org.eclipse.swt.events.SelectionListener#widgetDefaultSelected(org.eclipse.swt.events.SelectionEvent) */ public void widgetDefaultSelected(SelectionEvent e) { fScrollbarClicked= true; } /* * @see org.eclipse.swt.events.FocusListener#focusGained(org.eclipse.swt.events.FocusEvent) */ public void focusGained(FocusEvent e) { } /* * @see org.eclipse.swt.events.FocusListener#focusLost(org.eclipse.swt.events.FocusEvent) */ public void focusLost(final FocusEvent e) { fScrollbarClicked= false; Display d= fTable.getDisplay(); d.asyncExec(new Runnable() { public void run() { if (Helper2.okToUse(fTable) && !fTable.isFocusControl() && !fScrollbarClicked) fContentAssistant.popupFocusLost(e); } }); } }
43,103
Bug 43103 RenameType Refactoring - detected information not shown
null
resolved fixed
69d1f0e
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2003-09-16T08:21:40Z
2003-09-15T15:33:20Z
org.eclipse.jdt.ui/core
43,103
Bug 43103 RenameType Refactoring - detected information not shown
null
resolved fixed
69d1f0e
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2003-09-16T08:21:40Z
2003-09-15T15:33:20Z
refactoring/org/eclipse/jdt/internal/corext/refactoring/rename/RenameTypeProcessor.java
41,000
Bug 41000 Override/Implement Methods dialog does not (properly) resize [code manipulation]
The Override/Implement Methods dialog contents are not re-layouted properly when the windows is resized, i.e. the list on top is not scaled at all on windows and unproportionally (regarding the bottom part of the dialog) on linux.
resolved fixed
f600b77
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2003-09-16T13:13:41Z
2003-07-31T14:00:00Z
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/dialogs/SourceActionDialog.java
/******************************************************************************* * Copyright (c) 2000, 2003 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Common Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/cpl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.jdt.internal.ui.dialogs; import java.util.ArrayList; import java.util.List; 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.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.jface.dialogs.IDialogConstants; import org.eclipse.jface.dialogs.IDialogSettings; import org.eclipse.jface.text.TextSelection; import org.eclipse.jface.viewers.CheckboxTreeViewer; import org.eclipse.jface.viewers.ILabelProvider; import org.eclipse.jface.viewers.ITreeContentProvider; import org.eclipse.ui.dialogs.CheckedTreeSelectionDialog; import org.eclipse.jdt.core.IField; import org.eclipse.jdt.core.IJavaElement; import org.eclipse.jdt.core.IMethod; import org.eclipse.jdt.core.IType; import org.eclipse.jdt.core.JavaModelException; import org.eclipse.jdt.core.dom.Modifier; import org.eclipse.jdt.internal.corext.codemanipulation.CodeGenerationSettings; import org.eclipse.jdt.internal.ui.JavaPlugin; import org.eclipse.jdt.internal.ui.actions.ActionMessages; import org.eclipse.jdt.internal.ui.javaeditor.CompilationUnitEditor; import org.eclipse.jdt.internal.ui.preferences.JavaPreferencesSettings; import org.eclipse.jdt.internal.ui.refactoring.IVisibilityChangeListener; import org.eclipse.jdt.internal.ui.refactoring.RefactoringMessages; import org.eclipse.jdt.internal.ui.viewsupport.JavaElementLabels; /** * An advanced version of CheckedTreeSelectionDialog with right-side button layout and * extra buttons and composites. */ public class SourceActionDialog extends CheckedTreeSelectionDialog { private int fInsertPosition; private IDialogSettings fSettings; private CompilationUnitEditor fEditor; private ITreeContentProvider fContentProvider; private boolean fGenerateComment; private IType fType; private int fWidth = 60; private int fHeight = 18; private String fCommentString; private int fVisibilityModifier; private boolean fFinal; private boolean fSynchronized; private final String SETTINGS_SECTION= "SourceActionDialog"; //$NON-NLS-1$ public final String SETTINGS_INSERTPOSITION= "InsertPosition"; //$NON-NLS-1$ private final String VISIBILITY_MODIFIER= "VisibilityModifier"; //$NON-NLS-1$ private final String FINAL_MODIFIER= "FinalModifier"; //$NON-NLS-1$ private final String SYNCHRONIZED_MODIFIER= "SynchronizedModifier"; //$NON-NLS-1$ public SourceActionDialog(Shell parent, ILabelProvider labelProvider, ITreeContentProvider contentProvider, CompilationUnitEditor editor, IType type) { super(parent, labelProvider, contentProvider); fEditor= editor; fContentProvider= contentProvider; fType= type; fCommentString= ActionMessages.getString("SourceActionDialog.createMethodComment"); //$NON-NLS-1$ // Take the default from the default for generating comments from the code gen prefs CodeGenerationSettings settings= JavaPreferencesSettings.getCodeGenerationSettings(); fGenerateComment= settings.createComments; IDialogSettings dialogSettings= JavaPlugin.getDefault().getDialogSettings(); fSettings= dialogSettings.getSection(SETTINGS_SECTION); if (fSettings == null) { fSettings= dialogSettings.addNewSection(SETTINGS_SECTION); fSettings.put(VISIBILITY_MODIFIER, Modifier.PUBLIC); //$NON-NLS-1$ fSettings.put(FINAL_MODIFIER, false); //$NON-NLS-1$ fSettings.put(SYNCHRONIZED_MODIFIER, false); //$NON-NLS-1$ fSettings.put(SETTINGS_INSERTPOSITION, 1); //$NON-NLS-1$ } try { fVisibilityModifier= fSettings.getInt(VISIBILITY_MODIFIER); fFinal= fSettings.getBoolean(FINAL_MODIFIER); fSynchronized= fSettings.getBoolean(SYNCHRONIZED_MODIFIER); fInsertPosition= fSettings.getInt(SETTINGS_INSERTPOSITION); } catch (NumberFormatException e) { fSettings= dialogSettings.addNewSection(SETTINGS_SECTION); fSettings.put(VISIBILITY_MODIFIER, Modifier.PUBLIC); //$NON-NLS-1$ fSettings.put(FINAL_MODIFIER, false); //$NON-NLS-1$ fSettings.put(SYNCHRONIZED_MODIFIER, false); //$NON-NLS-1$ fSettings.put(SETTINGS_INSERTPOSITION, 1); //$NON-NLS-1$ } } /*** * Returns 0 for the first method, 1 for the last method, > 1 for all else. */ public int getInsertPosition() { return fInsertPosition; } /*** * Set insert position valid input is 0 for the first position, 1 for the last position, > 1 for all else. */ public void setInsertPosition(int insert) { if (fInsertPosition != insert) { fInsertPosition= insert; fSettings.put(SETTINGS_INSERTPOSITION, insert); } } public void setCommentString(String string) { fCommentString= string; } protected ITreeContentProvider getContentProvider() { return fContentProvider; } public boolean getGenerateComment() { return fGenerateComment; } public int getVisibilityModifier() { return fVisibilityModifier; } private void setGenerateComment(boolean comment) { fGenerateComment= comment; } /** * Sets the size of the tree in unit of characters. * @param width the width of the tree. * @param height the height of the tree. */ public void setSize(int width, int height) { fWidth = width; fHeight = height; } public void setVisibility(int visibility) { if (fVisibilityModifier != visibility) { fVisibilityModifier= visibility; fSettings.put(VISIBILITY_MODIFIER, visibility); } } public void setFinal(boolean value) { if (fFinal != value) { fFinal= value; fSettings.put(FINAL_MODIFIER, value); } } public void setSynchronized(boolean value) { if (fSynchronized != value) { fSynchronized= value; fSettings.put(SYNCHRONIZED_MODIFIER, value); } } protected Composite createSelectionButtons(Composite composite) { Composite buttonComposite= super.createSelectionButtons(composite); GridLayout layout = new GridLayout(); buttonComposite.setLayout(layout); layout.marginHeight= 0; layout.marginWidth= 0; layout.numColumns= 1; return buttonComposite; } protected void buttonPressed(int buttonId) { switch (buttonId) { case IDialogConstants.OK_ID: { okPressed(); break; } case IDialogConstants.CANCEL_ID: { cancelPressed(); break; } } } /** * Returns a composite containing the label created at the top of the dialog. Returns null if there is the * message for the label is null. */ protected Label createMessageArea(Composite composite) { if (getMessage() != null) { Label label = new Label(composite,SWT.NONE); label.setText(getMessage()); label.setFont(composite.getFont()); return label; } return null; } /* * @see Dialog#createDialogArea(Composite) */ protected Control createDialogArea(Composite parent) { initializeDialogUnits(parent); Composite composite= new Composite(parent, SWT.NONE); GridLayout layout= new GridLayout(); GridData gd= null; layout.marginHeight= convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN); layout.marginWidth= convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN); layout.verticalSpacing= convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING); layout.horizontalSpacing= convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING); composite.setLayout(layout); Label messageLabel = createMessageArea(composite); if (messageLabel != null) { gd= new GridData(GridData.HORIZONTAL_ALIGN_FILL); gd.horizontalSpan= 2; messageLabel.setLayoutData(gd); } Composite inner= new Composite(composite, SWT.NONE); GridLayout innerLayout = new GridLayout(); innerLayout.numColumns= 2; innerLayout.marginHeight= 0; innerLayout.marginWidth= 0; inner.setLayout(innerLayout); inner.setFont(parent.getFont()); CheckboxTreeViewer treeViewer= createTreeViewer(inner); gd= new GridData(GridData.FILL_BOTH); gd.widthHint = convertWidthInCharsToPixels(fWidth); gd.heightHint = convertHeightInCharsToPixels(fHeight); treeViewer.getControl().setLayoutData(gd); Composite buttonComposite= createSelectionButtons(inner); gd= new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_FILL); buttonComposite.setLayoutData(gd); gd= new GridData(GridData.FILL_BOTH); inner.setLayoutData(gd); Composite entryComposite= createEntryPtCombo(composite); entryComposite.setLayoutData(new GridData(GridData.FILL_BOTH)); Composite commentComposite= createCommentSelection(composite); commentComposite.setLayoutData(new GridData(GridData.FILL_BOTH)); gd= new GridData(GridData.FILL_BOTH); composite.setLayoutData(gd); applyDialogFont(composite); return composite; } protected Composite createCommentSelection(Composite composite) { Composite commentComposite = new Composite(composite, SWT.NONE); GridLayout layout = new GridLayout(); layout.marginHeight= 0; layout.marginWidth= 0; commentComposite.setLayout(layout); commentComposite.setFont(composite.getFont()); Button commentButton= new Button(commentComposite, SWT.CHECK); commentButton.setText(fCommentString); //$NON-NLS-1$ commentButton.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL)); commentButton.addSelectionListener(new SelectionListener() { public void widgetSelected(SelectionEvent e) { boolean isSelected= (((Button) e.widget).getSelection()); setGenerateComment(isSelected); } public void widgetDefaultSelected(SelectionEvent e) { widgetSelected(e); } }); commentButton.setSelection(getGenerateComment()); GridData gd= new GridData(GridData.HORIZONTAL_ALIGN_FILL); gd.horizontalSpan= 2; commentButton.setLayoutData(gd); return commentComposite; } protected Composite addVisibilityAndModifiersChoices(Composite buttonComposite) { // Add visibility and modifiers buttons: http://bugs.eclipse.org/bugs/show_bug.cgi?id=35870 // Add persistence of options: http://bugs.eclipse.org/bugs/show_bug.cgi?id=38400 IVisibilityChangeListener visibilityChangeListener= new IVisibilityChangeListener(){ public void visibilityChanged(int newVisibility) { setVisibility(newVisibility); } public void modifierChanged(int modifier, boolean isChecked) { switch (modifier) { case Modifier.FINAL: { setFinal(isChecked); return; } case Modifier.SYNCHRONIZED: { setSynchronized(isChecked); return; } default: return; } } }; int initialVisibility= getVisibilityModifier(); int[] availableVisibilities= new int[]{Modifier.PUBLIC, Modifier.PROTECTED, Modifier.PRIVATE, Modifier.NONE}; Composite visibilityComposite= createVisibilityControlAndModifiers(buttonComposite, visibilityChangeListener, availableVisibilities, initialVisibility); return visibilityComposite; } private List convertToIntegerList(int[] array) { List result= new ArrayList(array.length); for (int i= 0; i < array.length; i++) { result.add(new Integer(array[i])); } return result; } protected Composite createVisibilityControl(Composite parent, final IVisibilityChangeListener visibilityChangeListener, int[] availableVisibilities, int correctVisibility) { List allowedVisibilities= convertToIntegerList(availableVisibilities); if (allowedVisibilities.size() == 1) return null; Group group= new Group(parent, SWT.NONE); group.setText(RefactoringMessages.getString("VisibilityControlUtil.Access_modifier")); //$NON-NLS-1$ GridData gd= new GridData(GridData.FILL_BOTH); group.setLayoutData(gd); GridLayout layout= new GridLayout(); layout.makeColumnsEqualWidth= true; layout.numColumns= 4; group.setLayout(layout); String[] labels= new String[] { "&public", //$NON-NLS-1$ "pro&tected", //$NON-NLS-1$ RefactoringMessages.getString("VisibilityControlUtil.defa&ult_4"), //$NON-NLS-1$ "pri&vate" //$NON-NLS-1$ }; Integer[] data= new Integer[] { new Integer(Modifier.PUBLIC), new Integer(Modifier.PROTECTED), new Integer(Modifier.NONE), new Integer(Modifier.PRIVATE)}; Integer initialVisibility= new Integer(correctVisibility); for (int i= 0; i < labels.length; i++) { Button radio= new Button(group, SWT.RADIO); Integer visibilityCode= data[i]; radio.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL)); radio.setText(labels[i]); radio.setData(visibilityCode); radio.setSelection(visibilityCode.equals(initialVisibility)); radio.setEnabled(allowedVisibilities.contains(visibilityCode)); radio.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent event) { visibilityChangeListener.visibilityChanged(((Integer)event.widget.getData()).intValue()); } }); } return group; } protected Composite createVisibilityControlAndModifiers(Composite parent, final IVisibilityChangeListener visibilityChangeListener, int[] availableVisibilities, int correctVisibility) { Composite visibilityComposite= createVisibilityControl(parent, visibilityChangeListener, availableVisibilities, correctVisibility); Button finalCheckboxButton= new Button(visibilityComposite, SWT.CHECK); finalCheckboxButton.setText(RefactoringMessages.getString("VisibilityControlUtil.final")); //$NON-NLS-1$ GridData gd= new GridData(GridData.HORIZONTAL_ALIGN_FILL); finalCheckboxButton.setLayoutData(gd); finalCheckboxButton.setData(new Integer(Modifier.FINAL)); finalCheckboxButton.setEnabled(true); finalCheckboxButton.setSelection(isFinal()); finalCheckboxButton.addSelectionListener(new SelectionListener() { public void widgetSelected(SelectionEvent event) { visibilityChangeListener.modifierChanged(((Integer)event.widget.getData()).intValue(), ((Button) event.widget).getSelection()); } public void widgetDefaultSelected(SelectionEvent event) { widgetSelected(event); } }); Button syncCheckboxButton= new Button(visibilityComposite, SWT.CHECK); syncCheckboxButton.setText(RefactoringMessages.getString("VisibilityControlUtil.synchronized")); //$NON-NLS-1$ gd= new GridData(GridData.HORIZONTAL_ALIGN_FILL); syncCheckboxButton.setLayoutData(gd); syncCheckboxButton.setData(new Integer(Modifier.SYNCHRONIZED)); syncCheckboxButton.setEnabled(true); syncCheckboxButton.setSelection(isSynchronized()); syncCheckboxButton.addSelectionListener(new SelectionListener() { public void widgetSelected(SelectionEvent event) { visibilityChangeListener.modifierChanged(((Integer)event.widget.getData()).intValue(), ((Button) event.widget).getSelection()); } public void widgetDefaultSelected(SelectionEvent event) { widgetSelected(event); } }); return visibilityComposite; } protected Composite createEntryPtCombo(Composite composite) { Composite selectionComposite = new Composite(composite, SWT.NONE); GridLayout layout = new GridLayout(); layout.marginHeight= 0; layout.marginWidth= 0; selectionComposite.setLayout(layout); addOrderEntryChoices(selectionComposite); return selectionComposite; } private Composite addOrderEntryChoices(Composite buttonComposite) { Label enterLabel= new Label(buttonComposite, SWT.NONE); enterLabel.setText(ActionMessages.getString("SourceActionDialog.enterAt_label")); //$NON-NLS-1$ GridData gd= new GridData(GridData.HORIZONTAL_ALIGN_FILL); enterLabel.setLayoutData(gd); final Combo enterCombo= new Combo(buttonComposite, SWT.READ_ONLY); fillWithPossibleInsertPositions(enterCombo); gd= new GridData(GridData.FILL_BOTH); enterCombo.setLayoutData(gd); enterCombo.addSelectionListener(new SelectionAdapter(){ public void widgetSelected(SelectionEvent e) { int index= enterCombo.getSelectionIndex(); // Add persistence only if first or last method: http://bugs.eclipse.org/bugs/show_bug.cgi?id=38400 setInsertPosition(index); } }); return buttonComposite; } private void fillWithPossibleInsertPositions(Combo combo) { try { int position= 0; int presetOffset= 0; if (fEditor != null) { presetOffset= ((TextSelection) fEditor.getSelectionProvider().getSelection()).getOffset(); } else { List preselected= getInitialElementSelections(); int size= preselected.size(); if ((size > 1) || (size == 0)) presetOffset= 0; else { IJavaElement element= (IJavaElement) preselected.get(0); int type= element.getElementType(); if (type == IJavaElement.FIELD) presetOffset= ((IField)element).getSourceRange().getOffset(); else if (type == IJavaElement.METHOD) presetOffset= ((IMethod)element).getSourceRange().getOffset(); } } IMethod[] methods= fType.getMethods(); combo.add(ActionMessages.getString("SourceActionDialog.first_method")); //$NON-NLS-1$ combo.add(ActionMessages.getString("SourceActionDialog.last_method")); //$NON-NLS-1$ int bestDiff= Integer.MAX_VALUE; for (int i= 0; i < methods.length; i++) { int currDiff= 0; IMethod curr= methods[i]; combo.add(JavaElementLabels.getElementLabel(methods[i], JavaElementLabels.M_PARAMETER_TYPES)); // calculate method to pre-select currDiff= presetOffset - curr.getSourceRange().getOffset(); if (currDiff >= 0) if(currDiff < bestDiff) { bestDiff= currDiff; position= i + 2; // first two entries are first/last } else break; } // Add persistence only if first or last method: http://bugs.eclipse.org/bugs/show_bug.cgi?id=38400 int index= getInsertPosition(); if (index > 1) combo.select(position); else combo.select(index); setInsertPosition(combo.getSelectionIndex()); } catch (JavaModelException e) { } } public boolean getFinal() { return fFinal; } public boolean getSynchronized() { return fSynchronized; } public boolean isFinal() { return fFinal; } public boolean isSynchronized() { return fSynchronized; } /* * Determine where in the file to enter the newly created methods. */ public IJavaElement getElementPosition() { int comboBoxIndex= getInsertPosition(); try { if (comboBoxIndex == 0) // as first method return asFirstMethod(fType); else if (comboBoxIndex == 1) // as last method return null; else // method position return atElementPosition(fType, comboBoxIndex); } catch (JavaModelException e) { return null; } } private IMethod asFirstMethod(IType type) throws JavaModelException { if (type != null) { IMethod[] methods= type.getMethods(); if (methods.length > 0) { return methods[0]; } } return null; } /* Returns the element directly following the method to insert after. Index should never * always be > 2 since 0 means first method, and 1 means last method. */ private IJavaElement atElementPosition(IType type, int index) throws JavaModelException { if (type != null) { IMethod[] methods= type.getMethods(); IJavaElement[] elements= type.getChildren(); for (int i= 0; i < (elements.length-1); i++) { if (methods[index-2] == elements[i]) // first two entries are first/last return elements[i+1]; } } return null; } }
21,586
Bug 21586 Javadoc-Help: Illegal access error
null
resolved fixed
26b746a
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2003-09-17T08:19:22Z
2002-07-15T16:20:00Z
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/actions/OpenBrowserUtil.java
/******************************************************************************* * Copyright (c) 2000, 2003 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Common Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/cpl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.jdt.internal.ui.actions; import java.net.URL; import org.eclipse.swt.custom.BusyIndicator; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Shell; import org.eclipse.jface.dialogs.MessageDialog; import org.eclipse.ui.help.WorkbenchHelp; import org.eclipse.jdt.internal.ui.JavaPlugin; import org.eclipse.help.IHelp; public class OpenBrowserUtil { public static void open(final URL url, Shell shell, String dialogTitle) { if (shell == null) { shell= JavaPlugin.getActiveWorkbenchShell(); if (shell == null) { return; } } IHelp help= WorkbenchHelp.getHelpSupport(); if (help != null) { BusyIndicator.showWhile(shell.getDisplay(), new Runnable() { public void run() { WorkbenchHelp.getHelpSupport().displayHelpResource(url.toExternalForm()); } }); } else { showMessage(shell, dialogTitle, ActionMessages.getString("OpenBrowserUtil.help_not_available"), false); //$NON-NLS-1$ } } private static void showMessage(final Shell shell, final String title, final String message, final boolean isError) { Display.getDefault().asyncExec(new Runnable() { public void run() { if (isError) { MessageDialog.openError(shell, title, message); } else { MessageDialog.openInformation(shell, title, message); } } }); } }
21,586
Bug 21586 Javadoc-Help: Illegal access error
null
resolved fixed
26b746a
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2003-09-17T08:19:22Z
2002-07-15T16:20:00Z
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/util/JavadocHelpContext.java
/******************************************************************************* * Copyright (c) 2000, 2003 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Common Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/cpl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.jdt.internal.ui.util; import java.io.File; import java.io.IOException; import java.net.URL; import java.text.BreakIterator; import java.util.ArrayList; import java.util.List; import org.eclipse.core.runtime.CoreException; import org.eclipse.ui.help.WorkbenchHelp; import org.eclipse.help.IContext; import org.eclipse.help.IHelp; import org.eclipse.help.IHelpResource; import org.eclipse.jdt.core.IJavaElement; import org.eclipse.jdt.core.IMember; import org.eclipse.jdt.core.IPackageFragmentRoot; import org.eclipse.jdt.core.JavaModelException; import org.eclipse.jdt.ui.JavaUI; import org.eclipse.jdt.internal.corext.Assert; import org.eclipse.jdt.internal.corext.javadoc.JavaDocAccess; import org.eclipse.jdt.internal.corext.javadoc.SingleCharReader; import org.eclipse.jdt.internal.corext.util.JavaModelUtil; import org.eclipse.jdt.internal.ui.JavaPlugin; import org.eclipse.jdt.internal.ui.JavaUIMessages; import org.eclipse.jdt.internal.ui.text.HTML2TextReader; import org.eclipse.jdt.internal.ui.viewsupport.JavaElementLabels; public class JavadocHelpContext implements IContext { public static void displayHelp(String contextId, Object[] selected) throws CoreException { IHelp help= WorkbenchHelp.getHelpSupport(); if (help == null) { return; // no help support installed } IContext context= help.getContext(contextId); if (selected != null && selected.length > 0) { context= new JavadocHelpContext(context, selected); } WorkbenchHelp.displayHelp(context); } private static class JavaUIHelpResource implements IHelpResource { private IJavaElement fElement; private String fUrl; public JavaUIHelpResource(IJavaElement element, String url) { fElement= element; fUrl= url; } public String getHref() { return fUrl; } public String getLabel() { String label= JavaElementLabels.getTextLabel(fElement, JavaElementLabels.ALL_DEFAULT); return JavaUIMessages.getFormattedString("JavaUIHelp.link.label", label); //$NON-NLS-1$ } } private IHelpResource[] fHelpResources; private String fText; public JavadocHelpContext(IContext context, Object[] elements) throws CoreException { Assert.isNotNull(elements); List helpResources= new ArrayList(); if (context != null) { IHelpResource[] resources= context.getRelatedTopics(); if (resources != null) { for (int j= 0; j < resources.length; j++) { helpResources.add(resources[j]); } } } for (int i= 0; i < elements.length; i++) { if (elements[i] instanceof IJavaElement) { IJavaElement element= (IJavaElement) elements[i]; if (fText == null) { fText= retrieveText(element); } else { fText= ""; // no doc on multiple selection //$NON-NLS-1$ } URL url= JavaUI.getJavadocLocation(element, true); if (url == null || doesNotExist(url)) { IPackageFragmentRoot root= JavaModelUtil.getPackageFragmentRoot(element); if (root != null) { url= JavaUI.getJavadocBaseLocation(element); if (root.getKind() == IPackageFragmentRoot.K_SOURCE) { element= element.getJavaProject(); } else { element= root; } url= JavaUI.getJavadocLocation(element, false); } } if (url != null) { IHelpResource javaResource= new JavaUIHelpResource(element, url.toExternalForm()); helpResources.add(javaResource); } } } fHelpResources= (IHelpResource[]) helpResources.toArray(new IHelpResource[helpResources.size()]); if (fText == null || fText.length() == 0) { if (context != null) { fText= context.getText(); } } if (fText != null && fText.length() == 0) { fText= null; // see 14207 } } private boolean doesNotExist(URL url) { if (url.getProtocol().equals("file")) { //$NON-NLS-1$ File file= new File(url.getFile()); return !file.exists(); } return false; } private String retrieveText(IJavaElement elem) throws JavaModelException { if (elem instanceof IMember) { try { SingleCharReader reader= JavaDocAccess.getJavaDoc((IMember) elem, true); if (reader != null) { HTML2TextReader htmlReader= new HTML2TextReader(reader, null); String str= htmlReader.getString(); BreakIterator breakIterator= BreakIterator.getSentenceInstance(); breakIterator.setText(str); return str.substring(0, breakIterator.next()); } } catch (IOException e) { JavaPlugin.log(e); // ignore } } return ""; //$NON-NLS-1$ } public IHelpResource[] getRelatedTopics() { return fHelpResources; } public String getText() { return fText; } }
43,109
Bug 43109 AssertionFailedException in CUCorrectionProposal
200309100800 no steps, found this in the log: !MESSAGE Unhandled exception caught in event loop. Unhandled exception caught in event loop. Reason: !ENTRY org.eclipse.ui 4 0 Sep 15, 2003 17:19:24.461 !MESSAGE assertion failed; !STACK 0 org.eclipse.jdt.internal.corext.Assert$AssertionFailedException: assertion failed; at org.eclipse.jdt.internal.corext.Assert.isTrue(Assert.java:136) at org.eclipse.jdt.internal.corext.Assert.isTrue(Assert.java:121) at org.eclipse.jdt.internal.corext.refactoring.changes.TextChange.getNewTextRange(TextChange.java:416) at org.eclipse.jdt.internal.ui.text.correction.CUCorrectionProposal.enterLinkedMode(CUCorrectionProposal.java:25 5) at org.eclipse.jdt.internal.ui.text.correction.CUCorrectionProposal.apply(CUCorrectionProposal.java:234) at org.eclipse.jface.text.contentassist.CompletionProposalPopup.insertProposal(CompletionProposalPopup.java:328) at org.eclipse.jface.text.contentassist.CompletionProposalPopup.selectProposalWithMask(CompletionProposalPopup.j ava:292) at org.eclipse.jface.text.contentassist.CompletionProposalPopup.verifyKey(CompletionProposalPopup.java:585) at org.eclipse.jface.text.contentassist.ContentAssistant$InternalListener.verifyKey(ContentAssistant.java:601) at org.eclipse.jface.text.TextViewer$VerifyKeyListenersManager.verifyKey(TextViewer.java:368) at org.eclipse.swt.custom.StyledTextListener.handleEvent(StyledTextListener.java:55) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:82) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:847) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:871) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:856) at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java:664) at org.eclipse.swt.custom.StyledText.handleKeyDown(StyledText.java:5281) at org.eclipse.swt.custom.StyledText$8.handleEvent(StyledText.java:5030) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:82) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:847) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:871) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:856) at org.eclipse.swt.widgets.Control.sendKeyEvent(Control.java:1688) at org.eclipse.swt.widgets.Control.sendKeyEvent(Control.java:1684) at org.eclipse.swt.widgets.Control.WM_CHAR(Control.java:3014) at org.eclipse.swt.widgets.Control.windowProc(Control.java:2893) at org.eclipse.swt.widgets.Display.windowProc(Display.java:2713) at org.eclipse.swt.internal.win32.OS.DispatchMessageW(Native Method) at org.eclipse.swt.internal.win32.OS.DispatchMessage(OS.java:1343) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:1876) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2037) at org.eclipse.ui.internal.Workbench.run(Workbench.java:2020) at org.eclipse.core.internal.boot.InternalBootLoader.run(InternalBootLoader.java:858) at org.eclipse.core.boot.BootLoader.run(BootLoader.java:461) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:324) at org.eclipse.core.launcher.Main.basicRun(Main.java:295) at org.eclipse.core.launcher.Main.run(Main.java:751) at org.eclipse.core.launcher.Main.main(Main.java:587)
resolved fixed
f51d40d
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2003-09-17T09:19:12Z
2003-09-15T15:33:20Z
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/CUCorrectionProposal.java
/******************************************************************************* * Copyright (c) 2000, 2003 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Common Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/cpl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.jdt.internal.ui.text.correction; import org.eclipse.text.edits.MultiTextEdit; import org.eclipse.text.edits.TextEdit; import org.eclipse.compare.contentmergeviewer.ITokenComparator; import org.eclipse.compare.rangedifferencer.RangeDifference; import org.eclipse.compare.rangedifferencer.RangeDifferencer; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IStatus; import org.eclipse.jdt.core.ICompilationUnit; import org.eclipse.swt.graphics.Image; import org.eclipse.jface.dialogs.ErrorDialog; import org.eclipse.jface.text.BadLocationException; import org.eclipse.jface.text.IDocument; import org.eclipse.jface.text.IRegion; import org.eclipse.jface.text.ITextViewer; import org.eclipse.jface.text.contentassist.ICompletionProposal; import org.eclipse.ui.IEditorPart; import org.eclipse.ui.IWorkbenchPage; import org.eclipse.ui.texteditor.ITextEditor; import org.eclipse.jdt.internal.corext.refactoring.base.Change; import org.eclipse.jdt.internal.corext.refactoring.changes.CompilationUnitChange; import org.eclipse.jdt.internal.corext.textmanipulation.GroupDescription; import org.eclipse.jdt.internal.corext.textmanipulation.TextBuffer; import org.eclipse.jdt.internal.corext.textmanipulation.TextRegion; import org.eclipse.jdt.internal.corext.util.JavaModelUtil; import org.eclipse.jdt.internal.corext.util.Resources; import org.eclipse.jdt.internal.corext.util.Strings; import org.eclipse.jdt.internal.ui.JavaPlugin; import org.eclipse.jdt.internal.ui.JavaPluginImages; import org.eclipse.jdt.internal.ui.compare.JavaTokenComparator; import org.eclipse.jdt.internal.ui.javaeditor.EditorUtility; import org.eclipse.jdt.internal.ui.javaeditor.JavaEditor; import org.eclipse.jdt.internal.ui.text.link.LinkedPositionManager; import org.eclipse.jdt.internal.ui.text.link.LinkedPositionUI; public class CUCorrectionProposal extends ChangeCorrectionProposal { private ICompilationUnit fCompilationUnit; private TextEdit fRootEdit; public CUCorrectionProposal(String name, ICompilationUnit cu, int relevance) { this(name, cu, relevance, JavaPluginImages.get(JavaPluginImages.IMG_CORRECTION_CHANGE)); } public CUCorrectionProposal(String name, ICompilationUnit cu, int relevance, Image image) { super(name, null, relevance, image); fRootEdit= new MultiTextEdit(); fCompilationUnit= cu; } public CUCorrectionProposal(String name, CompilationUnitChange change, int relevance, Image image) { super(name, change, relevance, image); fCompilationUnit= change.getCompilationUnit(); } protected CompilationUnitChange createCompilationUnitChange(String name, ICompilationUnit cu, TextEdit rootEdit) throws CoreException { CompilationUnitChange change= new CompilationUnitChange(name, cu); change.setEdit(rootEdit); change.setSave(false); setChange(change); return change; } /* * @see ChangeCorrectionProposal#getChange() */ protected Change getChange() throws CoreException { Change change= super.getChange(); if (change == null) { return createCompilationUnitChange(getDisplayString(), fCompilationUnit, fRootEdit); } return change; } protected final void addEdits(CompilationUnitChange change) throws CoreException { } protected GroupDescription[] getLinkedRanges() { return null; } protected ICompletionProposal[] getLinkedModeProposals(String name) { return null; } protected GroupDescription getSelectionDescription() { return null; } /* * @see ICompletionProposal#getAdditionalProposalInfo() */ public String getAdditionalProposalInfo() { StringBuffer buf= new StringBuffer(); try { CompilationUnitChange change= getCompilationUnitChange(); TextBuffer previewConent= change.getPreviewTextBuffer(); String currentConentString= change.getCurrentContent(); ITokenComparator leftSide= new JavaTokenComparator(previewConent.getContent(), true); ITokenComparator rightSide= new JavaTokenComparator(currentConentString, true); RangeDifference[] differences= RangeDifferencer.findRanges(leftSide, rightSide); for (int i= 0; i < differences.length; i++) { RangeDifference curr= differences[i]; int start= leftSide.getTokenStart(curr.leftStart()); int end= leftSide.getTokenStart(curr.leftEnd()); if (curr.kind() == RangeDifference.CHANGE && curr.leftLength() > 0) { buf.append("<b>"); //$NON-NLS-1$ appendContent(previewConent, start, end, buf, false); buf.append("</b>"); //$NON-NLS-1$ } else if (curr.kind() == RangeDifference.NOCHANGE) { appendContent(previewConent, start, end, buf, true); } } } catch (CoreException e) { JavaPlugin.log(e); } return buf.toString(); } private final int surroundLines= 1; private void appendContent(TextBuffer text, int startOffset, int endOffset, StringBuffer buf, boolean surroundLinesOnly) { int startLine= text.getLineOfOffset(startOffset); int endLine= text.getLineOfOffset(endOffset); boolean dotsAdded= false; if (surroundLinesOnly && startOffset == 0) { // no surround lines for the top no-change range startLine= Math.max(endLine - surroundLines, 0); buf.append("...<br>"); //$NON-NLS-1$ dotsAdded= true; } for (int i= startLine; i <= endLine; i++) { if (surroundLinesOnly) { if ((i - startLine > surroundLines) && (endLine - i > surroundLines)) { if (!dotsAdded) { buf.append("...<br>"); //$NON-NLS-1$ dotsAdded= true; } else if (endOffset == text.getLength()) { return; // no surround lines for the bottom no-change range } continue; } } TextRegion lineInfo= text.getLineInformation(i); int start= lineInfo.getOffset(); int end= start + lineInfo.getLength(); int from= Math.max(start, startOffset); int to= Math.min(end, endOffset); String content= text.getContent(from, to - from); if (surroundLinesOnly && (from == start) && Strings.containsOnlyWhitespaces(content)) { continue; // ignore empty lines exept when range started in the middle of a line } buf.append(content); if (to == end && to != endOffset) { // new line when at the end of the line, and not end of range buf.append("<br>"); //$NON-NLS-1$ } } } /* (non-Javadoc) * @see org.eclipse.jface.text.contentassist.ICompletionProposal#apply(org.eclipse.jface.text.IDocument) */ public void apply(IDocument document) { try { ICompilationUnit unit= JavaModelUtil.toOriginal(getCompilationUnit()); IStatus status= Resources.makeCommittable(unit.getResource(), null); if (!status.isOK()) { String label= CorrectionMessages.getString("CUCorrectionProposal.error.title"); //$NON-NLS-1$ String message= CorrectionMessages.getString("CUCorrectionProposal.error.message"); //$NON-NLS-1$ ErrorDialog.openError(JavaPlugin.getActiveWorkbenchShell(), label, message, status); return; } CompilationUnitChange change= getCompilationUnitChange(); GroupDescription selection= getSelectionDescription(); GroupDescription[] linked= getLinkedRanges(); IEditorPart part= null; if (selection != null || linked != null) { change.setKeepExecutedTextEdits(true); part= EditorUtility.isOpenInEditor(unit); if (part == null) { part= EditorUtility.openInEditor(unit, true); } IWorkbenchPage page= JavaPlugin.getActivePage(); if (page != null && part != null) { page.bringToTop(part); } if (part != null) { part.setFocus(); } } super.apply(document); if (part == null) { return; } if (linked != null && part instanceof JavaEditor) { // enter linked mode ITextViewer viewer= ((JavaEditor) part).getViewer(); enterLinkedMode(change, viewer, linked, selection); } else if (selection != null && part instanceof ITextEditor) { // select a result IRegion range= change.getNewTextRange(selection.getTextEdits()); ((ITextEditor) part).selectAndReveal(range.getOffset(), range.getLength()); } } catch (CoreException e) { JavaPlugin.log(e); } catch (BadLocationException e) { JavaPlugin.log(e); } } private void enterLinkedMode(CompilationUnitChange change, ITextViewer viewer, GroupDescription[] linked, GroupDescription selection) throws BadLocationException { LinkedPositionManager manager= new LinkedPositionManager(viewer.getDocument()); LinkedPositionUI editor= new LinkedPositionUI(viewer, manager); for (int i= 0; i < linked.length; i++) { GroupDescription curr= linked[i]; String name= curr.getName(); // name used as key for link mode proposals & as kind for linked mode IRegion range= change.getNewTextRange(curr.getTextEdits()); if (range != null && name != null) { ICompletionProposal[] linkedModeProposals= getLinkedModeProposals(name); if (linkedModeProposals != null && linkedModeProposals.length > 1) { manager.addPosition(range.getOffset(), range.getLength(), name, linkedModeProposals); } else { manager.addPosition(range.getOffset(), range.getLength(), name); } if (i == 0) { editor.setInitialOffset(range.getOffset()); } } } if (selection != null) { IRegion range= change.getNewTextRange(selection.getTextEdits()); if (range != null) { editor.setFinalCaretOffset(range.getOffset() + range.getLength()); } } else { int cursorPosition= viewer.getSelectedRange().x; if (cursorPosition != 0) { editor.setFinalCaretOffset(cursorPosition); } } editor.enter(); IRegion region= editor.getSelectedRegion(); viewer.setSelectedRange(region.getOffset(), region.getLength()); viewer.revealRange(region.getOffset(), region.getLength()); } /** * Gets the compilationUnitChange. * @return Returns a CompilationUnitChange */ public CompilationUnitChange getCompilationUnitChange() throws CoreException { return (CompilationUnitChange) getChange(); } /** * @return Returns the root text edit */ public TextEdit getRootTextEdit() { return fRootEdit; } /** * Returns the compilationUnit. * @return ICompilationUnit */ public ICompilationUnit getCompilationUnit() { return fCompilationUnit; } }
42,770
Bug 42770 Deleting a member requires save
I20030903 + plug-in export from 20030909 0. Ensure preference Java > Refactoring > Save all modified resources... is unchecked (this is the default for new workspaces) 1. Open a CU 2. Make it dirty 3. In the Outline view delete a method of the CU ==> You have to save the CU - this is wrong If the preference in 0. is checked then the CU is saved which is wrong too.
verified fixed
11b4ded
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2003-09-17T10:32:32Z
2003-09-09T12:20:00Z
org.eclipse.jdt.ui/ui
42,770
Bug 42770 Deleting a member requires save
I20030903 + plug-in export from 20030909 0. Ensure preference Java > Refactoring > Save all modified resources... is unchecked (this is the default for new workspaces) 1. Open a CU 2. Make it dirty 3. In the Outline view delete a method of the CU ==> You have to save the CU - this is wrong If the preference in 0. is checked then the CU is saved which is wrong too.
verified fixed
11b4ded
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2003-09-17T10:32:32Z
2003-09-09T12:20:00Z
refactoring/org/eclipse/jdt/internal/ui/refactoring/UserInterfaceStarter.java
42,770
Bug 42770 Deleting a member requires save
I20030903 + plug-in export from 20030909 0. Ensure preference Java > Refactoring > Save all modified resources... is unchecked (this is the default for new workspaces) 1. Open a CU 2. Make it dirty 3. In the Outline view delete a method of the CU ==> You have to save the CU - this is wrong If the preference in 0. is checked then the CU is saved which is wrong too.
verified fixed
11b4ded
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2003-09-17T10:32:32Z
2003-09-09T12:20:00Z
org.eclipse.jdt.ui/ui
42,770
Bug 42770 Deleting a member requires save
I20030903 + plug-in export from 20030909 0. Ensure preference Java > Refactoring > Save all modified resources... is unchecked (this is the default for new workspaces) 1. Open a CU 2. Make it dirty 3. In the Outline view delete a method of the CU ==> You have to save the CU - this is wrong If the preference in 0. is checked then the CU is saved which is wrong too.
verified fixed
11b4ded
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2003-09-17T10:32:32Z
2003-09-09T12:20:00Z
refactoring/org/eclipse/jdt/internal/ui/refactoring/reorg/DeleteAction.java
42,770
Bug 42770 Deleting a member requires save
I20030903 + plug-in export from 20030909 0. Ensure preference Java > Refactoring > Save all modified resources... is unchecked (this is the default for new workspaces) 1. Open a CU 2. Make it dirty 3. In the Outline view delete a method of the CU ==> You have to save the CU - this is wrong If the preference in 0. is checked then the CU is saved which is wrong too.
verified fixed
11b4ded
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2003-09-17T10:32:32Z
2003-09-09T12:20:00Z
org.eclipse.jdt.ui/ui
42,770
Bug 42770 Deleting a member requires save
I20030903 + plug-in export from 20030909 0. Ensure preference Java > Refactoring > Save all modified resources... is unchecked (this is the default for new workspaces) 1. Open a CU 2. Make it dirty 3. In the Outline view delete a method of the CU ==> You have to save the CU - this is wrong If the preference in 0. is checked then the CU is saved which is wrong too.
verified fixed
11b4ded
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2003-09-17T10:32:32Z
2003-09-09T12:20:00Z
refactoring/org/eclipse/jdt/internal/ui/refactoring/reorg/RenameMethodUserInterfaceStarter.java
42,770
Bug 42770 Deleting a member requires save
I20030903 + plug-in export from 20030909 0. Ensure preference Java > Refactoring > Save all modified resources... is unchecked (this is the default for new workspaces) 1. Open a CU 2. Make it dirty 3. In the Outline view delete a method of the CU ==> You have to save the CU - this is wrong If the preference in 0. is checked then the CU is saved which is wrong too.
verified fixed
11b4ded
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2003-09-17T10:32:32Z
2003-09-09T12:20:00Z
org.eclipse.jdt.ui/ui
42,770
Bug 42770 Deleting a member requires save
I20030903 + plug-in export from 20030909 0. Ensure preference Java > Refactoring > Save all modified resources... is unchecked (this is the default for new workspaces) 1. Open a CU 2. Make it dirty 3. In the Outline view delete a method of the CU ==> You have to save the CU - this is wrong If the preference in 0. is checked then the CU is saved which is wrong too.
verified fixed
11b4ded
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2003-09-17T10:32:32Z
2003-09-09T12:20:00Z
refactoring/org/eclipse/jdt/internal/ui/refactoring/reorg/RenameUserInterfaceStarter.java
43,207
Bug 43207 Javadoc info for content assist only shown once
I20030916 Javadoc infos for content assist are only shown the first time an editor is opened. Afterwards, no javadoc is shown any more. - open a java source file (e.g. public class A { }) - Press Ctrl+Space to invoke content assist => works: selection in proposal list shows javadoc hover (if javadoc available) - Press Esc, press Ctrl+Space again => fails: selection in proposal list does not make any javadocs appear
verified fixed
958a5ea
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2003-09-17T10:47:06Z
2003-09-17T09:13:20Z
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/link/contentassist/CompletionProposalPopup2.java
/******************************************************************************* * Copyright (c) 2000, 2003 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Common Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/cpl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.jdt.internal.ui.text.link.contentassist; import java.util.ArrayList; import java.util.List; import org.eclipse.swt.SWT; import org.eclipse.swt.custom.BusyIndicator; import org.eclipse.swt.custom.StyledText; import org.eclipse.swt.events.ControlEvent; import org.eclipse.swt.events.ControlListener; import org.eclipse.swt.events.DisposeEvent; import org.eclipse.swt.events.DisposeListener; import org.eclipse.swt.events.KeyEvent; import org.eclipse.swt.events.KeyListener; import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.events.SelectionListener; import org.eclipse.swt.events.VerifyEvent; import org.eclipse.swt.graphics.Color; import org.eclipse.swt.graphics.Point; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Control; import org.eclipse.swt.widgets.Shell; import org.eclipse.swt.widgets.Table; import org.eclipse.swt.widgets.TableItem; import org.eclipse.jface.resource.JFaceResources; import org.eclipse.jface.text.BadLocationException; import org.eclipse.jface.text.DocumentEvent; import org.eclipse.jface.text.IDocument; import org.eclipse.jface.text.IDocumentListener; import org.eclipse.jface.text.IRewriteTarget; import org.eclipse.jface.text.ITextViewer; import org.eclipse.jface.text.ITextViewerExtension; import org.eclipse.jface.text.TextUtilities; import org.eclipse.jface.text.contentassist.ICompletionProposal; import org.eclipse.jface.text.contentassist.ICompletionProposalExtension; import org.eclipse.jface.text.contentassist.ICompletionProposalExtension2; import org.eclipse.jface.text.contentassist.IContextInformation; /** * This class is used to present proposals to the user. If additional * information exists for a proposal, then selecting that proposal * will result in the information being displayed in a secondary * window. * * @see org.eclipse.jface.text.contentassist.ICompletionProposal * @see org.eclipse.jface.text.contentassist.AdditionalInfoController */ class CompletionProposalPopup2 implements IContentAssistListener2 { /** The associated text viewer */ private ITextViewer fViewer; /** The associated content assistant */ private ContentAssistant2 fContentAssistant; /** The used additional info controller */ private AdditionalInfoController2 fAdditionalInfoController; /** The closing strategy for this completion proposal popup */ private PopupCloser2 fPopupCloser= new PopupCloser2(); /** The popup shell */ private Shell fProposalShell; /** The proposal table */ private Table fProposalTable; /** Indicates whether a completion proposal is being inserted */ private boolean fInserting= false; /** The key listener to control navigation */ private KeyListener fKeyListener; /** List of document events used for filtering proposals */ private List fDocumentEvents= new ArrayList(); /** Listener filling the document event queue */ private IDocumentListener fDocumentListener; /** Reentrance count for <code>filterProposals</code> */ private long fInvocationCounter= 0; /** The filter list of proposals */ private ICompletionProposal[] fFilteredProposals; /** The computed list of proposals */ private ICompletionProposal[] fComputedProposals; /** The offset for which the proposals have been computed */ private int fInvocationOffset; /** The offset for which the computed proposaks have been filtered */ private int fFilterOffset; /** The default line delimiter of the viewer's widget */ private String fLineDelimiter; /** The most recently selected proposal. */ private ICompletionProposal fLastProposal; /** * Creates a new completion proposal popup for the given elements. * * @param contentAssistant the content assistant feeding this popup * @param viewer the viewer on top of which this popup appears * @param infoController the info control collaborating with this popup * @since 2.0 */ public CompletionProposalPopup2(ContentAssistant2 contentAssistant, ITextViewer viewer, AdditionalInfoController2 infoController) { fContentAssistant= contentAssistant; fViewer= viewer; fAdditionalInfoController= infoController; } /** * Computes and presents completion proposals. The flag indicates whether this call has * be made out of an auto activation context. * * @param autoActivated <code>true</code> if auto activation context * @return an error message or <code>null</code> in case of no error */ public String showProposals(final boolean autoActivated) { if (fKeyListener == null) { fKeyListener= new KeyListener() { public void keyPressed(KeyEvent e) { if (!Helper2.okToUse(fProposalShell)) return; if (e.character == 0 && e.keyCode == SWT.MOD1) { // http://dev.eclipse.org/bugs/show_bug.cgi?id=34754 int index= fProposalTable.getSelectionIndex(); if (index >= 0) selectProposal(index, true); } } public void keyReleased(KeyEvent e) { if (!Helper2.okToUse(fProposalShell)) return; if (e.character == 0 && e.keyCode == SWT.MOD1) { // http://dev.eclipse.org/bugs/show_bug.cgi?id=34754 int index= fProposalTable.getSelectionIndex(); if (index >= 0) selectProposal(index, false); } } }; } final StyledText styledText= fViewer.getTextWidget(); if (styledText != null && !styledText.isDisposed()) styledText.addKeyListener(fKeyListener); BusyIndicator.showWhile(styledText.getDisplay(), new Runnable() { public void run() { fInvocationOffset= fViewer.getSelectedRange().x; // lazily compute proposals // if (fComputedProposals == null) fComputedProposals= computeProposals(fContentAssistant.getCompletionPosition()); fComputedProposals= computeProposals(fInvocationOffset); int count= (fComputedProposals == null ? 0 : fComputedProposals.length); if (count == 0) { if (!autoActivated) styledText.getDisplay().beep(); } else { if (count == 1 && !autoActivated && fContentAssistant.isAutoInserting()) insertProposal(fComputedProposals[0], (char) 0, 0, fInvocationOffset); else { if (fLineDelimiter == null) fLineDelimiter= styledText.getLineDelimiter(); createProposalSelector(); setProposals(fComputedProposals); resizeProposalSelector(true); displayProposals(); } } } }); return getErrorMessage(); } /** * Returns the completion proposal available at the given offset of the * viewer's document. Delegates the work to the content assistant. * * @param offset the offset * @return the completion proposals available at this offset */ private ICompletionProposal[] computeProposals(int offset) { return fContentAssistant.computeCompletionProposals(fViewer, offset); } /** * Returns the error message. * * @return the error message */ private String getErrorMessage() { return fContentAssistant.getErrorMessage(); } /** * Creates the proposal selector. */ private void createProposalSelector() { if (Helper2.okToUse(fProposalShell)) return; Control control= fViewer.getTextWidget(); fProposalShell= new Shell(control.getShell(), SWT.ON_TOP); // fProposalShell= new Shell(control.getShell(), SWT.ON_TOP | SWT.RESIZE ); fProposalTable= new Table(fProposalShell, SWT.H_SCROLL | SWT.V_SCROLL); // fProposalTable= new Table(fProposalShell, SWT.H_SCROLL | SWT.V_SCROLL); fProposalTable.setLocation(0, 0); if (fAdditionalInfoController != null) fAdditionalInfoController.setSizeConstraints(50, 10, true, false); GridLayout layout= new GridLayout(); layout.marginWidth= 0; layout.marginHeight= 0; fProposalShell.setLayout(layout); GridData data= new GridData(GridData.FILL_BOTH); fProposalTable.setLayoutData(data); fProposalShell.pack(); // set location Point currentLocation= fProposalShell.getLocation(); Point newLocation= getLocation(); if ((newLocation.x < currentLocation.x && newLocation.y == currentLocation.y) || newLocation.y < currentLocation.y) fProposalShell.setLocation(newLocation); if (fAdditionalInfoController != null) { fProposalShell.addControlListener(new ControlListener() { public void controlMoved(ControlEvent e) {} public void controlResized(ControlEvent e) { // resets the cached resize constraints fAdditionalInfoController.setSizeConstraints(50, 10, true, false); } }); } fProposalShell.setBackground(control.getDisplay().getSystemColor(SWT.COLOR_BLACK)); Color c= fContentAssistant.getProposalSelectorBackground(); if (c == null) c= control.getDisplay().getSystemColor(SWT.COLOR_INFO_BACKGROUND); fProposalTable.setBackground(c); c= fContentAssistant.getProposalSelectorForeground(); if (c == null) c= control.getDisplay().getSystemColor(SWT.COLOR_INFO_FOREGROUND); fProposalTable.setForeground(c); fProposalTable.addSelectionListener(new SelectionListener() { public void widgetSelected(SelectionEvent e) {} public void widgetDefaultSelected(SelectionEvent e) { selectProposalWithMask(e.stateMask); } }); fPopupCloser.install(fContentAssistant, fProposalTable); fProposalShell.addDisposeListener(new DisposeListener() { public void widgetDisposed(DisposeEvent e) { unregister(); // but don't dispose the shell, since we're being called from its disposal event! } }); fProposalTable.setHeaderVisible(false); fContentAssistant.addToLayout(this, fProposalShell, ContentAssistant2.LayoutManager.LAYOUT_PROPOSAL_SELECTOR, fContentAssistant.getSelectionOffset()); } /** * Returns the proposal selected in the proposal selector. * * @return the selected proposal * @since 2.0 */ private ICompletionProposal getSelectedProposal() { int i= fProposalTable.getSelectionIndex(); if (i < 0 || i >= fFilteredProposals.length) return null; return fFilteredProposals[i]; } /** * Takes the selected proposal and applies it. * * @param stateMask the state mask * @since 2.1 */ private void selectProposalWithMask(int stateMask) { ICompletionProposal p= getSelectedProposal(); hide(); if (p != null) insertProposal(p, (char) 0, stateMask, fViewer.getSelectedRange().x); } /** * Applies the given proposal at the given offset. The given character is the * one that triggered the insertion of this proposal. * * @param p the completion proposal * @param trigger the trigger character * @param offset the offset * @since 2.1 */ private void insertProposal(ICompletionProposal p, char trigger, int stateMask, int offset) { fInserting= true; IRewriteTarget target= null; try { IDocument document= fViewer.getDocument(); if (fViewer instanceof ITextViewerExtension) { ITextViewerExtension extension= (ITextViewerExtension) fViewer; target= extension.getRewriteTarget(); } if (target != null) target.beginCompoundChange(); if (p instanceof ICompletionProposalExtension2) { ICompletionProposalExtension2 e= (ICompletionProposalExtension2) p; e.apply(fViewer, trigger, stateMask, offset); } else if (p instanceof ICompletionProposalExtension) { ICompletionProposalExtension e= (ICompletionProposalExtension) p; e.apply(document, trigger, offset); } else { p.apply(document); } Point selection= p.getSelection(document); if (selection != null) { fViewer.setSelectedRange(selection.x, selection.y); fViewer.revealRange(selection.x, selection.y); } IContextInformation info= p.getContextInformation(); if (info != null) { int position; if (p instanceof ICompletionProposalExtension) { ICompletionProposalExtension e= (ICompletionProposalExtension) p; position= e.getContextInformationPosition(); } else { if (selection == null) selection= fViewer.getSelectedRange(); position= selection.x + selection.y; } fContentAssistant.showContextInformation(info, position); } fContentAssistant.setProposalChosen(true); } finally { if (target != null) target.endCompoundChange(); fInserting= false; } } /** * Returns whether this popup has the focus. * * @return <code>true</code> if the popup has the focus */ public boolean hasFocus() { if (Helper2.okToUse(fProposalShell)) return (fProposalShell.isFocusControl() || fProposalTable.isFocusControl()); return false; } /** * Hides this popup. */ public void hide() { unregister(); if (Helper2.okToUse(fProposalShell)) { fContentAssistant.removeContentAssistListener(this, ContentAssistant2.PROPOSAL_SELECTOR); fPopupCloser.uninstall(); fProposalShell.setVisible(false); fProposalShell.dispose(); fProposalShell= null; } } private void unregister() { if (fDocumentListener != null) { IDocument document= fViewer.getDocument(); if (document != null) document.removeDocumentListener(fDocumentListener); fDocumentListener= null; } fDocumentEvents.clear(); StyledText styledText= fViewer.getTextWidget(); if (fKeyListener != null && styledText != null && !styledText.isDisposed()) styledText.removeKeyListener(fKeyListener); if (fLastProposal != null) { if (fLastProposal instanceof ICompletionProposalExtension2) { ICompletionProposalExtension2 extension= (ICompletionProposalExtension2) fLastProposal; extension.unselected(fViewer); } fLastProposal= null; } if (fAdditionalInfoController != null) { fAdditionalInfoController.dispose(); } fFilteredProposals= null; fContentAssistant.possibleCompletionsClosed(); } /** *Returns whether this popup is active. It is active if the propsal selector is visible. * * @return <code>true</code> if this popup is active */ public boolean isActive() { return fProposalShell != null && !fProposalShell.isDisposed(); } /** * Initializes the proposal selector with these given proposals. * * @param proposals the proposals */ private void setProposals(ICompletionProposal[] proposals) { if (Helper2.okToUse(fProposalTable)) { ICompletionProposal oldProposal= getSelectedProposal(); if (oldProposal instanceof ICompletionProposalExtension2) ((ICompletionProposalExtension2) oldProposal).unselected(fViewer); fFilteredProposals= proposals; fProposalTable.setRedraw(false); fProposalTable.removeAll(); Point selection= fViewer.getSelectedRange(); int endOffset; endOffset= selection.x + selection.y; IDocument document= fViewer.getDocument(); boolean validate= false; if (selection.y != 0 && document != null) validate= true; int selectionIndex= 0; TableItem item; ICompletionProposal p; for (int i= 0; i < proposals.length; i++) { p= proposals[i]; item= new TableItem(fProposalTable, SWT.NULL); if (p.getImage() != null) item.setImage(p.getImage()); item.setText(p.getDisplayString()); item.setData(p); if (validate && validateProposal(document, p, endOffset, null)) { selectionIndex= i; validate= false; } } resizeProposalSelector(false); selectProposal(selectionIndex, false); fProposalTable.setRedraw(true); } } private void resizeProposalSelector(boolean adjustWidth) { // in order to fill in the table items so size computation works correctly // will cause flicker, though fProposalTable.setRedraw(true); int width= adjustWidth ? SWT.DEFAULT : ((GridData)fProposalTable.getLayoutData()).widthHint; Point size= fProposalTable.computeSize(width, SWT.DEFAULT, true); GridData data= new GridData(GridData.FILL_BOTH); data.widthHint= adjustWidth ? Math.min(size.x, 300) : width; data.heightHint= Math.min(getTableHeightHint(fProposalTable, fProposalTable.getItemCount() - 1), getTableHeightHint(fProposalTable, 9)); fProposalTable.setLayoutData(data); fProposalShell.layout(true); fProposalShell.pack(); } /** * Computes the table hight hint for <code>table</code>. * * @param table the table to compute the height for * @param rows the number of rows to compute the height for * @return the height hint for <code>table</code> */ private int getTableHeightHint(Table table, int rows) { if (table.getFont().equals(JFaceResources.getDefaultFont())) table.setFont(JFaceResources.getDialogFont()); int result= table.getItemHeight() * rows; if (table.getLinesVisible()) result+= table.getGridLineWidth() * (rows - 1); // TODO adjustment might just work on windows return result + 4; } private boolean validateProposal(IDocument document, ICompletionProposal p, int offset, DocumentEvent event) { // detect selected if (p instanceof ICompletionProposalExtension2) { ICompletionProposalExtension2 e= (ICompletionProposalExtension2) p; if (e.validate(document, offset, event)) return true; } else if (p instanceof ICompletionProposalExtension) { ICompletionProposalExtension e= (ICompletionProposalExtension) p; if (e.isValidFor(document, offset)) return true; } return false; } /** * Returns the graphical location at which this popup should be made visible. * * @return the location of this popup */ private Point getLocation() { StyledText text= fViewer.getTextWidget(); Point selection= text.getSelection(); Point p= text.getLocationAtOffset(selection.x); // TODO subtract border width! p.x -= fProposalShell.getBorderWidth(); if (p.x < 0) p.x= 0; if (p.y < 0) p.y= 0; p= new Point(p.x, p.y + text.getLineHeight()); p= text.toDisplay(p); if (p.x < 0) p.x= 0; if (p.y < 0) p.y= 0; return p; } /** *Displays this popup and install the additional info controller, so that additional info * is displayed when a proposal is selected and additional info is available. */ private void displayProposals() { if (fContentAssistant.addContentAssistListener(this, ContentAssistant2.PROPOSAL_SELECTOR)) { if (fDocumentListener == null) fDocumentListener= new IDocumentListener() { public void documentAboutToBeChanged(DocumentEvent event) { if (!fInserting) fDocumentEvents.add(event); } public void documentChanged(DocumentEvent event) { if (!fInserting) filterProposals(); } }; IDocument document= fViewer.getDocument(); if (document != null) document.addDocumentListener(fDocumentListener); fProposalShell.setVisible(true); if (fAdditionalInfoController != null) { fAdditionalInfoController.install(fProposalTable); fAdditionalInfoController.handleTableSelectionChanged(); } } } /* * @see IContentAssistListener#verifyKey(VerifyEvent) */ public boolean verifyKey(VerifyEvent e) { if (!Helper2.okToUse(fProposalShell)) return true; char key= e.character; if (key == 0) { int newSelection= fProposalTable.getSelectionIndex(); int visibleRows= (fProposalTable.getSize().y / fProposalTable.getItemHeight()) - 1; boolean smartToggle= false; switch (e.keyCode) { case SWT.ARROW_LEFT : case SWT.ARROW_RIGHT : filterProposals(); return true; case SWT.ARROW_UP : newSelection -= 1; if (newSelection < 0) newSelection= fProposalTable.getItemCount() - 1; break; case SWT.ARROW_DOWN : newSelection += 1; if (newSelection > fProposalTable.getItemCount() - 1) newSelection= 0; break; case SWT.PAGE_DOWN : newSelection += visibleRows; if (newSelection >= fProposalTable.getItemCount()) newSelection= fProposalTable.getItemCount() - 1; break; case SWT.PAGE_UP : newSelection -= visibleRows; if (newSelection < 0) newSelection= 0; break; case SWT.HOME : newSelection= 0; break; case SWT.END : newSelection= fProposalTable.getItemCount() - 1; break; default : if (e.keyCode != SWT.MOD1 && e.keyCode != SWT.MOD2 && e.keyCode != SWT.MOD3 && e.keyCode != SWT.MOD4) hide(); return true; } selectProposal(newSelection, smartToggle); e.doit= false; return false; } else { switch (key) { case 0x1B: // Esc e.doit= false; hide(); break; case '\n': // Ctrl-Enter on w2k case '\r': // Enter // e.doit= false; selectProposalWithMask(e.stateMask); break; // in linked mode: hide popup // plus: don't invalidate the event in order to give LinkedUI a chance to handle it case '\t': hide(); break; default: ICompletionProposal p= getSelectedProposal(); if (p instanceof ICompletionProposalExtension) { ICompletionProposalExtension t= (ICompletionProposalExtension) p; char[] triggers= t.getTriggerCharacters(); if (contains(triggers, key)) { hide(); if (key == ';') { e.doit= true; insertProposal(p, (char) 0, e.stateMask, fViewer.getSelectedRange().x); } else { e.doit= false; insertProposal(p, key, e.stateMask, fViewer.getSelectedRange().x); } } } } } return true; } /** * Selects the entry with the given index in the proposal selector and feeds * the selection to the additional info controller. * * @param index the index in the list * @param smartToggle <code>true</code> if the smart toogle key has been pressed * @since 2.1 */ private void selectProposal(int index, boolean smartToggle) { ICompletionProposal oldProposal= getSelectedProposal(); if (oldProposal instanceof ICompletionProposalExtension2) ((ICompletionProposalExtension2) oldProposal).unselected(fViewer); ICompletionProposal proposal= fFilteredProposals[index]; if (proposal instanceof ICompletionProposalExtension2) ((ICompletionProposalExtension2) proposal).selected(fViewer, smartToggle); fLastProposal= proposal; fProposalTable.setSelection(index); fProposalTable.showSelection(); if (fAdditionalInfoController != null) fAdditionalInfoController.handleTableSelectionChanged(); } /** * Returns whether the given character is contained in the given array of * characters. * * @param characters the list of characters * @param c the character to look for in the list * @return <code>true</code> if character belongs to the list * @since 2.0 */ private boolean contains(char[] characters, char c) { if (characters == null) return false; for (int i= 0; i < characters.length; i++) { if (c == characters[i]) return true; } return false; } /* * @see IEventConsumer#processEvent(VerifyEvent) */ public void processEvent(VerifyEvent e) { } /** * Filters the displayed proposal based on the given cursor position and the * offset of the original invocation of the content assistant. */ private void filterProposals() { ++ fInvocationCounter; Control control= fViewer.getTextWidget(); control.getDisplay().asyncExec(new Runnable() { long fCounter= fInvocationCounter; public void run() { if (fCounter != fInvocationCounter) return; int offset= fViewer.getSelectedRange().x; ICompletionProposal[] proposals= null; try { if (offset > -1) { DocumentEvent event= TextUtilities.mergeProcessedDocumentEvents(fDocumentEvents); proposals= computeFilteredProposals(offset, event); } } catch (BadLocationException x) { } finally { fDocumentEvents.clear(); } fFilterOffset= offset; if (proposals != null && proposals.length > 0) setProposals(proposals); else hide(); } }); } /** * Computes the subset of already computed propsals that are still valid for * the given offset. * * @param offset the offset * @param event the merged document event * @return the set of filtered proposals * @since 2.0 */ private ICompletionProposal[] computeFilteredProposals(int offset, DocumentEvent event) { if (offset == fInvocationOffset && event == null) return fComputedProposals; if (offset < fInvocationOffset) { return null; } ICompletionProposal[] proposals= fComputedProposals; if (offset > fFilterOffset) proposals= fFilteredProposals; if (proposals == null) return null; IDocument document= fViewer.getDocument(); int length= proposals.length; List filtered= new ArrayList(length); for (int i= 0; i < length; i++) { if (proposals[i] instanceof ICompletionProposalExtension2) { ICompletionProposalExtension2 p= (ICompletionProposalExtension2) proposals[i]; if (p.validate(document, offset, event)) filtered.add(p); } else if (proposals[i] instanceof ICompletionProposalExtension) { ICompletionProposalExtension p= (ICompletionProposalExtension) proposals[i]; if (p.isValidFor(document, offset)) filtered.add(p); } else { // restore original behavior fInvocationOffset= offset; fComputedProposals= computeProposals(fInvocationOffset); return fComputedProposals; } } ICompletionProposal[] p= new ICompletionProposal[filtered.size()]; filtered.toArray(p); return p; } /** * Requests the proposal shell to take focus. * * @since 3.0 */ public void setFocus() { if (Helper2.okToUse(fProposalShell)) fProposalShell.setFocus(); } }
43,052
Bug 43052 [templates] Code Assist, for loops and int arrays
I typed in the following code: int[] array = new int[10]; for using code assist to complete the for loop (array with temporary variable) results in a loop that uses i both for the loop counter and for the inner temp variable. This causes problems when trying to change the name of the temo variable or the loop counter.
resolved fixed
777290c
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2003-09-17T12:46:41Z
2003-09-12T20:53:20Z
org.eclipse.jdt.ui/core
43,052
Bug 43052 [templates] Code Assist, for loops and int arrays
I typed in the following code: int[] array = new int[10]; for using code assist to complete the for loop (array with temporary variable) results in a loop that uses i both for the loop counter and for the inner temp variable. This causes problems when trying to change the name of the temo variable or the loop counter.
resolved fixed
777290c
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2003-09-17T12:46:41Z
2003-09-12T20:53:20Z
extension/org/eclipse/jdt/internal/corext/template/java/JavaContext.java
43,294
Bug 43294 Primary working copy: No updates when changed in working copy mode
20030918 see test cases TypeHierarchyTest.testHierarchyWithWorkingCopy1, TypeHierarchyTest.testHierarchyWithWorkingCopy2, TypeHierarchyTest.testHierarchyWithWorkingCopy3 A hierarchy is created on a type that is then opened in an editor. The super type is modified, the editor saved: The type hierarchy does not send a 'typeHierarchyChanged' notification. If I understood correctly, the 'typeHierarchyChanged' is supposed to notify only on save, not while editing the working copy. Crrently it doesn't notify at all.
verified fixed
7a25063
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2003-09-18T14:16:31Z
2003-09-18T13:00:00Z
org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/core/TypeHierarchyTest.java
/******************************************************************************* * Copyright (c) 2000, 2003 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Common Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/cpl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.jdt.ui.tests.core; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.eclipse.jdt.core.ICompilationUnit; import org.eclipse.jdt.core.IJavaProject; import org.eclipse.jdt.core.IPackageFragment; import org.eclipse.jdt.core.IPackageFragmentRoot; import org.eclipse.jdt.core.IType; import org.eclipse.jdt.core.ITypeHierarchy; import org.eclipse.jdt.testplugin.JavaProjectHelper; public class TypeHierarchyTest extends TestCase { private static final Class THIS= TypeHierarchyTest.class; private IJavaProject fJavaProject1; private IJavaProject fJavaProject2; public TypeHierarchyTest(String name) { super(name); } public static Test suite() { if (true) { return new TestSuite(THIS); } else { TestSuite suite= new TestSuite(); suite.addTest(new TypeHierarchyTest("test1")); return suite; } } protected void setUp() throws Exception { fJavaProject1= JavaProjectHelper.createJavaProject("TestProject1", "bin"); fJavaProject2= JavaProjectHelper.createJavaProject("TestProject2", "bin"); } protected void tearDown () throws Exception { JavaProjectHelper.delete(fJavaProject1); JavaProjectHelper.delete(fJavaProject2); } public void test1() throws Exception { IPackageFragmentRoot jdk= JavaProjectHelper.addRTJar(fJavaProject1); assertTrue("jdk not found", jdk != null); IPackageFragmentRoot root1= JavaProjectHelper.addSourceContainer(fJavaProject1, "src"); IPackageFragment pack1= root1.createPackageFragment("pack1", true, null); ICompilationUnit cu1= pack1.getCompilationUnit("A.java"); cu1.createType("public class A {\n}\n", null, true, null); JavaProjectHelper.addRTJar(fJavaProject2); JavaProjectHelper.addRequiredProject(fJavaProject2, fJavaProject1); IPackageFragmentRoot root2= JavaProjectHelper.addSourceContainer(fJavaProject2, "src"); IPackageFragment pack2= root2.createPackageFragment("pack2", true, null); ICompilationUnit cu2= pack2.getCompilationUnit("B.java"); IType type2= cu2.createType("public class B extends pack1.A {\n}\n", null, true, null); ITypeHierarchy hierarchy= type2.newSupertypeHierarchy(null); IType[] allTypes= hierarchy.getAllTypes(); assertTrue("Should contain 3 types, contains: " + allTypes.length, allTypes.length == 3); IType type= fJavaProject2.findType("pack1.A"); assertTrue("Type not found", type != null); } }
43,228
Bug 43228 Encoding Support for Java editor broken
I20030916 This has been broken with the introduction of ExtendedTextEditor.
verified fixed
421e4eb
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2003-09-19T09:15:26Z
2003-09-17T17:33:20Z
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/JavaEditor.java
/******************************************************************************* * Copyright (c) 2000, 2003 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Common Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/cpl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.jdt.internal.ui.javaeditor; import java.text.CollationElementIterator; import java.text.Collator; import java.text.RuleBasedCollator; import java.util.ArrayList; import java.util.Iterator; import java.util.List; import java.util.ResourceBundle; import java.util.StringTokenizer; import org.eclipse.core.resources.IMarker; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.Platform; import org.eclipse.core.runtime.Preferences; import org.eclipse.swt.SWT; import org.eclipse.swt.custom.BidiSegmentEvent; import org.eclipse.swt.custom.BidiSegmentListener; import org.eclipse.swt.custom.ST; import org.eclipse.swt.custom.StyleRange; import org.eclipse.swt.custom.StyledText; import org.eclipse.swt.events.FocusEvent; import org.eclipse.swt.events.FocusListener; import org.eclipse.swt.events.KeyEvent; import org.eclipse.swt.events.KeyListener; import org.eclipse.swt.events.MouseEvent; import org.eclipse.swt.events.MouseListener; import org.eclipse.swt.events.MouseMoveListener; import org.eclipse.swt.events.PaintEvent; import org.eclipse.swt.events.PaintListener; import org.eclipse.swt.graphics.Color; import org.eclipse.swt.graphics.Cursor; import org.eclipse.swt.graphics.GC; import org.eclipse.swt.graphics.Image; import org.eclipse.swt.graphics.Point; import org.eclipse.swt.graphics.RGB; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Control; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Event; import org.eclipse.swt.widgets.Shell; import org.eclipse.jface.action.Action; import org.eclipse.jface.action.GroupMarker; import org.eclipse.jface.action.IAction; import org.eclipse.jface.action.IMenuManager; import org.eclipse.jface.action.IStatusLineManager; import org.eclipse.jface.action.Separator; import org.eclipse.jface.preference.IPreferenceStore; import org.eclipse.jface.preference.PreferenceConverter; import org.eclipse.jface.util.IPropertyChangeListener; import org.eclipse.jface.util.PropertyChangeEvent; import org.eclipse.jface.viewers.IPostSelectionProvider; import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.ISelectionChangedListener; import org.eclipse.jface.viewers.ISelectionProvider; import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.jface.viewers.SelectionChangedEvent; import org.eclipse.jface.viewers.StructuredSelection; import org.eclipse.jface.text.BadLocationException; import org.eclipse.jface.text.DefaultInformationControl; import org.eclipse.jface.text.DocumentEvent; import org.eclipse.jface.text.IDocument; import org.eclipse.jface.text.IDocumentListener; import org.eclipse.jface.text.IInformationControl; import org.eclipse.jface.text.IInformationControlCreator; import org.eclipse.jface.text.IRegion; import org.eclipse.jface.text.ITextHover; import org.eclipse.jface.text.ITextInputListener; import org.eclipse.jface.text.ITextSelection; import org.eclipse.jface.text.ITextViewer; import org.eclipse.jface.text.ITextViewerExtension2; import org.eclipse.jface.text.ITextViewerExtension3; import org.eclipse.jface.text.ITextViewerExtension4; import org.eclipse.jface.text.ITypedRegion; import org.eclipse.jface.text.Position; import org.eclipse.jface.text.Region; import org.eclipse.jface.text.TextSelection; import org.eclipse.jface.text.TextUtilities; import org.eclipse.jface.text.information.IInformationProvider; import org.eclipse.jface.text.information.IInformationProviderExtension2; import org.eclipse.jface.text.information.InformationPresenter; import org.eclipse.jface.text.source.Annotation; import org.eclipse.jface.text.source.IAnnotationAccess; import org.eclipse.jface.text.source.IAnnotationModel; import org.eclipse.jface.text.source.IOverviewRuler; import org.eclipse.jface.text.source.ISourceViewer; import org.eclipse.jface.text.source.IVerticalRuler; import org.eclipse.jface.text.source.LineChangeHover; import org.eclipse.jface.text.source.SourceViewerConfiguration; import org.eclipse.ui.IEditorActionBarContributor; import org.eclipse.ui.IEditorInput; import org.eclipse.ui.IPageLayout; import org.eclipse.ui.IPartService; import org.eclipse.ui.IViewPart; import org.eclipse.ui.IWorkbenchPage; import org.eclipse.ui.IWorkbenchPart; import org.eclipse.ui.IWorkbenchWindow; import org.eclipse.ui.actions.ActionContext; import org.eclipse.ui.actions.ActionGroup; import org.eclipse.ui.help.WorkbenchHelp; import org.eclipse.ui.part.EditorActionBarContributor; import org.eclipse.ui.part.IShowInTargetList; import org.eclipse.ui.texteditor.AddTaskAction; import org.eclipse.ui.texteditor.AnnotationPreference; import org.eclipse.ui.texteditor.DefaultMarkerAnnotationAccess; import org.eclipse.ui.texteditor.DefaultRangeIndicator; import org.eclipse.ui.texteditor.ExtendedTextEditor; import org.eclipse.ui.texteditor.IAbstractTextEditorHelpContextIds; import org.eclipse.ui.texteditor.IEditorStatusLine; import org.eclipse.ui.texteditor.ITextEditorActionConstants; import org.eclipse.ui.texteditor.ITextEditorActionDefinitionIds; import org.eclipse.ui.texteditor.MarkerAnnotation; import org.eclipse.ui.texteditor.MarkerAnnotationPreferences; import org.eclipse.ui.texteditor.ResourceAction; import org.eclipse.ui.texteditor.SourceViewerDecorationSupport; import org.eclipse.ui.texteditor.TextEditorAction; import org.eclipse.ui.texteditor.TextNavigationAction; import org.eclipse.ui.texteditor.TextOperationAction; import org.eclipse.ui.views.contentoutline.ContentOutline; import org.eclipse.ui.views.contentoutline.IContentOutlinePage; import org.eclipse.ui.views.tasklist.TaskList; import org.eclipse.jdt.core.IClassFile; import org.eclipse.jdt.core.ICodeAssist; import org.eclipse.jdt.core.ICompilationUnit; import org.eclipse.jdt.core.IImportContainer; import org.eclipse.jdt.core.IImportDeclaration; import org.eclipse.jdt.core.IJavaElement; import org.eclipse.jdt.core.IMember; import org.eclipse.jdt.core.IPackageDeclaration; import org.eclipse.jdt.core.ISourceRange; import org.eclipse.jdt.core.ISourceReference; import org.eclipse.jdt.core.JavaCore; import org.eclipse.jdt.core.JavaModelException; import org.eclipse.jdt.ui.IContextMenuConstants; import org.eclipse.jdt.ui.JavaUI; import org.eclipse.jdt.ui.PreferenceConstants; import org.eclipse.jdt.ui.actions.IJavaEditorActionDefinitionIds; import org.eclipse.jdt.ui.actions.JavaSearchActionGroup; import org.eclipse.jdt.ui.actions.OpenEditorActionGroup; import org.eclipse.jdt.ui.actions.OpenViewActionGroup; import org.eclipse.jdt.ui.actions.ShowActionGroup; import org.eclipse.jdt.ui.text.JavaSourceViewerConfiguration; import org.eclipse.jdt.ui.text.JavaTextTools; import org.eclipse.jdt.internal.ui.IJavaHelpContextIds; import org.eclipse.jdt.internal.ui.JavaPlugin; import org.eclipse.jdt.internal.ui.actions.CompositeActionGroup; import org.eclipse.jdt.internal.ui.actions.SelectionConverter; import org.eclipse.jdt.internal.ui.javaeditor.selectionactions.GoToNextPreviousMemberAction; import org.eclipse.jdt.internal.ui.javaeditor.selectionactions.SelectionHistory; import org.eclipse.jdt.internal.ui.javaeditor.selectionactions.StructureSelectEnclosingAction; import org.eclipse.jdt.internal.ui.javaeditor.selectionactions.StructureSelectHistoryAction; import org.eclipse.jdt.internal.ui.javaeditor.selectionactions.StructureSelectNextAction; import org.eclipse.jdt.internal.ui.javaeditor.selectionactions.StructureSelectPreviousAction; import org.eclipse.jdt.internal.ui.javaeditor.selectionactions.StructureSelectionAction; import org.eclipse.jdt.internal.ui.text.HTMLTextPresenter; import org.eclipse.jdt.internal.ui.text.IJavaPartitions; import org.eclipse.jdt.internal.ui.text.JavaChangeHover; import org.eclipse.jdt.internal.ui.text.JavaPairMatcher; import org.eclipse.jdt.internal.ui.util.JavaUIHelp; import org.eclipse.jdt.internal.ui.viewsupport.IViewPartInputProvider; /** * Java specific text editor. */ public abstract class JavaEditor extends ExtendedTextEditor implements IViewPartInputProvider { /** * Internal implementation class for a change listener. * @since 3.0 */ protected abstract class AbstractSelectionChangedListener implements ISelectionChangedListener { /** * Installs this selection changed listener with the given selection provider. If * the selection provider is a post selection provider, post selection changed * events are the preferred choice, otherwise normal selection changed events * are requested. * * @param selectionProvider */ public void install(ISelectionProvider selectionProvider) { if (selectionProvider == null) return; if (selectionProvider instanceof IPostSelectionProvider) { IPostSelectionProvider provider= (IPostSelectionProvider) selectionProvider; provider.addPostSelectionChangedListener(this); } else { selectionProvider.addSelectionChangedListener(this); } } /** * Removes this selection changed listener from the given selection provider. * * @param selectionProvider */ public void uninstall(ISelectionProvider selectionProvider) { if (selectionProvider == null) return; if (selectionProvider instanceof IPostSelectionProvider) { IPostSelectionProvider provider= (IPostSelectionProvider) selectionProvider; provider.removePostSelectionChangedListener(this); } else { selectionProvider.removeSelectionChangedListener(this); } } } /** * Updates the Java outline page selection and this editor's range indicator. * * @since 3.0 */ private class EditorSelectionChangedListener extends AbstractSelectionChangedListener { /* * @see org.eclipse.jface.viewers.ISelectionChangedListener#selectionChanged(org.eclipse.jface.viewers.SelectionChangedEvent) */ public void selectionChanged(SelectionChangedEvent event) { selectionChanged(); } public void selectionChanged() { ISourceReference element= computeHighlightRangeSourceReference(); synchronizeOutlinePage(element); setSelection(element, false); } } /** * Updates the selection in the editor's widget with the selection of the outline page. */ class OutlineSelectionChangedListener extends AbstractSelectionChangedListener { public void selectionChanged(SelectionChangedEvent event) { doSelectionChanged(event); } } /* * Link mode. */ class MouseClickListener implements KeyListener, MouseListener, MouseMoveListener, FocusListener, PaintListener, IPropertyChangeListener, IDocumentListener, ITextInputListener { /** The session is active. */ private boolean fActive; /** The currently active style range. */ private IRegion fActiveRegion; /** The currently active style range as position. */ private Position fRememberedPosition; /** The hand cursor. */ private Cursor fCursor; /** The link color. */ private Color fColor; /** The key modifier mask. */ private int fKeyModifierMask; public void deactivate() { deactivate(false); } public void deactivate(boolean redrawAll) { if (!fActive) return; repairRepresentation(redrawAll); fActive= false; } public void install() { ISourceViewer sourceViewer= getSourceViewer(); if (sourceViewer == null) return; StyledText text= sourceViewer.getTextWidget(); if (text == null || text.isDisposed()) return; updateColor(sourceViewer); sourceViewer.addTextInputListener(this); IDocument document= sourceViewer.getDocument(); if (document != null) document.addDocumentListener(this); text.addKeyListener(this); text.addMouseListener(this); text.addMouseMoveListener(this); text.addFocusListener(this); text.addPaintListener(this); updateKeyModifierMask(); IPreferenceStore preferenceStore= getPreferenceStore(); preferenceStore.addPropertyChangeListener(this); } private void updateKeyModifierMask() { String modifiers= getPreferenceStore().getString(BROWSER_LIKE_LINKS_KEY_MODIFIER); fKeyModifierMask= computeStateMask(modifiers); if (fKeyModifierMask == -1) { // Fallback to stored state mask fKeyModifierMask= getPreferenceStore().getInt(BROWSER_LIKE_LINKS_KEY_MODIFIER_MASK); } } private int computeStateMask(String modifiers) { if (modifiers == null) return -1; if (modifiers.length() == 0) return SWT.NONE; int stateMask= 0; StringTokenizer modifierTokenizer= new StringTokenizer(modifiers, ",;.:+-* "); //$NON-NLS-1$ while (modifierTokenizer.hasMoreTokens()) { int modifier= EditorUtility.findLocalizedModifier(modifierTokenizer.nextToken()); if (modifier == 0 || (stateMask & modifier) == modifier) return -1; stateMask= stateMask | modifier; } return stateMask; } public void uninstall() { if (fColor != null) { fColor.dispose(); fColor= null; } if (fCursor != null) { fCursor.dispose(); fCursor= null; } ISourceViewer sourceViewer= getSourceViewer(); if (sourceViewer == null) return; sourceViewer.removeTextInputListener(this); IDocument document= sourceViewer.getDocument(); if (document != null) document.removeDocumentListener(this); IPreferenceStore preferenceStore= getPreferenceStore(); if (preferenceStore != null) preferenceStore.removePropertyChangeListener(this); StyledText text= sourceViewer.getTextWidget(); if (text == null || text.isDisposed()) return; text.removeKeyListener(this); text.removeMouseListener(this); text.removeMouseMoveListener(this); text.removeFocusListener(this); text.removePaintListener(this); } /* * @see IPropertyChangeListener#propertyChange(PropertyChangeEvent) */ public void propertyChange(PropertyChangeEvent event) { if (event.getProperty().equals(JavaEditor.LINK_COLOR)) { ISourceViewer viewer= getSourceViewer(); if (viewer != null) updateColor(viewer); } else if (event.getProperty().equals(BROWSER_LIKE_LINKS_KEY_MODIFIER)) { updateKeyModifierMask(); } } private void updateColor(ISourceViewer viewer) { if (fColor != null) fColor.dispose(); StyledText text= viewer.getTextWidget(); if (text == null || text.isDisposed()) return; Display display= text.getDisplay(); fColor= createColor(getPreferenceStore(), JavaEditor.LINK_COLOR, display); } /** * Creates a color from the information stored in the given preference store. * Returns <code>null</code> if there is no such information available. */ private Color createColor(IPreferenceStore store, String key, Display display) { RGB rgb= null; if (store.contains(key)) { if (store.isDefault(key)) rgb= PreferenceConverter.getDefaultColor(store, key); else rgb= PreferenceConverter.getColor(store, key); if (rgb != null) return new Color(display, rgb); } return null; } private void repairRepresentation() { repairRepresentation(false); } private void repairRepresentation(boolean redrawAll) { if (fActiveRegion == null) return; ISourceViewer viewer= getSourceViewer(); if (viewer != null) { resetCursor(viewer); int offset= fActiveRegion.getOffset(); int length= fActiveRegion.getLength(); // remove style if (!redrawAll && viewer instanceof ITextViewerExtension2) ((ITextViewerExtension2) viewer).invalidateTextPresentation(offset, length); else viewer.invalidateTextPresentation(); // remove underline if (viewer instanceof ITextViewerExtension3) { ITextViewerExtension3 extension= (ITextViewerExtension3) viewer; offset= extension.modelOffset2WidgetOffset(offset); } else { offset -= viewer.getVisibleRegion().getOffset(); } StyledText text= viewer.getTextWidget(); try { text.redrawRange(offset, length, true); } catch (IllegalArgumentException x) { JavaPlugin.log(x); } } fActiveRegion= null; } // will eventually be replaced by a method provided by jdt.core private IRegion selectWord(IDocument document, int anchor) { try { int offset= anchor; char c; while (offset >= 0) { c= document.getChar(offset); if (!Character.isJavaIdentifierPart(c)) break; --offset; } int start= offset; offset= anchor; int length= document.getLength(); while (offset < length) { c= document.getChar(offset); if (!Character.isJavaIdentifierPart(c)) break; ++offset; } int end= offset; if (start == end) return new Region(start, 0); else return new Region(start + 1, end - start - 1); } catch (BadLocationException x) { return null; } } IRegion getCurrentTextRegion(ISourceViewer viewer) { int offset= getCurrentTextOffset(viewer); if (offset == -1) return null; IJavaElement input= SelectionConverter.getInput(JavaEditor.this); if (input == null) return null; try { IJavaElement[] elements= null; synchronized (input) { elements= ((ICodeAssist) input).codeSelect(offset, 0); } if (elements == null || elements.length == 0) return null; return selectWord(viewer.getDocument(), offset); } catch (JavaModelException e) { return null; } } private int getCurrentTextOffset(ISourceViewer viewer) { try { StyledText text= viewer.getTextWidget(); if (text == null || text.isDisposed()) return -1; Display display= text.getDisplay(); Point absolutePosition= display.getCursorLocation(); Point relativePosition= text.toControl(absolutePosition); int widgetOffset= text.getOffsetAtLocation(relativePosition); if (viewer instanceof ITextViewerExtension3) { ITextViewerExtension3 extension= (ITextViewerExtension3) viewer; return extension.widgetOffset2ModelOffset(widgetOffset); } else { return widgetOffset + viewer.getVisibleRegion().getOffset(); } } catch (IllegalArgumentException e) { return -1; } } private void highlightRegion(ISourceViewer viewer, IRegion region) { if (region.equals(fActiveRegion)) return; repairRepresentation(); StyledText text= viewer.getTextWidget(); if (text == null || text.isDisposed()) return; // highlight region int offset= 0; int length= 0; if (viewer instanceof ITextViewerExtension3) { ITextViewerExtension3 extension= (ITextViewerExtension3) viewer; IRegion widgetRange= extension.modelRange2WidgetRange(region); if (widgetRange == null) return; offset= widgetRange.getOffset(); length= widgetRange.getLength(); } else { offset= region.getOffset() - viewer.getVisibleRegion().getOffset(); length= region.getLength(); } StyleRange oldStyleRange= text.getStyleRangeAtOffset(offset); Color foregroundColor= fColor; Color backgroundColor= oldStyleRange == null ? text.getBackground() : oldStyleRange.background; int fontStyle= oldStyleRange== null ? SWT.NORMAL : oldStyleRange.fontStyle; StyleRange styleRange= new StyleRange(offset, length, foregroundColor, backgroundColor, fontStyle); text.setStyleRange(styleRange); // underline text.redrawRange(offset, length, true); fActiveRegion= region; } private void activateCursor(ISourceViewer viewer) { StyledText text= viewer.getTextWidget(); if (text == null || text.isDisposed()) return; Display display= text.getDisplay(); if (fCursor == null) fCursor= new Cursor(display, SWT.CURSOR_HAND); text.setCursor(fCursor); } private void resetCursor(ISourceViewer viewer) { StyledText text= viewer.getTextWidget(); if (text != null && !text.isDisposed()) text.setCursor(null); if (fCursor != null) { fCursor.dispose(); fCursor= null; } } /* * @see org.eclipse.swt.events.KeyListener#keyPressed(org.eclipse.swt.events.KeyEvent) */ public void keyPressed(KeyEvent event) { if (fActive) { deactivate(); return; } if (event.keyCode != fKeyModifierMask) { deactivate(); return; } fActive= true; // removed for #25871 // // ISourceViewer viewer= getSourceViewer(); // if (viewer == null) // return; // // IRegion region= getCurrentTextRegion(viewer); // if (region == null) // return; // // highlightRegion(viewer, region); // activateCursor(viewer); } /* * @see org.eclipse.swt.events.KeyListener#keyReleased(org.eclipse.swt.events.KeyEvent) */ public void keyReleased(KeyEvent event) { if (!fActive) return; deactivate(); } /* * @see org.eclipse.swt.events.MouseListener#mouseDoubleClick(org.eclipse.swt.events.MouseEvent) */ public void mouseDoubleClick(MouseEvent e) {} /* * @see org.eclipse.swt.events.MouseListener#mouseDown(org.eclipse.swt.events.MouseEvent) */ public void mouseDown(MouseEvent event) { if (!fActive) return; if (event.stateMask != fKeyModifierMask) { deactivate(); return; } if (event.button != 1) { deactivate(); return; } } /* * @see org.eclipse.swt.events.MouseListener#mouseUp(org.eclipse.swt.events.MouseEvent) */ public void mouseUp(MouseEvent e) { if (!fActive) return; if (e.button != 1) { deactivate(); return; } boolean wasActive= fCursor != null; deactivate(); if (wasActive) { IAction action= getAction("OpenEditor"); //$NON-NLS-1$ if (action != null) action.run(); } } /* * @see org.eclipse.swt.events.MouseMoveListener#mouseMove(org.eclipse.swt.events.MouseEvent) */ public void mouseMove(MouseEvent event) { if (event.widget instanceof Control && !((Control) event.widget).isFocusControl()) { deactivate(); return; } if (!fActive) { if (event.stateMask != fKeyModifierMask) return; // modifier was already pressed fActive= true; } ISourceViewer viewer= getSourceViewer(); if (viewer == null) { deactivate(); return; } StyledText text= viewer.getTextWidget(); if (text == null || text.isDisposed()) { deactivate(); return; } if ((event.stateMask & SWT.BUTTON1) != 0 && text.getSelectionCount() != 0) { deactivate(); return; } IRegion region= getCurrentTextRegion(viewer); if (region == null || region.getLength() == 0) { repairRepresentation(); return; } highlightRegion(viewer, region); activateCursor(viewer); } /* * @see org.eclipse.swt.events.FocusListener#focusGained(org.eclipse.swt.events.FocusEvent) */ public void focusGained(FocusEvent e) {} /* * @see org.eclipse.swt.events.FocusListener#focusLost(org.eclipse.swt.events.FocusEvent) */ public void focusLost(FocusEvent event) { deactivate(); } /* * @see org.eclipse.jface.text.IDocumentListener#documentAboutToBeChanged(org.eclipse.jface.text.DocumentEvent) */ public void documentAboutToBeChanged(DocumentEvent event) { if (fActive && fActiveRegion != null) { fRememberedPosition= new Position(fActiveRegion.getOffset(), fActiveRegion.getLength()); try { event.getDocument().addPosition(fRememberedPosition); } catch (BadLocationException x) { fRememberedPosition= null; } } } /* * @see org.eclipse.jface.text.IDocumentListener#documentChanged(org.eclipse.jface.text.DocumentEvent) */ public void documentChanged(DocumentEvent event) { if (fRememberedPosition != null && !fRememberedPosition.isDeleted()) { event.getDocument().removePosition(fRememberedPosition); fActiveRegion= new Region(fRememberedPosition.getOffset(), fRememberedPosition.getLength()); } fRememberedPosition= null; ISourceViewer viewer= getSourceViewer(); if (viewer != null) { StyledText widget= viewer.getTextWidget(); if (widget != null && !widget.isDisposed()) { widget.getDisplay().asyncExec(new Runnable() { public void run() { deactivate(); } }); } } } /* * @see org.eclipse.jface.text.ITextInputListener#inputDocumentAboutToBeChanged(org.eclipse.jface.text.IDocument, org.eclipse.jface.text.IDocument) */ public void inputDocumentAboutToBeChanged(IDocument oldInput, IDocument newInput) { if (oldInput == null) return; deactivate(); oldInput.removeDocumentListener(this); } /* * @see org.eclipse.jface.text.ITextInputListener#inputDocumentChanged(org.eclipse.jface.text.IDocument, org.eclipse.jface.text.IDocument) */ public void inputDocumentChanged(IDocument oldInput, IDocument newInput) { if (newInput == null) return; newInput.addDocumentListener(this); } /* * @see PaintListener#paintControl(PaintEvent) */ public void paintControl(PaintEvent event) { if (fActiveRegion == null) return; ISourceViewer viewer= getSourceViewer(); if (viewer == null) return; StyledText text= viewer.getTextWidget(); if (text == null || text.isDisposed()) return; int offset= 0; int length= 0; if (viewer instanceof ITextViewerExtension3) { ITextViewerExtension3 extension= (ITextViewerExtension3) viewer; IRegion widgetRange= extension.modelRange2WidgetRange(new Region(offset, length)); if (widgetRange == null) return; offset= widgetRange.getOffset(); length= widgetRange.getLength(); } else { IRegion region= viewer.getVisibleRegion(); if (!includes(region, fActiveRegion)) return; offset= fActiveRegion.getOffset() - region.getOffset(); length= fActiveRegion.getLength(); } // support for bidi Point minLocation= getMinimumLocation(text, offset, length); Point maxLocation= getMaximumLocation(text, offset, length); int x1= minLocation.x; int x2= minLocation.x + maxLocation.x - minLocation.x - 1; int y= minLocation.y + text.getLineHeight() - 1; GC gc= event.gc; if (fColor != null && !fColor.isDisposed()) gc.setForeground(fColor); gc.drawLine(x1, y, x2, y); } private boolean includes(IRegion region, IRegion position) { return position.getOffset() >= region.getOffset() && position.getOffset() + position.getLength() <= region.getOffset() + region.getLength(); } private Point getMinimumLocation(StyledText text, int offset, int length) { Point minLocation= new Point(Integer.MAX_VALUE, Integer.MAX_VALUE); for (int i= 0; i <= length; i++) { Point location= text.getLocationAtOffset(offset + i); if (location.x < minLocation.x) minLocation.x= location.x; if (location.y < minLocation.y) minLocation.y= location.y; } return minLocation; } private Point getMaximumLocation(StyledText text, int offset, int length) { Point maxLocation= new Point(Integer.MIN_VALUE, Integer.MIN_VALUE); for (int i= 0; i <= length; i++) { Point location= text.getLocationAtOffset(offset + i); if (location.x > maxLocation.x) maxLocation.x= location.x; if (location.y > maxLocation.y) maxLocation.y= location.y; } return maxLocation; } } /** * This action dispatches into two behaviours: If there is no current text * hover, the javadoc is displayed using information presenter. If there is * a current text hover, it is converted into a information presenter in * order to make it sticky. */ class InformationDispatchAction extends TextEditorAction { /** The wrapped text operation action. */ private final TextOperationAction fTextOperationAction; /** * Creates a dispatch action. */ public InformationDispatchAction(ResourceBundle resourceBundle, String prefix, final TextOperationAction textOperationAction) { super(resourceBundle, prefix, JavaEditor.this); if (textOperationAction == null) throw new IllegalArgumentException(); fTextOperationAction= textOperationAction; } /* * @see org.eclipse.jface.action.IAction#run() */ public void run() { /** * Information provider used to present the information. * * @since 3.0 */ class InformationProvider implements IInformationProvider, IInformationProviderExtension2 { private IRegion fHoverRegion; private String fHoverInfo; private IInformationControlCreator fControlCreator; InformationProvider(IRegion hoverRegion, String hoverInfo, IInformationControlCreator controlCreator) { fHoverRegion= hoverRegion; fHoverInfo= hoverInfo; fControlCreator= controlCreator; } /* * @see org.eclipse.jface.text.information.IInformationProvider#getSubject(org.eclipse.jface.text.ITextViewer, int) */ public IRegion getSubject(ITextViewer textViewer, int invocationOffset) { return fHoverRegion; } /* * @see org.eclipse.jface.text.information.IInformationProvider#getInformation(org.eclipse.jface.text.ITextViewer, org.eclipse.jface.text.IRegion) */ public String getInformation(ITextViewer textViewer, IRegion subject) { return fHoverInfo; } /* * @see org.eclipse.jface.text.information.IInformationProviderExtension2#getInformationPresenterControlCreator() * @since 3.0 */ public IInformationControlCreator getInformationPresenterControlCreator() { return fControlCreator; } } ISourceViewer sourceViewer= getSourceViewer(); if (sourceViewer == null) { fTextOperationAction.run(); return; } if (sourceViewer instanceof ITextViewerExtension4) { ITextViewerExtension4 extension4= (ITextViewerExtension4) sourceViewer; extension4.moveFocusToWidgetToken(); } if (! (sourceViewer instanceof ITextViewerExtension2)) { fTextOperationAction.run(); return; } ITextViewerExtension2 textViewerExtension2= (ITextViewerExtension2) sourceViewer; // does a text hover exist? ITextHover textHover= textViewerExtension2.getCurrentTextHover(); if (textHover == null) { fTextOperationAction.run(); return; } Point hoverEventLocation= textViewerExtension2.getHoverEventLocation(); int offset= computeOffsetAtLocation(sourceViewer, hoverEventLocation.x, hoverEventLocation.y); if (offset == -1) { fTextOperationAction.run(); return; } try { // get the text hover content String contentType= TextUtilities.getContentType(sourceViewer.getDocument(), IJavaPartitions.JAVA_PARTITIONING, offset); IRegion hoverRegion= textHover.getHoverRegion(sourceViewer, offset); if (hoverRegion == null) return; String hoverInfo= textHover.getHoverInfo(sourceViewer, hoverRegion); IInformationControlCreator controlCreator= null; if (textHover instanceof IInformationProviderExtension2) controlCreator= ((IInformationProviderExtension2)textHover).getInformationPresenterControlCreator(); IInformationProvider informationProvider= new InformationProvider(hoverRegion, hoverInfo, controlCreator); fInformationPresenter.setOffset(offset); fInformationPresenter.setInformationProvider(informationProvider, contentType); fInformationPresenter.showInformation(); } catch (BadLocationException e) { } } // modified version from TextViewer private int computeOffsetAtLocation(ITextViewer textViewer, int x, int y) { StyledText styledText= textViewer.getTextWidget(); IDocument document= textViewer.getDocument(); if (document == null) return -1; try { int widgetLocation= styledText.getOffsetAtLocation(new Point(x, y)); if (textViewer instanceof ITextViewerExtension3) { ITextViewerExtension3 extension= (ITextViewerExtension3) textViewer; return extension.widgetOffset2ModelOffset(widgetLocation); } else { IRegion visibleRegion= textViewer.getVisibleRegion(); return widgetLocation + visibleRegion.getOffset(); } } catch (IllegalArgumentException e) { return -1; } } } static protected class AnnotationAccess extends DefaultMarkerAnnotationAccess { public AnnotationAccess(MarkerAnnotationPreferences markerAnnotationPreferences) { super(markerAnnotationPreferences); } /* * @see org.eclipse.jface.text.source.IAnnotationAccess#getType(org.eclipse.jface.text.source.Annotation) */ public Object getType(Annotation annotation) { if (annotation instanceof IJavaAnnotation) { IJavaAnnotation javaAnnotation= (IJavaAnnotation) annotation; if (javaAnnotation.isRelevant()) return javaAnnotation.getAnnotationType(); } return null; } /* * @see org.eclipse.jface.text.source.IAnnotationAccess#isMultiLine(org.eclipse.jface.text.source.Annotation) */ public boolean isMultiLine(Annotation annotation) { return true; } /* * @see org.eclipse.jface.text.source.IAnnotationAccess#isTemporary(org.eclipse.jface.text.source.Annotation) */ public boolean isTemporary(Annotation annotation) { if (annotation instanceof IJavaAnnotation) { IJavaAnnotation javaAnnotation= (IJavaAnnotation) annotation; if (javaAnnotation.isRelevant()) return javaAnnotation.isTemporary(); } return false; } } private class PropertyChangeListener implements org.eclipse.core.runtime.Preferences.IPropertyChangeListener { /* * @see IPropertyChangeListener#propertyChange(PropertyChangeEvent) */ public void propertyChange(org.eclipse.core.runtime.Preferences.PropertyChangeEvent event) { handlePreferencePropertyChanged(event); } } /** * This action implements smart home. * * Instead of going to the start of a line it does the following: * * - if smart home/end is enabled and the caret is after the line's first non-whitespace then the caret is moved directly before it, taking JavaDoc and multi-line comments into account. * - if the caret is before the line's first non-whitespace the caret is moved to the beginning of the line * - if the caret is at the beginning of the line see first case. * * @since 3.0 */ protected class SmartLineStartAction extends LineStartAction { /** * Creates a new smart line start action * * @param textWidget the styled text widget * @param doSelect a boolean flag which tells if the text up to the beginning of the line should be selected */ public SmartLineStartAction(final StyledText textWidget, final boolean doSelect) { super(textWidget, doSelect); } /* * @see org.eclipse.ui.texteditor.AbstractTextEditor.LineStartAction#getLineStartPosition(java.lang.String, int, java.lang.String) */ protected int getLineStartPosition(final IDocument document, final String line, final int length, final int offset) { String type= IDocument.DEFAULT_CONTENT_TYPE; try { type= TextUtilities.getPartition(document, IJavaPartitions.JAVA_PARTITIONING, offset).getType(); } catch (BadLocationException exception) { // Should not happen } int index= super.getLineStartPosition(document, line, length, offset); if (type.equals(IJavaPartitions.JAVA_DOC) || type.equals(IJavaPartitions.JAVA_MULTI_LINE_COMMENT)) { if (index < length - 1 && line.charAt(index) == '*' && line.charAt(index + 1) != '/') { do { ++index; } while (index < length && Character.isWhitespace(line.charAt(index))); } } else { if (index < length - 1 && line.charAt(index) == '/' && line.charAt(++index) == '/') { do { ++index; } while (index < length && Character.isWhitespace(line.charAt(index))); } } return index; } } /** * Text navigation action to navigate to the next sub-word. * * @since 3.0 */ protected abstract class NextSubWordAction extends TextNavigationAction { /** Collator to determine the sub-word boundaries */ private final RuleBasedCollator fCollator= (RuleBasedCollator)Collator.getInstance(); /** * Creates a new next sub-word action. * * @param code Action code for the default operation. Must be an action code from @see org.eclipse.swt.custom.ST. */ protected NextSubWordAction(int code) { super(getSourceViewer().getTextWidget(), code); // Only compare upper-/lower case fCollator.setStrength(Collator.TERTIARY); } /* * @see org.eclipse.jface.action.IAction#run() */ public void run() { try { final ISourceViewer viewer= getSourceViewer(); final IDocument document= viewer.getDocument(); int position= widgetOffset2ModelOffset(viewer, viewer.getTextWidget().getCaretOffset()); // Check whether we are in a java code partititon and the preference is enabled final IPreferenceStore store= getPreferenceStore(); final ITypedRegion region= TextUtilities.getPartition(document, IJavaPartitions.JAVA_PARTITIONING, position); if (!store.getBoolean(PreferenceConstants.EDITOR_SUB_WORD_NAVIGATION)) { super.run(); return; } // Check whether right hand character of caret is valid identifier start if (Character.isJavaIdentifierStart(document.getChar(position))) { int offset= 0; int order= CollationElementIterator.NULLORDER; short previous= Short.MAX_VALUE; short next= Short.MAX_VALUE; // Acquire collator for partition around caret final String buffer= document.get(position, region.getOffset() + region.getLength() - position); final CollationElementIterator iterator= fCollator.getCollationElementIterator(buffer); // Iterate to first upper-case character do { // Check whether we reached end of word offset= iterator.getOffset(); if (!Character.isJavaIdentifierPart(document.getChar(position + offset))) throw new BadLocationException(); // Test next characters order= iterator.next(); next= CollationElementIterator.tertiaryOrder(order); if (next <= previous) previous= next; else break; } while (order != CollationElementIterator.NULLORDER); // Check for leading underscores position += offset; if (Character.getType(document.getChar(position - 1)) != Character.CONNECTOR_PUNCTUATION) { setCaretPosition(position); return; } } } catch (BadLocationException exception) { // Use default behavior } super.run(); } /** * Sets the caret position to the sub-word boundary given with <code>position</code>. * * @param position Position where the action should move the caret */ protected abstract void setCaretPosition(int position); } /** * Text navigation action to navigate to the next sub-word. * * @since 3.0 */ protected class NavigateNextSubWordAction extends NextSubWordAction { /** * Creates a new navigate next sub-word action. */ public NavigateNextSubWordAction() { super(ST.WORD_NEXT); } /* * @see org.eclipse.jdt.internal.ui.javaeditor.JavaEditor.NextSubWordAction#setCaretPosition(int) */ protected void setCaretPosition(final int position) { final ISourceViewer viewer= getSourceViewer(); viewer.getTextWidget().setCaretOffset(modelOffset2WidgetOffset(viewer, position)); } } /** * Text operation action to delete the next sub-word. * * @since 3.0 */ protected class DeleteNextSubWordAction extends NextSubWordAction { /** * Creates a new delete next sub-word action. */ public DeleteNextSubWordAction() { super(ST.DELETE_WORD_NEXT); } /* * @see org.eclipse.jdt.internal.ui.javaeditor.JavaEditor.NextSubWordAction#setCaretPosition(int) */ protected void setCaretPosition(final int position) { final ISourceViewer viewer= getSourceViewer(); final int caret= widgetOffset2ModelOffset(viewer, viewer.getTextWidget().getCaretOffset()); try { viewer.getDocument().replace(caret, position - caret, ""); //$NON-NLS-1$ } catch (BadLocationException exception) { // Should not happen } } } /** * Text operation action to select the next sub-word. * * @since 3.0 */ protected class SelectNextSubWordAction extends NextSubWordAction { /** * Creates a new select next sub-word action. */ public SelectNextSubWordAction() { super(ST.SELECT_WORD_NEXT); } /* * @see org.eclipse.jdt.internal.ui.javaeditor.JavaEditor.NextSubWordAction#setCaretPosition(int) */ protected void setCaretPosition(final int position) { final ISourceViewer viewer= getSourceViewer(); final StyledText text= viewer.getTextWidget(); if (text != null && !text.isDisposed()) { final Point selection= text.getSelection(); final int caret= text.getCaretOffset(); final int offset= modelOffset2WidgetOffset(viewer, position); if (caret == selection.x) text.setSelectionRange(selection.y, offset - selection.y); else text.setSelectionRange(selection.x, offset - selection.x); final Event event= new Event(); event.x= text.getSelection().x; event.y= text.getSelection().y; text.notifyListeners(SWT.Selection, event); } } } /** * Text navigation action to navigate to the previous sub-word. * * @since 3.0 */ protected abstract class PreviousSubWordAction extends TextNavigationAction { /** Collator to determine the sub-word boundaries */ private final RuleBasedCollator fCollator= (RuleBasedCollator)Collator.getInstance(); /** * Creates a new previous sub-word action. * * @param code Action code for the default operation. Must be an action code from @see org.eclipse.swt.custom.ST. */ protected PreviousSubWordAction(final int code) { super(getSourceViewer().getTextWidget(), code); // Only compare upper-/lower case fCollator.setStrength(Collator.TERTIARY); } /* * @see org.eclipse.jface.action.IAction#run() */ public void run() { try { final ISourceViewer viewer= getSourceViewer(); final IDocument document= viewer.getDocument(); int position= widgetOffset2ModelOffset(viewer, viewer.getTextWidget().getCaretOffset()) - 1; // Check whether we are in a java code partititon and the preference is enabled final IPreferenceStore store= getPreferenceStore(); if (!store.getBoolean(PreferenceConstants.EDITOR_SUB_WORD_NAVIGATION)) { super.run(); return; } // Ignore trailing white spaces char character= document.getChar(position); while (position > 0 && Character.isWhitespace(character)) { --position; character= document.getChar(position); } // Check whether left hand character of caret is valid identifier part if (Character.isJavaIdentifierPart(character)) { int offset= 0; int order= CollationElementIterator.NULLORDER; short previous= Short.MAX_VALUE; short next= Short.MAX_VALUE; // Acquire collator for partition around caret final ITypedRegion region= TextUtilities.getPartition(document, IJavaPartitions.JAVA_PARTITIONING, position); final String buffer= document.get(region.getOffset(), position - region.getOffset() + 1); final CollationElementIterator iterator= fCollator.getCollationElementIterator(buffer); // Iterate to first upper-case character iterator.setOffset(buffer.length() - 1); do { // Check whether we reached begin of word or single upper-case start offset= iterator.getOffset(); character= document.getChar(region.getOffset() + offset); if (!Character.isJavaIdentifierPart(character)) throw new BadLocationException(); else if (Character.isUpperCase(character)) { ++offset; break; } // Test next characters order= iterator.previous(); next= CollationElementIterator.tertiaryOrder(order); if (next <= previous) previous= next; else break; } while (order != CollationElementIterator.NULLORDER); // Check left character for multiple upper-case characters position= position - buffer.length() + offset - 1; character= document.getChar(position); while (position >= 0 && Character.isUpperCase(character)) character= document.getChar(--position); setCaretPosition(position + 1); return; } } catch (BadLocationException exception) { // Use default behavior } super.run(); } /** * Sets the caret position to the sub-word boundary given with <code>position</code>. * * @param position Position where the action should move the caret */ protected abstract void setCaretPosition(int position); } /** * Text navigation action to navigate to the previous sub-word. * * @since 3.0 */ protected class NavigatePreviousSubWordAction extends PreviousSubWordAction { /** * Creates a new navigate previous sub-word action. */ public NavigatePreviousSubWordAction() { super(ST.WORD_PREVIOUS); } /* * @see org.eclipse.jdt.internal.ui.javaeditor.JavaEditor.PreviousSubWordAction#setCaretPosition(int) */ protected void setCaretPosition(final int position) { final ISourceViewer viewer= getSourceViewer(); viewer.getTextWidget().setCaretOffset(modelOffset2WidgetOffset(viewer, position)); } } /** * Text operation action to delete the previous sub-word. * * @since 3.0 */ protected class DeletePreviousSubWordAction extends PreviousSubWordAction { /** * Creates a new delete previous sub-word action. */ public DeletePreviousSubWordAction() { super(ST.DELETE_WORD_PREVIOUS); } /* * @see org.eclipse.jdt.internal.ui.javaeditor.JavaEditor.PreviousSubWordAction#setCaretPosition(int) */ protected void setCaretPosition(final int position) { final ISourceViewer viewer= getSourceViewer(); final int caret= widgetOffset2ModelOffset(viewer, viewer.getTextWidget().getCaretOffset()); try { viewer.getDocument().replace(position, caret - position, ""); //$NON-NLS-1$ } catch (BadLocationException exception) { // Should not happen } } } /** * Text operation action to select the previous sub-word. * * @since 3.0 */ protected class SelectPreviousSubWordAction extends PreviousSubWordAction { /** * Creates a new select previous sub-word action. */ public SelectPreviousSubWordAction() { super(ST.SELECT_WORD_PREVIOUS); } /* * @see org.eclipse.jdt.internal.ui.javaeditor.JavaEditor.PreviousSubWordAction#setCaretPosition(int) */ protected void setCaretPosition(final int position) { final ISourceViewer viewer= getSourceViewer(); final StyledText text= viewer.getTextWidget(); if (text != null && !text.isDisposed()) { final Point selection= text.getSelection(); final int caret= text.getCaretOffset(); final int offset= modelOffset2WidgetOffset(viewer, position); if (caret == selection.x) text.setSelectionRange(selection.y, offset - selection.y); else text.setSelectionRange(selection.x, offset - selection.x); final Event event= new Event(); event.x= text.getSelection().x; event.y= text.getSelection().y; text.notifyListeners(SWT.Selection, event); } } } /** * Quick format action to format the enclosing java element. * * @since 3.0 */ protected class QuickFormatAction extends Action { /** * Formats the range of the source viewer document. * * @param viewer The source viewer to operate on * @param offset The offset of the range to be formatted * @param length The length of the range to be formatted * @param normalize <code>true</code> iff the region should be block normalized, <code>false</code> otherwise */ protected void format(final JavaSourceViewer viewer, int offset, int length, boolean normalize) { final IDocument document= viewer.getDocument(); final Point selection= viewer.getSelectedRange(); viewer.saveSelection(selection.x, selection.y); if (normalize) { try { final ITypedRegion region= TextUtilities.getPartition(document, IJavaPartitions.JAVA_PARTITIONING, offset); if (region.getType() != IDocument.DEFAULT_CONTENT_TYPE) { final int delta= region.getOffset() + region.getLength() - offset + 2; offset += delta; length -= delta; } final IRegion line= document.getLineInformationOfOffset(offset); final int delta= offset - line.getOffset(); offset -= delta; length += delta; } catch (BadLocationException exception) { // Should not happen } } viewer.setSelectedRange(offset, length); viewer.doOperation(ISourceViewer.FORMAT); viewer.restoreSelection(); } /* * @see org.eclipse.jface.action.IAction#run() */ public void run() { final JavaSourceViewer viewer= (JavaSourceViewer)getSourceViewer(); if (viewer.isEditable()) { final IDocument document= viewer.getDocument(); final Point selection= viewer.getSelectedRange(); try { if (selection.y == 0) { final String type= TextUtilities.getContentType(document, IJavaPartitions.JAVA_PARTITIONING, selection.x); if (type.equals(IJavaPartitions.JAVA_DOC) || type.equals(IJavaPartitions.JAVA_MULTI_LINE_COMMENT) || type.equals(IJavaPartitions.JAVA_SINGLE_LINE_COMMENT)) { final ITypedRegion partition= TextUtilities.getPartition(document, IJavaPartitions.JAVA_PARTITIONING, selection.x); format(viewer, partition.getOffset(), partition.getLength(), false); } else if (type.equals(IDocument.DEFAULT_CONTENT_TYPE)) { try { final IJavaElement element= getElementAt(selection.x, true); if (element != null && element.exists()) { ISourceRange range= null; final int kind= element.getElementType(); if (kind == IJavaElement.TYPE || kind == IJavaElement.METHOD || kind == IJavaElement.INITIALIZER) { final ISourceReference reference= (ISourceReference)element; range= reference.getSourceRange(); } if (range != null) format(viewer, range.getOffset(), range.getLength(), true); } } catch (JavaModelException exception) { // Should not happen } } } else format(viewer, selection.x, selection.y, true); } catch (BadLocationException exception) { // Should not happen } } } } /** Preference key for the link color */ protected final static String LINK_COLOR= PreferenceConstants.EDITOR_LINK_COLOR; /** Preference key for matching brackets */ protected final static String MATCHING_BRACKETS= PreferenceConstants.EDITOR_MATCHING_BRACKETS; /** Preference key for matching brackets color */ protected final static String MATCHING_BRACKETS_COLOR= PreferenceConstants.EDITOR_MATCHING_BRACKETS_COLOR; /** Preference key for compiler task tags */ private final static String COMPILER_TASK_TAGS= JavaCore.COMPILER_TASK_TAGS; /** Preference key for browser like links */ private final static String BROWSER_LIKE_LINKS= PreferenceConstants.EDITOR_BROWSER_LIKE_LINKS; /** Preference key for key modifier of browser like links */ private final static String BROWSER_LIKE_LINKS_KEY_MODIFIER= PreferenceConstants.EDITOR_BROWSER_LIKE_LINKS_KEY_MODIFIER; /** * Preference key for key modifier mask of browser like links. * The value is only used if the value of <code>EDITOR_BROWSER_LIKE_LINKS</code> * cannot be resolved to valid SWT modifier bits. * * @since 2.1.1 */ private final static String BROWSER_LIKE_LINKS_KEY_MODIFIER_MASK= PreferenceConstants.EDITOR_BROWSER_LIKE_LINKS_KEY_MODIFIER_MASK; protected final static char[] BRACKETS= { '{', '}', '(', ')', '[', ']' }; /** The outline page */ protected JavaOutlinePage fOutlinePage; /** Outliner context menu Id */ protected String fOutlinerContextMenuId; /** * The editor selection changed listener. * * @since 3.0 */ private EditorSelectionChangedListener fEditorSelectionChangedListener; /** The selection changed listener */ protected AbstractSelectionChangedListener fOutlineSelectionChangedListener= new OutlineSelectionChangedListener(); /** The editor's bracket matcher */ protected JavaPairMatcher fBracketMatcher= new JavaPairMatcher(BRACKETS); /** The mouse listener */ private MouseClickListener fMouseListener; /** The information presenter. */ private InformationPresenter fInformationPresenter; /** History for structure select action */ private SelectionHistory fSelectionHistory; /** The preference property change listener for java core. */ private org.eclipse.core.runtime.Preferences.IPropertyChangeListener fPropertyChangeListener= new PropertyChangeListener(); protected CompositeActionGroup fActionGroups; private CompositeActionGroup fContextMenuGroup; /** * Returns the most narrow java element including the given offset. * * @param offset the offset inside of the requested element * @return the most narrow java element */ abstract protected IJavaElement getElementAt(int offset); /** * Returns the java element of this editor's input corresponding to the given IJavaElement */ abstract protected IJavaElement getCorrespondingElement(IJavaElement element); /** * Sets the input of the editor's outline page. */ abstract protected void setOutlinePageInput(JavaOutlinePage page, IEditorInput input); /** * Default constructor. */ public JavaEditor() { super(); JavaTextTools textTools= JavaPlugin.getDefault().getJavaTextTools(); setSourceViewerConfiguration(new JavaSourceViewerConfiguration(textTools, this, IJavaPartitions.JAVA_PARTITIONING)); setRangeIndicator(new DefaultRangeIndicator()); setPreferenceStore(JavaPlugin.getDefault().getPreferenceStore()); setKeyBindingScopes(new String[] { "org.eclipse.jdt.ui.javaEditorScope" }); //$NON-NLS-1$ } /* * @see AbstractTextEditor#createSourceViewer(Composite, IVerticalRuler, int) */ protected final ISourceViewer createSourceViewer(Composite parent, IVerticalRuler verticalRuler, int styles) { ISourceViewer viewer= createJavaSourceViewer(parent, verticalRuler, getOverviewRuler(), isOverviewRulerVisible(), styles); StyledText text= viewer.getTextWidget(); text.addBidiSegmentListener(new BidiSegmentListener() { public void lineGetSegments(BidiSegmentEvent event) { event.segments= getBidiLineSegments(event.lineOffset, event.lineText); } }); JavaUIHelp.setHelp(this, text, IJavaHelpContextIds.JAVA_EDITOR); // ensure source viewer decoration support has been created and configured getSourceViewerDecorationSupport(viewer); return viewer; } /* * @see org.eclipse.ui.texteditor.ExtendedTextEditor#createAnnotationAccess() */ protected IAnnotationAccess createAnnotationAccess() { return new AnnotationAccess(new MarkerAnnotationPreferences()); } public final ISourceViewer getViewer() { return getSourceViewer(); } /* * @see AbstractTextEditor#createSourceViewer(Composite, IVerticalRuler, int) */ protected ISourceViewer createJavaSourceViewer(Composite parent, IVerticalRuler verticalRuler, IOverviewRuler overviewRuler, boolean isOverviewRulerVisible, int styles) { return new JavaSourceViewer(parent, verticalRuler, getOverviewRuler(), isOverviewRulerVisible(), styles); } /* * @see AbstractTextEditor#affectsTextPresentation(PropertyChangeEvent) */ protected boolean affectsTextPresentation(PropertyChangeEvent event) { JavaTextTools textTools= JavaPlugin.getDefault().getJavaTextTools(); return textTools.affectsBehavior(event); } /** * Sets the outliner's context menu ID. */ protected void setOutlinerContextMenuId(String menuId) { fOutlinerContextMenuId= menuId; } /** * Returns the standard action group of this editor. */ protected ActionGroup getActionGroup() { return fActionGroups; } /* * @see AbstractTextEditor#editorContextMenuAboutToShow */ public void editorContextMenuAboutToShow(IMenuManager menu) { super.editorContextMenuAboutToShow(menu); menu.appendToGroup(ITextEditorActionConstants.GROUP_UNDO, new Separator(IContextMenuConstants.GROUP_OPEN)); menu.insertAfter(IContextMenuConstants.GROUP_OPEN, new GroupMarker(IContextMenuConstants.GROUP_SHOW)); ActionContext context= new ActionContext(getSelectionProvider().getSelection()); fContextMenuGroup.setContext(context); fContextMenuGroup.fillContextMenu(menu); fContextMenuGroup.setContext(null); } /** * Creates the outline page used with this editor. */ protected JavaOutlinePage createOutlinePage() { JavaOutlinePage page= new JavaOutlinePage(fOutlinerContextMenuId, this); fOutlineSelectionChangedListener.install(page); setOutlinePageInput(page, getEditorInput()); return page; } /** * Informs the editor that its outliner has been closed. */ public void outlinePageClosed() { if (fOutlinePage != null) { fOutlineSelectionChangedListener.uninstall(fOutlinePage); fOutlinePage= null; resetHighlightRange(); } } /** * Synchronizes the outliner selection with the given element * position in the editor. * * @param element the java element to select */ protected void synchronizeOutlinePage(ISourceReference element) { synchronizeOutlinePage(element, true); } /** * Synchronizes the outliner selection with the given element * position in the editor. * * @param element the java element to select * @param checkIfOutlinePageActive <code>true</code> if check for active outline page needs to be done */ protected void synchronizeOutlinePage(ISourceReference element, boolean checkIfOutlinePageActive) { if (fOutlinePage != null && element != null && !(checkIfOutlinePageActive && isJavaOutlinePageActive())) { fOutlineSelectionChangedListener.uninstall(fOutlinePage); fOutlinePage.select(element); fOutlineSelectionChangedListener.install(fOutlinePage); } } /** * Synchronizes the outliner selection with the actual cursor * position in the editor. */ public void synchronizeOutlinePageSelection() { synchronizeOutlinePage(computeHighlightRangeSourceReference()); } /* * Get the desktop's StatusLineManager */ protected IStatusLineManager getStatusLineManager() { IEditorActionBarContributor contributor= getEditorSite().getActionBarContributor(); if (contributor instanceof EditorActionBarContributor) { return ((EditorActionBarContributor) contributor).getActionBars().getStatusLineManager(); } return null; } /* * @see AbstractTextEditor#getAdapter(Class) */ public Object getAdapter(Class required) { if (IContentOutlinePage.class.equals(required)) { if (fOutlinePage == null) fOutlinePage= createOutlinePage(); return fOutlinePage; } if (required == IShowInTargetList.class) { return new IShowInTargetList() { public String[] getShowInTargetIds() { return new String[] { JavaUI.ID_PACKAGES, IPageLayout.ID_OUTLINE, IPageLayout.ID_RES_NAV }; } }; } return super.getAdapter(required); } protected void setSelection(ISourceReference reference, boolean moveCursor) { ISelection selection= getSelectionProvider().getSelection(); if (selection instanceof TextSelection) { TextSelection textSelection= (TextSelection) selection; // PR 39995: [navigation] Forward history cleared after going back in navigation history: // mark only in navigation history if the cursor is being moved (which it isn't if // this is called from a PostSelectionEvent that should only update the magnet) if (moveCursor && (textSelection.getOffset() != 0 || textSelection.getLength() != 0)) markInNavigationHistory(); } if (reference != null) { StyledText textWidget= null; ISourceViewer sourceViewer= getSourceViewer(); if (sourceViewer != null) textWidget= sourceViewer.getTextWidget(); if (textWidget == null) return; try { ISourceRange range= reference.getSourceRange(); if (range == null) return; int offset= range.getOffset(); int length= range.getLength(); if (offset < 0 || length < 0) return; setHighlightRange(offset, length, moveCursor); if (!moveCursor) return; offset= -1; length= -1; if (reference instanceof IMember) { range= ((IMember) reference).getNameRange(); if (range != null) { offset= range.getOffset(); length= range.getLength(); } } else if (reference instanceof IImportDeclaration) { String name= ((IImportDeclaration) reference).getElementName(); if (name != null && name.length() > 0) { String content= reference.getSource(); if (content != null) { offset= range.getOffset() + content.indexOf(name); length= name.length(); } } } else if (reference instanceof IPackageDeclaration) { String name= ((IPackageDeclaration) reference).getElementName(); if (name != null && name.length() > 0) { String content= reference.getSource(); if (content != null) { offset= range.getOffset() + content.indexOf(name); length= name.length(); } } } if (offset > -1 && length > 0) { try { textWidget.setRedraw(false); sourceViewer.revealRange(offset, length); sourceViewer.setSelectedRange(offset, length); } finally { textWidget.setRedraw(true); } markInNavigationHistory(); } } catch (JavaModelException x) { } catch (IllegalArgumentException x) { } } else if (moveCursor) { resetHighlightRange(); markInNavigationHistory(); } } public void setSelection(IJavaElement element) { if (element == null || element instanceof ICompilationUnit || element instanceof IClassFile) { /* * If the element is an ICompilationUnit this unit is either the input * of this editor or not being displayed. In both cases, nothing should * happened. (http://dev.eclipse.org/bugs/show_bug.cgi?id=5128) */ return; } IJavaElement corresponding= getCorrespondingElement(element); if (corresponding instanceof ISourceReference) { ISourceReference reference= (ISourceReference) corresponding; // set hightlight range setSelection(reference, true); // set outliner selection if (fOutlinePage != null) { fOutlineSelectionChangedListener.uninstall(fOutlinePage); fOutlinePage.select(reference); fOutlineSelectionChangedListener.install(fOutlinePage); } } } protected void doSelectionChanged(SelectionChangedEvent event) { ISourceReference reference= null; ISelection selection= event.getSelection(); Iterator iter= ((IStructuredSelection) selection).iterator(); while (iter.hasNext()) { Object o= iter.next(); if (o instanceof ISourceReference) { reference= (ISourceReference) o; break; } } if (!isActivePart() && JavaPlugin.getActivePage() != null) JavaPlugin.getActivePage().bringToTop(this); setSelection(reference, !isActivePart()); } /* * @see AbstractTextEditor#adjustHighlightRange(int, int) */ protected void adjustHighlightRange(int offset, int length) { try { IJavaElement element= getElementAt(offset); while (element instanceof ISourceReference) { ISourceRange range= ((ISourceReference) element).getSourceRange(); if (offset < range.getOffset() + range.getLength() && range.getOffset() < offset + length) { setHighlightRange(range.getOffset(), range.getLength(), true); if (fOutlinePage != null) { fOutlineSelectionChangedListener.uninstall(fOutlinePage); fOutlinePage.select((ISourceReference) element); fOutlineSelectionChangedListener.install(fOutlinePage); } return; } element= element.getParent(); } } catch (JavaModelException x) { JavaPlugin.log(x.getStatus()); } resetHighlightRange(); } protected boolean isActivePart() { IWorkbenchPart part= getActivePart(); return part != null && part.equals(this); } private boolean isJavaOutlinePageActive() { IWorkbenchPart part= getActivePart(); return part instanceof ContentOutline && ((ContentOutline)part).getCurrentPage() == fOutlinePage; } private IWorkbenchPart getActivePart() { IWorkbenchWindow window= getSite().getWorkbenchWindow(); IPartService service= window.getPartService(); IWorkbenchPart part= service.getActivePart(); return part; } /* * @see AbstractTextEditor#doSetInput */ protected void doSetInput(IEditorInput input) throws CoreException { super.doSetInput(input); setOutlinePageInput(fOutlinePage, input); } /* * @see IWorkbenchPart#dispose() */ public void dispose() { if (isBrowserLikeLinks()) disableBrowserLikeLinks(); if (fPropertyChangeListener != null) { Preferences preferences= JavaCore.getPlugin().getPluginPreferences(); preferences.removePropertyChangeListener(fPropertyChangeListener); fPropertyChangeListener= null; } if (fBracketMatcher != null) { fBracketMatcher.dispose(); fBracketMatcher= null; } if (fSelectionHistory != null) { fSelectionHistory.dispose(); fSelectionHistory= null; } if (fEditorSelectionChangedListener != null) { fEditorSelectionChangedListener.uninstall(getSelectionProvider()); fEditorSelectionChangedListener= null; } super.dispose(); } protected void createActions() { super.createActions(); ResourceAction resAction= new AddTaskAction(JavaEditorMessages.getResourceBundle(), "AddTask.", this); //$NON-NLS-1$ resAction.setHelpContextId(IAbstractTextEditorHelpContextIds.ADD_TASK_ACTION); resAction.setActionDefinitionId(ITextEditorActionDefinitionIds.ADD_TASK); setAction(ITextEditorActionConstants.ADD_TASK, resAction); ActionGroup oeg, ovg, jsg, sg; fActionGroups= new CompositeActionGroup(new ActionGroup[] { oeg= new OpenEditorActionGroup(this), sg= new ShowActionGroup(this), ovg= new OpenViewActionGroup(this), jsg= new JavaSearchActionGroup(this) }); fContextMenuGroup= new CompositeActionGroup(new ActionGroup[] {oeg, ovg, sg, jsg}); resAction= new TextOperationAction(JavaEditorMessages.getResourceBundle(), "ShowJavaDoc.", this, ISourceViewer.INFORMATION, true); //$NON-NLS-1$ resAction= new InformationDispatchAction(JavaEditorMessages.getResourceBundle(), "ShowJavaDoc.", (TextOperationAction) resAction); //$NON-NLS-1$ resAction.setActionDefinitionId(IJavaEditorActionDefinitionIds.SHOW_JAVADOC); setAction("ShowJavaDoc", resAction); //$NON-NLS-1$ WorkbenchHelp.setHelp(resAction, IJavaHelpContextIds.SHOW_JAVADOC_ACTION); Action action= new GotoMatchingBracketAction(this); action.setActionDefinitionId(IJavaEditorActionDefinitionIds.GOTO_MATCHING_BRACKET); setAction(GotoMatchingBracketAction.GOTO_MATCHING_BRACKET, action); action= new TextOperationAction(JavaEditorMessages.getResourceBundle(),"ShowOutline.", this, JavaSourceViewer.SHOW_OUTLINE, true); //$NON-NLS-1$ action.setActionDefinitionId(IJavaEditorActionDefinitionIds.SHOW_OUTLINE); setAction(IJavaEditorActionDefinitionIds.SHOW_OUTLINE, action); WorkbenchHelp.setHelp(action, IJavaHelpContextIds.SHOW_OUTLINE_ACTION); action= new TextOperationAction(JavaEditorMessages.getResourceBundle(),"OpenStructure.", this, JavaSourceViewer.OPEN_STRUCTURE, true); //$NON-NLS-1$ action.setActionDefinitionId(IJavaEditorActionDefinitionIds.OPEN_STRUCTURE); setAction(IJavaEditorActionDefinitionIds.OPEN_STRUCTURE, action); WorkbenchHelp.setHelp(action, IJavaHelpContextIds.OPEN_STRUCTURE_ACTION); action= new TextOperationAction(JavaEditorMessages.getResourceBundle(),"OpenHierarchy.", this, JavaSourceViewer.SHOW_HIERARCHY, true); //$NON-NLS-1$ action.setActionDefinitionId(IJavaEditorActionDefinitionIds.OPEN_HIERARCHY); setAction(IJavaEditorActionDefinitionIds.OPEN_HIERARCHY, action); WorkbenchHelp.setHelp(action, IJavaHelpContextIds.OPEN_HIERARCHY_ACTION); fSelectionHistory= new SelectionHistory(this); action= new StructureSelectEnclosingAction(this, fSelectionHistory); action.setActionDefinitionId(IJavaEditorActionDefinitionIds.SELECT_ENCLOSING); setAction(StructureSelectionAction.ENCLOSING, action); action= new StructureSelectNextAction(this, fSelectionHistory); action.setActionDefinitionId(IJavaEditorActionDefinitionIds.SELECT_NEXT); setAction(StructureSelectionAction.NEXT, action); action= new StructureSelectPreviousAction(this, fSelectionHistory); action.setActionDefinitionId(IJavaEditorActionDefinitionIds.SELECT_PREVIOUS); setAction(StructureSelectionAction.PREVIOUS, action); StructureSelectHistoryAction historyAction= new StructureSelectHistoryAction(this, fSelectionHistory); historyAction.setActionDefinitionId(IJavaEditorActionDefinitionIds.SELECT_LAST); setAction(StructureSelectionAction.HISTORY, historyAction); fSelectionHistory.setHistoryAction(historyAction); action= GoToNextPreviousMemberAction.newGoToNextMemberAction(this); action.setActionDefinitionId(IJavaEditorActionDefinitionIds.GOTO_NEXT_MEMBER); setAction(GoToNextPreviousMemberAction.NEXT_MEMBER, action); action= GoToNextPreviousMemberAction.newGoToPreviousMemberAction(this); action.setActionDefinitionId(IJavaEditorActionDefinitionIds.GOTO_PREVIOUS_MEMBER); setAction(GoToNextPreviousMemberAction.PREVIOUS_MEMBER, action); action= new QuickFormatAction(); action.setActionDefinitionId(IJavaEditorActionDefinitionIds.QUICK_FORMAT); setAction(IJavaEditorActionDefinitionIds.QUICK_FORMAT, action); } public void updatedTitleImage(Image image) { setTitleImage(image); } /* * @see AbstractTextEditor#handlePreferenceStoreChanged(PropertyChangeEvent) */ protected void handlePreferenceStoreChanged(PropertyChangeEvent event) { try { ISourceViewer sourceViewer= getSourceViewer(); if (sourceViewer == null) return; String property= event.getProperty(); if (PreferenceConstants.EDITOR_TAB_WIDTH.equals(property)) { Object value= event.getNewValue(); if (value instanceof Integer) { sourceViewer.getTextWidget().setTabs(((Integer) value).intValue()); } else if (value instanceof String) { sourceViewer.getTextWidget().setTabs(Integer.parseInt((String) value)); } return; } if (isJavaEditorHoverProperty(property)) updateHoverBehavior(); if (BROWSER_LIKE_LINKS.equals(property)) { if (isBrowserLikeLinks()) enableBrowserLikeLinks(); else disableBrowserLikeLinks(); return; } if (PreferenceConstants.EDITOR_SYNC_OUTLINE_ON_CURSOR_MOVE.equals(property)) { if ((event.getNewValue() instanceof Boolean) && ((Boolean)event.getNewValue()).booleanValue()) { fEditorSelectionChangedListener= new EditorSelectionChangedListener(); fEditorSelectionChangedListener.install(getSelectionProvider()); fEditorSelectionChangedListener.selectionChanged(); } else { fEditorSelectionChangedListener.uninstall(getSelectionProvider()); fEditorSelectionChangedListener= null; } return; } if (PreferenceConstants.EDITOR_DISABLE_OVERWRITE_MODE.equals(property)) { if (event.getNewValue() instanceof Boolean) { Boolean disable= (Boolean) event.getNewValue(); configureInsertMode(OVERWRITE, !disable.booleanValue()); } } } finally { super.handlePreferenceStoreChanged(event); } } private boolean isJavaEditorHoverProperty(String property) { return PreferenceConstants.EDITOR_TEXT_HOVER_MODIFIERS.equals(property); } /** * Return whether the browser like links should be enabled * according to the preference store settings. * @return <code>true</code> if the browser like links should be enabled */ private boolean isBrowserLikeLinks() { IPreferenceStore store= getPreferenceStore(); return store.getBoolean(BROWSER_LIKE_LINKS); } /** * Enables browser like links. */ private void enableBrowserLikeLinks() { if (fMouseListener == null) { fMouseListener= new MouseClickListener(); fMouseListener.install(); } } /** * Disables browser like links. */ private void disableBrowserLikeLinks() { if (fMouseListener != null) { fMouseListener.uninstall(); fMouseListener= null; } } /** * Handles a property change event describing a change * of the java core's preferences and updates the preference * related editor properties. * * @param event the property change event */ protected void handlePreferencePropertyChanged(org.eclipse.core.runtime.Preferences.PropertyChangeEvent event) { if (COMPILER_TASK_TAGS.equals(event.getProperty())) { ISourceViewer sourceViewer= getSourceViewer(); if (sourceViewer != null && affectsTextPresentation(new PropertyChangeEvent(event.getSource(), event.getProperty(), event.getOldValue(), event.getNewValue()))) sourceViewer.invalidateTextPresentation(); } } /** * Returns a segmentation of the line of the given viewer's input document appropriate for * bidi rendering. The default implementation returns only the string literals of a java code * line as segments. * * @param viewer the text viewer * @param lineOffset the offset of the line * @return the line's bidi segmentation * @throws BadLocationException in case lineOffset is not valid in document */ public static int[] getBidiLineSegments(ITextViewer viewer, int lineOffset) throws BadLocationException { IDocument document= viewer.getDocument(); if (document == null) return null; IRegion line= document.getLineInformationOfOffset(lineOffset); ITypedRegion[] linePartitioning= TextUtilities.computePartitioning(document, IJavaPartitions.JAVA_PARTITIONING, lineOffset, line.getLength()); List segmentation= new ArrayList(); for (int i= 0; i < linePartitioning.length; i++) { if (IJavaPartitions.JAVA_STRING.equals(linePartitioning[i].getType())) segmentation.add(linePartitioning[i]); } if (segmentation.size() == 0) return null; int size= segmentation.size(); int[] segments= new int[size * 2 + 1]; int j= 0; for (int i= 0; i < size; i++) { ITypedRegion segment= (ITypedRegion) segmentation.get(i); if (i == 0) segments[j++]= 0; int offset= segment.getOffset() - lineOffset; if (offset > segments[j - 1]) segments[j++]= offset; if (offset + segment.getLength() >= line.getLength()) break; segments[j++]= offset + segment.getLength(); } if (j < segments.length) { int[] result= new int[j]; System.arraycopy(segments, 0, result, 0, j); segments= result; } return segments; } /** * Returns a segmentation of the given line appropriate for bidi rendering. The default * implementation returns only the string literals of a java code line as segments. * * @param lineOffset the offset of the line * @param line the content of the line * @return the line's bidi segmentation */ protected int[] getBidiLineSegments(int widgetLineOffset, String line) { if (line != null && line.length() > 0) { ISourceViewer sourceViewer= getSourceViewer(); if (sourceViewer != null) { int lineOffset; if (sourceViewer instanceof ITextViewerExtension3) { ITextViewerExtension3 extension= (ITextViewerExtension3) sourceViewer; lineOffset= extension.widgetOffset2ModelOffset(widgetLineOffset); } else { IRegion visible= sourceViewer.getVisibleRegion(); lineOffset= visible.getOffset() + widgetLineOffset; } try { return getBidiLineSegments(sourceViewer, lineOffset); } catch (BadLocationException x) { // don't segment line in this case } } } return null; } /* * Update the hovering behavior depending on the preferences. */ private void updateHoverBehavior() { SourceViewerConfiguration configuration= getSourceViewerConfiguration(); String[] types= configuration.getConfiguredContentTypes(getSourceViewer()); for (int i= 0; i < types.length; i++) { String t= types[i]; ISourceViewer sourceViewer= getSourceViewer(); if (sourceViewer instanceof ITextViewerExtension2) { // Remove existing hovers ((ITextViewerExtension2)sourceViewer).removeTextHovers(t); int[] stateMasks= configuration.getConfiguredTextHoverStateMasks(getSourceViewer(), t); if (stateMasks != null) { for (int j= 0; j < stateMasks.length; j++) { int stateMask= stateMasks[j]; ITextHover textHover= configuration.getTextHover(sourceViewer, t, stateMask); ((ITextViewerExtension2)sourceViewer).setTextHover(textHover, t, stateMask); } } else { ITextHover textHover= configuration.getTextHover(sourceViewer, t); ((ITextViewerExtension2)sourceViewer).setTextHover(textHover, t, ITextViewerExtension2.DEFAULT_HOVER_STATE_MASK); } } else sourceViewer.setTextHover(configuration.getTextHover(sourceViewer, t), t); } } /* * @see org.eclipse.jdt.internal.ui.viewsupport.IViewPartInputProvider#getViewPartInput() */ public Object getViewPartInput() { return getEditorInput().getAdapter(IJavaElement.class); } /* * @see org.eclipse.ui.texteditor.AbstractTextEditor#doSetSelection(ISelection) */ protected void doSetSelection(ISelection selection) { super.doSetSelection(selection); synchronizeOutlinePageSelection(); } /* * @see org.eclipse.ui.IWorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite) */ public void createPartControl(Composite parent) { super.createPartControl(parent); Preferences preferences= JavaCore.getPlugin().getPluginPreferences(); preferences.addPropertyChangeListener(fPropertyChangeListener); IInformationControlCreator informationControlCreator= new IInformationControlCreator() { public IInformationControl createInformationControl(Shell shell) { boolean cutDown= false; int style= cutDown ? SWT.NONE : (SWT.V_SCROLL | SWT.H_SCROLL); return new DefaultInformationControl(shell, SWT.RESIZE, style, new HTMLTextPresenter(cutDown)); } }; fInformationPresenter= new InformationPresenter(informationControlCreator); fInformationPresenter.setSizeConstraints(60, 10, true, true); fInformationPresenter.install(getSourceViewer()); if (PreferenceConstants.getPreferenceStore().getBoolean(PreferenceConstants.EDITOR_SYNC_OUTLINE_ON_CURSOR_MOVE)) { fEditorSelectionChangedListener= new EditorSelectionChangedListener(); fEditorSelectionChangedListener.install(getSelectionProvider()); } if (isBrowserLikeLinks()) enableBrowserLikeLinks(); if (PreferenceConstants.getPreferenceStore().getBoolean(PreferenceConstants.EDITOR_DISABLE_OVERWRITE_MODE)) configureInsertMode(OVERWRITE, false); } protected void configureSourceViewerDecorationSupport(SourceViewerDecorationSupport support) { support.setCharacterPairMatcher(fBracketMatcher); support.setMatchingCharacterPainterPreferenceKeys(MATCHING_BRACKETS, MATCHING_BRACKETS_COLOR); super.configureSourceViewerDecorationSupport(support); } /** * Jumps to the next enabled annotation according to the given direction. * An annotation type is enabled if it is configured to be in the * Next/Previous tool bar drop down menu and if it is checked. */ public void gotoAnnotation(boolean forward) { ISelectionProvider provider= getSelectionProvider(); ITextSelection s= (ITextSelection) provider.getSelection(); Position annotationPosition= new Position(0, 0); IJavaAnnotation nextAnnotation= getNextAnnotation(s.getOffset(), s.getLength(),forward, annotationPosition); setStatusLineErrorMessage(null); if (nextAnnotation != null) { IMarker marker= null; if (nextAnnotation instanceof MarkerAnnotation) marker= ((MarkerAnnotation) nextAnnotation).getMarker(); else { Iterator e= nextAnnotation.getOverlaidIterator(); if (e != null) { while (e.hasNext()) { Object o= e.next(); if (o instanceof MarkerAnnotation) { marker= ((MarkerAnnotation) o).getMarker(); break; } } } } if (marker != null) { IWorkbenchPage page= getSite().getPage(); IViewPart view= view= page.findView("org.eclipse.ui.views.TaskList"); //$NON-NLS-1$ if (view instanceof TaskList) { StructuredSelection ss= new StructuredSelection(marker); ((TaskList) view).setSelection(ss, true); } } selectAndReveal(annotationPosition.getOffset(), annotationPosition.getLength()); if (nextAnnotation.isProblem()) setStatusLineErrorMessage(nextAnnotation.getMessage()); } } /** * Jumps to the matching bracket. */ public void gotoMatchingBracket() { ISourceViewer sourceViewer= getSourceViewer(); IDocument document= sourceViewer.getDocument(); if (document == null) return; IRegion selection= getSignedSelection(sourceViewer); int selectionLength= Math.abs(selection.getLength()); if (selectionLength > 1) { setStatusLineErrorMessage(JavaEditorMessages.getString("GotoMatchingBracket.error.invalidSelection")); //$NON-NLS-1$ sourceViewer.getTextWidget().getDisplay().beep(); return; } // #26314 int sourceCaretOffset= selection.getOffset() + selection.getLength(); if (isSurroundedByBrackets(document, sourceCaretOffset)) sourceCaretOffset -= selection.getLength(); IRegion region= fBracketMatcher.match(document, sourceCaretOffset); if (region == null) { setStatusLineErrorMessage(JavaEditorMessages.getString("GotoMatchingBracket.error.noMatchingBracket")); //$NON-NLS-1$ sourceViewer.getTextWidget().getDisplay().beep(); return; } int offset= region.getOffset(); int length= region.getLength(); if (length < 1) return; int anchor= fBracketMatcher.getAnchor(); // http://dev.eclipse.org/bugs/show_bug.cgi?id=34195 int targetOffset= (JavaPairMatcher.RIGHT == anchor) ? offset + 1: offset + length; boolean visible= false; if (sourceViewer instanceof ITextViewerExtension3) { ITextViewerExtension3 extension= (ITextViewerExtension3) sourceViewer; visible= (extension.modelOffset2WidgetOffset(targetOffset) > -1); } else { IRegion visibleRegion= sourceViewer.getVisibleRegion(); // http://dev.eclipse.org/bugs/show_bug.cgi?id=34195 visible= (targetOffset >= visibleRegion.getOffset() && targetOffset <= visibleRegion.getOffset() + visibleRegion.getLength()); } if (!visible) { setStatusLineErrorMessage(JavaEditorMessages.getString("GotoMatchingBracket.error.bracketOutsideSelectedElement")); //$NON-NLS-1$ sourceViewer.getTextWidget().getDisplay().beep(); return; } if (selection.getLength() < 0) targetOffset -= selection.getLength(); sourceViewer.setSelectedRange(targetOffset, selection.getLength()); sourceViewer.revealRange(targetOffset, selection.getLength()); } /** * Ses the given message as error message to this editor's status line. * @param msg message to be set */ protected void setStatusLineErrorMessage(String msg) { IEditorStatusLine statusLine= (IEditorStatusLine) getAdapter(IEditorStatusLine.class); if (statusLine != null) statusLine.setMessage(true, msg, null); } private static IRegion getSignedSelection(ITextViewer viewer) { StyledText text= viewer.getTextWidget(); int caretOffset= text.getCaretOffset(); Point selection= text.getSelection(); // caret left int offset, length; if (caretOffset == selection.x) { offset= selection.y; length= selection.x - selection.y; // caret right } else { offset= selection.x; length= selection.y - selection.x; } return new Region(offset, length); } private static boolean isBracket(char character) { for (int i= 0; i != BRACKETS.length; ++i) if (character == BRACKETS[i]) return true; return false; } private static boolean isSurroundedByBrackets(IDocument document, int offset) { if (offset == 0 || offset == document.getLength()) return false; try { return isBracket(document.getChar(offset - 1)) && isBracket(document.getChar(offset)); } catch (BadLocationException e) { return false; } } private IJavaAnnotation getNextAnnotation(int offset, int length, boolean forward, Position annotationPosition) { IJavaAnnotation nextAnnotation= null; Position nextAnnotationPosition= null; IJavaAnnotation containingAnnotation= null; Position containingAnnotationPosition= null; boolean currentAnnotation= false; IDocument document= getDocumentProvider().getDocument(getEditorInput()); int endOfDocument= document.getLength(); int distance= 0; IAnnotationModel model= getDocumentProvider().getAnnotationModel(getEditorInput()); Iterator e= new JavaAnnotationIterator(model, true); while (e.hasNext()) { IJavaAnnotation a= (IJavaAnnotation) e.next(); Preferences workbenchTextEditorPrefStore= Platform.getPlugin("org.eclipse.ui.workbench.texteditor").getPluginPreferences(); //$NON-NLS-1$ Iterator iter= getAnnotationPreferences().getAnnotationPreferences().iterator(); boolean isNavigationTarget= false; while (iter.hasNext()) { AnnotationPreference annotationPref= (AnnotationPreference)iter.next(); if (annotationPref.getAnnotationType().equals(a.getAnnotationType())) { String key; /* * Fixes bug 41689 * This code can be simplified if we decide that * we don't allow to use different settings for go to * previous and go to next annotation. */ key= annotationPref.getIsGoToNextNavigationTargetKey(); // if (forward) // key= annotationPref.getIsGoToNextNavigationTargetKey(); // else // key= annotationPref.getIsGoToPreviousNavigationTargetKey(); if (key != null) isNavigationTarget= workbenchTextEditorPrefStore.getBoolean(key); break; } annotationPref= null; } if (a.hasOverlay() || !isNavigationTarget) continue; Position p= model.getPosition((Annotation) a); if (!(p.includes(offset) || (p.getLength() == 0 && offset == p.offset))) { int currentDistance= 0; if (forward) { currentDistance= p.getOffset() - offset; if (currentDistance < 0) currentDistance= endOfDocument - offset + p.getOffset(); } else { currentDistance= offset - p.getOffset(); if (currentDistance < 0) currentDistance= offset + endOfDocument - p.getOffset(); } if (nextAnnotation == null || currentDistance < distance) { distance= currentDistance; nextAnnotation= a; nextAnnotationPosition= p; } } else { if (containingAnnotationPosition == null || containingAnnotationPosition.length > p.length) { containingAnnotation= a; containingAnnotationPosition= p; if (length == p.length) currentAnnotation= true; } } } if (containingAnnotationPosition != null && (!currentAnnotation || nextAnnotation == null)) { annotationPosition.setOffset(containingAnnotationPosition.getOffset()); annotationPosition.setLength(containingAnnotationPosition.getLength()); return containingAnnotation; } if (nextAnnotationPosition != null) { annotationPosition.setOffset(nextAnnotationPosition.getOffset()); annotationPosition.setLength(nextAnnotationPosition.getLength()); } return nextAnnotation; } /** * Computes and returns the source reference that includes the caret and * serves as provider for the outline page selection and the editor range * indication. * * @return the computed source reference * @since 3.0 */ protected ISourceReference computeHighlightRangeSourceReference() { ISourceViewer sourceViewer= getSourceViewer(); if (sourceViewer == null) return null; StyledText styledText= sourceViewer.getTextWidget(); if (styledText == null) return null; int caret= 0; if (sourceViewer instanceof ITextViewerExtension3) { ITextViewerExtension3 extension= (ITextViewerExtension3)sourceViewer; caret= extension.widgetOffset2ModelOffset(styledText.getCaretOffset()); } else { int offset= sourceViewer.getVisibleRegion().getOffset(); caret= offset + styledText.getCaretOffset(); } IJavaElement element= getElementAt(caret, false); if ( !(element instanceof ISourceReference)) return null; if (element.getElementType() == IJavaElement.IMPORT_DECLARATION) { IImportDeclaration declaration= (IImportDeclaration) element; IImportContainer container= (IImportContainer) declaration.getParent(); ISourceRange srcRange= null; try { srcRange= container.getSourceRange(); } catch (JavaModelException e) { } if (srcRange != null && srcRange.getOffset() == caret) return container; } return (ISourceReference) element; } /** * Returns the most narrow java element including the given offset. * * @param offset the offset inside of the requested element * @param reconcile <code>true</code> if editor input should be reconciled in advance * @return the most narrow java element * @since 3.0 */ protected IJavaElement getElementAt(int offset, boolean reconcile) { return getElementAt(offset); } /* * @see org.eclipse.ui.texteditor.ExtendedTextEditor#createChangeHover() */ protected LineChangeHover createChangeHover() { return new JavaChangeHover(IJavaPartitions.JAVA_PARTITIONING); } protected boolean isPrefQuickDiffAlwaysOn() { return false; // never show change ruler for the non-editable java editor. Overridden in subclasses like CompilationUnitEditor } /* * @see org.eclipse.ui.texteditor.AbstractTextEditor#createNavigationActions() */ protected void createNavigationActions() { super.createNavigationActions(); final StyledText textWidget= getSourceViewer().getTextWidget(); IAction action= new SmartLineStartAction(textWidget, false); action.setActionDefinitionId(ITextEditorActionDefinitionIds.LINE_START); setAction(ITextEditorActionDefinitionIds.LINE_START, action); action= new SmartLineStartAction(textWidget, true); action.setActionDefinitionId(ITextEditorActionDefinitionIds.SELECT_LINE_START); setAction(ITextEditorActionDefinitionIds.SELECT_LINE_START, action); action= new NavigatePreviousSubWordAction(); action.setActionDefinitionId(ITextEditorActionDefinitionIds.WORD_PREVIOUS); setAction(ITextEditorActionDefinitionIds.WORD_PREVIOUS, action); textWidget.setKeyBinding(SWT.CTRL | SWT.ARROW_LEFT, SWT.NULL); action= new NavigateNextSubWordAction(); action.setActionDefinitionId(ITextEditorActionDefinitionIds.WORD_NEXT); setAction(ITextEditorActionDefinitionIds.WORD_NEXT, action); textWidget.setKeyBinding(SWT.CTRL | SWT.ARROW_RIGHT, SWT.NULL); action= new DeletePreviousSubWordAction(); action.setActionDefinitionId(ITextEditorActionDefinitionIds.DELETE_PREVIOUS_WORD); setAction(ITextEditorActionDefinitionIds.DELETE_PREVIOUS_WORD, action); textWidget.setKeyBinding(SWT.CTRL | SWT.BS, SWT.NULL); action= new DeleteNextSubWordAction(); action.setActionDefinitionId(ITextEditorActionDefinitionIds.DELETE_NEXT_WORD); setAction(ITextEditorActionDefinitionIds.DELETE_NEXT_WORD, action); textWidget.setKeyBinding(SWT.CTRL | SWT.DEL, SWT.NULL); action= new SelectPreviousSubWordAction(); action.setActionDefinitionId(ITextEditorActionDefinitionIds.SELECT_WORD_PREVIOUS); setAction(ITextEditorActionDefinitionIds.SELECT_WORD_PREVIOUS, action); textWidget.setKeyBinding(SWT.CTRL | SWT.SHIFT | SWT.ARROW_LEFT, SWT.NULL); action= new SelectNextSubWordAction(); action.setActionDefinitionId(ITextEditorActionDefinitionIds.SELECT_WORD_NEXT); setAction(ITextEditorActionDefinitionIds.SELECT_WORD_NEXT, action); textWidget.setKeyBinding(SWT.CTRL | SWT.SHIFT | SWT.ARROW_RIGHT, SWT.NULL); } }
43,352
Bug 43352 IBuffer not line delimiter aware
20030919 The buffer adapter provided from org.eclipse.core.filebuffers nomalizes all text coming from IBuffer.append, IBuffer.replace and IBuffer.setContents to ensure line delimiter consistency. When working copies are created IBuffer.setContents is used what leads to the normalization of the whole source content. This is not wanted, only new text should be normalized. See test case PrimaryWorkingCopyTest.testLineDelimiterConsistency2 Suggestion is to - either add a new method setRawContent that does not normalize or - make IBuffer line delimiter aware: All client should first normalize what they want to insert or replace. A method IBuffer.normalize() could offer this. An extended request would be to also add the rest of line tracking methods to IBuffer: As offered by IDocument int getLineOfOffset(int offset) int getLineOffset(int line) int getLineLength(int line) IRegion getLineInformation(int line) IRegion getLineInformationOfOffset(int offset) int getNumberOfLines() String[] getLegalLineDelimiters() (all line delimiters in the document) String getLineDelimiter(int line) To implement this, the ILineTracker of org.eclipse.text can be used (but only created on demand).
resolved fixed
41088f5
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2003-09-19T13:53:03Z
2003-09-19T14:00:00Z
org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/core/PrimaryWorkingCopyTest.java
/******************************************************************************* * Copyright (c) 2000, 2003 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Common Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/cpl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.jdt.ui.tests.core; import java.util.List; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.eclipse.jdt.testplugin.JavaProjectHelper; import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.jface.text.IDocument; import org.eclipse.ui.IEditorPart; import org.eclipse.jdt.core.ICompilationUnit; import org.eclipse.jdt.core.IJavaProject; import org.eclipse.jdt.core.IPackageFragment; import org.eclipse.jdt.core.IPackageFragmentRoot; import org.eclipse.jdt.core.IWorkingCopy; import org.eclipse.jdt.core.JavaModelException; import org.eclipse.jdt.core.search.IJavaSearchConstants; import org.eclipse.jdt.core.search.IJavaSearchScope; import org.eclipse.jdt.core.search.SearchEngine; import org.eclipse.jdt.ui.JavaUI; import org.eclipse.jdt.internal.corext.refactoring.SearchResultCollector; import org.eclipse.jdt.internal.ui.JavaPlugin; import org.eclipse.jdt.internal.ui.javaeditor.EditorUtility; public class PrimaryWorkingCopyTest extends TestCase { private static final Class THIS= PrimaryWorkingCopyTest.class; private IJavaProject fJavaProject1; public PrimaryWorkingCopyTest(String name) { super(name); } public static Test allTests() { return new ProjectTestSetup(new TestSuite(THIS)); } public static Test suite() { if (true) { return allTests(); } else { TestSuite suite= new TestSuite(); suite.addTest(new AllTypesCacheTest("testHierarchyWithWorkingCopy")); return suite; } } protected void setUp() throws Exception { fJavaProject1= ProjectTestSetup.getProject(); } protected void tearDown() throws Exception { JavaProjectHelper.clear(fJavaProject1, ProjectTestSetup.getDefaultClasspath()); } public void testSearchInWorkingCopies() throws Exception { IPackageFragmentRoot root1= JavaProjectHelper.addSourceContainer(fJavaProject1, "src"); IPackageFragment pack1= root1.createPackageFragment("pack1", true, null); StringBuffer buf= new StringBuffer(); buf.append("public class A {\n"); buf.append("}\n"); ICompilationUnit cu1= pack1.getCompilationUnit("A.java"); cu1.createType(buf.toString(), null, true, null); buf= new StringBuffer(); buf.append("public class B {\n"); buf.append(" A a;\n"); buf.append("}\n"); ICompilationUnit cu2= pack1.getCompilationUnit("B.java"); cu2.createType(buf.toString(), null, true, null); IPackageFragment pack2= root1.createPackageFragment("pack2", true, null); buf= new StringBuffer(); buf.append("public class C {\n"); buf.append(" //Here\n"); buf.append("}\n"); ICompilationUnit cu3= pack2.getCompilationUnit("C.java"); cu3.createType(buf.toString(), null, true, null); // empty array when USE_WORKING_COPY_OWNERS is true IWorkingCopy[] workingCopies= JavaUI.getSharedWorkingCopiesOnClasspath(); List result= doSearchForReferences("A", JavaUI.getSharedWorkingCopiesOnClasspath()); assertTrue("Should contain 1 references, contains: " + result.size(), result.size() == 1); IEditorPart part= EditorUtility.openInEditor(cu3); try { IDocument document= JavaUI.getDocumentProvider().getDocument(part.getEditorInput()); String replacedString= "//Here"; int offset= document.search(0, replacedString, true, true, false); document.replace(offset, replacedString.length(), "A a;"); workingCopies= JavaUI.getSharedWorkingCopiesOnClasspath(); result= doSearchForReferences("A", workingCopies); assertTrue("Should contain 2 references, contains: " + result.size(), result.size() == 2); //save part.doSave(null); workingCopies= JavaUI.getSharedWorkingCopiesOnClasspath(); result= doSearchForReferences("A", workingCopies); assertTrue("Should contain 2 references, contains: " + result.size(), result.size() == 2); } finally { JavaPlugin.getActivePage().closeAllEditors(false); } workingCopies= JavaUI.getSharedWorkingCopiesOnClasspath(); result= doSearchForReferences("A", workingCopies); assertTrue("Should contain 2 references, contains: " + result.size(), result.size() == 2); } public void testSearchInWorkingCopies2() throws Exception { IPackageFragmentRoot root1= JavaProjectHelper.addSourceContainer(fJavaProject1, "src"); IPackageFragment pack1= root1.createPackageFragment("pack1", true, null); StringBuffer buf= new StringBuffer(); buf.append("public class A {\n"); buf.append("}\n"); ICompilationUnit cu1= pack1.getCompilationUnit("A.java"); cu1.createType(buf.toString(), null, true, null); buf= new StringBuffer(); buf.append("public class B {\n"); buf.append(" A a;\n"); buf.append("}\n"); ICompilationUnit cu2= pack1.getCompilationUnit("B.java"); cu2.createType(buf.toString(), null, true, null); IPackageFragment pack2= root1.createPackageFragment("pack2", true, null); buf= new StringBuffer(); buf.append("public class C {\n"); buf.append(" //Here\n"); buf.append("}\n"); ICompilationUnit cu3= pack2.getCompilationUnit("C.java"); cu3.createType(buf.toString(), null, true, null); // empty array when USE_WORKING_COPY_OWNERS is true IWorkingCopy[] workingCopies= JavaUI.getSharedWorkingCopiesOnClasspath(); List result= doSearchForReferences("A", workingCopies); assertTrue("Should contain 1 references, contains: " + result.size(), result.size() == 1); IEditorPart part= EditorUtility.openInEditor(cu3); try { IDocument document= JavaUI.getDocumentProvider().getDocument(part.getEditorInput()); String replacedString= "//Here"; int offset= document.search(0, replacedString, true, true, false); document.replace(offset, replacedString.length(), "A a;"); workingCopies= JavaUI.getSharedWorkingCopiesOnClasspath(); result= doSearchForReferences("A", workingCopies); assertTrue("Should contain 2 references, contains: " + result.size(), result.size() == 2); ICompilationUnit wcopy= (ICompilationUnit) cu2.getWorkingCopy(); // create sand box working copy try { String source= wcopy.getSource(); replacedString= "A a;"; offset= source.indexOf(replacedString); source= source.substring(0, offset) + source.substring(offset + replacedString.length()); // remove reference wcopy.getBuffer().setContents(source); workingCopies= JavaUI.getSharedWorkingCopiesOnClasspath(); IWorkingCopy[] newWorkingCopies= new IWorkingCopy[workingCopies.length + 1]; System.arraycopy(workingCopies, 0, newWorkingCopies, 0, workingCopies.length); newWorkingCopies[workingCopies.length]= wcopy; result= doSearchForReferences("A", newWorkingCopies); assertTrue("Should contain 1 references, contains: " + result.size(), result.size() == 1); // no save } finally { wcopy.destroy(); } } finally { JavaPlugin.getActivePage().closeAllEditors(false); } workingCopies= JavaUI.getSharedWorkingCopiesOnClasspath(); result= doSearchForReferences("A", workingCopies); assertTrue("Should contain 1 references, contains: " + result.size(), result.size() == 1); } private static boolean BUG_43300= true; private List doSearchForReferences(String ref, IWorkingCopy[] workingCopies) throws JavaModelException { SearchEngine engine= new SearchEngine(workingCopies); if (BUG_43300 && workingCopies.length == 0) { engine= new SearchEngine(); } IJavaSearchScope scope= SearchEngine.createWorkspaceScope(); SearchResultCollector collector= new SearchResultCollector(null); engine.search(ResourcesPlugin.getWorkspace(), ref, IJavaSearchConstants.TYPE, IJavaSearchConstants.REFERENCES, scope, collector); return collector.getResults(); } }
41,241
Bug 41241 enhance 'move static' to handle member types [refactoring]
I20030806 - create class package p1; public class A { static class Inner { } public void foo() { Inner inner= null; } } - select Inner in outliner and move it to p2.C observe: - this doesn't seem to be a refactoring since the files stay unsave and there isn't any undo - no references are updated - I can't move the Inner class into another class. Only into a CU.
verified fixed
3f5bef3
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2003-09-22T09:26:09Z
2003-08-07T09:53:20Z
org.eclipse.jdt.ui.tests.refactoring/resources/MoveMembers/test36/in/A.java
41,241
Bug 41241 enhance 'move static' to handle member types [refactoring]
I20030806 - create class package p1; public class A { static class Inner { } public void foo() { Inner inner= null; } } - select Inner in outliner and move it to p2.C observe: - this doesn't seem to be a refactoring since the files stay unsave and there isn't any undo - no references are updated - I can't move the Inner class into another class. Only into a CU.
verified fixed
3f5bef3
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2003-09-22T09:26:09Z
2003-08-07T09:53:20Z
org.eclipse.jdt.ui.tests.refactoring/resources/MoveMembers/test36/in/B.java
41,241
Bug 41241 enhance 'move static' to handle member types [refactoring]
I20030806 - create class package p1; public class A { static class Inner { } public void foo() { Inner inner= null; } } - select Inner in outliner and move it to p2.C observe: - this doesn't seem to be a refactoring since the files stay unsave and there isn't any undo - no references are updated - I can't move the Inner class into another class. Only into a CU.
verified fixed
3f5bef3
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2003-09-22T09:26:09Z
2003-08-07T09:53:20Z
org.eclipse.jdt.ui.tests.refactoring/resources/MoveMembers/test36/out/A.java
41,241
Bug 41241 enhance 'move static' to handle member types [refactoring]
I20030806 - create class package p1; public class A { static class Inner { } public void foo() { Inner inner= null; } } - select Inner in outliner and move it to p2.C observe: - this doesn't seem to be a refactoring since the files stay unsave and there isn't any undo - no references are updated - I can't move the Inner class into another class. Only into a CU.
verified fixed
3f5bef3
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2003-09-22T09:26:09Z
2003-08-07T09:53:20Z
org.eclipse.jdt.ui.tests.refactoring/resources/MoveMembers/test36/out/B.java
41,241
Bug 41241 enhance 'move static' to handle member types [refactoring]
I20030806 - create class package p1; public class A { static class Inner { } public void foo() { Inner inner= null; } } - select Inner in outliner and move it to p2.C observe: - this doesn't seem to be a refactoring since the files stay unsave and there isn't any undo - no references are updated - I can't move the Inner class into another class. Only into a CU.
verified fixed
3f5bef3
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2003-09-22T09:26:09Z
2003-08-07T09:53:20Z
org.eclipse.jdt.ui.tests.refactoring/resources/MoveMembers/test37/in/A.java
41,241
Bug 41241 enhance 'move static' to handle member types [refactoring]
I20030806 - create class package p1; public class A { static class Inner { } public void foo() { Inner inner= null; } } - select Inner in outliner and move it to p2.C observe: - this doesn't seem to be a refactoring since the files stay unsave and there isn't any undo - no references are updated - I can't move the Inner class into another class. Only into a CU.
verified fixed
3f5bef3
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2003-09-22T09:26:09Z
2003-08-07T09:53:20Z
org.eclipse.jdt.ui.tests.refactoring/resources/MoveMembers/test37/in/B.java
41,241
Bug 41241 enhance 'move static' to handle member types [refactoring]
I20030806 - create class package p1; public class A { static class Inner { } public void foo() { Inner inner= null; } } - select Inner in outliner and move it to p2.C observe: - this doesn't seem to be a refactoring since the files stay unsave and there isn't any undo - no references are updated - I can't move the Inner class into another class. Only into a CU.
verified fixed
3f5bef3
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2003-09-22T09:26:09Z
2003-08-07T09:53:20Z
org.eclipse.jdt.ui.tests.refactoring/resources/MoveMembers/test37/out/A.java
41,241
Bug 41241 enhance 'move static' to handle member types [refactoring]
I20030806 - create class package p1; public class A { static class Inner { } public void foo() { Inner inner= null; } } - select Inner in outliner and move it to p2.C observe: - this doesn't seem to be a refactoring since the files stay unsave and there isn't any undo - no references are updated - I can't move the Inner class into another class. Only into a CU.
verified fixed
3f5bef3
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2003-09-22T09:26:09Z
2003-08-07T09:53:20Z
org.eclipse.jdt.ui.tests.refactoring/resources/MoveMembers/test37/out/B.java
41,241
Bug 41241 enhance 'move static' to handle member types [refactoring]
I20030806 - create class package p1; public class A { static class Inner { } public void foo() { Inner inner= null; } } - select Inner in outliner and move it to p2.C observe: - this doesn't seem to be a refactoring since the files stay unsave and there isn't any undo - no references are updated - I can't move the Inner class into another class. Only into a CU.
verified fixed
3f5bef3
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2003-09-22T09:26:09Z
2003-08-07T09:53:20Z
org.eclipse.jdt.ui.tests.refactoring/resources/MoveMembers/test38/in/A.java
41,241
Bug 41241 enhance 'move static' to handle member types [refactoring]
I20030806 - create class package p1; public class A { static class Inner { } public void foo() { Inner inner= null; } } - select Inner in outliner and move it to p2.C observe: - this doesn't seem to be a refactoring since the files stay unsave and there isn't any undo - no references are updated - I can't move the Inner class into another class. Only into a CU.
verified fixed
3f5bef3
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2003-09-22T09:26:09Z
2003-08-07T09:53:20Z
org.eclipse.jdt.ui.tests.refactoring/resources/MoveMembers/test38/in/B.java
41,241
Bug 41241 enhance 'move static' to handle member types [refactoring]
I20030806 - create class package p1; public class A { static class Inner { } public void foo() { Inner inner= null; } } - select Inner in outliner and move it to p2.C observe: - this doesn't seem to be a refactoring since the files stay unsave and there isn't any undo - no references are updated - I can't move the Inner class into another class. Only into a CU.
verified fixed
3f5bef3
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2003-09-22T09:26:09Z
2003-08-07T09:53:20Z
org.eclipse.jdt.ui.tests.refactoring/resources/MoveMembers/test38/out/A.java
41,241
Bug 41241 enhance 'move static' to handle member types [refactoring]
I20030806 - create class package p1; public class A { static class Inner { } public void foo() { Inner inner= null; } } - select Inner in outliner and move it to p2.C observe: - this doesn't seem to be a refactoring since the files stay unsave and there isn't any undo - no references are updated - I can't move the Inner class into another class. Only into a CU.
verified fixed
3f5bef3
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2003-09-22T09:26:09Z
2003-08-07T09:53:20Z
org.eclipse.jdt.ui.tests.refactoring/resources/MoveMembers/test38/out/B.java
41,241
Bug 41241 enhance 'move static' to handle member types [refactoring]
I20030806 - create class package p1; public class A { static class Inner { } public void foo() { Inner inner= null; } } - select Inner in outliner and move it to p2.C observe: - this doesn't seem to be a refactoring since the files stay unsave and there isn't any undo - no references are updated - I can't move the Inner class into another class. Only into a CU.
verified fixed
3f5bef3
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2003-09-22T09:26:09Z
2003-08-07T09:53:20Z
org.eclipse.jdt.ui.tests.refactoring/resources/MoveMembers/test39/in/A.java
41,241
Bug 41241 enhance 'move static' to handle member types [refactoring]
I20030806 - create class package p1; public class A { static class Inner { } public void foo() { Inner inner= null; } } - select Inner in outliner and move it to p2.C observe: - this doesn't seem to be a refactoring since the files stay unsave and there isn't any undo - no references are updated - I can't move the Inner class into another class. Only into a CU.
verified fixed
3f5bef3
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2003-09-22T09:26:09Z
2003-08-07T09:53:20Z
org.eclipse.jdt.ui.tests.refactoring/resources/MoveMembers/test39/in/B.java
41,241
Bug 41241 enhance 'move static' to handle member types [refactoring]
I20030806 - create class package p1; public class A { static class Inner { } public void foo() { Inner inner= null; } } - select Inner in outliner and move it to p2.C observe: - this doesn't seem to be a refactoring since the files stay unsave and there isn't any undo - no references are updated - I can't move the Inner class into another class. Only into a CU.
verified fixed
3f5bef3
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2003-09-22T09:26:09Z
2003-08-07T09:53:20Z
org.eclipse.jdt.ui.tests.refactoring/resources/MoveMembers/test39/in/C.java
41,241
Bug 41241 enhance 'move static' to handle member types [refactoring]
I20030806 - create class package p1; public class A { static class Inner { } public void foo() { Inner inner= null; } } - select Inner in outliner and move it to p2.C observe: - this doesn't seem to be a refactoring since the files stay unsave and there isn't any undo - no references are updated - I can't move the Inner class into another class. Only into a CU.
verified fixed
3f5bef3
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2003-09-22T09:26:09Z
2003-08-07T09:53:20Z
org.eclipse.jdt.ui.tests.refactoring/test
41,241
Bug 41241 enhance 'move static' to handle member types [refactoring]
I20030806 - create class package p1; public class A { static class Inner { } public void foo() { Inner inner= null; } } - select Inner in outliner and move it to p2.C observe: - this doesn't seem to be a refactoring since the files stay unsave and there isn't any undo - no references are updated - I can't move the Inner class into another class. Only into a CU.
verified fixed
3f5bef3
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2003-09-22T09:26:09Z
2003-08-07T09:53:20Z
cases/org/eclipse/jdt/ui/tests/refactoring/MoveMembersTests.java
41,241
Bug 41241 enhance 'move static' to handle member types [refactoring]
I20030806 - create class package p1; public class A { static class Inner { } public void foo() { Inner inner= null; } } - select Inner in outliner and move it to p2.C observe: - this doesn't seem to be a refactoring since the files stay unsave and there isn't any undo - no references are updated - I can't move the Inner class into another class. Only into a CU.
verified fixed
3f5bef3
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2003-09-22T09:26:09Z
2003-08-07T09:53:20Z
org.eclipse.jdt.ui/core
41,241
Bug 41241 enhance 'move static' to handle member types [refactoring]
I20030806 - create class package p1; public class A { static class Inner { } public void foo() { Inner inner= null; } } - select Inner in outliner and move it to p2.C observe: - this doesn't seem to be a refactoring since the files stay unsave and there isn't any undo - no references are updated - I can't move the Inner class into another class. Only into a CU.
verified fixed
3f5bef3
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2003-09-22T09:26:09Z
2003-08-07T09:53:20Z
refactoring/org/eclipse/jdt/internal/corext/refactoring/structure/MoveStaticMemberAnalyzer.java
41,241
Bug 41241 enhance 'move static' to handle member types [refactoring]
I20030806 - create class package p1; public class A { static class Inner { } public void foo() { Inner inner= null; } } - select Inner in outliner and move it to p2.C observe: - this doesn't seem to be a refactoring since the files stay unsave and there isn't any undo - no references are updated - I can't move the Inner class into another class. Only into a CU.
verified fixed
3f5bef3
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2003-09-22T09:26:09Z
2003-08-07T09:53:20Z
org.eclipse.jdt.ui/core
41,241
Bug 41241 enhance 'move static' to handle member types [refactoring]
I20030806 - create class package p1; public class A { static class Inner { } public void foo() { Inner inner= null; } } - select Inner in outliner and move it to p2.C observe: - this doesn't seem to be a refactoring since the files stay unsave and there isn't any undo - no references are updated - I can't move the Inner class into another class. Only into a CU.
verified fixed
3f5bef3
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2003-09-22T09:26:09Z
2003-08-07T09:53:20Z
refactoring/org/eclipse/jdt/internal/corext/refactoring/structure/MoveStaticMembersRefactoring.java
41,241
Bug 41241 enhance 'move static' to handle member types [refactoring]
I20030806 - create class package p1; public class A { static class Inner { } public void foo() { Inner inner= null; } } - select Inner in outliner and move it to p2.C observe: - this doesn't seem to be a refactoring since the files stay unsave and there isn't any undo - no references are updated - I can't move the Inner class into another class. Only into a CU.
verified fixed
3f5bef3
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2003-09-22T09:26:09Z
2003-08-07T09:53:20Z
org.eclipse.jdt.ui/core
41,241
Bug 41241 enhance 'move static' to handle member types [refactoring]
I20030806 - create class package p1; public class A { static class Inner { } public void foo() { Inner inner= null; } } - select Inner in outliner and move it to p2.C observe: - this doesn't seem to be a refactoring since the files stay unsave and there isn't any undo - no references are updated - I can't move the Inner class into another class. Only into a CU.
verified fixed
3f5bef3
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2003-09-22T09:26:09Z
2003-08-07T09:53:20Z
refactoring/org/eclipse/jdt/internal/corext/refactoring/structure/MovedMemberAnalyzer.java
41,241
Bug 41241 enhance 'move static' to handle member types [refactoring]
I20030806 - create class package p1; public class A { static class Inner { } public void foo() { Inner inner= null; } } - select Inner in outliner and move it to p2.C observe: - this doesn't seem to be a refactoring since the files stay unsave and there isn't any undo - no references are updated - I can't move the Inner class into another class. Only into a CU.
verified fixed
3f5bef3
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2003-09-22T09:26:09Z
2003-08-07T09:53:20Z
org.eclipse.jdt.ui/core
41,241
Bug 41241 enhance 'move static' to handle member types [refactoring]
I20030806 - create class package p1; public class A { static class Inner { } public void foo() { Inner inner= null; } } - select Inner in outliner and move it to p2.C observe: - this doesn't seem to be a refactoring since the files stay unsave and there isn't any undo - no references are updated - I can't move the Inner class into another class. Only into a CU.
verified fixed
3f5bef3
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2003-09-22T09:26:09Z
2003-08-07T09:53:20Z
refactoring/org/eclipse/jdt/internal/corext/refactoring/structure/ReferenceAnalyzer.java
41,241
Bug 41241 enhance 'move static' to handle member types [refactoring]
I20030806 - create class package p1; public class A { static class Inner { } public void foo() { Inner inner= null; } } - select Inner in outliner and move it to p2.C observe: - this doesn't seem to be a refactoring since the files stay unsave and there isn't any undo - no references are updated - I can't move the Inner class into another class. Only into a CU.
verified fixed
3f5bef3
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2003-09-22T09:26:09Z
2003-08-07T09:53:20Z
org.eclipse.jdt.ui/core
41,241
Bug 41241 enhance 'move static' to handle member types [refactoring]
I20030806 - create class package p1; public class A { static class Inner { } public void foo() { Inner inner= null; } } - select Inner in outliner and move it to p2.C observe: - this doesn't seem to be a refactoring since the files stay unsave and there isn't any undo - no references are updated - I can't move the Inner class into another class. Only into a CU.
verified fixed
3f5bef3
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2003-09-22T09:26:09Z
2003-08-07T09:53:20Z
refactoring/org/eclipse/jdt/internal/corext/refactoring/util/JavaElementUtil.java
42,605
Bug 42605 [hovering] NPE in AnnotationHover
Win2K, Build 200308281813, J2RE 1.3.1 IBM J9 build 20030702 (JIT enabled) This appeared in my DOS console - not sure when. There was nothing in the .log file for my workspace. java.lang.NullPointerException at java.lang.Throwable.<init>(Throwable.java) at java.lang.Throwable.<init>(Throwable.java) at java.lang.NullPointerException.<init>(NullPointerException.java:63) at org.eclipse.jdt.internal.ui.text.java.hover.AnnotationHover.getHoverI nfo(AnnotationHover.java:78) at org.eclipse.jdt.internal.ui.text.java.hover.BestMatchHover.getHoverIn fo(BestMatchHover.java) at org.eclipse.jdt.internal.ui.text.java.hover.JavaEditorTextHoverProxy. getHoverInfo(JavaEditorTextHoverProxy.java:69) at org.eclipse.jface.text.TextViewerHoverManager$2.run(TextViewerHoverMa nager.java)
resolved fixed
7763e35
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2003-09-22T09:44:09Z
2003-09-05T13:53:20Z
org.eclipse.jdt.ui.examples.javafamily/src/org/eclipse/jdt/internal/ui/examples/jspeditor/AnnotationTextHover.java
/******************************************************************************* * Copyright (c) 2000, 2003 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Common Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/cpl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.jdt.internal.ui.examples.jspeditor; import java.util.Iterator; import org.eclipse.jface.text.Assert; import org.eclipse.jface.text.IRegion; import org.eclipse.jface.text.ITextHover; import org.eclipse.jface.text.ITextViewer; import org.eclipse.jface.text.Position; import org.eclipse.jface.text.Region; import org.eclipse.jface.text.source.Annotation; import org.eclipse.jface.text.source.IAnnotationModel; import org.eclipse.ui.texteditor.IAnnotationExtension; /** * A simple text hover to show annotation information. * * @since 3.0 */ public class AnnotationTextHover implements ITextHover { /** This hover's annotation model */ private IAnnotationModel fModel; /** * Creates a new annotation hover. * * @param model this hover's annotation model */ public AnnotationTextHover(IAnnotationModel model) { Assert.isNotNull(model); fModel= model; } /* * @see org.eclipse.jface.text.ITextHover#getHoverInfo(org.eclipse.jface.text.ITextViewer, org.eclipse.jface.text.IRegion) */ public String getHoverInfo(ITextViewer textViewer, IRegion hoverRegion) { Iterator e= fModel.getAnnotationIterator(); while (e.hasNext()) { Annotation a= (Annotation) e.next(); Position p= fModel.getPosition(a); if (p.overlapsWith(hoverRegion.getOffset(), hoverRegion.getLength())) { if (a instanceof IAnnotationExtension) { String msg= ((IAnnotationExtension) a).getMessage(); if (msg != null && msg.trim().length() > 0) return msg; } } } return null; } /* * @see org.eclipse.jface.text.ITextHover#getHoverRegion(org.eclipse.jface.text.ITextViewer, int) */ public IRegion getHoverRegion(ITextViewer textViewer, int offset) { /* * XXX: If this is too slow then we might return new Region(offset, 0); */ Iterator e= fModel.getAnnotationIterator(); while (e.hasNext()) { Annotation a= (Annotation) e.next(); Position p= fModel.getPosition(a); if (p.overlapsWith(offset, 0)) { if (a instanceof IAnnotationExtension) { String msg= ((IAnnotationExtension) a).getMessage(); if (msg != null && msg.trim().length() > 0) return new Region(p.offset, p.length); } } } return null; } }
42,605
Bug 42605 [hovering] NPE in AnnotationHover
Win2K, Build 200308281813, J2RE 1.3.1 IBM J9 build 20030702 (JIT enabled) This appeared in my DOS console - not sure when. There was nothing in the .log file for my workspace. java.lang.NullPointerException at java.lang.Throwable.<init>(Throwable.java) at java.lang.Throwable.<init>(Throwable.java) at java.lang.NullPointerException.<init>(NullPointerException.java:63) at org.eclipse.jdt.internal.ui.text.java.hover.AnnotationHover.getHoverI nfo(AnnotationHover.java:78) at org.eclipse.jdt.internal.ui.text.java.hover.BestMatchHover.getHoverIn fo(BestMatchHover.java) at org.eclipse.jdt.internal.ui.text.java.hover.JavaEditorTextHoverProxy. getHoverInfo(JavaEditorTextHoverProxy.java:69) at org.eclipse.jface.text.TextViewerHoverManager$2.run(TextViewerHoverMa nager.java)
resolved fixed
7763e35
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2003-09-22T09:44:09Z
2003-09-05T13:53:20Z
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/java/hover/AnnotationHover.java
/******************************************************************************* * Copyright (c) 2000, 2003 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Common Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/cpl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.jdt.internal.ui.text.java.hover; import java.util.Iterator; import org.eclipse.jface.preference.IPreferenceStore; import org.eclipse.jface.text.IRegion; import org.eclipse.jface.text.ITextViewer; import org.eclipse.jface.text.Position; import org.eclipse.jface.text.source.Annotation; import org.eclipse.jface.text.source.IAnnotationModel; import org.eclipse.ui.IEditorPart; import org.eclipse.ui.texteditor.AnnotationPreference; import org.eclipse.ui.texteditor.IAnnotationExtension; import org.eclipse.ui.texteditor.IDocumentProvider; import org.eclipse.ui.texteditor.MarkerAnnotationPreferences; import org.eclipse.jdt.ui.PreferenceConstants; import org.eclipse.jdt.internal.ui.JavaPlugin; import org.eclipse.jdt.internal.ui.javaeditor.CompilationUnitEditor; import org.eclipse.jdt.internal.ui.javaeditor.IJavaAnnotation; import org.eclipse.jdt.internal.ui.javaeditor.JavaAnnotationIterator; import org.eclipse.jdt.internal.ui.text.HTMLPrinter; public class AnnotationHover extends AbstractJavaEditorTextHover { private MarkerAnnotationPreferences fMarkerAnnotationPreferences= new MarkerAnnotationPreferences(); private IPreferenceStore fStore= JavaPlugin.getDefault().getPreferenceStore(); /* * Formats a message as HTML text. */ private String formatMessage(String message) { StringBuffer buffer= new StringBuffer(); HTMLPrinter.addPageProlog(buffer); HTMLPrinter.addParagraph(buffer, HTMLPrinter.convertToHTMLContent(message)); HTMLPrinter.addPageEpilog(buffer); return buffer.toString(); } /* * @see ITextHover#getHoverInfo(ITextViewer, IRegion) */ public String getHoverInfo(ITextViewer textViewer, IRegion hoverRegion) { if (getEditor() == null) return null; IDocumentProvider provider= JavaPlugin.getDefault().getCompilationUnitDocumentProvider(); IAnnotationModel model= provider.getAnnotationModel(getEditor().getEditorInput()); if (model != null) { Iterator e= new JavaAnnotationIterator(model, true); while (e.hasNext()) { Annotation a= (Annotation) e.next(); if (a instanceof IAnnotationExtension) { AnnotationPreference preference= getAnnotationPreference((IAnnotationExtension)a); if (preference == null || !fStore.getBoolean(preference.getTextPreferenceKey())) continue; } Position p= model.getPosition(a); if (p.overlapsWith(hoverRegion.getOffset(), hoverRegion.getLength())) { String msg= ((IJavaAnnotation) a).getMessage(); if (msg != null && msg.trim().length() > 0) return formatMessage(msg); } } } return null; } /* * @see IJavaEditorTextHover#setEditor(IEditorPart) */ public void setEditor(IEditorPart editor) { if (editor instanceof CompilationUnitEditor) super.setEditor(editor); else super.setEditor(null); } /** * Returns the annotation preference for the given marker. * * @param marker * @return the annotation preference or <code>null</code> if none */ private AnnotationPreference getAnnotationPreference(IAnnotationExtension annotation) { String markerType= annotation.getMarkerType(); int severity= annotation.getSeverity(); Iterator e= fMarkerAnnotationPreferences.getAnnotationPreferences().iterator(); while (e.hasNext()) { AnnotationPreference info= (AnnotationPreference) e.next(); if (info.getMarkerType().equals(markerType) && severity == info.getSeverity()) return info; } return null; } static boolean isJavaProblemHover(String id) { return PreferenceConstants.ID_PROBLEM_HOVER.equals(id); } }
43,364
Bug 43364 [typing] new line insertion sometimes goes wrong!
try and put a new line between the two variable declarations. It will shift the second variable declaration to line up with "c". ------------------------------------------------------------ public class A { private static final String[] var = new String[] { "a", "b", "c", "d"}; private static final int var2 = 4; //press enter at beginning of this line } ------------------------------------------------------------
resolved fixed
a9ad462
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2003-09-23T08:46:52Z
2003-09-19T16:46:40Z
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/JavaHeuristicScanner.java
/******************************************************************************* * Copyright (c) 2000, 2003 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Common Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/cpl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.jdt.internal.ui.text; import java.util.Arrays; import org.eclipse.jface.text.Assert; import org.eclipse.jface.text.BadLocationException; import org.eclipse.jface.text.IDocument; import org.eclipse.jface.text.IRegion; import org.eclipse.jface.text.ITypedRegion; import org.eclipse.jface.text.Region; import org.eclipse.jface.text.TextUtilities; /** * Utility methods for heuristic based Java manipulations in an incomplete Java source file. * * <p>An instance holds some internal position in the document and is therefore not threadsafe.</p> * * @since 3.0 */ public class JavaHeuristicScanner implements Symbols { /** * Returned by all methods when the requested position could not be found, or if a * {@link BadLocationException} was thrown while scanning. */ public static final int NOT_FOUND= -1; /** * Special bound parameter that means either -1 (backward scanning) or * <code>fDocument.getLength()</code> (forward scanning). */ public static final int UNBOUND= -2; /* character constants */ private static final char LBRACE= '{'; private static final char RBRACE= '}'; private static final char LPAREN= '('; private static final char RPAREN= ')'; private static final char SEMICOLON= ';'; private static final char COLON= ':'; private static final char COMMA= ','; private static final char LBRACKET= '['; private static final char RBRACKET= ']'; private static final char QUESTIONMARK= '?'; private static final char EQUAL= '='; /** * Specifies the stop condition, upon which the <code>scanXXX</code> methods will decide whether * to keep scanning or not. This interface may implemented by clients. */ public interface StopCondition { /** * Instructs the scanner to return the current position. * * @param ch the char at the current position * @param position the current position * @return <code>true</code> if the stop condition is met. */ boolean stop(char ch, int position); } /** * Stops upon a non-whitespace (as defined by {@link Character#isWhitespace(char)}) character. */ private static class NonWhitespace implements StopCondition { /* * @see org.eclipse.jdt.internal.ui.text.JavaHeuristicScanner.StopCondition#stop(char) */ public boolean stop(char ch, int position) { return !Character.isWhitespace(ch); } } /** * Stops upon a non-whitespace character in the default partition. * * @see NonWhitespace */ private class NonWhitespaceDefaultPartition extends NonWhitespace { /* * @see org.eclipse.jdt.internal.ui.text.JavaHeuristicScanner.StopCondition#stop(char) */ public boolean stop(char ch, int position) { return super.stop(ch, position) && isDefaultPartition(position); } } /** * Stops upon a non-java identifier (as defined by {@link Character#isJavaIdentifierPart(char)}) character. */ private static class NonJavaIdentifierPart implements StopCondition { /* * @see org.eclipse.jdt.internal.ui.text.JavaHeuristicScanner.StopCondition#stop(char) */ public boolean stop(char ch, int position) { return !Character.isJavaIdentifierPart(ch); } } /** * Stops upon a non-java identifier character in the default partition. * * @see NonJavaIdentifierPart */ private class NonJavaIdentifierPartDefaultPartition extends NonJavaIdentifierPart { /* * @see org.eclipse.jdt.internal.ui.text.JavaHeuristicScanner.StopCondition#stop(char) */ public boolean stop(char ch, int position) { return super.stop(ch, position) || !isDefaultPartition(position); } } /** * Stops upon a character in the default partition that matches the given character list. */ private class CharacterMatch implements StopCondition { private final char[] fChars; /** * Creates a new instance. * @param ch the single character to match */ public CharacterMatch(char ch) { this(new char[] {ch}); } /** * Creates a new instance. * @param chars the chars to match. */ public CharacterMatch(char[] chars) { Assert.isNotNull(chars); Assert.isTrue(chars.length > 0); fChars= chars; Arrays.sort(chars); } /* * @see org.eclipse.jdt.internal.ui.text.JavaHeuristicScanner.StopCondition#stop(char, int) */ public boolean stop(char ch, int position) { return Arrays.binarySearch(fChars, ch) >= 0 && isDefaultPartition(position); } } /** The document being scanned. */ private IDocument fDocument; /** The partitioning being used for scanning. */ private String fPartitioning; /** The partition to scan in. */ private String fPartition; /* internal scan state */ /** the most recently read character. */ private char fChar; /** the most recently read position. */ private int fPos; /* preset stop conditions */ private final StopCondition fNonWSDefaultPart= new NonWhitespaceDefaultPartition(); private final static StopCondition fNonWS= new NonWhitespace(); private final StopCondition fNonIdent= new NonJavaIdentifierPartDefaultPartition(); /** * Creates a new instance. * * @param document the document to scan * @param partitioning the partitioning to use for scanning * @param partition the partition to scan in */ public JavaHeuristicScanner(IDocument document, String partitioning, String partition) { Assert.isNotNull(document); Assert.isNotNull(partitioning); Assert.isNotNull(partition); fDocument= document; fPartitioning= partitioning; fPartition= partition; } /** * Calls <code>this(document, IJavaPartitions.JAVA_PARTITIONING, IDocument.DEFAULT_CONTENT_TYPE)</code>. * * @param document the document to scan. */ public JavaHeuristicScanner(IDocument document) { this(document, IJavaPartitions.JAVA_PARTITIONING, IDocument.DEFAULT_CONTENT_TYPE); } /** * Returns the most recent internal scan position. * * @return the most recent internal scan position. */ public int getPosition() { return fPos; } /** * Returns the next token in forward direction, starting at <code>start</code>, and not extending * further than <code>bound</code>. The return value is one of the constants defined in {@link Symbols}. * After a call, {@link #getPosition()} will return the position just after the scanned token * (i.e. the next position that will be scanned). * * @param start the first character position in the document to consider * @param bound the first position not to consider any more * @return a constant from {@link Symbols} describing the next token */ public int nextToken(int start, int bound) { int pos= scanForward(start, bound, fNonWSDefaultPart); if (pos == NOT_FOUND) return TokenEOF; fPos++; switch (fChar) { case LBRACE: return TokenLBRACE; case RBRACE: return TokenRBRACE; case LBRACKET: return TokenLBRACKET; case RBRACKET: return TokenRBRACKET; case LPAREN: return TokenLPAREN; case RPAREN: return TokenRPAREN; case SEMICOLON: return TokenSEMICOLON; case COMMA: return TokenCOMMA; case QUESTIONMARK: return TokenQUESTIONMARK; case EQUAL: return TokenEQUAL; } // else if (Character.isJavaIdentifierPart(fChar)) { // assume an ident or keyword int from= pos, to; pos= scanForward(pos + 1, bound, fNonIdent); if (pos == NOT_FOUND) to= bound; else to= pos; String identOrKeyword; try { identOrKeyword= fDocument.get(from, to - from); } catch (BadLocationException e) { return TokenEOF; } return getToken(identOrKeyword); } else { // operators, number literals etc return TokenOTHER; } } /** * Returns the next token in backward direction, starting at <code>start</code>, and not extending * further than <code>bound</code>. The return value is one of the constants defined in {@link Symbols}. * After a call, {@link #getPosition()} will return the position just before the scanned token * starts (i.e. the next position that will be scanned). * * @param start the first character position in the document to consider * @param bound the first position not to consider any more * @return a constant from {@link Symbols} describing the previous token */ public int previousToken(int start, int bound) { int pos= scanBackward(start, bound, fNonWSDefaultPart); if (pos == NOT_FOUND) return TokenEOF; fPos--; switch (fChar) { case LBRACE: return TokenLBRACE; case RBRACE: return TokenRBRACE; case LBRACKET: return TokenLBRACKET; case RBRACKET: return TokenRBRACKET; case LPAREN: return TokenLPAREN; case RPAREN: return TokenRPAREN; case SEMICOLON: return TokenSEMICOLON; case COLON: return TokenCOLON; case COMMA: return TokenCOMMA; case QUESTIONMARK: return TokenQUESTIONMARK; case EQUAL: return TokenEQUAL; } // else if (Character.isJavaIdentifierPart(fChar)) { // assume an ident or keyword int from, to= pos + 1; pos= scanBackward(pos - 1, bound, fNonIdent); if (pos == NOT_FOUND) from= bound + 1; else from= pos + 1; String identOrKeyword; try { identOrKeyword= fDocument.get(from, to - from); } catch (BadLocationException e) { return TokenEOF; } return getToken(identOrKeyword); } else { // operators, number literals etc return TokenOTHER; } } /** * Returns one of the keyword constants or <code>TokenIDENT</code> for a scanned identifier. * * @param s a scanned identifier * @return one of the constants defined in {@link Symbols} */ private int getToken(String s) { Assert.isNotNull(s); switch (s.length()) { case 2: if ("if".equals(s)) //$NON-NLS-1$ return TokenIF; if ("do".equals(s)) //$NON-NLS-1$ return TokenDO; break; case 3: if ("for".equals(s)) //$NON-NLS-1$ return TokenFOR; if ("try".equals(s)) //$NON-NLS-1$ return TokenTRY; if ("new".equals(s)) //$NON-NLS-1$ return TokenNEW; break; case 4: if ("case".equals(s)) //$NON-NLS-1$ return TokenCASE; if ("else".equals(s)) //$NON-NLS-1$ return TokenELSE; if ("goto".equals(s)) //$NON-NLS-1$ return TokenGOTO; break; case 5: if ("break".equals(s)) //$NON-NLS-1$ return TokenBREAK; if ("catch".equals(s)) //$NON-NLS-1$ return TokenCATCH; if ("while".equals(s)) //$NON-NLS-1$ return TokenWHILE; break; case 6: if ("return".equals(s)) //$NON-NLS-1$ return TokenRETURN; if ("static".equals(s)) //$NON-NLS-1$ return TokenSTATIC; if ("switch".equals(s)) //$NON-NLS-1$ return TokenSWITCH; break; case 7: if ("default".equals(s)) //$NON-NLS-1$ return TokenDEFAULT; if ("finally".equals(s)) //$NON-NLS-1$ return TokenFINALLY; break; case 12: if ("synchronized".equals(s)) //$NON-NLS-1$ return TokenSYNCHRONIZED; break; } return TokenIDENT; } /** * Returns the position of the closing peer character (forward search). Any scopes introduced by opening peers * are skipped. All peers accounted for must reside in the default partition. * * <p>Note that <code>start</code> must not point to the opening peer, but to the first * character being searched.</p> * * @param start the start position * @param openingPeer the opening peer character (e.g. '{') * @param closingPeer the closing peer character (e.g. '}') * @return the matching peer character position, or <code>NOT_FOUND</code> */ public int findClosingPeer(int start, final char openingPeer, final char closingPeer) { Assert.isNotNull(fDocument); Assert.isTrue(start >= 0); try { int depth= 1; start -= 1; while (true) { start= scanForward(start + 1, UNBOUND, new CharacterMatch(new char[] {openingPeer, closingPeer})); if (start == NOT_FOUND) return NOT_FOUND; if (fDocument.getChar(start) == openingPeer) depth++; else depth--; if (depth == 0) return start; } } catch (BadLocationException e) { return NOT_FOUND; } } /** * Returns the position of the opening peer character (backward search). Any scopes introduced by closing peers * are skipped. All peers accounted for must reside in the default partition. * * <p>Note that <code>start</code> must not point to the closing peer, but to the first * character being searched.</p> * * @param start the start position * @param openingPeer the opening peer character (e.g. '{') * @param closingPeer the closing peer character (e.g. '}') * @return the matching peer character position, or <code>NOT_FOUND</code> */ public int findOpeningPeer(int start, char openingPeer, char closingPeer) { Assert.isTrue(start < fDocument.getLength()); try { int depth= 1; start += 1; while (true) { start= scanBackward(start - 1, UNBOUND, new CharacterMatch(new char[] {openingPeer, closingPeer})); if (start == NOT_FOUND) return NOT_FOUND; if (fDocument.getChar(start) == closingPeer) depth++; else depth--; if (depth == 0) return start; } } catch (BadLocationException e) { return NOT_FOUND; } } /** * Computes the surrounding block around <code>offset</code>. The search is started at the * beginning of <code>offset</code>, i.e. an opening brace at <code>offset</code> will not be * part of the surrounding block, but a closing brace will. * * @param offset the offset for which the surrounding block is computed * @return a region describing the surrounding block, or <code>null</code> if none can be found */ public IRegion findSurroundingBlock(int offset) { if (offset < 1 || offset >= fDocument.getLength()) return null; int begin= findOpeningPeer(offset - 1, LBRACE, RBRACE); int end= findClosingPeer(offset, LBRACE, RBRACE); if (begin == NOT_FOUND || end == NOT_FOUND) return null; return new Region(begin, end + 1 - begin); } /** * Finds the smallest position in <code>fDocument</code> such that the position is &gt;= <code>position</code> * and &lt; <code>bound</code> and <code>Character.isWhitespace(fDocument.getChar(pos))</code> evaluates to <code>false</code> * and the position is in the default partition. * * @param position the first character position in <code>fDocument</code> to be considered * @param bound the first position in <code>fDocument</code> to not consider any more, with <code>bound</code> &gt; <code>position</code>, or <code>UNBOUND</code> * @return the smallest position of a non-whitespace character in [<code>position</code>, <code>bound</code>) that resides in a Java partition, or <code>-1</code> if none can be found */ public int findNonWhitespaceForward(int position, int bound) { return scanForward(position, bound, fNonWSDefaultPart); } /** * Finds the smallest position in <code>fDocument</code> such that the position is &gt;= <code>position</code> * and &lt; <code>bound</code> and <code>Character.isWhitespace(fDocument.getChar(pos))</code> evaluates to <code>false</code>. * * @param position the first character position in <code>fDocument</code> to be considered * @param bound the first position in <code>fDocument</code> to not consider any more, with <code>bound</code> &gt; <code>position</code>, or <code>UNBOUND</code> * @return the smallest position of a non-whitespace character in [<code>position</code>, <code>bound</code>), or <code>-1</code> if none can be found */ public int findNonWhitespaceForwardInAnyPartition(int position, int bound) { return scanForward(position, bound, fNonWS); } /** * Finds the highest position in <code>fDocument</code> such that the position is &lt;= <code>position</code> * and &gt; <code>bound</code> and <code>Character.isWhitespace(fDocument.getChar(pos))</code> evaluates to <code>false</code> * and the position is in the default partition. * * @param position the first character position in <code>fDocument</code> to be considered * @param bound the first position in <code>fDocument</code> to not consider any more, with <code>bound</code> &lt; <code>position</code>, or <code>UNBOUND</code> * @return the highest position of a non-whitespace character in (<code>bound</code>, <code>position</code>] that resides in a Java partition, or <code>-1</code> if none can be found */ public int findNonWhitespaceBackward(int position, int bound) { return scanBackward(position, bound, fNonWSDefaultPart); } /** * Finds the lowest position <code>p</code> in <code>fDocument</code> such that <code>start</code> &lt;= p &lt; * <code>bound</code> and <code>condition.stop(fDocument.getChar(p), p)</code> evaluates to <code>true</code>. * * @param start the first character position in <code>fDocument</code> to be considered * @param bound the first position in <code>fDocument</code> to not consider any more, with <code>bound</code> &gt; <code>start</code>, or <code>UNBOUND</code> * @param condition the <code>StopCondition</code> to check * @return the lowest position in [<code>start</code>, <code>bound</code>) for which <code>condition</code> holds, or <code>-1</code> if none can be found */ public int scanForward(int start, int bound, StopCondition condition) { Assert.isTrue(start >= 0); if (bound == UNBOUND) bound= fDocument.getLength(); Assert.isTrue(bound <= fDocument.getLength()); try { fPos= start; while (fPos < bound) { fChar= fDocument.getChar(fPos); if (condition.stop(fChar, fPos)) return fPos; fPos++; } } catch (BadLocationException e) { } return NOT_FOUND; } /** * Finds the lowest position in <code>fDocument</code> such that the position is &gt;= <code>position</code> * and &lt; <code>bound</code> and <code>fDocument.getChar(position) == ch</code> evaluates to <code>true</code> * and the position is in the default partition. * * @param position the first character position in <code>fDocument</code> to be considered * @param bound the first position in <code>fDocument</code> to not consider any more, with <code>bound</code> &gt; <code>position</code>, or <code>UNBOUND</code> * @param ch the <code>char</code> to search for * @return the lowest position of <code>ch</code> in (<code>bound</code>, <code>position</code>] that resides in a Java partition, or <code>-1</code> if none can be found */ public int scanForward(int position, int bound, char ch) { return scanForward(position, bound, new CharacterMatch(ch)); } /** * Finds the lowest position in <code>fDocument</code> such that the position is &gt;= <code>position</code> * and &lt; <code>bound</code> and <code>fDocument.getChar(position) == ch</code> evaluates to <code>true</code> for at least one * ch in <code>chars</code> and the position is in the default partition. * * @param position the first character position in <code>fDocument</code> to be considered * @param bound the first position in <code>fDocument</code> to not consider any more, with <code>bound</code> &gt; <code>position</code>, or <code>UNBOUND</code> * @param chars an array of <code>char</code> to search for * @return the lowest position of a non-whitespace character in [<code>position</code>, <code>bound</code>) that resides in a Java partition, or <code>-1</code> if none can be found */ public int scanForward(int position, int bound, char[] chars) { return scanForward(position, bound, new CharacterMatch(chars)); } /** * Finds the highest position <code>p</code> in <code>fDocument</code> such that <code>bound</code> &lt; <code>p</code> &lt;= <code>start</code> * and <code>condition.stop(fDocument.getChar(p), p)</code> evaluates to <code>true</code>. * * @param start the first character position in <code>fDocument</code> to be considered * @param bound the first position in <code>fDocument</code> to not consider any more, with <code>bound</code> &lt; <code>start</code>, or <code>UNBOUND</code> * @param condition the <code>StopCondition</code> to check * @return the highest position in (<code>bound</code>, <code>start</code> for which <code>condition</code> holds, or <code>-1</code> if none can be found */ public int scanBackward(int start, int bound, StopCondition condition) { if (bound == UNBOUND) bound= -1; Assert.isTrue(bound >= -1); Assert.isTrue(start < fDocument.getLength() ); try { fPos= start; while (fPos > bound) { fChar= fDocument.getChar(fPos); if (condition.stop(fChar, fPos)) return fPos; fPos--; } } catch (BadLocationException e) { } return NOT_FOUND; } /** * Finds the highest position in <code>fDocument</code> such that the position is &lt;= <code>position</code> * and &gt; <code>bound</code> and <code>fDocument.getChar(position) == ch</code> evaluates to <code>true</code> for at least one * ch in <code>chars</code> and the position is in the default partition. * * @param position the first character position in <code>fDocument</code> to be considered * @param bound the first position in <code>fDocument</code> to not consider any more, with <code>bound</code> &lt; <code>position</code>, or <code>UNBOUND</code> * @param ch the <code>char</code> to search for * @return the highest position of one element in <code>chars</code> in (<code>bound</code>, <code>position</code>] that resides in a Java partition, or <code>-1</code> if none can be found */ public int scanBackward(int position, int bound, char ch) { return scanBackward(position, bound, new CharacterMatch(ch)); } /** * Finds the highest position in <code>fDocument</code> such that the position is &lt;= <code>position</code> * and &gt; <code>bound</code> and <code>fDocument.getChar(position) == ch</code> evaluates to <code>true</code> for at least one * ch in <code>chars</code> and the position is in the default partition. * * @param position the first character position in <code>fDocument</code> to be considered * @param bound the first position in <code>fDocument</code> to not consider any more, with <code>bound</code> &lt; <code>position</code>, or <code>UNBOUND</code> * @param chars an array of <code>char</code> to search for * @return the highest position of one element in <code>chars</code> in (<code>bound</code>, <code>position</code>] that resides in a Java partition, or <code>-1</code> if none can be found */ public int scanBackward(int position, int bound, char[] chars) { return scanBackward(position, bound, new CharacterMatch(chars)); } /** * Checks whether <code>position</code> resides in a default (Java) partition of <code>fDocument</code>. * * @param position the position to be checked * @return <code>true</code> if <code>position</code> is in the default partition of <code>fDocument</code>, <code>false</code> otherwise */ public boolean isDefaultPartition(int position) { Assert.isTrue(position >= 0); Assert.isTrue(position <= fDocument.getLength()); try { ITypedRegion region= TextUtilities.getPartition(fDocument, fPartitioning, position); return region.getType().equals(fPartition); } catch (BadLocationException e) { } return false; } /** * Checks if the line seems to be an open condition not followed by a block (i.e. an if, while, * or for statement with just one following statement, see example below). * * <pre> * if (condition) * doStuff(); * </pre> * * <p>Algorithm: if the last non-WS, non-Comment code on the line is an if (condition), while (condition), * for( expression), do, else, and there is no statement after that </p> * * @param position the insert position of the new character * @param bound the lowest position to consider * @return <code>true</code> if the code is a conditional statement or loop without a block, <code>false</code> otherwise */ public boolean isBracelessBlockStart(int position, int bound) { if (position < 1) return false; switch (previousToken(position, bound)) { case TokenDO: case TokenELSE: return true; case TokenRPAREN: position= findOpeningPeer(fPos, LPAREN, RPAREN); if (position > 0) { switch (previousToken(position - 1, bound)) { case TokenIF: case TokenFOR: case TokenWHILE: return true; } } } return false; } }
43,364
Bug 43364 [typing] new line insertion sometimes goes wrong!
try and put a new line between the two variable declarations. It will shift the second variable declaration to line up with "c". ------------------------------------------------------------ public class A { private static final String[] var = new String[] { "a", "b", "c", "d"}; private static final int var2 = 4; //press enter at beginning of this line } ------------------------------------------------------------
resolved fixed
a9ad462
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2003-09-23T08:46:52Z
2003-09-19T16:46:40Z
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/JavaIndenter.java
/******************************************************************************* * Copyright (c) 2000, 2003 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Common Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/cpl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.jdt.internal.ui.text; import org.eclipse.jface.text.Assert; import org.eclipse.jface.text.BadLocationException; import org.eclipse.jface.text.IDocument; import org.eclipse.jface.text.IRegion; import org.eclipse.jdt.internal.corext.util.CodeFormatterUtil; import org.eclipse.jdt.internal.ui.JavaPlugin; /** * Uses the {@link org.eclipse.jdt.internal.ui.text.JavaHeuristicScanner} to get the indentation * level for a certain position in a document. * * <p>An instance holds some internal position in the document and is therefore not threadsafe.</p> * * @since 3.0 */ public class JavaIndenter { /** The document being scanned. */ private IDocument fDocument; /** The indentation accumulated by <code>findPreviousIndenationUnit</code>. */ private int fIndent; /** The absolute (character-counted) indentation offset for special cases (method defs, array initializers) */ private int fAlign; /** Whether to add one space to the absolute indentation. */ private boolean fAlignPlusOne; /** The stateful scanpositionf or the indentation methods. */ private int fPosition; /** The previous position. */ private int fPreviousPos; /** The most recent token. */ private int fToken; /** * The scanner we will use to scan the document. It has to be installed on the same document * as the one we get. */ private JavaHeuristicScanner fScanner; /** * Creates a new instance. * * @param document the document to scan */ public JavaIndenter(IDocument document, JavaHeuristicScanner scanner) { Assert.isNotNull(document); Assert.isNotNull(scanner); fDocument= document; fScanner= scanner; } /** * Computes the indentation at the reference point of <code>position</code>. * * @param position the position in the document, either at the beginning of a line or in the * whitespace at the beginning of a line * @return a String which reflects the indentation at the line in which the reference position * to <code>position</code> resides, or <code>null</code> if it cannot be determined. */ public String getReferenceIndentation(int position) { try { // account for unindenation characters already typed in, but after position // also account for a dangling else boolean danglingElse= false; boolean matchBrace= false; if (position < fDocument.getLength()) { IRegion line= fDocument.getLineInformationOfOffset(position); int next= fScanner.nextToken(position, line.getOffset() + line.getLength()); switch (next) { case Symbols.TokenEOF: case Symbols.TokenELSE: danglingElse= true; break; case Symbols.TokenRBRACE: // closing braces get unindented matchBrace= true; } } else { danglingElse= true; } // find the base position int unit= findReferencePosition(position, danglingElse, matchBrace); // if we were unable to find anything, return null if (unit == JavaHeuristicScanner.NOT_FOUND) return null; //$NON-NLS-1$ // get base indent at the reference location IRegion line= fDocument.getLineInformationOfOffset(unit); int offset= line.getOffset(); int nonWS= fScanner.findNonWhitespaceForwardInAnyPartition(offset, offset + line.getLength()); StringBuffer indent= new StringBuffer(fDocument.get(offset, nonWS - offset)); return indent.toString(); } catch (BadLocationException e) { } return null; } /** * Computes the indentation at <code>position</code>. * * @param position the position in the document, either at the beginning of a line or in the * whitespace at the beginning of a line * @return a String which reflects the correct indentation for the line in which position * resides, or <code>null</code> if it cannot be determined.. */ public String computeIndentation(int position) { try { // account for unindenation characters already typed in, but after position // also account for a dangling else boolean danglingElse= false; boolean unindent= false; boolean matchBrace= false; if (position < fDocument.getLength()) { IRegion line= fDocument.getLineInformationOfOffset(position); int next= fScanner.nextToken(position, line.getOffset() + line.getLength()); int prevPos= Math.max(position - 1, 0); switch (next) { case Symbols.TokenEOF: case Symbols.TokenELSE: danglingElse= true; break; case Symbols.TokenCASE: case Symbols.TokenDEFAULT: // only if not right after the brace! if (prefAlignCaseWithSwitch() || fScanner.previousToken(prevPos, JavaHeuristicScanner.UNBOUND) != Symbols.TokenLBRACE) unindent= true; break; case Symbols.TokenLBRACE: // for opening-brace-on-new-line style if (fScanner.isBracelessBlockStart(prevPos, JavaHeuristicScanner.UNBOUND)) unindent= true; break; case Symbols.TokenRBRACE: // closing braces get unindented matchBrace= true; } } else { danglingElse= true; } // find the base position int unit= findReferencePosition(position, danglingElse, matchBrace); // handle special alignment if (fAlign != JavaHeuristicScanner.NOT_FOUND) { // a special case has been detected. IRegion line= fDocument.getLineInformationOfOffset(fAlign); int offset= line.getOffset(); return createIndent(offset, fAlign); } // if we were unable to find anything, return null if (unit == JavaHeuristicScanner.NOT_FOUND) return null; //$NON-NLS-1$ // get base indent at the reference location IRegion line= fDocument.getLineInformationOfOffset(unit); int offset= line.getOffset(); int nonWS= fScanner.findNonWhitespaceForwardInAnyPartition(offset, offset + line.getLength()); StringBuffer indent= new StringBuffer(fDocument.get(offset, nonWS - offset)); // add additional indent indent.append(createIndent(fIndent)); if (unindent) unindent(indent); return indent.toString(); } catch (BadLocationException e) { } return null; //$NON-NLS-1$ } /** * Reduces indentation in <code>indent</code> by one. * * @param indent the indentation to be modified */ private void unindent(StringBuffer indent) { String oneIndent= createIndent(1); int i= indent.lastIndexOf(oneIndent); //$NON-NLS-1$ if (i != -1) { indent.deleteCharAt(i); } } /** * Creates an indentation string of the length indent - start + 1, consisting of the content * in <code>fDocument</code> in the range [start, indent), with every character replaced by * a space except for tabs, which are kept as such. * * @return the indentation corresponding to the document content specified by <code>start</code> * and <code>indent</code> */ private String createIndent(int start, int indent) { int tabLen; if (JavaPlugin.getDefault() != null) tabLen= CodeFormatterUtil.getTabWidth(); else tabLen= 4; StringBuffer ret= new StringBuffer(); try { int spaces= 0; while (start < indent) { char ch= fDocument.getChar(start); if (ch == '\t') { ret.append('\t'); spaces= 0; } else { spaces++; if (spaces == tabLen) { ret.append('\t'); spaces= 0; } } start++; } if (fAlignPlusOne) spaces++; if (spaces == tabLen) ret.append('\t'); else while (spaces-- > 0) ret.append(' '); } catch (BadLocationException e) { } return ret.toString(); } /** * Creates a string that represents the given number of indents (can be spaces or tabs..) * @param indent the requested indentation level. * * @return the indentation specified by <code>indent</code> */ private String createIndent(int indent) { // get a sensible default when running without the infrastructure for testing if (JavaPlugin.getDefault() == null) { StringBuffer ret= new StringBuffer(); while (indent-- > 0) ret.append('\t'); return ret.toString(); } return CodeFormatterUtil.createIndentString(indent); } /** * Returns the reference position regarding to indentation for <code>position</code>, or * <code>NOT_FOUND</code>. <code>fIndent</code> will contain the relative indentation (in * indentation units, not characters) after the call. If there is a special alignment (e.g. for * a method declaration where parameters should be aligned), <code>fAlign</code> will contain the absolute * position of the alignment reference in <code>fDocument</code>, otherwise <code>fAlign</code> * is set to <code>JavaHeuristicScanner.NOT_FOUND</code>. * * @param position the position for which the reference is computed * @return the reference statement relative to which <code>position</code> should be indented. */ public int findReferencePosition(int position) { return findReferencePosition(position, false, false); } /** * Returns the reference position regarding to indentation for <code>position</code>, or * <code>NOT_FOUND</code>. <code>fIndent</code> will contain the relative indentation (in * indentation units, not characters) after the call. If there is a special alignment (e.g. for * a method declaration where parameters should be aligned), <code>fAlign</code> will contain the absolute * position of the alignment reference in <code>fDocument</code>, otherwise <code>fAlign</code> * is set to <code>JavaHeuristicScanner.NOT_FOUND</code>. * * @param position the position for which the reference is computed * @param danglingElse whether a dangling else should be assumed at <code>position</code> * @param matchBrace whether the position of the matching brace should be returned instead of doing code analysis * @return the reference statement relative to which <code>position</code> should be indented. */ private int findReferencePosition(int position, boolean danglingElse, boolean matchBrace) { fIndent= 0; // the indentation modification fAlign= JavaHeuristicScanner.NOT_FOUND; fPosition= position; boolean indentBlockLess= true; // whether to indent after an if / while / for without block (set false by semicolons and braces) boolean takeNextExit= true; // whether the next possible exit should be taken (instead of looking for the base; see blockless stuff) boolean found= false; // whether we have found anything at all. If we have, we'll trace back to it once we have a hoist point boolean hasBrace= false; if (matchBrace) { if (!skipScope(Symbols.TokenLBRACE, Symbols.TokenRBRACE)) fPosition= position; else { indentBlockLess= false; hasBrace= true; } } nextToken(); while (true) { switch (fToken) { // skip all scopes introduced by parenthesis' or brackets: case Symbols.TokenRBRACKET: skipScope(Symbols.TokenLBRACKET, Symbols.TokenRBRACKET); nextToken(); break; case Symbols.TokenRPAREN: skipScope(Symbols.TokenLPAREN, Symbols.TokenRPAREN); // handle special indentations: non-block conditionals nextToken(); int pos= fPosition; switch (fToken) { case Symbols.TokenWHILE: if (hasMatchingDo()) { nextToken(); break; } else { nextToken(pos); } case Symbols.TokenIF: if (danglingElse && fToken == Symbols.TokenIF) takeNextExit= true; case Symbols.TokenFOR: if (indentBlockLess) fIndent++; if (takeNextExit) return pos; } break; case Symbols.TokenDO: // do blockless special if (indentBlockLess) fIndent++; else // after a do, there has to come a while, on the same indentation as the do fIndent= 0; return fPosition; case Symbols.TokenELSE: // else blockless special if (indentBlockLess) fIndent++; if (takeNextExit) return fPosition; // else if (!searchIfForElse()) return JavaHeuristicScanner.NOT_FOUND; nextToken(); break; case Symbols.TokenCOLON: // switch statements and labels if (searchCaseGotoDefault()) { if (!hasBrace) fIndent++; return fPosition; } break; case Symbols.TokenQUESTIONMARK: // ternary expressions if (takeNextExit && prefTenaryDeepAlign()) fAlign= fPosition; nextToken(); break; // When we find a semi or lbrace, we have found a hoist point // Take the first start to the right from it. If there is only whitespace // up to position, search one step more. case Symbols.TokenLBRACE: int searchPos= fPreviousPos; // special array handling nextToken(); if (fToken == Symbols.TokenEQUAL || skipBrackets()) { int first= fScanner.findNonWhitespaceForwardInAnyPartition(searchPos, position); // ... with a first element already defined - take its offset if (prefArrayDeepIndent() && first != JavaHeuristicScanner.NOT_FOUND) { fAlign= first; } else fIndent += prefArrayIndent(); } hasBrace= true; if (found) return fScanner.findNonWhitespaceForward(searchPos, position); // search start of code forward or continue takeNextExit= true; indentBlockLess= false; // indent when searching over an LBRACE fIndent++; break; case Symbols.TokenSEMICOLON: // search start of code forward or continue if (found) return fScanner.findNonWhitespaceForward(fPreviousPos, position); takeNextExit= false; // search to the bottom of blockless statements indentBlockLess= false; // don't indent at the next blockless introducer nextToken(); break; case Symbols.TokenEOF: if (found) return fScanner.findNonWhitespaceForward(0, position); return JavaHeuristicScanner.NOT_FOUND; // RBRACE is either the end of a statement as SEMICOLON, // or - if no statement start can be found - must be skipped as RPAREN and RBRACKET case Symbols.TokenRBRACE: if (found) return fScanner.findNonWhitespaceForward(fPreviousPos, position); skipScope(Symbols.TokenLBRACE, Symbols.TokenRBRACE); takeNextExit= false; // search to the bottom of blockless statements indentBlockLess= false; // don't indent at the next blockless introducer nextToken(); break; // use double indentation inside conditions and calls // handle method definitions separately case Symbols.TokenLPAREN: // TODO differentiate between conditional continuation and calls if (!hasBrace) fIndent += prefCallContinuationIndent(); searchPos= fPreviousPos; if (prefMethodDeclDeepIndent() && looksLikeMethodDecl() && found) { fAlign= fScanner.findNonWhitespaceForward(searchPos, position); } break; // array dimensions case Symbols.TokenLBRACKET: if (prefArrayDimensionsDeepIndent() && found) fAlign= fScanner.findNonWhitespaceForward(fPreviousPos, position); fIndent+= prefArrayDimensionIndent(); nextToken(); break; default: nextToken(); } found= true; } } /** * Searches for a case, goto, or default after a scanned colon. * * @return <code>true</code> if one of the above keywords can be scanned, possibly separated * by an identifier or constant. */ private boolean searchCaseGotoDefault() { // after a colon while (true) { nextToken(); switch (fToken) { // number or char literals won't bother us, no scopes allowed case Symbols.TokenOTHER: case Symbols.TokenIDENT: break; case Symbols.TokenEOF: return false; case Symbols.TokenCASE: case Symbols.TokenDEFAULT: case Symbols.TokenGOTO: return true; default: return false; } } } /** * while(condition); is ambiguous when parsed backwardly, as it is a valid statement by its own, * so we have to check whether there is a matching do. A <code>do</code> can either be separated * from the while by a block, or by a single statement, which limits our search distance. * * @return <code>true</code> if the <code>while</code> currently in <code>fToken</code> has a matching <code>do</code>. */ private boolean hasMatchingDo() { Assert.isTrue(fToken == Symbols.TokenWHILE); return skipStatementOrBlock() && fToken == Symbols.TokenDO; } /** * Skips a statement or block, the token being the next token after it. * * @return <code>true</code> if a statement or block could be parsed, <code>false</code> otherwise. */ private boolean skipStatementOrBlock() { nextToken(); switch (fToken) { case Symbols.TokenRBRACE: // do { BLOCK } while if (skipScope(Symbols.TokenLBRACE, Symbols.TokenRBRACE)) { nextToken(); return true; } break; case Symbols.TokenSEMICOLON: // do statement; while nextToken(); while (true) { switch (fToken) { case Symbols.TokenRBRACE: // array definition skipScope(Symbols.TokenLBRACE, Symbols.TokenRBRACE); nextToken(); if (skipBrackets()) break; else return false; case Symbols.TokenRBRACKET: // array index skipScope(Symbols.TokenLBRACKET, Symbols.TokenRBRACKET); break; case Symbols.TokenRPAREN: // call, if , for, ..., step over skipScope(Symbols.TokenLPAREN, Symbols.TokenRPAREN); break; case Symbols.TokenSEMICOLON: return true; case Symbols.TokenLBRACE: return true; case Symbols.TokenLPAREN: return false; case Symbols.TokenLBRACKET: return false; case Symbols.TokenDO: return true; case Symbols.TokenIF: return true; case Symbols.TokenFOR: return true; case Symbols.TokenWHILE: return true; case Symbols.TokenEOF: return false; } nextToken(); } } return false; } /** * Skips brackets if the current token is a RBRACKET. There can be nothing in between, this is * only to be used for <code>[]</code> elements. * * @return <code>true</code> if a <code>[]</code> could be scanned, the current token is left at * the LBRACKET. */ private boolean skipBrackets() { if (fToken == Symbols.TokenRBRACKET) { nextToken(); if (fToken == Symbols.TokenLBRACKET) { return true; } } return false; } /** * Searches for the <code>if</code> matching a just scanned else. * * @return <code>true</code> if the matching if can be found, <code>false</code> otherwise */ private boolean searchIfForElse() { int depth= 1; while (true) { nextToken(); switch (fToken) { case Symbols.TokenRBRACE: skipScope(Symbols.TokenLBRACE, Symbols.TokenRBRACE); break; case Symbols.TokenIF: depth--; if (depth == 0) return true; break; case Symbols.TokenELSE: depth++; break; case Symbols.TokenEOF: return false; } } } /** * Reads the next token in backward direction from the heuristic scanner and sets the fields * <code>fToken, fPreviousPosition</code> and <code>fPosition</code> accordingly. */ private void nextToken() { nextToken(fPosition); } /** * Reads the next token in backward direction of <code>start</code> from the heuristic scanner and sets the fields * <code>fToken, fPreviousPosition</code> and <code>fPosition</code> accordingly. */ private void nextToken(int start) { fToken= fScanner.previousToken(start - 1, JavaHeuristicScanner.UNBOUND); fPreviousPos= start; fPosition= fScanner.getPosition() + 1; } /** * Returns <code>true</code> if the current tokens look like a method declaration header * (i.e. only the return type and method name). * * @return <code>true</code> if the current position looks like a method header. */ private boolean looksLikeMethodDecl() { nextToken(); if (fToken == Symbols.TokenIDENT) { // method name do nextToken(); while (skipBrackets()); // optional brackets for array valued return types return fToken == Symbols.TokenIDENT; // type name } return false; } /** * Scans tokens for the matching parenthesis. * * @return <code>true</code> if a matching token was found, <code>false</code> otherwise */ private boolean skipScope(int openToken, int closeToken) { int depth= 1; while (true) { nextToken(); if (fToken == closeToken) { depth++; } else if (fToken == openToken) { depth--; if (depth == 0) return true; } else if (fToken == Symbols.TokenEOF) { return false; } } } private boolean prefAlignCaseWithSwitch() { // TODO preference lookup return false; } private int prefArrayDimensionIndent() { // TODO preference lookup return 2; } private boolean prefArrayDimensionsDeepIndent() { // TODO preference lookup return true; } private boolean prefMethodDeclDeepIndent() { // TODO preference lookup return true; } private int prefCallContinuationIndent() { // TODO preference lookup return 2; } private int prefArrayIndent() { // TODO preference lookup return 2; } private boolean prefArrayDeepIndent() { // TODO preference lookup return false; } private boolean prefTenaryDeepAlign() { // TODO preference lookup return true; } }
42,785
Bug 42785 Write more AddUnimplementedConstructors Tests
Add more AddUnimplementedConstructorsTests to org.eclipse.jdt.ui.tests
resolved fixed
ea0bdd8
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2003-09-23T14:51:50Z
2003-09-09T15:06:40Z
org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/core/AddUnimplementedConstructorsTest.java
/******************************************************************************* * Copyright (c) 2000, 2003 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Common Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/cpl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.jdt.ui.tests.core; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.eclipse.jdt.testplugin.JavaProjectHelper; import org.eclipse.jdt.core.ICompilationUnit; import org.eclipse.jdt.core.IJavaElement; import org.eclipse.jdt.core.IJavaProject; import org.eclipse.jdt.core.IMethod; import org.eclipse.jdt.core.IPackageFragment; import org.eclipse.jdt.core.IPackageFragmentRoot; import org.eclipse.jdt.core.IType; import org.eclipse.jdt.internal.corext.codemanipulation.StubUtility; public class AddUnimplementedConstructorsTest extends TestCase { private static final Class THIS= AddUnimplementedConstructorsTest.class; private IJavaProject fJavaProject; private IPackageFragment fPackage; private IType fClassA; public AddUnimplementedConstructorsTest(String name) { super(name); } public static Test allTests() { return new ProjectTestSetup(new TestSuite(THIS)); } public static Test suite() { if (true) { return allTests(); } else { TestSuite suite= new TestSuite(); suite.addTest(new AddUnimplementedMethodsTest("test1")); return suite; } } /** * Creates a new test Java project. */ protected void setUp() throws Exception { } /** * Removes the test java project. */ protected void tearDown () throws Exception { JavaProjectHelper.delete(fJavaProject); fJavaProject= null; fPackage= null; fClassA= null; } /* * basic test: test with one constructor */ public void test1() throws Exception { fJavaProject= JavaProjectHelper.createJavaProject("DummyProject", "bin"); assertNotNull(JavaProjectHelper.addRTJar(fJavaProject)); IPackageFragmentRoot root= JavaProjectHelper.addSourceContainer(fJavaProject, "src"); fPackage= root.createPackageFragment("ibm.util", true, null); ICompilationUnit cu= fPackage.getCompilationUnit("A.java"); fClassA= cu.createType("public class A {\n}\n", null, true, null); fClassA.createMethod("public A() {\nsuper();}\n", null, true, null); ICompilationUnit cu2= fPackage.getCompilationUnit("Test1.java"); //$NON-NLS-1$ IType testClass= cu2.createType("public class Test1 extends A {\n}\n", null, true, null); //$NON-NLS-1$ IMethod[] constructorMethods= StubUtility.getOverridableConstructors(testClass); checkMethods(new String[] { "A" }, constructorMethods); //$NON-NLS-1$ } /* * basic test: test with 2 constructors to override */ public void test2() throws Exception { fJavaProject= JavaProjectHelper.createJavaProject("DummyProject", "bin"); assertNotNull(JavaProjectHelper.addRTJar(fJavaProject)); IPackageFragmentRoot root= JavaProjectHelper.addSourceContainer(fJavaProject, "src"); fPackage= root.createPackageFragment("ibm.util", true, null); ICompilationUnit cu= fPackage.getCompilationUnit("A.java"); fClassA= cu.createType("public class A {\n}\n", null, true, null); fClassA.createMethod("public A() {\nsuper();}\n", null, true, null); fClassA.createMethod("public A(int a) {super()}\n", null, true, null); ICompilationUnit cu2= fPackage.getCompilationUnit("Test1.java"); IType testClass= cu2.createType("public class Test1 extends A {\n}\n", null, true, null); IMethod[] constructorMethods= StubUtility.getOverridableConstructors(testClass); checkMethods(new String[] { "A", "A" }, constructorMethods); //$NON-NLS-1$ //$NON-NLS-2$ } /* * basic test: test with 3 constructors to override */ public void test3() throws Exception { fJavaProject= JavaProjectHelper.createJavaProject("DummyProject", "bin"); assertNotNull(JavaProjectHelper.addRTJar(fJavaProject)); IPackageFragmentRoot root= JavaProjectHelper.addSourceContainer(fJavaProject, "src"); fPackage= root.createPackageFragment("ibm.util", true, null); ICompilationUnit cu= fPackage.getCompilationUnit("A.java"); fClassA= cu.createType("public class A {\n}\n", null, true, null); fClassA.createMethod("public A() {\nsuper();}\n", null, true, null); fClassA.createMethod("public A(int a) {super()}\n", null, true, null); fClassA.createMethod("public A(int a, boolean boo) {super()}\n", null, true, null); ICompilationUnit cu2= fPackage.getCompilationUnit("Test1.java"); IType testClass= cu2.createType("public class Test1 extends A {\n}\n", null, true, null); IMethod[] constructorMethods= StubUtility.getOverridableConstructors(testClass); checkMethods(new String[] { "A", "A", "A" }, constructorMethods); //$NON-NLS-1$ //$NON-NLS-2$ } /* * basic test: test with default constructor only */ public void test4() throws Exception { fJavaProject= JavaProjectHelper.createJavaProject("DummyProject", "bin"); assertNotNull(JavaProjectHelper.addRTJar(fJavaProject)); IPackageFragmentRoot root= JavaProjectHelper.addSourceContainer(fJavaProject, "src"); fPackage= root.createPackageFragment("ibm.util", true, null); ICompilationUnit cu= fPackage.getCompilationUnit("A.java"); fClassA= cu.createType("public class A {\n}\n", null, true, null); ICompilationUnit cu2= fPackage.getCompilationUnit("Test1.java"); IType testClass= cu2.createType("public class Test1 extends A {\n}\n", null, true, null); IMethod[] constructorMethods= StubUtility.getOverridableConstructors(testClass); checkMethods(new String[] { "Object" }, constructorMethods); //$NON-NLS-1$ //$NON-NLS-2$ } /* * basic test: test with nothing to override */ public void test5() throws Exception { fJavaProject= JavaProjectHelper.createJavaProject("DummyProject", "bin"); assertNotNull(JavaProjectHelper.addRTJar(fJavaProject)); IPackageFragmentRoot root= JavaProjectHelper.addSourceContainer(fJavaProject, "src"); fPackage= root.createPackageFragment("ibm.util", true, null); ICompilationUnit cu= fPackage.getCompilationUnit("A.java"); fClassA= cu.createType("public class A {\n}\n", null, true, null); ICompilationUnit cu2= fPackage.getCompilationUnit("Test1.java"); IType testClass= cu2.createType("public class Test1 extends A {\n}\n", null, true, null); testClass.createMethod("public Test1(){}\n", null, true, null); IMethod[] constructorMethods= StubUtility.getOverridableConstructors(testClass); checkMethods(new String[] {}, constructorMethods); //$NON-NLS-1$ //$NON-NLS-2$ } private void checkMethods(String[] expected, IMethod[] methods) { int nMethods= methods.length; int nExpected= expected.length; assertTrue("" + nExpected + " methods expected, is " + nMethods, nMethods == nExpected); for (int i= 0; i < nExpected; i++) { String methName= expected[i]; assertTrue("method " + methName + " expected", nameContained(methName, methods)); } } private boolean nameContained(String methName, IJavaElement[] methods) { for (int i= 0; i < methods.length; i++) { if (methods[i].getElementName().equals(methName)) { return true; } } return false; } }
43,437
Bug 43437 Scanner does not like string literals
20030922 1. Create a scanner and initalize it with the string "\"hello\"" 2. Read two tokens: You get a TokenNameStringLiteral and a InvalidInputException: Unterminated_String I'd expect to get - TokenNameStringLiteral and a - TokenNameEOF
verified fixed
4774113
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2003-09-24T08:26:34Z
2003-09-22T17:00:00Z
org.eclipse.jdt.ui/core
43,437
Bug 43437 Scanner does not like string literals
20030922 1. Create a scanner and initalize it with the string "\"hello\"" 2. Read two tokens: You get a TokenNameStringLiteral and a InvalidInputException: Unterminated_String I'd expect to get - TokenNameStringLiteral and a - TokenNameEOF
verified fixed
4774113
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2003-09-24T08:26:34Z
2003-09-22T17:00:00Z
extension/org/eclipse/jdt/internal/corext/dom/CompilationUnitBuffer.java
43,437
Bug 43437 Scanner does not like string literals
20030922 1. Create a scanner and initalize it with the string "\"hello\"" 2. Read two tokens: You get a TokenNameStringLiteral and a InvalidInputException: Unterminated_String I'd expect to get - TokenNameStringLiteral and a - TokenNameEOF
verified fixed
4774113
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2003-09-24T08:26:34Z
2003-09-22T17:00:00Z
org.eclipse.jdt.ui/core
43,437
Bug 43437 Scanner does not like string literals
20030922 1. Create a scanner and initalize it with the string "\"hello\"" 2. Read two tokens: You get a TokenNameStringLiteral and a InvalidInputException: Unterminated_String I'd expect to get - TokenNameStringLiteral and a - TokenNameEOF
verified fixed
4774113
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2003-09-24T08:26:34Z
2003-09-22T17:00:00Z
extension/org/eclipse/jdt/internal/corext/javadoc/JavaDocAccess.java
43,437
Bug 43437 Scanner does not like string literals
20030922 1. Create a scanner and initalize it with the string "\"hello\"" 2. Read two tokens: You get a TokenNameStringLiteral and a InvalidInputException: Unterminated_String I'd expect to get - TokenNameStringLiteral and a - TokenNameEOF
verified fixed
4774113
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2003-09-24T08:26:34Z
2003-09-22T17:00:00Z
org.eclipse.jdt.ui/core
43,437
Bug 43437 Scanner does not like string literals
20030922 1. Create a scanner and initalize it with the string "\"hello\"" 2. Read two tokens: You get a TokenNameStringLiteral and a InvalidInputException: Unterminated_String I'd expect to get - TokenNameStringLiteral and a - TokenNameEOF
verified fixed
4774113
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2003-09-24T08:26:34Z
2003-09-22T17:00:00Z
extension/org/eclipse/jdt/internal/corext/util/CodeFormatterUtil.java