Author: sdzmitrovich
Date: 2009-09-11 11:03:19 -0400 (Fri, 11 Sep 2009)
New Revision: 17526
Modified:
trunk/jst/plugins/org.jboss.tools.jst.css/src/org/jboss/tools/jst/css/common/CSSSelectionListener.java
trunk/jst/plugins/org.jboss.tools.jst.css/src/org/jboss/tools/jst/css/common/CSSStyleManager.java
trunk/jst/plugins/org.jboss.tools.jst.css/src/org/jboss/tools/jst/css/properties/CSSPropertyPage.java
trunk/jst/plugins/org.jboss.tools.jst.css/src/org/jboss/tools/jst/css/view/CSSEditorView.java
trunk/jst/plugins/org.jboss.tools.jst.css/src/org/jboss/tools/jst/css/view/CSSPreview.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-4850
Modified:
trunk/jst/plugins/org.jboss.tools.jst.css/src/org/jboss/tools/jst/css/common/CSSSelectionListener.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.css/src/org/jboss/tools/jst/css/common/CSSSelectionListener.java 2009-09-11
00:46:47 UTC (rev 17525)
+++
trunk/jst/plugins/org.jboss.tools.jst.css/src/org/jboss/tools/jst/css/common/CSSSelectionListener.java 2009-09-11
15:03:19 UTC (rev 17526)
@@ -59,7 +59,6 @@
private void startListening() {
PlatformUI.getWorkbench().getActiveWorkbenchWindow()
.getSelectionService().addPostSelectionListener(this);
-
}
private void stopListening() {
Modified:
trunk/jst/plugins/org.jboss.tools.jst.css/src/org/jboss/tools/jst/css/common/CSSStyleManager.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.css/src/org/jboss/tools/jst/css/common/CSSStyleManager.java 2009-09-11
00:46:47 UTC (rev 17525)
+++
trunk/jst/plugins/org.jboss.tools.jst.css/src/org/jboss/tools/jst/css/common/CSSStyleManager.java 2009-09-11
15:03:19 UTC (rev 17526)
@@ -24,8 +24,6 @@
import org.eclipse.wst.xml.core.internal.contentmodel.CMNamedNodeMap;
import org.eclipse.wst.xml.core.internal.contentmodel.modelquery.ModelQuery;
import org.eclipse.wst.xml.core.internal.modelquery.ModelQueryUtil;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMAttr;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMElement;
import org.w3c.dom.Attr;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
@@ -65,8 +63,8 @@
if (styleRule != null)
container = new CSSStyleRuleContainer(styleRule);
- } else if ((selectedObject instanceof IDOMElement)
- || (selectedObject instanceof IDOMAttr)) {
+ } else if ((selectedObject instanceof Element)
+ || (selectedObject instanceof Attr)) {
Element selectedElement = null;
Modified:
trunk/jst/plugins/org.jboss.tools.jst.css/src/org/jboss/tools/jst/css/properties/CSSPropertyPage.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.css/src/org/jboss/tools/jst/css/properties/CSSPropertyPage.java 2009-09-11
00:46:47 UTC (rev 17525)
+++
trunk/jst/plugins/org.jboss.tools.jst.css/src/org/jboss/tools/jst/css/properties/CSSPropertyPage.java 2009-09-11
15:03:19 UTC (rev 17526)
@@ -11,8 +11,6 @@
package org.jboss.tools.jst.css.properties;
-import java.util.Map;
-
import org.eclipse.core.databinding.DataBindingContext;
import org.eclipse.core.databinding.observable.ChangeEvent;
import org.eclipse.core.databinding.observable.IChangeListener;
@@ -27,7 +25,6 @@
import org.eclipse.ui.part.IPageSite;
import org.eclipse.ui.views.properties.tabbed.ITabbedPropertySheetPageContributor;
import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetPage;
-import org.jboss.tools.jst.css.common.CSSSelectionListener;
import org.jboss.tools.jst.css.common.StyleContainer;
import org.jboss.tools.jst.css.view.CSSEditorView;
import org.jboss.tools.jst.jsp.outline.cssdialog.common.StyleAttributes;
@@ -63,7 +60,7 @@
public void init(IPageSite pageSite) {
super.init(pageSite);
- CSSSelectionListener.getInstance().addSelectionListener(this);
+ // CSSSelectionListener.getInstance().addSelectionListener(this);
// FIXED FOR JBIDE-4791
pageSite.setSelectionProvider(new ISelectionProvider() {
@@ -87,7 +84,7 @@
@Override
public void dispose() {
- CSSSelectionListener.getInstance().removeSelectionListener(this);
+ // CSSSelectionListener.getInstance().removeSelectionListener(this);
super.dispose();
}
@@ -97,13 +94,7 @@
if ((this.part != part) && (selection instanceof IStructuredSelection)) {
IStructuredSelection structuredSelection = (IStructuredSelection) selection;
Object newSelectedObject = structuredSelection.getFirstElement();
- if (structuredSelection.getFirstElement() instanceof StyleContainer) {
- updateStyleAttributes(((StyleContainer) newSelectedObject)
- .getStyleAttributes());
-
- }
-
if ((selectedObject == null)
|| (!selectedObject.equals(newSelectedObject)))
super.selectionChanged(part, selection);
@@ -113,13 +104,16 @@
}
- private void updateStyleAttributes(Map<String, String> attributes) {
+ public void update() {
- ((IObservable) getStyleAttributes().getAttributeMap())
- .removeChangeListener(this);
- getStyleAttributes().setStyleProperties(attributes);
- ((IObservable) getStyleAttributes().getAttributeMap())
- .addChangeListener(this);
+ if (selectedObject instanceof StyleContainer) {
+ ((IObservable) getStyleAttributes().getAttributeMap())
+ .removeChangeListener(this);
+ getStyleAttributes().setStyleProperties(
+ ((StyleContainer) selectedObject).getStyleAttributes());
+ ((IObservable) getStyleAttributes().getAttributeMap())
+ .addChangeListener(this);
+ }
}
Modified:
trunk/jst/plugins/org.jboss.tools.jst.css/src/org/jboss/tools/jst/css/view/CSSEditorView.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.css/src/org/jboss/tools/jst/css/view/CSSEditorView.java 2009-09-11
00:46:47 UTC (rev 17525)
+++
trunk/jst/plugins/org.jboss.tools.jst.css/src/org/jboss/tools/jst/css/view/CSSEditorView.java 2009-09-11
15:03:19 UTC (rev 17526)
@@ -13,12 +13,15 @@
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.ui.IViewSite;
import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.PartInitException;
import org.eclipse.ui.part.IContributedContentsView;
import org.eclipse.ui.part.IPageBookViewPage;
import org.eclipse.ui.views.properties.IPropertySheetPage;
import org.eclipse.ui.views.properties.PropertySheet;
import org.eclipse.ui.views.properties.tabbed.ITabbedPropertySheetPageContributor;
+import org.jboss.tools.jst.css.common.CSSSelectionListener;
import org.jboss.tools.jst.css.properties.CSSPropertyPage;
/**
@@ -30,8 +33,30 @@
static public String CONTRIBUTOR_ID =
"org.eclipse.wst.css.core.csssource.source"; //$NON-NLS-1$
@Override
+ public void init(IViewSite site) throws PartInitException {
+
+ super.init(site);
+ getSite().getPage().removeSelectionListener(this);
+ CSSSelectionListener.getInstance().addSelectionListener(this);
+ }
+
+ @Override
+ public void dispose() {
+
+ super.dispose();
+ CSSSelectionListener.getInstance().removeSelectionListener(this);
+
+ }
+
+ @Override
public void selectionChanged(IWorkbenchPart part, ISelection sel) {
- // do nothing
+ super.selectionChanged(part, sel);
+
+ // TODO find better way to react upon changing of node i source editor.
+ // Description of problem: when node is been editing PropertySheet will
+ // not send selection event to page as selection is same;
+ if (getCurrentPage() instanceof CSSPropertyPage)
+ ((CSSPropertyPage) getCurrentPage()).update();
}
@Override
Modified:
trunk/jst/plugins/org.jboss.tools.jst.css/src/org/jboss/tools/jst/css/view/CSSPreview.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.css/src/org/jboss/tools/jst/css/view/CSSPreview.java 2009-09-11
00:46:47 UTC (rev 17525)
+++
trunk/jst/plugins/org.jboss.tools.jst.css/src/org/jboss/tools/jst/css/view/CSSPreview.java 2009-09-11
15:03:19 UTC (rev 17526)
@@ -49,6 +49,8 @@
private String previewContent = CSSUIMessages.CSSPreview_DefaultBrowserText;
+ private String currentStyle = new String();
+
private Map<String, String> styleAttributes = new HashMap<String,
String>();
@Override
@@ -81,7 +83,6 @@
previewComposite.setLayoutData(gridData);
browser = new Browser(previewComposite, SWT.BORDER | SWT.MOZILLA);
- browser.setText(generateBrowserPage());
browser.setLayoutData(gridData);
browser.addMouseListener(new MouseAdapter() {
public void mouseDoubleClick(MouseEvent e) {
@@ -93,6 +94,8 @@
}
});
+ updateBrowser();
+
previewText = new Text(previewComposite, SWT.NONE | SWT.H_SCROLL);
previewText.setLayoutData(gridData);
previewText.setText(getPreviewContent());
@@ -100,14 +103,17 @@
public void focusLost(FocusEvent e) {
if (e.widget == previewText) {
String text = previewText.getText();
- if (text == null || text.equals(Constants.EMPTY)) {
- setPreviewContent(CSSUIMessages.CSSPreview_DefaultBrowserText);
- } else {
- setPreviewContent(text);
+ if (!getPreviewContent().equals(text)) {
+ if (text == null || text.equals(Constants.EMPTY)) {
+ setPreviewContent(CSSUIMessages.CSSPreview_DefaultBrowserText);
+ } else {
+ setPreviewContent(text);
+ }
+ updateBrowser();
}
browser.setEnabled(true);
- browser.setText(generateBrowserPage());
+
previewComposite.setMaximizedControl(browser);
}
}
@@ -132,18 +138,10 @@
* @return String html text representation
*/
public String generateBrowserPage() {
+ String html = Constants.OPEN_DIV_TAG + getCurrentStyle()
+ + "\">" + getPreviewContent() + Constants.CLOSE_DIV_TAG;
//$NON-NLS-1$
- StringBuffer html = new StringBuffer(Constants.OPEN_DIV_TAG);
-
- for (Map.Entry<String, String> styleItem : styleAttributes.entrySet()) {
-
- html.append(styleItem.getKey() + Constants.COLON
- + styleItem.getValue() + Constants.SEMICOLON);
- }
-
- html.append("\">" + getPreviewContent() + Constants.CLOSE_DIV_TAG);
//$NON-NLS-1$
-
- return html.toString();
+ return html;
}
public String getPreviewContent() {
@@ -167,7 +165,13 @@
styleAttributes.clear();
}
- updateBrowser();
+ String newStyle = getStyle(styleAttributes);
+ if (!newStyle.equals(currentStyle)) {
+
+ currentStyle = newStyle;
+ updateBrowser();
+ }
+
}
}
@@ -176,4 +180,20 @@
browser.setText(generateBrowserPage());
}
+ protected String getStyle(Map<String, String> styleAttributes) {
+
+ StringBuffer style = new StringBuffer();
+
+ for (Map.Entry<String, String> styleItem : styleAttributes.entrySet()) {
+
+ style.append(styleItem.getKey() + Constants.COLON
+ + styleItem.getValue() + Constants.SEMICOLON);
+ }
+
+ return style.toString();
+ }
+
+ public String getCurrentStyle() {
+ return currentStyle;
+ }
}