Author: izhukov
Date: 2008-11-26 08:40:20 -0500 (Wed, 26 Nov 2008)
New Revision: 12074
Modified:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/messages/JstUIMessages.java
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/messages/messages.properties
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/CSSClassDialog.java
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/CSSStyleDialog.java
Log:
CSS dialog opened via context menu loads selected CSS style class
Modified:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/messages/JstUIMessages.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/messages/JstUIMessages.java 2008-11-26
12:25:06 UTC (rev 12073)
+++
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/messages/JstUIMessages.java 2008-11-26
13:40:20 UTC (rev 12074)
@@ -45,6 +45,7 @@
public static String CSS_STYLE_CLASS_EDITOR_HEADER_TITLE;
public static String CSS_STYLE_CLASS_EDITOR_DESCRIPTION;
public static String CSS_STYLE_CLASS_EDITOR_TITLE;
+ public static String CSS_STYLE_EDITOR_TITLE;
public static String CSS_EMPTY_FILE_PATH_MESSAGE;
public static String CSS_EMPTY_STYLE_CLASS_MESSAGE;
public static String CSS_SAVE_DIALOG_TITLE;
Modified:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/messages/messages.properties
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/messages/messages.properties 2008-11-26
12:25:06 UTC (rev 12073)
+++
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/messages/messages.properties 2008-11-26
13:40:20 UTC (rev 12074)
@@ -5,6 +5,7 @@
CSS_STYLE_CLASS_EDITOR_HEADER_TITLE=CSS Style Class Editor
CSS_STYLE_CLASS_EDITOR_DESCRIPTION=Create New CSS Class
CSS_STYLE_CLASS_EDITOR_TITLE=CSS Class
+CSS_STYLE_EDITOR_TITLE=CSS Style
CSS_EMPTY_FILE_PATH_MESSAGE=Choose any CSS file
CSS_EMPTY_STYLE_CLASS_MESSAGE=Style class is empty
CSS_SAVE_DIALOG_TITLE=Save CSS file
Modified:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/CSSClassDialog.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/CSSClassDialog.java 2008-11-26
12:25:06 UTC (rev 12073)
+++
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/CSSClassDialog.java 2008-11-26
13:40:20 UTC (rev 12074)
@@ -40,7 +40,6 @@
import org.eclipse.swt.events.MouseListener;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
@@ -159,8 +158,8 @@
// within this file where cursor is located
if (currentFile == null) {
currentFile = Util.getActiveCssFile();
- currentClassStyle = Util.getActivePageCSSSelectorIfAny();
}
+ currentClassStyle = Util.getActivePageCSSSelectorIfAny();
}
/**
@@ -229,8 +228,6 @@
/* ============================================= */
Composite downSplitPane = getCompositeElement(split);
- Color veryLightGray = new Color(null, 127, 127, 127);
- downSplitPane.setForeground(veryLightGray);
Composite classComposite = new Composite(downSplitPane, SWT.BORDER);
GridData gridData = new GridData(GridData.FILL, GridData.BEGINNING, true,
false);
Modified:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/CSSStyleDialog.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/CSSStyleDialog.java 2008-11-26
12:25:06 UTC (rev 12073)
+++
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/CSSStyleDialog.java 2008-11-26
13:40:20 UTC (rev 12074)
@@ -16,11 +16,17 @@
import org.eclipse.jface.dialogs.IDialogSettings;
import org.eclipse.swt.SWT;
import org.eclipse.swt.browser.Browser;
+import org.eclipse.swt.events.FocusEvent;
+import org.eclipse.swt.events.FocusListener;
+import org.eclipse.swt.events.MouseEvent;
+import org.eclipse.swt.events.MouseListener;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Text;
+import org.jboss.tools.common.model.ui.widgets.Split;
import org.jboss.tools.jst.jsp.JspEditorPlugin;
import org.jboss.tools.jst.jsp.messages.JstUIMessages;
import org.jboss.tools.jst.jsp.outline.cssdialog.common.Constants;
@@ -33,13 +39,16 @@
*
* @author Dzmitry Sakovich (dsakovich(a)exadel.com)
*/
-public class CSSStyleDialog extends Dialog {
+public class CSSStyleDialog extends Dialog implements MouseListener, FocusListener {
final static int MIN_HEIGHT_FOR_BROWSER = 60;
private String previewBrowserValue = Constants.TEXT_FOR_PREVIEW;
+ private Composite browserContainer = null;
private Browser browser = null;
+ private Text textBrowser = null;
+
private StyleComposite styleComposite = null;
private StyleAttributes styleAttributes = null;
private String oldStyle;
@@ -65,30 +74,58 @@
*/
@Override
protected Control createDialogArea(final Composite parent) {
- final Composite composite = (Composite) super.createDialogArea(parent);
+ final Composite composite = (Composite) super.createDialogArea(parent);
+ Split split = new Split(composite, SWT.VERTICAL);
+
GridLayout layout = new GridLayout();
layout.numColumns = 1;
- browser = new Browser(composite, SWT.BORDER);
-
composite.setLayout(layout);
+ // initialize browser container
+ browserContainer = getCompositeElement(split);
+ createBrowserComponent();
+
styleAttributes.addChangeStyleListener(new ChangeStyleListener() {
public void styleChanged(ChangeStyleEvent event) {
browser.setText(getTextForBrowser());
}
});
- styleComposite = new StyleComposite(composite, styleAttributes, oldStyle);
+ styleComposite = new StyleComposite(split, styleAttributes, oldStyle);
- GridData gridData = new GridData(GridData.FILL, GridData.FILL, true, true);
- gridData.minimumHeight = MIN_HEIGHT_FOR_BROWSER;
- browser.setLayoutData(gridData);
- browser.setText(getTextForBrowser());
+ split.setWeights(new int[]{15, 85});
+ split.setLayoutData(new GridData(GridData.FILL, GridData.BEGINNING, true,
true));
return composite;
}
/**
+ * Create container that take up 2 cells and contains fontSizeCombo and
extFontSizeCombo elements.
+ */
+ private Composite getCompositeElement(Composite parent) {
+ GridData gridData = new GridData(GridData.FILL, GridData.FILL, true, true);
+ GridLayout gridLayoutTmp = new GridLayout();
+ gridLayoutTmp.marginHeight = 0;
+ gridLayoutTmp.marginWidth = 0;
+ Composite classComposite = new Composite(parent, SWT.FILL);
+ classComposite.setLayout(gridLayoutTmp);
+ classComposite.setLayoutData(gridData);
+
+ return classComposite;
+ }
+
+ /**
+ * Method is used to create browser component to display preview html.
+ */
+ private void createBrowserComponent() {
+ GridData gridData = new GridData(GridData.FILL, GridData.FILL, true, true);
+ browser = new Browser(browserContainer, SWT.BORDER | SWT.MOZILLA);
+ browser.setText(getTextForBrowser());
+ browser.addMouseListener(this);
+ browser.setLayoutData(gridData);
+ }
+
+ /**
* Method is used to build html body that is appropriate to browse.
*
* @return String html text representation
@@ -113,7 +150,7 @@
@Override
protected void configureShell(Shell newShell) {
super.configureShell(newShell);
- newShell.setText(JstUIMessages.CSS_STYLE_CLASS_EDITOR_TITLE);
+ newShell.setText(JstUIMessages.CSS_STYLE_EDITOR_TITLE);
}
/**
@@ -132,4 +169,55 @@
protected IDialogSettings getDialogBoundsSettings() {
return JspEditorPlugin.getDefault().getDialogSettings();
}
+
+ /**
+ * @see
org.eclipse.swt.events.MouseListener#mouseDoubleClick(org.eclipse.swt.events.MouseEvent)
+ */
+ public void mouseDoubleClick(MouseEvent e) {
+ if (e.widget == browser) {
+ browser.removeMouseListener(this);
+ browser.dispose();
+ // create Text area component instead of HTML Browser
+ GridData gridData = new GridData(GridData.FILL, GridData.FILL, true, true);
+ textBrowser = new Text(browserContainer, SWT.MULTI | SWT.V_SCROLL |
SWT.H_SCROLL);
+ textBrowser.setText(previewBrowserValue);
+ textBrowser.addFocusListener(this);
+ textBrowser.setLayoutData(gridData);
+ textBrowser.setEditable(true);
+ textBrowser.setFocus();
+ }
+ browserContainer.layout();
+ }
+
+ /**
+ * @see
org.eclipse.swt.events.FocusListener#focusLost(org.eclipse.swt.events.FocusEvent)
+ */
+ public void focusLost(FocusEvent e) {
+ if (e.widget == textBrowser) {
+ previewBrowserValue = textBrowser.getText();
+ textBrowser.removeFocusListener(this);
+ textBrowser.dispose();
+ // create Browse component instead of text area
+ createBrowserComponent();
+ }
+ browserContainer.layout();
+ }
+
+ /* (non-Javadoc)
+ * @see
org.eclipse.swt.events.MouseListener#mouseDown(org.eclipse.swt.events.MouseEvent)
+ */
+ public void mouseDown(MouseEvent e) {
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.swt.events.MouseListener#mouseUp(org.eclipse.swt.events.MouseEvent)
+ */
+ public void mouseUp(MouseEvent e) {
+ }
+
+ /* (non-Javadoc)
+ * @see
org.eclipse.swt.events.FocusListener#focusGained(org.eclipse.swt.events.FocusEvent)
+ */
+ public void focusGained(FocusEvent e) {
+ }
}