A massive organize imports and formatting of the sources using default Eclipse code...
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpdt / internal / ui / text / java / hover / SourceViewerInformationControl.java
index d48678b..d852710 100644 (file)
@@ -41,202 +41,246 @@ import org.eclipse.swt.widgets.Label;
 import org.eclipse.swt.widgets.Shell;
 
 /**
- * Source viewer based implementation of <code>IInformationControl</code>. 
- * Displays information in a source viewer. 
+ * Source viewer based implementation of <code>IInformationControl</code>.
+ * Displays information in a source viewer.
  * 
  * @since 3.0
  */
-public class SourceViewerInformationControl implements IInformationControl, IInformationControlExtension, DisposeListener {
-       
+public class SourceViewerInformationControl implements IInformationControl,
+               IInformationControlExtension, DisposeListener {
+
        /** Border thickness in pixels. */
-       private static final int BORDER= 1;
+       private static final int BORDER = 1;
+
        /** The control's shell */
        private Shell fShell;
+
        /** The control's text widget */
        private StyledText fText;
+
        /** The control's source viewer */
-       private SourceViewer fViewer;   
+       private SourceViewer fViewer;
+
        /**
         * The optional status field.
         * 
         * @since 3.0
         */
-       private Label fStatusField; 
+       private Label fStatusField;
+
        /**
         * The separator for the optional status field.
         * 
         * @since 3.0
         */
-       private Label fSeparator; 
+       private Label fSeparator;
+
        /**
         * The font of the optional status text label.
         * 
         * @since 3.0
         */
        private Font fStatusTextFont;
-       
+
        /**
-        * Creates a default information control with the given shell as parent. The given
-        * information presenter is used to process the information to be displayed. The given
-        * styles are applied to the created styled text widget.
+        * Creates a default information control with the given shell as parent. The
+        * given information presenter is used to process the information to be
+        * displayed. The given styles are applied to the created styled text
+        * widget.
         * 
-        * @param parent the parent shell
-        * @param shellStyle the additional styles for the shell
-        * @param style the additional styles for the styled text widget
+        * @param parent
+        *            the parent shell
+        * @param shellStyle
+        *            the additional styles for the shell
+        * @param style
+        *            the additional styles for the styled text widget
         */
-       public SourceViewerInformationControl(Shell parent, int shellStyle, int style) {
+       public SourceViewerInformationControl(Shell parent, int shellStyle,
+                       int style) {
                this(parent, shellStyle, style, null);
        }
-       
+
        /**
-        * Creates a default information control with the given shell as parent. The given
-        * information presenter is used to process the information to be displayed. The given
-        * styles are applied to the created styled text widget.
+        * Creates a default information control with the given shell as parent. The
+        * given information presenter is used to process the information to be
+        * displayed. The given styles are applied to the created styled text
+        * widget.
         * 
-        * @param parent the parent shell
-        * @param shellStyle the additional styles for the shell
-        * @param style the additional styles for the styled text widget
-        * @param statusFieldText the text to be used in the optional status field
-        *                         or <code>null</code> if the status field should be hidden
+        * @param parent
+        *            the parent shell
+        * @param shellStyle
+        *            the additional styles for the shell
+        * @param style
+        *            the additional styles for the styled text widget
+        * @param statusFieldText
+        *            the text to be used in the optional status field or
+        *            <code>null</code> if the status field should be hidden
         * @since 3.0
         */
-       public SourceViewerInformationControl(Shell parent, int shellStyle, int style, String statusFieldText) {
+       public SourceViewerInformationControl(Shell parent, int shellStyle,
+                       int style, String statusFieldText) {
                GridLayout layout;
                GridData gd;
 
-               fShell= new Shell(parent, SWT.NO_FOCUS | SWT.ON_TOP | shellStyle);
-               Display display= fShell.getDisplay();           
+               fShell = new Shell(parent, SWT.NO_FOCUS | SWT.ON_TOP | shellStyle);
+               Display display = fShell.getDisplay();
                fShell.setBackground(display.getSystemColor(SWT.COLOR_BLACK));
 
-               Composite composite= fShell;
-               layout= new GridLayout(1, false);
-               int border= ((shellStyle & SWT.NO_TRIM) == 0) ? 0 : BORDER;
-               layout.marginHeight= border;
-               layout.marginWidth= border;
+               Composite composite = fShell;
+               layout = new GridLayout(1, false);
+               int border = ((shellStyle & SWT.NO_TRIM) == 0) ? 0 : BORDER;
+               layout.marginHeight = border;
+               layout.marginWidth = border;
                composite.setLayout(layout);
-               gd= new GridData(GridData.FILL_HORIZONTAL);
+               gd = new GridData(GridData.FILL_HORIZONTAL);
                composite.setLayoutData(gd);
 
                if (statusFieldText != null) {
-                       composite= new Composite(composite, SWT.NONE);
-                       layout= new GridLayout(1, false);
-                       layout.marginHeight= 0;
-                       layout.marginWidth= 0;
+                       composite = new Composite(composite, SWT.NONE);
+                       layout = new GridLayout(1, false);
+                       layout.marginHeight = 0;
+                       layout.marginWidth = 0;
                        composite.setLayout(layout);
-                       gd= new GridData(GridData.FILL_BOTH);
+                       gd = new GridData(GridData.FILL_BOTH);
                        composite.setLayoutData(gd);
-                       composite.setForeground(display.getSystemColor(SWT.COLOR_INFO_FOREGROUND));
-                       composite.setBackground(display.getSystemColor(SWT.COLOR_INFO_BACKGROUND));
-               }               
+                       composite.setForeground(display
+                                       .getSystemColor(SWT.COLOR_INFO_FOREGROUND));
+                       composite.setBackground(display
+                                       .getSystemColor(SWT.COLOR_INFO_BACKGROUND));
+               }
 
                // Source viewer
-               IPreferenceStore store= PHPeclipsePlugin.getDefault().getCombinedPreferenceStore();
-               fViewer= new JavaSourceViewer(composite, null, null, false, style, store);
-               fViewer.configure(new PHPSourceViewerConfiguration(PHPeclipsePlugin.getDefault().getJavaTextTools().getColorManager(), store, null, null));
+               IPreferenceStore store = PHPeclipsePlugin.getDefault()
+                               .getCombinedPreferenceStore();
+               fViewer = new JavaSourceViewer(composite, null, null, false, style,
+                               store);
+               fViewer.configure(new PHPSourceViewerConfiguration(PHPeclipsePlugin
+                               .getDefault().getJavaTextTools().getColorManager(), store,
+                               null, null));
                fViewer.setEditable(false);
-               
-               fText= fViewer.getTextWidget();
-               gd= new GridData(GridData.BEGINNING | GridData.FILL_BOTH);
+
+               fText = fViewer.getTextWidget();
+               gd = new GridData(GridData.BEGINNING | GridData.FILL_BOTH);
                fText.setLayoutData(gd);
-               fText.setForeground(parent.getDisplay().getSystemColor(SWT.COLOR_INFO_FOREGROUND));
-               fText.setBackground(parent.getDisplay().getSystemColor(SWT.COLOR_INFO_BACKGROUND));
-                       
+               fText.setForeground(parent.getDisplay().getSystemColor(
+                               SWT.COLOR_INFO_FOREGROUND));
+               fText.setBackground(parent.getDisplay().getSystemColor(
+                               SWT.COLOR_INFO_BACKGROUND));
+
                fText.addKeyListener(new KeyListener() {
-                               
-                       public void keyPressed(KeyEvent e)  {
+
+                       public void keyPressed(KeyEvent e) {
                                if (e.character == 0x1B) // ESC
                                        fShell.dispose();
                        }
-                               
-                       public void keyReleased(KeyEvent e) {}
+
+                       public void keyReleased(KeyEvent e) {
+                       }
                });
 
                // Status field
                if (statusFieldText != null) {
 
                        // Horizontal separator line
-                       fSeparator= new Label(composite, SWT.SEPARATOR | SWT.HORIZONTAL | SWT.LINE_DOT);
+                       fSeparator = new Label(composite, SWT.SEPARATOR | SWT.HORIZONTAL
+                                       | SWT.LINE_DOT);
                        fSeparator.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
 
                        // Status field label
-                       fStatusField= new Label(composite, SWT.RIGHT);
+                       fStatusField = new Label(composite, SWT.RIGHT);
                        fStatusField.setText(statusFieldText);
-                       Font font= fStatusField.getFont();
-                       FontData[] fontDatas= font.getFontData();
-                       for (int i= 0; i < fontDatas.length; i++)
+                       Font font = fStatusField.getFont();
+                       FontData[] fontDatas = font.getFontData();
+                       for (int i = 0; i < fontDatas.length; i++)
                                fontDatas[i].setHeight(fontDatas[i].getHeight() * 9 / 10);
-                       fStatusTextFont= new Font(fStatusField.getDisplay(), fontDatas);
+                       fStatusTextFont = new Font(fStatusField.getDisplay(), fontDatas);
                        fStatusField.setFont(fStatusTextFont);
-                       GridData gd2= new GridData(GridData.FILL_VERTICAL | GridData.FILL_HORIZONTAL | GridData.HORIZONTAL_ALIGN_BEGINNING | GridData.VERTICAL_ALIGN_BEGINNING);
+                       GridData gd2 = new GridData(GridData.FILL_VERTICAL
+                                       | GridData.FILL_HORIZONTAL
+                                       | GridData.HORIZONTAL_ALIGN_BEGINNING
+                                       | GridData.VERTICAL_ALIGN_BEGINNING);
                        fStatusField.setLayoutData(gd2);
 
                        // Regarding the color see bug 41128
-                       fStatusField.setForeground(display.getSystemColor(SWT.COLOR_WIDGET_DARK_SHADOW));
+                       fStatusField.setForeground(display
+                                       .getSystemColor(SWT.COLOR_WIDGET_DARK_SHADOW));
 
-                       fStatusField.setBackground(display.getSystemColor(SWT.COLOR_INFO_BACKGROUND));
+                       fStatusField.setBackground(display
+                                       .getSystemColor(SWT.COLOR_INFO_BACKGROUND));
                }
-               
+
                addDisposeListener(this);
        }
 
        /**
-        * Creates a default information control with the given shell as parent. The given
-        * information presenter is used to process the information to be displayed. The given
-        * styles are applied to the created styled text widget.
+        * Creates a default information control with the given shell as parent. The
+        * given information presenter is used to process the information to be
+        * displayed. The given styles are applied to the created styled text
+        * widget.
         * 
-        * @param parent the parent shell
-        * @param style the additional styles for the styled text widget
-        */     
-       public SourceViewerInformationControl(Shell parent,int style) {
+        * @param parent
+        *            the parent shell
+        * @param style
+        *            the additional styles for the styled text widget
+        */
+       public SourceViewerInformationControl(Shell parent, int style) {
                this(parent, SWT.NO_TRIM, style);
        }
-       
+
        /**
-        * Creates a default information control with the given shell as parent. The given
-        * information presenter is used to process the information to be displayed. The given
-        * styles are applied to the created styled text widget.
+        * Creates a default information control with the given shell as parent. The
+        * given information presenter is used to process the information to be
+        * displayed. The given styles are applied to the created styled text
+        * widget.
         * 
-        * @param parent the parent shell
-        * @param style the additional styles for the styled text widget
-        * @param statusFieldText the text to be used in the optional status field
-        *                         or <code>null</code> if the status field should be hidden
+        * @param parent
+        *            the parent shell
+        * @param style
+        *            the additional styles for the styled text widget
+        * @param statusFieldText
+        *            the text to be used in the optional status field or
+        *            <code>null</code> if the status field should be hidden
         * @since 3.0
-        */     
-       public SourceViewerInformationControl(Shell parent,int style, String statusFieldText) {
+        */
+       public SourceViewerInformationControl(Shell parent, int style,
+                       String statusFieldText) {
                this(parent, SWT.NO_TRIM, style, statusFieldText);
        }
 
        /**
-        * Creates a default information control with the given shell as parent.
-        * No information presenter is used to process the information
-        * to be displayed. No additional styles are applied to the styled text widget.
+        * Creates a default information control with the given shell as parent. No
+        * information presenter is used to process the information to be displayed.
+        * No additional styles are applied to the styled text widget.
         * 
-        * @param parent the parent shell
+        * @param parent
+        *            the parent shell
         */
        public SourceViewerInformationControl(Shell parent) {
                this(parent, SWT.NONE);
        }
 
        /**
-        * Creates a default information control with the given shell as parent.
-        * No information presenter is used to process the information
-        * to be displayed. No additional styles are applied to the styled text widget.
+        * Creates a default information control with the given shell as parent. No
+        * information presenter is used to process the information to be displayed.
+        * No additional styles are applied to the styled text widget.
         * 
-        * @param parent the parent shell
-        * @param statusFieldText the text to be used in the optional status field
-        *                         or <code>null</code> if the status field should be hidden
+        * @param parent
+        *            the parent shell
+        * @param statusFieldText
+        *            the text to be used in the optional status field or
+        *            <code>null</code> if the status field should be hidden
         * @since 3.0
         */
        public SourceViewerInformationControl(Shell parent, String statusFieldText) {
                this(parent, SWT.NONE, statusFieldText);
        }
-       
+
        /*
         * @see org.eclipse.jface.text.IInformationControlExtension2#setInput(java.lang.Object)
         */
        public void setInput(Object input) {
                if (input instanceof String)
-                       setInformation((String)input);
+                       setInformation((String) input);
                else
                        setInformation(null);
        }
@@ -249,33 +293,35 @@ public class SourceViewerInformationControl implements IInformationControl, IInf
                        fViewer.setInput(null);
                        return;
                }
-                               
-               IDocument doc= new Document(content);
-               PHPeclipsePlugin.getDefault().getJavaTextTools().setupJavaDocumentPartitioner(doc);
-               
+
+               IDocument doc = new Document(content);
+               PHPeclipsePlugin.getDefault().getJavaTextTools()
+                               .setupJavaDocumentPartitioner(doc);
+
                fViewer.setInput(doc);
        }
-       
+
        /*
         * @see IInformationControl#setVisible(boolean)
         */
        public void setVisible(boolean visible) {
-                       fShell.setVisible(visible);
+               fShell.setVisible(visible);
        }
 
        /**
         * {@inheritDoc}
+        * 
         * @since 3.0
         */
        public void widgetDisposed(DisposeEvent event) {
                if (fStatusTextFont != null && !fStatusTextFont.isDisposed())
                        fStatusTextFont.dispose();
-               
-               fStatusTextFont= null;
-               fShell= null;
-               fText= null;
+
+               fStatusTextFont = null;
+               fShell = null;
+               fText = null;
        }
-               
+
        /**
         * {@inheritDoc}
         */
@@ -285,84 +331,86 @@ public class SourceViewerInformationControl implements IInformationControl, IInf
                else
                        widgetDisposed(null);
        }
-       
+
        /*
         * @see IInformationControl#setSize(int, int)
         */
        public void setSize(int width, int height) {
-               
+
                if (fStatusField != null) {
-                       GridData gd= (GridData)fViewer.getTextWidget().getLayoutData();
-                       Point statusSize= fStatusField.computeSize(SWT.DEFAULT, SWT.DEFAULT, true);
-                       Point separatorSize= fSeparator.computeSize(SWT.DEFAULT, SWT.DEFAULT, true);
-                       gd.heightHint= height - statusSize.y - separatorSize.y;
+                       GridData gd = (GridData) fViewer.getTextWidget().getLayoutData();
+                       Point statusSize = fStatusField.computeSize(SWT.DEFAULT,
+                                       SWT.DEFAULT, true);
+                       Point separatorSize = fSeparator.computeSize(SWT.DEFAULT,
+                                       SWT.DEFAULT, true);
+                       gd.heightHint = height - statusSize.y - separatorSize.y;
                }
                fShell.setSize(width, height);
-               
+
                if (fStatusField != null)
                        fShell.pack(true);
        }
-       
+
        /*
         * @see IInformationControl#setLocation(Point)
         */
        public void setLocation(Point location) {
-               Rectangle trim= fShell.computeTrim(0, 0, 0, 0);
-               Point textLocation= fText.getLocation();                                
-               location.x += trim.x - textLocation.x;          
-               location.y += trim.y - textLocation.y;          
-               fShell.setLocation(location);           
+               Rectangle trim = fShell.computeTrim(0, 0, 0, 0);
+               Point textLocation = fText.getLocation();
+               location.x += trim.x - textLocation.x;
+               location.y += trim.y - textLocation.y;
+               fShell.setLocation(location);
        }
-       
+
        /*
         * @see IInformationControl#setSizeConstraints(int, int)
         */
        public void setSizeConstraints(int maxWidth, int maxHeight) {
-               maxWidth= maxHeight;
+               maxWidth = maxHeight;
        }
-       
+
        /*
         * @see IInformationControl#computeSizeHint()
         */
        public Point computeSizeHint() {
                return fShell.computeSize(SWT.DEFAULT, SWT.DEFAULT);
        }
-       
+
        /*
         * @see IInformationControl#addDisposeListener(DisposeListener)
         */
        public void addDisposeListener(DisposeListener listener) {
                fShell.addDisposeListener(listener);
        }
-       
+
        /*
         * @see IInformationControl#removeDisposeListener(DisposeListener)
         */
        public void removeDisposeListener(DisposeListener listener) {
                fShell.removeDisposeListener(listener);
        }
-       
+
        /*
         * @see IInformationControl#setForegroundColor(Color)
         */
        public void setForegroundColor(Color foreground) {
                fText.setForeground(foreground);
        }
-       
+
        /*
         * @see IInformationControl#setBackgroundColor(Color)
         */
        public void setBackgroundColor(Color background) {
                fText.setBackground(background);
        }
-       
+
        /*
         * @see IInformationControl#isFocusControl()
         */
        public boolean isFocusControl() {
                return fText.isFocusControl();
        }
-       
+
        /*
         * @see IInformationControl#setFocus()
         */
@@ -370,29 +418,29 @@ public class SourceViewerInformationControl implements IInformationControl, IInf
                fShell.forceFocus();
                fText.setFocus();
        }
-       
+
        /*
         * @see IInformationControl#addFocusListener(FocusListener)
         */
        public void addFocusListener(FocusListener listener) {
                fText.addFocusListener(listener);
        }
-       
+
        /*
         * @see IInformationControl#removeFocusListener(FocusListener)
         */
        public void removeFocusListener(FocusListener listener) {
                fText.removeFocusListener(listener);
        }
-       
+
        /*
         * @see IInformationControlExtension#hasContents()
         */
        public boolean hasContents() {
                return fText.getCharCount() > 0;
        }
-       
-       protected ISourceViewer getViewer()  {
+
+       protected ISourceViewer getViewer() {
                return fViewer;
        }
 }