[Title] Advanced Declaration View
authorhyukmin kwon <hyukmin0530.kwon@samsung.com>
Sun, 9 Jun 2013 08:30:36 +0000 (17:30 +0900)
committerhyukmin kwon <hyukmin0530.kwon@samsung.com>
Sun, 9 Jun 2013 08:30:36 +0000 (17:30 +0900)
[Desc.] Path info is moved to top and underlines are applied.
[Issue] REDMINE-9560

org.tizen.web.advanceddeclarationview/src/org/tizen/web/advanceddeclarationview/ui/GUIBuilderDeclarationPage.java
org.tizen.web.advanceddeclarationview/src/org/tizen/web/advanceddeclarationview/ui/HTMLDeclarationPage.java
org.tizen.web.advanceddeclarationview/src/org/tizen/web/advanceddeclarationview/ui/JSDeclarationPage.java

index f7c1817..817fb3b 100644 (file)
@@ -54,11 +54,13 @@ import org.eclipse.jface.viewers.LabelProvider;
 import org.eclipse.jface.viewers.SelectionChangedEvent;
 import org.eclipse.jface.viewers.StructuredSelection;
 import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.StyleRange;
 import org.eclipse.swt.custom.StyledText;
 import org.eclipse.swt.events.SelectionAdapter;
 import org.eclipse.swt.events.SelectionEvent;
 import org.eclipse.swt.graphics.Color;
 import org.eclipse.swt.graphics.Font;
+import org.eclipse.swt.graphics.FontData;
 import org.eclipse.swt.graphics.Point;
 import org.eclipse.swt.graphics.RGB;
 import org.eclipse.swt.layout.FormAttachment;
@@ -131,8 +133,8 @@ IMenuListener, IPropertyChangeListener {
 
        private TextSourceViewerConfiguration[] fViewerConfigurations;
        
-       /** This view's javascript element info label */
-       private Label fElementInfoLabel;
+       /** This view's element info label */
+       private StyledText fElementInfoLabel;
        
        /** The viewer's vertical ruler */
        private CompositeRuler[] fVerticalRulers;
@@ -276,7 +278,18 @@ IMenuListener, IPropertyChangeListener {
                        
                        fSrcViewer.invalidateTextPresentation();
                }
-               fElementInfoLabel.setText(getElementInfoString());
+               String elementInfoString = getElementInfoString();
+               fElementInfoLabel.setText(elementInfoString);
+               switch (mode) {
+                       case MODE_HTML:
+                       case MODE_CSS:  
+                               break;
+                       case MODE_JS:
+                               setUnderlineStyle(fElementInfoLabel, elementInfoString);
+                               break;
+                       default:
+                               break;
+               }
        }
                        
        /**
@@ -375,8 +388,13 @@ IMenuListener, IPropertyChangeListener {
                        }
                });
                                                
-               fElementInfoLabel = new Label(mainComposite, SWT.LEFT);
+               Display display= getSite().getShell().getDisplay();
+               fElementInfoLabel = new StyledText(mainComposite, SWT.LEFT);
                fElementInfoLabel.setText("");
+               FontData fontData = fElementInfoLabel.getFont().getFontData()[0];
+               Font font = new Font(display, new FontData(fontData.getName(), fontData
+                   .getHeight(), SWT.ITALIC));
+               fElementInfoLabel.setFont(font);
                
                fComboBoxLabel = new Label((Composite)(tabFolder.getItem(MODE_JS).getControl()), SWT.LEFT);
                fComboBoxLabel.setText("");
@@ -777,14 +795,14 @@ IMenuListener, IPropertyChangeListener {
                formData = new FormData();
                formData.left = new FormAttachment(0, margin);
                formData.right = new FormAttachment(100, -margin);
-               formData.bottom = new FormAttachment(100, -margin);
+               formData.top = new FormAttachment(0, -margin);
                fElementInfoLabel.setLayoutData(formData);
                
                formData = new FormData();              
                formData.left = new FormAttachment(0, margin);
                formData.right = new FormAttachment(100, -margin);
-               formData.top = new FormAttachment(0, margin);
-               formData.bottom = new FormAttachment(fElementInfoLabel, -margin);
+               formData.bottom = new FormAttachment(100, -margin);
+               formData.top = new FormAttachment(fElementInfoLabel, margin);
                tabFolder.setLayoutData(formData);
                
                Composite itemComposite = (Composite)(tabFolder.getItem(mode).getControl());
@@ -888,6 +906,14 @@ IMenuListener, IPropertyChangeListener {
                }
        }
        
+       private void setUnderlineStyle(StyledText styledText, String text) {
+               StyleRange style1 = new StyleRange();
+           style1.start = 0;
+           style1.length = text.length();
+           style1.underline = true;
+           styledText.setStyleRange(style1);
+       }
+       
        private ISharedTextColors getSharedColors() {
                return EditorsUI.getSharedTextColors();
        }
index 550f7e4..3f5c34d 100644 (file)
@@ -49,6 +49,7 @@ import org.eclipse.swt.events.PaintEvent;
 import org.eclipse.swt.events.PaintListener;
 import org.eclipse.swt.graphics.Color;
 import org.eclipse.swt.graphics.Font;
+import org.eclipse.swt.graphics.FontData;
 import org.eclipse.swt.graphics.Image;
 import org.eclipse.swt.graphics.Point;
 import org.eclipse.swt.graphics.RGB;
@@ -185,7 +186,7 @@ IMenuListener, IPropertyChangeListener{
        private TextSourceViewerConfiguration[] fViewerConfigurations;
        
        /** This view's javascript element info label */
-       private Label fElementInfoLabel;
+       private StyledText fElementInfoLabel;
        
        /** The viewer's vertical ruler */
        private CompositeRuler[] fVerticalRulers;
@@ -378,8 +379,14 @@ IMenuListener, IPropertyChangeListener{
                mainComposite.setLayout(new FormLayout());
                subComposites  = new Composite[NUMBER_OF_MODES];
                        
-               fElementInfoLabel = new Label(mainComposite, SWT.LEFT);
+               Display display= getSite().getShell().getDisplay();
+               fElementInfoLabel = new StyledText(mainComposite, SWT.LEFT);
+               fElementInfoLabel.setEditable(false);
                fElementInfoLabel.setText("");
+               FontData fontData = fElementInfoLabel.getFont().getFontData()[0];
+               Font font = new Font(display, new FontData(fontData.getName(), fontData
+                   .getHeight(), SWT.ITALIC));
+               fElementInfoLabel.setFont(font);
                
                fComboBoxLabel = new Label(mainComposite, SWT.LEFT);
                fComboBoxLabel.setText("");             
@@ -1311,7 +1318,9 @@ IMenuListener, IPropertyChangeListener{
                        IDocument document= new Document(source);
                        JavaScriptPlugin.getDefault().getJavaTextTools().setupJavaDocumentPartitioner(document, IJavaScriptPartitions.JAVA_PARTITIONING);                       
                        fSrcViewer.setInput(document);
-
+                       
+                       fElementInfoLabel.setText(resourceAbsolutePath);
+                       setUnderlineStyle(fElementInfoLabel, resourceAbsolutePath);
                } else {
                        
                }               
@@ -1322,6 +1331,8 @@ IMenuListener, IPropertyChangeListener{
                String source = readTextFileToString(resourceAbsolutePath);
                if (source != null) {
                        fSrcViewer.getDocument().set(source);
+                       fElementInfoLabel.setText(resourceAbsolutePath);
+                       setUnderlineStyle(fElementInfoLabel, resourceAbsolutePath);
                } else {
                        
                }
@@ -1332,6 +1343,8 @@ IMenuListener, IPropertyChangeListener{
                String source = readTextFileToString(resourceAbsolutePath);
                if (source != null) {
                        fSrcViewer.getDocument().set(source);
+                       fElementInfoLabel.setText(resourceAbsolutePath);
+                       setUnderlineStyle(fElementInfoLabel, resourceAbsolutePath);
                } else {
                        
                }
@@ -1466,10 +1479,16 @@ IMenuListener, IPropertyChangeListener{
                        fComboViewer.getCombo().setVisible(true);
                        fComboBoxLabel.setVisible(true);
                        
+                       formData = new FormData();
+                       formData.left = new FormAttachment(0, margin);
+                       formData.right = new FormAttachment(100, -margin);
+                       formData.top = new FormAttachment(0, margin);
+                       fElementInfoLabel.setLayoutData(formData);
+                       
                        formData = new FormData();              
                        formData.left = new FormAttachment(0, margin);
                        formData.right = new FormAttachment(70, -2 * margin);
-                       formData.top = new FormAttachment(0, margin);
+                       formData.top = new FormAttachment(fElementInfoLabel, margin);
                        fComboViewer.getControl().setLayoutData(formData);
                        
                        formData = new FormData();              
@@ -1477,18 +1496,12 @@ IMenuListener, IPropertyChangeListener{
                        formData.right = new FormAttachment(100, -margin);
                        formData.top = new FormAttachment(0, margin);
                        fComboBoxLabel.setLayoutData(formData);
-                       
-                       formData = new FormData();
-                       formData.left = new FormAttachment(0, margin);
-                       formData.right = new FormAttachment(100, -margin);
-                       formData.bottom = new FormAttachment(100, -margin);
-                       fElementInfoLabel.setLayoutData(formData);      
-                                       
+                                                               
                        formData = new FormData();
                        formData.left = new FormAttachment(0, margin);
                        formData.right = new FormAttachment(100, -margin);
                        formData.top = new FormAttachment(fComboViewer.getControl(), margin);
-                       formData.bottom = new FormAttachment(fElementInfoLabel, -margin);
+                       formData.bottom = new FormAttachment(100, -margin);
                        subComposites[mode].setLayoutData(formData);
                } else { //without comboviewer
                        fComboViewer.getCombo().setVisible(false);
@@ -1497,14 +1510,14 @@ IMenuListener, IPropertyChangeListener{
                        formData = new FormData();
                        formData.left = new FormAttachment(0, margin);
                        formData.right = new FormAttachment(100, -margin);
-                       formData.bottom = new FormAttachment(100, -margin);
+                       formData.top = new FormAttachment(0, margin);
                        fElementInfoLabel.setLayoutData(formData);
                        
                        formData = new FormData();              
                        formData.left = new FormAttachment(0, margin);
                        formData.right = new FormAttachment(100, -margin);
-                       formData.top = new FormAttachment(0, margin);
-                       formData.bottom = new FormAttachment(fElementInfoLabel, -margin);
+                       formData.top = new FormAttachment(fElementInfoLabel, margin);
+                       formData.bottom = new FormAttachment(100, -margin);
                        subComposites[mode].setLayoutData(formData);
                }
                
@@ -1665,6 +1678,14 @@ IMenuListener, IPropertyChangeListener{
                }
        }
        
+       private void setUnderlineStyle(StyledText styledText, String text) {
+               StyleRange style1 = new StyleRange();
+           style1.start = 0;
+           style1.length = text.length();
+           style1.underline = true;
+           styledText.setStyleRange(style1);
+       }
+       
        private ISharedTextColors getSharedColors() {
                return EditorsUI.getSharedTextColors();
        }
index 6c6ef31..4f9b762 100644 (file)
@@ -60,6 +60,7 @@ import org.eclipse.swt.custom.StyleRange;
 import org.eclipse.swt.custom.StyledText;
 import org.eclipse.swt.graphics.Color;
 import org.eclipse.swt.graphics.Font;
+import org.eclipse.swt.graphics.FontData;
 import org.eclipse.swt.graphics.Point;
 import org.eclipse.swt.graphics.RGB;
 import org.eclipse.swt.layout.FormAttachment;
@@ -133,7 +134,7 @@ public class JSDeclarationPage extends DeclarationPage implements ISelectionList
        /** The viewers configuration */
        private JavaScriptSourceViewerConfiguration fViewerConfiguration;
        /** This view's javascript element info label */
-       private Label fElementInfoLabel;
+       private StyledText fElementInfoLabel;
        /** This view's result info label */
        private Label fComboBoxLabel;
        /** The viewer's vertical ruler */
@@ -533,8 +534,13 @@ public class JSDeclarationPage extends DeclarationPage implements ISelectionList
                        }
                });
                
-               fElementInfoLabel = new Label(mainComposite, SWT.LEFT);
+               Display display= getSite().getShell().getDisplay();
+               fElementInfoLabel = new StyledText(mainComposite, SWT.LEFT);
                fElementInfoLabel.setText("");
+               FontData fontData = fElementInfoLabel.getFont().getFontData()[0];
+               Font font = new Font(display, new FontData(fontData.getName(), fontData
+                   .getHeight(), SWT.ITALIC));
+               fElementInfoLabel.setFont(font);
                
                fComboBoxLabel = new Label(mainComposite, SWT.LEFT);
                fComboBoxLabel.setText("");
@@ -949,6 +955,7 @@ public class JSDeclarationPage extends DeclarationPage implements ISelectionList
                setInput(input);
                IJavaScriptElement inputElement= fSelectedElement;              
                fElementInfoLabel.setText(getElementLabelString(inputElement));
+               setUnderlineStyle(fElementInfoLabel, getElementLabelString(inputElement));
                 
                //setTitleToolTip(JavaScriptElementLabels.getElementLabelExtend(inputElement, TOOLTIP_LABEL_FLAGS));
        }
@@ -1006,10 +1013,16 @@ public class JSDeclarationPage extends DeclarationPage implements ISelectionList
                FormData formData; 
                int margin = 3;
                if (mode == LAYOUT_MULTIPLE_ELEMENTS) {
+                       formData = new FormData();
+                       formData.left = new FormAttachment(0, margin);
+                       formData.right = new FormAttachment(100, -margin);
+                       formData.top = new FormAttachment(0, margin);
+                       fElementInfoLabel.setLayoutData(formData);
+                       
                        formData = new FormData();              
                        formData.left = new FormAttachment(0, margin);
                        formData.right = new FormAttachment(70, -2 * margin);
-                       formData.top = new FormAttachment(0, margin);
+                       formData.top = new FormAttachment(fElementInfoLabel, -margin);
                        fComboViewer.getControl().setLayoutData(formData);
                        
                        formData = new FormData();              
@@ -1017,31 +1030,25 @@ public class JSDeclarationPage extends DeclarationPage implements ISelectionList
                        formData.right = new FormAttachment(100, -margin);
                        formData.top = new FormAttachment(0, margin);
                        fComboBoxLabel.setLayoutData(formData);
-                       
-                       formData = new FormData();
-                       formData.left = new FormAttachment(0, margin);
-                       formData.right = new FormAttachment(100, -margin);
-                       formData.bottom = new FormAttachment(100, -margin);
-                       fElementInfoLabel.setLayoutData(formData);      
                                        
                        formData = new FormData();
                        formData.left = new FormAttachment(0, margin);
                        formData.right = new FormAttachment(100, -margin);
                        formData.top = new FormAttachment(fComboViewer.getControl(), margin);
-                       formData.bottom = new FormAttachment(fElementInfoLabel, -margin);
+                       formData.bottom = new FormAttachment(100, -margin);
                        fSrcViewer.getControl().setLayoutData(formData);
                } else if (mode == LAYOUT_NORMAL) {
                        formData = new FormData();
                        formData.left = new FormAttachment(0, margin);
                        formData.right = new FormAttachment(100, -margin);
-                       formData.bottom = new FormAttachment(100, -margin);
+                       formData.top = new FormAttachment(0, margin);
                        fElementInfoLabel.setLayoutData(formData);      
                                        
                        formData = new FormData();
                        formData.left = new FormAttachment(0, margin);
                        formData.right = new FormAttachment(100, -margin);
-                       formData.top = new FormAttachment(0, margin);
-                       formData.bottom = new FormAttachment(fElementInfoLabel, -margin);
+                       formData.top = new FormAttachment(fElementInfoLabel, margin);
+                       formData.bottom = new FormAttachment(100, -margin);
                        fSrcViewer.getControl().setLayoutData(formData);
                } else if (mode == LAYOUT_NOTHING_TO_VIEW) {
                        formData = new FormData();
@@ -1092,6 +1099,14 @@ public class JSDeclarationPage extends DeclarationPage implements ISelectionList
                }
        }
        
+       private void setUnderlineStyle(StyledText styledText, String text) {
+               StyleRange style1 = new StyleRange();
+           style1.start = 0;
+           style1.length = text.length();
+           style1.underline = true;
+           styledText.setStyleRange(style1);
+       }
+       
        private ISharedTextColors getSharedColors() {
                return EditorsUI.getSharedTextColors();
        }