diff options
Diffstat (limited to 'org.eclipse.ui.workbench.texteditor/src/org')
15 files changed, 167 insertions, 167 deletions
diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/HippieCompletionEngine.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/HippieCompletionEngine.java index 25548967358..8c24259fadf 100644 --- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/HippieCompletionEngine.java +++ b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/HippieCompletionEngine.java @@ -162,15 +162,15 @@ public final class HippieCompletionEngine { /** * Search for possible completions in the backward direction. If there - * is a possible completion that begins before <code>firstPosition</code> - * but ends after that position, it will not be included in the results. + * is a possible completion that begins before <code>firstPosition</code> + * but ends after that position, it will not be included in the results. * * @param document the document to be scanned * @param prefix the completion prefix * @param firstPosition the caret position * @return a {@link List} of possible completions ({@link String}s) * from the caret position to the beginning of the document. - * The empty suggestion is not included in the results. + * The empty suggestion is not included in the results. * @throws BadLocationException if any error occurs */ public List<String> getCompletionsBackwards(IDocument document, CharSequence prefix, int firstPosition) throws BadLocationException { diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/quickdiff/DocumentLineDiffer.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/quickdiff/DocumentLineDiffer.java index 0439dff0f15..32ec5314c66 100644 --- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/quickdiff/DocumentLineDiffer.java +++ b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/quickdiff/DocumentLineDiffer.java @@ -1416,9 +1416,9 @@ public class DocumentLineDiffer implements ILineDiffer, IDocumentListener, IAnno fRightDocument= document; fRightDocument.addDocumentListener(this); if (document instanceof IDocumentExtension4) { - IDocumentExtension4 ext= (IDocumentExtension4) document; - ext.addDocumentRewriteSessionListener(fSessionListener); - } + IDocumentExtension4 ext= (IDocumentExtension4) document; + ext.addDocumentRewriteSessionListener(fSessionListener); + } initialize(); } } @@ -1454,9 +1454,9 @@ public class DocumentLineDiffer implements ILineDiffer, IDocumentListener, IAnno if (fRightDocument != null) { fRightDocument.removeDocumentListener(this); if (fRightDocument instanceof IDocumentExtension4) { - IDocumentExtension4 ext= (IDocumentExtension4) fRightDocument; - ext.removeDocumentRewriteSessionListener(fSessionListener); - } + IDocumentExtension4 ext= (IDocumentExtension4) fRightDocument; + ext.removeDocumentRewriteSessionListener(fSessionListener); + } } fRightDocument= null; fRightEquivalent= null; @@ -1486,7 +1486,7 @@ public class DocumentLineDiffer implements ILineDiffer, IDocumentListener, IAnno List<QuickDiffRangeDifference> differences= fDifferences; // atomic synchronized (differences) { copy= new ArrayList<>(differences); - } + } final Iterator<QuickDiffRangeDifference> iter= copy.iterator(); return new Iterator<Annotation>() { diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/quickdiff/compare/equivalence/DJBHashFunction.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/quickdiff/compare/equivalence/DJBHashFunction.java index 4fbc594af06..8223816b88d 100644 --- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/quickdiff/compare/equivalence/DJBHashFunction.java +++ b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/quickdiff/compare/equivalence/DJBHashFunction.java @@ -25,14 +25,14 @@ public final class DJBHashFunction implements IHashFunction { } private int hash(CharSequence seq){ - int hash = 5381; - int len= seq.length(); - for (int i= 0; i < len; i++) { - char ch= seq.charAt(i); - hash = ((hash << 5) + hash) + ch; /* hash * 33 + ch */ - } + int hash = 5381; + int len= seq.length(); + for (int i= 0; i < len; i++) { + char ch= seq.charAt(i); + hash = ((hash << 5) + hash) + ch; /* hash * 33 + ch */ + } - return hash; - } + return hash; + } } diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/AbstractTextEditor.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/AbstractTextEditor.java index 65f9467e92c..497865c87fa 100644 --- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/AbstractTextEditor.java +++ b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/AbstractTextEditor.java @@ -1860,7 +1860,7 @@ public abstract class AbstractTextEditor extends EditorPart implements ITextEdit return false; return getInformationPresenter().openFocusedAnnotationHover(annotationHover, line); - } + } /** * Returns the information presenter (creates it if necessary). @@ -3174,16 +3174,16 @@ public abstract class AbstractTextEditor extends EditorPart implements ITextEdit } catch (InvocationTargetException x) { Throwable t= x.getTargetException(); if (t instanceof CoreException) { - /* - /* XXX: Remove unpacking of CoreException once the following bug is - * fixed: https://bugs.eclipse.org/bugs/show_bug.cgi?id=81640 - */ - CoreException e= (CoreException)t; - IStatus status= e.getStatus(); - if (status.getException() != null) - throw new PartInitException(status); - throw new PartInitException(new Status(status.getSeverity(), status.getPlugin(), status.getCode(), status.getMessage(), t)); - } + /* + /* XXX: Remove unpacking of CoreException once the following bug is + * fixed: https://bugs.eclipse.org/bugs/show_bug.cgi?id=81640 + */ + CoreException e= (CoreException)t; + IStatus status= e.getStatus(); + if (status.getException() != null) + throw new PartInitException(status); + throw new PartInitException(new Status(status.getSeverity(), status.getPlugin(), status.getCode(), status.getMessage(), t)); + } throw new PartInitException(new Status(IStatus.ERROR, TextEditorPlugin.PLUGIN_ID, IStatus.OK, EditorMessages.Editor_error_init, t)); } } @@ -3685,14 +3685,14 @@ public abstract class AbstractTextEditor extends EditorPart implements ITextEdit } /** - * Tells whether the editor input should be included when adding object - * contributions to this editor's context menu. - * <p> - * This implementation always returns <code>true</code>. - * </p> - * + * Tells whether the editor input should be included when adding object + * contributions to this editor's context menu. + * <p> + * This implementation always returns <code>true</code>. + * </p> + * * @return <code>true</code> if the editor input should be considered - * @since 3.2 + * @since 3.2 */ protected boolean isEditorInputIncludedInContextMenu() { return true; @@ -6050,11 +6050,11 @@ public abstract class AbstractTextEditor extends EditorPart implements ITextEdit * @param newGroup the new group */ protected final void addGroup(IMenuManager menu, String existingGroup, String newGroup) { - IMenuManager subMenu= menu.findMenuUsingPath(existingGroup); - if (subMenu != null) - subMenu.add(new Separator(newGroup)); - else - menu.appendToGroup(existingGroup, new Separator(newGroup)); + IMenuManager subMenu= menu.findMenuUsingPath(existingGroup); + if (subMenu != null) + subMenu.add(new Separator(newGroup)); + else + menu.appendToGroup(existingGroup, new Separator(newGroup)); } /** @@ -6596,7 +6596,7 @@ public abstract class AbstractTextEditor extends EditorPart implements ITextEdit styledText.setCaret(fNonDefaultCaret); fNonDefaultCaretImage= fNonDefaultCaret.getImage(); } else if (fInitialCaret != styledText.getCaret()) - styledText.setCaret(fInitialCaret); + styledText.setCaret(fInitialCaret); } private void disposeNonDefaultCaret() { diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/AnnotationPreference.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/AnnotationPreference.java index cc9b923cb1c..00ff12d5508 100644 --- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/AnnotationPreference.java +++ b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/AnnotationPreference.java @@ -847,9 +847,9 @@ public class AnnotationPreference { } /** - * Sets the preference key for go to previous navigation enablement. - * - * @param isGoToPreviousNavigationTargetKey the preference key + * Sets the preference key for go to previous navigation enablement. + * + * @param isGoToPreviousNavigationTargetKey the preference key * @since 3.0 */ public void setIsGoToPreviousNavigationTargetKey(String isGoToPreviousNavigationTargetKey) { diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/BasicTextEditorActionContributor.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/BasicTextEditorActionContributor.java index 173b3da4210..f23c2164823 100644 --- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/BasicTextEditorActionContributor.java +++ b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/BasicTextEditorActionContributor.java @@ -292,12 +292,12 @@ public class BasicTextEditorActionContributor extends EditorActionBarContributor * @since 3.2 */ private void addOrInsert(IContributionManager menu, IContributionItem item) { - String id= item.getId(); + String id= item.getId(); if (menu.find(id) == null) - menu.add(item); - else - menu.insertAfter(id, item); - } + menu.add(item); + else + menu.insertAfter(id, item); + } @Override public void contributeToStatusLine(IStatusLineManager statusLineManager) { diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/ConfigurationElementSorter.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/ConfigurationElementSorter.java index 1fe94fcbf93..9082268f2de 100644 --- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/ConfigurationElementSorter.java +++ b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/ConfigurationElementSorter.java @@ -132,7 +132,7 @@ public abstract class ConfigurationElementSorter { Set<Bundle> fBundleSet= new HashSet<>(length); for (int i= 0; i < length; i++) { - IConfigurationElement configElement= getConfigurationElement(elements[i]); + IConfigurationElement configElement= getConfigurationElement(elements[i]); Bundle bundle= Platform.getBundle(configElement.getContributor().getName()); fDescriptorMapping.put(elements[i], bundle.getSymbolicName()); fBundleSet.add(bundle); @@ -148,18 +148,18 @@ public abstract class ConfigurationElementSorter { String requires = bundle.getHeaders().get(Constants.REQUIRE_BUNDLE); ManifestElement[] manifestElements; - try { - manifestElements = ManifestElement.parseHeader(Constants.REQUIRE_BUNDLE, requires); - } catch (BundleException e) { - String uid= getExtensionPointUniqueIdentifier(bundle); - String message= "ConfigurationElementSorter for '" + uid + "': getting required plug-ins for '" + bundle.getSymbolicName() + "' failed"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ - Status status= new Status(IStatus.ERROR, TextEditorPlugin.PLUGIN_ID, IStatus.OK, message, e); - TextEditorPlugin.getDefault().getLog().log(status); - continue; - } - - if (manifestElements == null) - continue; + try { + manifestElements = ManifestElement.parseHeader(Constants.REQUIRE_BUNDLE, requires); + } catch (BundleException e) { + String uid= getExtensionPointUniqueIdentifier(bundle); + String message= "ConfigurationElementSorter for '" + uid + "': getting required plug-ins for '" + bundle.getSymbolicName() + "' failed"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + Status status= new Status(IStatus.ERROR, TextEditorPlugin.PLUGIN_ID, IStatus.OK, message, e); + TextEditorPlugin.getDefault().getLog().log(status); + continue; + } + + if (manifestElements == null) + continue; int i= 0; while (i < manifestElements.length && !toTest.isEmpty()) { @@ -194,7 +194,7 @@ public abstract class ConfigurationElementSorter { while (iter.hasNext()) { Entry<Object, String> entry= iter.next(); if (bundleName.equals(entry.getValue())) { - IExtension extension = getConfigurationElement(entry.getKey()).getDeclaringExtension(); + IExtension extension = getConfigurationElement(entry.getKey()).getDeclaringExtension(); return extension.getExtensionPointUniqueIdentifier(); } } diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/FindReplaceAction.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/FindReplaceAction.java index 90bcab1dd8a..5839928d3c8 100644 --- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/FindReplaceAction.java +++ b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/FindReplaceAction.java @@ -290,7 +290,7 @@ public class FindReplaceAction extends ResourceAction implements IUpdate { Assert.isLegal(target != null && shell != null); fTarget= target; fShell= shell; - update(); + update(); } /** diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/IAbstractTextEditorHelpContextIds.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/IAbstractTextEditorHelpContextIds.java index 3f1e2a36b67..22e039b4273 100644 --- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/IAbstractTextEditorHelpContextIds.java +++ b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/IAbstractTextEditorHelpContextIds.java @@ -340,46 +340,46 @@ public interface IAbstractTextEditorHelpContextIds { */ String TOGGLE_INSERT_MODE_ACTION= PREFIX + "toggle_insert_mode" + ACTION_POSTFIX; //$NON-NLS-1$;; - /** - * Help context id for the word completion action. - * Value: <code>"org.eclipse.ui.hippie_completion_action_context"</code> - * @since 3.1 - */ - String HIPPIE_COMPLETION_ACTION= PREFIX + "hippie_completion" + ACTION_POSTFIX; //$NON-NLS-1$ - - /** - * Help context id for the content assist action. - * Value: <code>"org.eclipse.ui.content_assist_action_context"</code> - * @since 3.5 - */ - String CONTENT_ASSIST_ACTION= PREFIX + "content_assist" + ACTION_POSTFIX; //$NON-NLS-1$ - - /** - * Help context id for the content assist context information action. - * Value: <code>"org.eclipse.ui.content_assist_context_information_action_context"</code> - * @since 3.5 - */ - String CONTENT_ASSIST_CONTEXT_INFORMATION_ACTION= PREFIX + "content_assist_context_information" + ACTION_POSTFIX; //$NON-NLS-1$ - - /** - * Help context id for the quick assist action. - * Value: <code>"org.eclipse.ui.quick_assist_action_context"</code> - * @since 3.2 - */ - String QUICK_ASSIST_ACTION= PREFIX + "quick_assist" + ACTION_POSTFIX; //$NON-NLS-1$ - - /** - * Help context id for the recenter action. - * Value: <code>"org.eclipse.ui.recenter_action_context"</code> - * @since 3.3 - */ - String RECENTER_ACTION= PREFIX + "recenter" + ACTION_POSTFIX; //$NON-NLS-1$ - - /** - * Help context id for the show whitespace characters action. - * Value: <code>"org.eclipse.ui.show_whitespace_characters_action_context"</code> - * @since 3.3 - */ + /** + * Help context id for the word completion action. + * Value: <code>"org.eclipse.ui.hippie_completion_action_context"</code> + * @since 3.1 + */ + String HIPPIE_COMPLETION_ACTION= PREFIX + "hippie_completion" + ACTION_POSTFIX; //$NON-NLS-1$ + + /** + * Help context id for the content assist action. + * Value: <code>"org.eclipse.ui.content_assist_action_context"</code> + * @since 3.5 + */ + String CONTENT_ASSIST_ACTION= PREFIX + "content_assist" + ACTION_POSTFIX; //$NON-NLS-1$ + + /** + * Help context id for the content assist context information action. + * Value: <code>"org.eclipse.ui.content_assist_context_information_action_context"</code> + * @since 3.5 + */ + String CONTENT_ASSIST_CONTEXT_INFORMATION_ACTION= PREFIX + "content_assist_context_information" + ACTION_POSTFIX; //$NON-NLS-1$ + + /** + * Help context id for the quick assist action. + * Value: <code>"org.eclipse.ui.quick_assist_action_context"</code> + * @since 3.2 + */ + String QUICK_ASSIST_ACTION= PREFIX + "quick_assist" + ACTION_POSTFIX; //$NON-NLS-1$ + + /** + * Help context id for the recenter action. + * Value: <code>"org.eclipse.ui.recenter_action_context"</code> + * @since 3.3 + */ + String RECENTER_ACTION= PREFIX + "recenter" + ACTION_POSTFIX; //$NON-NLS-1$ + + /** + * Help context id for the show whitespace characters action. + * Value: <code>"org.eclipse.ui.show_whitespace_characters_action_context"</code> + * @since 3.3 + */ String SHOW_WHITESPACE_CHARACTERS_ACTION= PREFIX + "show_whitepsace_characters" + ACTION_POSTFIX; //$NON-NLS-1$ /** diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/InfoForm.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/InfoForm.java index cfd00592731..ccc5e44ff6c 100644 --- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/InfoForm.java +++ b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/InfoForm.java @@ -149,7 +149,7 @@ public class InfoForm { fText.setText(info); } - /** + /** * Handles the property change. * * @param event the property change event object describing which property changed and how diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/RetargetTextEditorAction.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/RetargetTextEditorAction.java index 18c6733c298..1359ef94528 100644 --- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/RetargetTextEditorAction.java +++ b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/RetargetTextEditorAction.java @@ -64,7 +64,7 @@ public final class RetargetTextEditorAction extends ResourceAction { * (described in <code>ResourceAction</code> constructor), or * <code>null</code> if none * @param style one of <code>IAction.AS_PUSH_BUTTON</code>, <code>IAction.AS_CHECK_BOX</code>, - * and <code>IAction.AS_RADIO_BUTTON</code>. + * and <code>IAction.AS_RADIO_BUTTON</code>. * * @see ResourceAction#ResourceAction(ResourceBundle, String, int) * @see IAction#AS_CHECK_BOX @@ -109,7 +109,7 @@ public final class RetargetTextEditorAction extends ResourceAction { * (described in <code>ResourceAction</code> constructor), or <code>null</code> if none * @param actionId the action id * @param style one of <code>IAction.AS_PUSH_BUTTON</code>, <code>IAction.AS_CHECK_BOX</code>, - * and <code>IAction.AS_RADIO_BUTTON</code>. + * and <code>IAction.AS_RADIO_BUTTON</code>. * * @see ResourceAction#ResourceAction(ResourceBundle, String, int) * @see IAction#AS_CHECK_BOX @@ -183,7 +183,7 @@ public final class RetargetTextEditorAction extends ResourceAction { setEnabled(false); if (getStyle() == AS_CHECK_BOX || getStyle() == AS_RADIO_BUTTON) - setChecked(false); + setChecked(false); setText(fDefaultText); setToolTipText(""); //$NON-NLS-1$ @@ -191,7 +191,7 @@ public final class RetargetTextEditorAction extends ResourceAction { setEnabled(fAction.isEnabled()); if (fAction.getStyle() == AS_CHECK_BOX || fAction.getStyle() == AS_RADIO_BUTTON) - super.setChecked(fAction.isChecked()); + super.setChecked(fAction.isChecked()); setText(fAction.getText()); setToolTipText(fAction.getToolTipText()); fAction.addPropertyChangeListener(fListener); diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/SourceViewerDecorationSupport.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/SourceViewerDecorationSupport.java index 87d43bdaf1f..e2e0e89c211 100644 --- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/SourceViewerDecorationSupport.java +++ b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/SourceViewerDecorationSupport.java @@ -507,7 +507,7 @@ public class SourceViewerDecorationSupport { /* * @see AbstractTextEditor#handlePreferenceStoreChanged(PropertyChangeEvent) - */ + */ protected void handlePreferenceStoreChanged(PropertyChangeEvent event) { String p= event.getProperty(); diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/templates/ColumnLayout.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/templates/ColumnLayout.java index ee22664199f..f0d77999ae1 100644 --- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/templates/ColumnLayout.java +++ b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/templates/ColumnLayout.java @@ -188,41 +188,41 @@ final class ColumnLayout extends Layout { @Override protected void layout(Composite composite, boolean flushCache) { - Rectangle area= composite.getClientArea(); - Table table= getTable(composite); - int tableWidth= table.getSize().x; - int trim= computeTrim(area, table, tableWidth); - int width= Math.max(0, area.width - trim); - - if (width > 1) - layoutTable(table, width, area, tableWidth < area.width); - - if( composite.getData(RECALCULATE_LAYOUT) == null ) { - composite.setData(RECALCULATE_LAYOUT, Boolean.FALSE); - composite.layout(); - } + Rectangle area= composite.getClientArea(); + Table table= getTable(composite); + int tableWidth= table.getSize().x; + int trim= computeTrim(area, table, tableWidth); + int width= Math.max(0, area.width - trim); + + if (width > 1) + layoutTable(table, width, area, tableWidth < area.width); + + if( composite.getData(RECALCULATE_LAYOUT) == null ) { + composite.setData(RECALCULATE_LAYOUT, Boolean.FALSE); + composite.layout(); + } } private int computeTrim(Rectangle area, Table table, int tableWidth) { Point preferredSize= computeTableSize(table, area.width, area.height); - int trim; - if (tableWidth > 1) { - trim= tableWidth - table.getClientArea().width; - } else { - // initially, the table has no extend and no client area - use the border with - // plus some padding as educated guess - trim= 2 * table.getBorderWidth() + 1 ; - } - if (preferredSize.y > area.height) { - // Subtract the scrollbar width from the total column width - // if a vertical scrollbar will be required, but is not currently showing - // (in which case it is already subtracted above) - ScrollBar vBar= table.getVerticalBar(); - if (!vBar.isVisible()) { - Point vBarSize= vBar.getSize(); - trim += vBarSize.x; - } - } + int trim; + if (tableWidth > 1) { + trim= tableWidth - table.getClientArea().width; + } else { + // initially, the table has no extend and no client area - use the border with + // plus some padding as educated guess + trim= 2 * table.getBorderWidth() + 1 ; + } + if (preferredSize.y > area.height) { + // Subtract the scrollbar width from the total column width + // if a vertical scrollbar will be required, but is not currently showing + // (in which case it is already subtracted above) + ScrollBar vBar= table.getVerticalBar(); + if (!vBar.isVisible()) { + Point vBarSize= vBar.getSize(); + trim += vBarSize.x; + } + } return trim; } diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/templates/TemplatePreferencePage.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/templates/TemplatePreferencePage.java index 2d93bbb6f98..1583a795f63 100644 --- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/templates/TemplatePreferencePage.java +++ b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/templates/TemplatePreferencePage.java @@ -832,24 +832,24 @@ public abstract class TemplatePreferencePage extends PreferencePage implements I layout.marginWidth= 0; parent.setLayout(layout); - Composite innerParent= new Composite(parent, SWT.NONE); - GridLayout innerLayout= new GridLayout(); - innerLayout.numColumns= 2; - innerLayout.marginHeight= 0; - innerLayout.marginWidth= 0; - innerParent.setLayout(innerLayout); - GridData gd= new GridData(GridData.FILL_BOTH); - gd.horizontalSpan= 2; - innerParent.setLayoutData(gd); - - Composite tableComposite= new Composite(innerParent, SWT.NONE); - GridData data= new GridData(GridData.FILL_BOTH); - data.widthHint= 360; - data.heightHint= convertHeightInCharsToPixels(10); - tableComposite.setLayoutData(data); - - ColumnLayout columnLayout= new ColumnLayout(); - tableComposite.setLayout(columnLayout); + Composite innerParent= new Composite(parent, SWT.NONE); + GridLayout innerLayout= new GridLayout(); + innerLayout.numColumns= 2; + innerLayout.marginHeight= 0; + innerLayout.marginWidth= 0; + innerParent.setLayout(innerLayout); + GridData gd= new GridData(GridData.FILL_BOTH); + gd.horizontalSpan= 2; + innerParent.setLayoutData(gd); + + Composite tableComposite= new Composite(innerParent, SWT.NONE); + GridData data= new GridData(GridData.FILL_BOTH); + data.widthHint= 360; + data.heightHint= convertHeightInCharsToPixels(10); + tableComposite.setLayoutData(data); + + ColumnLayout columnLayout= new ColumnLayout(); + tableComposite.setLayout(columnLayout); Table table= new Table(tableComposite, SWT.CHECK | SWT.BORDER | SWT.MULTI | SWT.FULL_SELECTION | SWT.H_SCROLL | SWT.V_SCROLL); table.setHeaderVisible(true); @@ -959,10 +959,10 @@ public abstract class TemplatePreferencePage extends PreferencePage implements I if (isShowFormatterSetting()) { fFormatButton= new Button(parent, SWT.CHECK); fFormatButton.setText(TemplatesMessages.TemplatePreferencePage_use_code_formatter); - GridData gd1= new GridData(); - gd1.horizontalSpan= 2; - fFormatButton.setLayoutData(gd1); - fFormatButton.setSelection(getPreferenceStore().getBoolean(getFormatterPreferenceKey())); + GridData gd1= new GridData(); + gd1.horizontalSpan= 2; + fFormatButton.setLayoutData(gd1); + fFormatButton.setSelection(getPreferenceStore().getBoolean(getFormatterPreferenceKey())); } fTableViewer.setInput(fTemplateStore); diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/templates/TemplatesTransfer.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/templates/TemplatesTransfer.java index a8edbdc3907..a7f1443458e 100644 --- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/templates/TemplatesTransfer.java +++ b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/templates/TemplatesTransfer.java @@ -69,9 +69,9 @@ class TemplatesTransfer extends ByteArrayTransfer { @Override protected Object nativeToJava(TransferData transferData) { - Object result= super.nativeToJava(transferData); - if (!(result instanceof byte[]) || !TYPE_NAME.equals(new String((byte[]) result))) - return null ; + Object result= super.nativeToJava(transferData); + if (!(result instanceof byte[]) || !TYPE_NAME.equals(new String((byte[]) result))) + return null ; return fObject ; } } |