summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhyukmin kwon <hyukmin0530.kwon@samsung.com>2013-05-12 16:39:33 +0900
committerhyukmin kwon <hyukmin0530.kwon@samsung.com>2013-05-12 16:39:33 +0900
commitc5092e8d0c9c093bc9bc0bda25a2e5188b1a4146 (patch)
tree7ff44dc6e7d4c51d2658f7e3846bd842bf88f9d7
parente9c179e35bab1c19b3f17ab30cf76a5ee8461459 (diff)
downloadjsdt-extension-eplugin-c5092e8d0c9c093bc9bc0bda25a2e5188b1a4146.tar.gz
jsdt-extension-eplugin-c5092e8d0c9c093bc9bc0bda25a2e5188b1a4146.tar.bz2
jsdt-extension-eplugin-c5092e8d0c9c093bc9bc0bda25a2e5188b1a4146.zip
[Title] Advanced Declaration View: Mode selection of ADV for HTML is
added. [Desc.] Mode selection of ADV for HTML is added. [Issue] REDMINE-9331
-rw-r--r--org.tizen.web.advanceddeclarationview/META-INF/MANIFEST.MF4
-rw-r--r--org.tizen.web.advanceddeclarationview/src/org/tizen/web/advanceddeclarationview/ui/AdvancedDeclarationView.java1
-rw-r--r--org.tizen.web.advanceddeclarationview/src/org/tizen/web/advanceddeclarationview/ui/HTMLDeclarationPage.java109
3 files changed, 83 insertions, 31 deletions
diff --git a/org.tizen.web.advanceddeclarationview/META-INF/MANIFEST.MF b/org.tizen.web.advanceddeclarationview/META-INF/MANIFEST.MF
index 75c7f18..b7feca2 100644
--- a/org.tizen.web.advanceddeclarationview/META-INF/MANIFEST.MF
+++ b/org.tizen.web.advanceddeclarationview/META-INF/MANIFEST.MF
@@ -10,7 +10,9 @@ Require-Bundle: org.eclipse.ui,
org.tizen.webuibuilder;bundle-version="1.0.0",
org.eclipse.core.resources;bundle-version="3.7.101",
org.eclipse.wst.sse.ui,
- org.eclipse.jst.pagedesigner
+ org.eclipse.jst.pagedesigner,
+ org.eclipse.wst.html.core,
+ org.eclipse.wst.xml.core;bundle-version="1.1.602"
Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Import-Package:
diff --git a/org.tizen.web.advanceddeclarationview/src/org/tizen/web/advanceddeclarationview/ui/AdvancedDeclarationView.java b/org.tizen.web.advanceddeclarationview/src/org/tizen/web/advanceddeclarationview/ui/AdvancedDeclarationView.java
index ef972c5..022cfac 100644
--- a/org.tizen.web.advanceddeclarationview/src/org/tizen/web/advanceddeclarationview/ui/AdvancedDeclarationView.java
+++ b/org.tizen.web.advanceddeclarationview/src/org/tizen/web/advanceddeclarationview/ui/AdvancedDeclarationView.java
@@ -162,6 +162,7 @@ public class AdvancedDeclarationView extends PageBookView implements ISelectionL
guiBuilderDeclarationPage.createControl(getPageBook());
return new PageRec(part, guiBuilderDeclarationPage);
} else if (part instanceof /*org.eclipse.jst.pagedesigner.editors.DesignerStructuredTextEditorJSP*/org.eclipse.wst.sse.ui.StructuredTextEditor) {
+ /*TODO: apply correct filtering*/
HTMLDeclarationPage htmlDeclarationPage = new HTMLDeclarationPage(getViewSite());
initPage(htmlDeclarationPage);
htmlDeclarationPage.createControl(getPageBook());
diff --git a/org.tizen.web.advanceddeclarationview/src/org/tizen/web/advanceddeclarationview/ui/HTMLDeclarationPage.java b/org.tizen.web.advanceddeclarationview/src/org/tizen/web/advanceddeclarationview/ui/HTMLDeclarationPage.java
index 3f27386..1458c14 100644
--- a/org.tizen.web.advanceddeclarationview/src/org/tizen/web/advanceddeclarationview/ui/HTMLDeclarationPage.java
+++ b/org.tizen.web.advanceddeclarationview/src/org/tizen/web/advanceddeclarationview/ui/HTMLDeclarationPage.java
@@ -1,11 +1,5 @@
package org.tizen.web.advanceddeclarationview.ui;
-import java.io.BufferedReader;
-import java.io.FileReader;
-import java.io.IOException;
-import java.nio.CharBuffer;
-import java.util.List;
-
import org.eclipse.jface.action.IMenuListener;
import org.eclipse.jface.action.IMenuManager;
import org.eclipse.jface.action.MenuManager;
@@ -14,8 +8,8 @@ import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.preference.PreferenceConverter;
import org.eclipse.jface.resource.ColorRegistry;
import org.eclipse.jface.resource.JFaceResources;
-import org.eclipse.jface.text.Document;
import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.TextSelection;
import org.eclipse.jface.text.source.CompositeRuler;
import org.eclipse.jface.text.source.ISharedTextColors;
import org.eclipse.jface.text.source.ISourceViewer;
@@ -25,32 +19,20 @@ import org.eclipse.jface.text.source.SourceViewer;
import org.eclipse.jface.text.source.SourceViewerConfiguration;
import org.eclipse.jface.util.IPropertyChangeListener;
import org.eclipse.jface.util.PropertyChangeEvent;
-import org.eclipse.jface.viewers.ArrayContentProvider;
-import org.eclipse.jface.viewers.ComboViewer;
import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.ISelectionChangedListener;
import org.eclipse.jface.viewers.ISelectionProvider;
-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.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.Point;
import org.eclipse.swt.graphics.RGB;
-import org.eclipse.swt.layout.FormAttachment;
-import org.eclipse.swt.layout.FormData;
import org.eclipse.swt.layout.FormLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Menu;
-import org.eclipse.swt.widgets.TabFolder;
-import org.eclipse.swt.widgets.TabItem;
import org.eclipse.ui.IActionBars;
import org.eclipse.ui.ISelectionListener;
import org.eclipse.ui.IViewSite;
@@ -60,6 +42,7 @@ import org.eclipse.ui.editors.text.TextSourceViewerConfiguration;
import org.eclipse.ui.texteditor.AbstractDecoratedTextEditorPreferenceConstants;
import org.eclipse.wst.css.core.internal.provisional.contenttype.ContentTypeIdForCSS;
import org.eclipse.wst.css.ui.StructuredTextViewerConfigurationCSS;
+import org.eclipse.wst.html.core.internal.document.DOMStyleModelImpl;
import org.eclipse.wst.html.core.internal.provisional.contenttype.ContentTypeIdForHTML;
import org.eclipse.wst.html.ui.StructuredTextViewerConfigurationHTML;
import org.eclipse.wst.jsdt.internal.ui.JavaScriptPlugin;
@@ -71,14 +54,11 @@ import org.eclipse.wst.sse.core.StructuredModelManager;
import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel;
import org.eclipse.wst.sse.ui.StructuredTextViewerConfiguration;
import org.eclipse.wst.sse.ui.internal.StructuredTextViewer;
+import org.eclipse.wst.sse.ui.internal.editor.SelectionConvertor;
import org.eclipse.wst.sse.ui.internal.provisional.style.LineStyleProvider;
-import org.tizen.web.advanceddeclarationview.ui.GUIBuilderDeclarationPage.ContentChangeListener;
-import org.tizen.web.advanceddeclarationview.ui.GUIBuilderDeclarationPage.FontPropertyChangeListener;
-import org.tizen.web.advanceddeclarationview.ui.GUIBuilderDeclarationPage.PropertyChangeListener;
-import org.tizen.webuibuilder.extintrf.DeclarationViewInfoProvider;
-import org.tizen.webuibuilder.extintrf.IContentChangeListener;
-import org.tizen.webuibuilder.extintrf.JsInfo;
-import org.tizen.webuibuilder.extintrf.WidgetInfo;
+import org.eclipse.wst.xml.core.internal.document.AttrImpl;
+import org.eclipse.wst.xml.core.internal.document.ElementImpl;
+import org.eclipse.wst.xml.core.internal.document.NodeImpl;
@SuppressWarnings("restriction")
public class HTMLDeclarationPage extends DeclarationPage implements ISelectionListener,
@@ -93,7 +73,8 @@ IMenuListener, IPropertyChangeListener{
private static final int MODE_IMAGE_VIEW = 3;
private static final int MODE_JS_FILE_VIEW = 4;
private static final int MODE_CSS_FILE_VIEW = 5;
- private static final int NUMBER_OF_MODES = 6;
+ private static final int MODE_INVALID_CASE = 6;
+ private static final int NUMBER_OF_MODES = 7;
private int mode = MODE_JS_DECLARATION;
/**
@@ -261,13 +242,14 @@ IMenuListener, IPropertyChangeListener{
fNoContentsLabels[MODE_IMAGE_VIEW].setText("No image file");
fNoContentsLabels[MODE_JS_FILE_VIEW].setText("No JavaScript file");
fNoContentsLabels[MODE_CSS_FILE_VIEW].setText("No CSS file");
+ fNoContentsLabels[MODE_INVALID_CASE].setText("Invalid selection");
setMode(mode);
JFaceResources.getFontRegistry().addListener(fFontPropertyChangeListener);
EditorsUI.getPreferenceStore().addPropertyChangeListener(fPropertyChangeListener);
- updateLayout(true);
+ updateLayout();
}
private TextSourceViewerConfiguration createTextViewerConfiguration(int mode) {
@@ -290,6 +272,8 @@ IMenuListener, IPropertyChangeListener{
case MODE_CSS_FILE_VIEW:
viewerConfiguration = createCSSTextViewerConfiguration();
break;
+ case MODE_INVALID_CASE:
+ break;
default:
break;
}
@@ -354,6 +338,8 @@ IMenuListener, IPropertyChangeListener{
case MODE_CSS_FILE_VIEW:
viewer = createCSSViewer(parent, verticalRuler, viewerConfiguration);
break;
+ case MODE_INVALID_CASE:
+ break;
default:
break;
}
@@ -531,9 +517,72 @@ IMenuListener, IPropertyChangeListener{
}
private void selectModeAndInit(IWorkbenchPart part, ISelection selection) {
+ IStructuredModel model = ((org.eclipse.wst.sse.ui.StructuredTextEditor)part).getModel();
+ TextSelection textSelection = (TextSelection) selection;
+ if (model instanceof DOMStyleModelImpl) {
+ DOMStyleModelImpl htmlModel = (DOMStyleModelImpl) model;
+ SelectionConvertor selectionConvertor = (SelectionConvertor) model.getAdapter(SelectionConvertor.class);
+ Object [] elements = selectionConvertor.getElements(model, textSelection.getOffset(), textSelection.getOffset());
+ if (elements.length >= 1) {
+ Object element = elements[0];
+ if (element instanceof AttrImpl) {
+ AttrImpl attrImpl = (AttrImpl) element;
+ ElementImpl ownerElement = (ElementImpl)(attrImpl.getOwnerElement());
+ if ("src".equalsIgnoreCase(attrImpl.getName())) {
+ /** External JavaScript file or image file*/
+ if ("script".equalsIgnoreCase(ownerElement.getTagName())) {
+ mode = MODE_JS_FILE_VIEW;
+ } else if ("img".equalsIgnoreCase(ownerElement.getTagName())) {
+ mode = MODE_IMAGE_VIEW;
+ } else {
+ mode = MODE_INVALID_CASE;
+ }
+ } else if ("href".equalsIgnoreCase(attrImpl.getName())) {
+ /** External CSS file*/
+ if ("link".equalsIgnoreCase(ownerElement.getTagName()) &&
+ "text/css".equalsIgnoreCase(ownerElement.getAttribute("type")) &&
+ "stylesheet".equalsIgnoreCase(ownerElement.getAttribute("rel"))) {
+ mode = MODE_CSS_FILE_VIEW;
+ } else {
+ mode = MODE_INVALID_CASE;
+ }
+ } else if ("class".equalsIgnoreCase(attrImpl.getName())) {
+ mode = MODE_CSS_DECLARATION;
+ } else if ("id".equalsIgnoreCase(attrImpl.getName())) {
+ mode = MODE_CSS_DECLARATION;
+ } else {
+ mode = MODE_INVALID_CASE;
+ }
+ } else if (element instanceof org.eclipse.wst.xml.core.internal.document.TextImpl) {
+ org.eclipse.wst.xml.core.internal.document.TextImpl textImpl = (org.eclipse.wst.xml.core.internal.document.TextImpl) element;
+ NodeImpl parentImpl = (NodeImpl)(textImpl.getParentNode());
+ if (parentImpl instanceof ElementImpl) {
+ ElementImpl parentElement = (ElementImpl)parentImpl;
+ if ("script".equalsIgnoreCase(parentElement.getTagName()) &&
+ "text/javascript".equalsIgnoreCase(parentElement.getAttribute("type"))) {
+ mode = MODE_JS_DECLARATION;
+ } else {
+ mode = MODE_INVALID_CASE;
+ }
+ } else {
+ mode = MODE_INVALID_CASE;
+ }
+
+ } else if (element instanceof org.eclipse.wst.xml.core.internal.document.ElementImpl) {
+ mode = MODE_TAG_HIERARCHY;
+ } else {
+ mode = MODE_INVALID_CASE;
+ }
+ } else {
+ mode = MODE_INVALID_CASE;
+ }
+ } else {
+ mode = MODE_INVALID_CASE;
+ }
+ updateLayout();
}
-
+
private void displayContents(IWorkbenchPart part, ISelection selection) {
}
@@ -570,7 +619,7 @@ IMenuListener, IPropertyChangeListener{
}
}
- private void updateLayout(boolean noContents) {
+ private void updateLayout() {
mainComposite.layout();