Author: dsakovich
Date: 2008-09-30 15:15:18 -0400 (Tue, 30 Sep 2008)
New Revision: 10577
Added:
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
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/StyleComposite.java
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/common/CSSModel.java
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/common/FileExtensionFilter.java
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/events/ChangeStyleEvent.java
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/events/ChangeStyleListener.java
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/events/StyleAttributes.java
Removed:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/CSSDialog.java
Modified:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/JSPDialogCellEditor.java
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/ImageSelectionDialog.java
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/common/Util.java
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/common/messages.properties
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/events/TabPropertySheetMouseAdapter.java
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/parsers/ParserListener.java
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/tabs/TabBackgroundControl.java
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/tabs/TabBoxesControl.java
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/tabs/TabPropertySheetControl.java
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/tabs/TabQuickEditControl.java
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/tabs/TabTextControl.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-2530
Modified:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/JSPDialogCellEditor.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/JSPDialogCellEditor.java 2008-09-30
18:45:39 UTC (rev 10576)
+++
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/JSPDialogCellEditor.java 2008-09-30
19:15:18 UTC (rev 10577)
@@ -26,7 +26,8 @@
import org.jboss.tools.jst.jsp.contentassist.FaceletsHtmlContentAssistProcessor;
import org.jboss.tools.jst.jsp.contentassist.JSPDialogCellEditorContentAssistProcessor;
import org.jboss.tools.jst.jsp.drop.treeviewer.model.RootElement;
-import org.jboss.tools.jst.jsp.outline.cssdialog.CSSDialog;
+import org.jboss.tools.jst.jsp.outline.cssdialog.CSSClassDialog;
+import org.jboss.tools.jst.jsp.outline.cssdialog.CSSStyleDialog;
/**
* @author Kabanovich Cell Editor for JSP attributes, of which values can be
@@ -116,15 +117,22 @@
: "";
context.put("value", value);
- if (attributeName.equals("style")) {
- CSSDialog dialog = new CSSDialog(cellEditorWindow.getShell(), (value == null ?
""
+ if (attributeName.equals("style") ||
attributeName.endsWith("Style")) {
+ CSSStyleDialog dialog = new CSSStyleDialog(cellEditorWindow.getShell(), (value ==
null ? ""
: value));
if (dialog.open() == Window.OK) {
externalEditing = false;
return dialog.getNewStyle();
}
- } else {
+ } else if (attributeName.endsWith("Class") ||
attributeName.endsWith("class") ) {
+ CSSClassDialog dialog = new CSSClassDialog(cellEditorWindow.getShell());
+ if (dialog.open() == Window.OK) {
+ externalEditing = false;
+ return dialog.getSelectorName();
+ }
+ }
+ else {
JSPTreeDialog dialog = new JSPTreeDialog();
dialog.setObject(context);
Added:
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
(rev 0)
+++
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/CSSClassDialog.java 2008-09-30
19:15:18 UTC (rev 10577)
@@ -0,0 +1,246 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Exadel, Inc. and Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.jst.jsp.outline.cssdialog;
+
+import java.util.List;
+import java.util.Set;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.browser.Browser;
+import org.eclipse.swt.events.DisposeEvent;
+import org.eclipse.swt.events.DisposeListener;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Combo;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.dialogs.ElementTreeSelectionDialog;
+import org.eclipse.ui.model.BaseWorkbenchContentProvider;
+import org.eclipse.ui.model.WorkbenchLabelProvider;
+import org.jboss.tools.jst.jsp.JspEditorPlugin;
+import org.jboss.tools.jst.jsp.outline.cssdialog.common.CSSModel;
+import org.jboss.tools.jst.jsp.outline.cssdialog.common.Constants;
+import org.jboss.tools.jst.jsp.outline.cssdialog.common.FileExtensionFilter;
+import org.jboss.tools.jst.jsp.outline.cssdialog.common.MessageUtil;
+import org.jboss.tools.jst.jsp.outline.cssdialog.common.Util;
+import org.jboss.tools.jst.jsp.outline.cssdialog.events.ChangeStyleEvent;
+import org.jboss.tools.jst.jsp.outline.cssdialog.events.ChangeStyleListener;
+import org.jboss.tools.jst.jsp.outline.cssdialog.events.StyleAttributes;
+
+public class CSSClassDialog extends Dialog {
+
+ private Browser browser = null;
+ private StyleComposite styleComposite = null;
+ private StyleAttributes styleAttributes = null;
+ private Text text;
+ private IFile file;
+ private Combo classCombo;
+ private CSSModel cssModel;
+ private String selectorName;
+
+ final static int MIN_HEIGHT_FOR_BROWSER = 60;
+ final static String[] fileExtensions = { "css" };
+ final static String CSS_FILE_SELECT_DIALOG_TITLE = "CSS File Selection";
+ final static String CSS_FILE_SELECT_DIALOG = "Select CSS file from the
tree:";
+ final static String CSS_FILE_SELECT_DIALOG_EMPTY_MESSAGE = "No CSS file in the
current project";
+ final static String SKIP_FIRST_CHAR = ".";
+
+ public CSSClassDialog(Shell parentShell) {
+ super(parentShell);
+ setShellStyle(getShellStyle() | SWT.RESIZE | SWT.MAX
+ | SWT.APPLICATION_MODAL);
+ styleAttributes = new StyleAttributes();
+ }
+
+ /**
+ * Method for creating dialog area
+ *
+ * @param parent
+ */
+ protected Control createDialogArea(final Composite parent) {
+
+ final Composite composite = (Composite) super.createDialogArea(parent);
+
+ GridLayout layout = new GridLayout();
+ layout.numColumns = 1;
+ composite.setLayout(layout);
+ browser = new Browser(composite, SWT.BORDER);
+
+ /* ============================================= */
+ Composite classComposite = new Composite(composite, SWT.BORDER);
+ GridData gridData = new GridData(GridData.FILL, GridData.FILL, true,
+ false);
+ classComposite.setLayoutData(gridData);
+
+ final GridLayout gridLayout = new GridLayout();
+ gridLayout.numColumns = 3;
+ classComposite.setLayout(gridLayout);
+
+ Label label = new Label(classComposite, SWT.LEFT);
+ label.setLayoutData(new GridData(GridData.END, GridData.CENTER, false,
+ false));
+ label.setText("CSS file :");
+
+ text = new Text(classComposite, SWT.BORDER);
+ text.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true,
+ false));
+ text.addModifyListener(new ModifyListener() {
+ public void modifyText(ModifyEvent e) {
+
+ IProject project = Util.getCurrentProject();
+ IResource res = project.findMember(text.getText());
+ if (res != null) {
+ if (res instanceof IFile) {
+ file = (IFile) res;
+ cssModel = new CSSModel(file);
+ classCombo.removeAll();
+ List<String> selectors = cssModel.getSelectors();
+ for (String selector : selectors) {
+ classCombo.add(selector);
+ }
+ }
+ }
+ }
+
+ });
+
+ Button button = new Button(classComposite, SWT.PUSH);
+ button.setLayoutData(new GridData(GridData.END, GridData.CENTER, false,
+ false));
+
+ ImageDescriptor imageDesc = JspEditorPlugin
+ .getImageDescriptor(Constants.IMAGE_FOLDERLARGE_FILE_LOCATION);
+ Image image = imageDesc.createImage();
+ button.setImage(image);
+ button.addDisposeListener(new DisposeListener() {
+ public void widgetDisposed(DisposeEvent e) {
+ Button button = (Button) e.getSource();
+ button.getImage().dispose();
+ }
+ });
+
+ label = new Label(classComposite, SWT.LEFT);
+ label.setLayoutData(new GridData(GridData.END, GridData.CENTER, false,
+ false));
+ label.setText("Style class :");
+
+ gridData = new GridData(GridData.FILL, GridData.CENTER, true, false);
+ gridData.horizontalSpan = 2;
+ classCombo = new Combo(classComposite, SWT.BORDER);
+ classCombo.setLayoutData(gridData);
+ classCombo.addSelectionListener(new SelectionListener() {
+
+ public void widgetDefaultSelected(SelectionEvent e) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void widgetSelected(SelectionEvent e) {
+ String style = cssModel.getStyle(classCombo.getText());
+ styleComposite.recreateStyleComposite(style);
+ }
+
+ });
+
+
+
+ button.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent event) {
+
+ IProject project = Util.getCurrentProject();
+
+ ElementTreeSelectionDialog dialog = new ElementTreeSelectionDialog(
+ getShell(), new WorkbenchLabelProvider(),
+ new BaseWorkbenchContentProvider());
+ dialog.addFilter(new FileExtensionFilter(fileExtensions));
+ dialog.setTitle(CSS_FILE_SELECT_DIALOG_TITLE);
+ dialog.setMessage(CSS_FILE_SELECT_DIALOG);
+ dialog.setInput(project);
+ dialog.setAllowMultiple(false);
+ dialog
+ .setEmptyListMessage(CSS_FILE_SELECT_DIALOG_EMPTY_MESSAGE);
+ dialog.open();
+ IResource res = (IResource) dialog.getFirstResult();
+ text.setText(res.getProjectRelativePath().toOSString());
+
+ }
+ });
+
+ /* ============================================ */
+ styleAttributes.addChangeStyleListener(new ChangeStyleListener() {
+ public void styleChanged(ChangeStyleEvent event) {
+ String styleForSpan = "";
+ String html = "";
+
+ Set<String> keySet = styleAttributes.keySet();
+
+ for (String key : keySet)
+ styleForSpan += key + Constants.COLON_STRING
+ + styleAttributes.getAttribute(key)
+ + Constants.SEMICOLON_STRING;
+
+ html = Constants.OPEN_SPAN_TAG + styleForSpan
+ + Constants.TEXT_FOR_PREVIEW + Constants.CLOSE_SPAN_TAG;
+ browser.setText(html);
+ }
+ });
+ styleComposite = new StyleComposite(composite, styleAttributes, "");
+
+ gridData = new GridData(GridData.FILL, GridData.FILL, true, true);
+ gridData.minimumHeight = MIN_HEIGHT_FOR_BROWSER;
+ browser.setLayoutData(gridData);
+
+ return composite;
+ }
+
+ /**
+ * Method for setting title for dialog
+ *
+ * @param newShell
+ */
+ protected void configureShell(Shell newShell) {
+ super.configureShell(newShell);
+ newShell.setText(MessageUtil.getString("CSS_STYLE_CLASS_DIALOG_TITLE"));
+ }
+
+ protected void okPressed() {
+ styleComposite.updateStyle();
+ String newStyle = styleComposite.getNewStyle();
+ cssModel.setCSS(classCombo.getText(), newStyle);
+ cssModel.saveModel();
+ String sel = classCombo.getText();
+ if (sel.trim().startsWith(SKIP_FIRST_CHAR)) {
+ sel = sel.substring(1);
+ }
+ selectorName = sel;
+ super.okPressed();
+ }
+
+ public String getSelectorName() {
+ return selectorName;
+ }
+
+}
Deleted:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/CSSDialog.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/CSSDialog.java 2008-09-30
18:45:39 UTC (rev 10576)
+++
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/CSSDialog.java 2008-09-30
19:15:18 UTC (rev 10577)
@@ -1,419 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Exadel, Inc. and Red Hat, Inc.
- * Distributed under license by Red Hat, Inc. All rights reserved.
- * This program is made available under the terms of the
- * Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at
http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
-package org.jboss.tools.jst.jsp.outline.cssdialog;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Set;
-import java.util.Map.Entry;
-
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.dialogs.IDialogSettings;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.browser.Browser;
-import org.eclipse.swt.custom.ScrolledComposite;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.TabFolder;
-import org.eclipse.swt.widgets.TabItem;
-import org.jboss.tools.jst.jsp.JspEditorPlugin;
-import org.jboss.tools.jst.jsp.outline.cssdialog.common.Constants;
-import org.jboss.tools.jst.jsp.outline.cssdialog.common.MessageUtil;
-import org.jboss.tools.jst.jsp.outline.cssdialog.parsers.BaseListener;
-import org.jboss.tools.jst.jsp.outline.cssdialog.parsers.CSSElementsParser;
-import org.jboss.tools.jst.jsp.outline.cssdialog.parsers.ComboParser;
-import org.jboss.tools.jst.jsp.outline.cssdialog.parsers.Parser;
-import org.jboss.tools.jst.jsp.outline.cssdialog.parsers.ParserListener;
-import org.jboss.tools.jst.jsp.outline.cssdialog.tabs.TabBackgroundControl;
-import org.jboss.tools.jst.jsp.outline.cssdialog.tabs.TabBoxesControl;
-import org.jboss.tools.jst.jsp.outline.cssdialog.tabs.TabPropertySheetControl;
-import org.jboss.tools.jst.jsp.outline.cssdialog.tabs.TabQuickEditControl;
-import org.jboss.tools.jst.jsp.outline.cssdialog.tabs.TabTextControl;
-import org.xml.sax.Attributes;
-
-/**
- * Class for CSS editor dialog
- *
- * @author Dzmitry Sakovich (dsakovich(a)exadel.com)
- */
-public class CSSDialog extends Dialog {
-
- private static int MIN_HEIGHT_FOR_BROWSER = 60;
-
- private static int TAB_TEXT_FONT_NUMBER = 0;
- private static int TAB_QUICK_EDIT_NUMBER = 4;
-
- private static int SIZE_NULL = 0;
-
- private static int FIRST_SELECTION = 0;
-
- private static String NODE_NAME_ELEMENTS = "elements";
- private static String NODE_NAME_VALUE = "value";
- private static String NODE_NAME_ELEMENT = "element";
- private static String NODE_ATTRIBUTE_NAME = "name";
-
- private Browser browser = null;
-
- private String oldStyle;
- private String newStyle;
-
- private TabItem lastSelectedTab = null;
-
- private TabTextControl tabTextControl;
- private TabBackgroundControl tabBackgroundControl;
- private TabBoxesControl tabBoxesControl;
- private TabPropertySheetControl tabPropertySheetControl;
- private TabQuickEditControl tabQuickEditControl;
-
- private TabItem tabTextFont;
- private TabItem tabBackground;
- private TabItem tabBoxes;
- private TabItem tabPropertySheet;
- private TabItem tabQuickEdit;
-
- private HashMap<String, ArrayList<String>> comboMap = new
HashMap<String, ArrayList<String>>();
- private HashMap<String, ArrayList<String>> elementsMap = new
HashMap<String, ArrayList<String>>();
- private HashMap<String, String> attributesMap = new HashMap<String,
String>();
-
- public CSSDialog(final Shell parentShell, String oldStyle) {
- super(parentShell);
- setShellStyle(getShellStyle() | SWT.RESIZE | SWT.MAX
- | SWT.APPLICATION_MODAL);
- this.oldStyle = oldStyle;
-
- ComboParser comboParser = new ComboParser();
- comboParser.setListener(new BaseListener(comboMap) {
-
- private ArrayList<String> list = null;
-
- public void startElement(String uri, String localName,
- String nodeName, Attributes attrs) {
-
- if (nodeName.trim().equalsIgnoreCase(NODE_NAME_ELEMENTS))
- return;
-
- if (!nodeName.trim().equalsIgnoreCase(NODE_NAME_VALUE)) {
- String name = nodeName;
- list = new ArrayList<String>();
- map.put(name, list);
- } else {
- list.add(attrs.getValue(NODE_ATTRIBUTE_NAME));
- }
- }
-
- });
- comboParser.parse();
-
- CSSElementsParser cssParser = new CSSElementsParser();
- cssParser.setListener(new BaseListener(elementsMap) {
-
- private ArrayList<String> list = null;
-
- public void startElement(String uri, String localName,
- String nodeName, Attributes attrs) {
-
- if (nodeName.trim().equalsIgnoreCase(NODE_NAME_ELEMENTS))
- return;
-
- if (!nodeName.trim().equalsIgnoreCase(NODE_NAME_ELEMENT)) {
- String name = nodeName;
- list = new ArrayList<String>();
- map.put(name, list);
- } else {
- list.add(attrs.getValue(NODE_ATTRIBUTE_NAME));
- }
- }
-
- });
- cssParser.parse();
-
- }
-
- /**
- * Getter for newStyle attribute
- *
- * @return
- */
- public String getNewStyle() {
- return newStyle;
- }
-
- /**
- * Setter for newStyle attribute
- *
- * @param newStyle
- */
- public void setNewStyle(String newStyle) {
- this.newStyle = newStyle;
- }
-
- /**
- * Method for creating dialog area
- *
- * @param parent
- */
- protected Control createDialogArea(final Composite parent) {
-
- ParserListener listener = new ParserListener(attributesMap);
- Parser parser = new Parser(elementsMap);
- parser.addListener(listener);
- parser.parse(oldStyle);
-
- final Composite composite = (Composite) super.createDialogArea(parent);
-
- final GridData gridData = new GridData(GridData.FILL, GridData.FILL,
- true, true);
-
- composite.setLayoutData(gridData);
- GridData gd = new GridData(GridData.FILL_BOTH
- | GridData.GRAB_HORIZONTAL | GridData.GRAB_VERTICAL);
-
- final TabFolder tabFolder = new TabFolder(composite, SWT.NONE);
- tabFolder.setLayoutData(gd);
-
- // ------------------------Browser-----------------------------------
-
- browser = new Browser(composite, SWT.BORDER);
- GridData gridBrowser = new GridData(GridData.FILL_BOTH);
- gridBrowser.minimumHeight = MIN_HEIGHT_FOR_BROWSER;
- browser.setLayoutData(gridBrowser);
- //browser.se
- setStyleForPreview();
- // ------------------------------------------------------------------
-
- // Create each tab and set its text, tool tip text,
- tabTextFont = new TabItem(tabFolder, SWT.NONE);
- tabTextFont.setText(MessageUtil.getString("TEXT_FONT_TAB_NAME"));
- tabTextFont.setToolTipText(MessageUtil.getString("TEXT_FONT_TAB_NAME"));
- tabTextFont.setControl(createTabTextControl(tabFolder));
- lastSelectedTab = tabTextFont;
-
- tabBackground = new TabItem(tabFolder, SWT.NONE);
- tabBackground.setText(MessageUtil.getString("BACKGROUND_TAB_NAME"));
- tabBackground.setToolTipText(MessageUtil
- .getString("BACKGROUND_TAB_NAME"));
- tabBackground.setControl(createTabBackgroundControl(tabFolder));
-
- tabBoxes = new TabItem(tabFolder, SWT.NONE);
- tabBoxes.setText(MessageUtil.getString("BOXES_TAB_NAME"));
- tabBoxes.setToolTipText(MessageUtil.getString("BOXES_TAB_NAME"));
- tabBoxes.setControl(createTabBoxesControl(tabFolder));
-
- tabPropertySheet = new TabItem(tabFolder, SWT.NONE);
- tabPropertySheet.setText(MessageUtil
- .getString("PROPERTY_SHEET_TAB_NAME"));
- tabPropertySheet.setToolTipText(MessageUtil
- .getString("PROPERTY_SHEET_TAB_NAME"));
- tabPropertySheet.setControl(createTabPropertySheetControl(tabFolder));
-
- tabFolder.setSelection(TAB_TEXT_FONT_NUMBER);
- if (attributesMap.size() > SIZE_NULL) {
- tabQuickEdit = new TabItem(tabFolder, SWT.NONE);
- tabQuickEdit.setText(MessageUtil.getString("QUICK_EDIT_TAB-NAME"));
- tabQuickEdit.setToolTipText(MessageUtil
- .getString("QUICK_EDIT_TAB-NAME"));
- tabQuickEdit.setControl(createTabQuickEditContol(tabFolder));
- tabFolder.setSelection(TAB_QUICK_EDIT_NUMBER);
- lastSelectedTab = tabQuickEdit;
- }
- tabFolder.addSelectionListener(new SelectionAdapter() {
-
- public void widgetSelected(SelectionEvent se) {
-
-
- if (tabFolder.getSelection()[FIRST_SELECTION] == tabQuickEdit) {
- tabQuickEditControl.dispose();
- tabQuickEdit
- .setControl(createTabQuickEditContol(tabFolder));
- lastSelectedTab = tabQuickEdit;
- } else if (tabFolder.getSelection()[FIRST_SELECTION] == tabTextFont) {
- tabTextControl.updateData(false);
- lastSelectedTab = tabTextFont;
- } else if (tabFolder.getSelection()[FIRST_SELECTION] == tabBackground) {
- tabBackgroundControl.updateData(false);
- lastSelectedTab = tabBackground;
- } else if (tabFolder.getSelection()[FIRST_SELECTION] == tabBoxes) {
- tabBoxesControl.updateData(false);
- lastSelectedTab = tabBoxes;
- } else if (tabFolder.getSelection()[FIRST_SELECTION] == tabPropertySheet) {
- tabPropertySheetControl.updateData(false);
- lastSelectedTab = tabPropertySheet;
- }
- }
- });
-
- return composite;
- }
-
- /**
- * Method for setting title for dialog
- *
- * @param newShell
- */
- protected void configureShell(Shell newShell) {
- super.configureShell(newShell);
- newShell.setText(MessageUtil.getString("CSS_DIALOG_TITLE"));
- }
-
- protected void okPressed() {
-
- if (lastSelectedTab == tabTextFont) {
- tabTextControl.updateData(true);
- } else if (lastSelectedTab == tabBackground) {
- tabBackgroundControl.updateData(true);
- } else if (lastSelectedTab == tabBoxes) {
- tabBoxesControl.updateData(true);
- } else if (lastSelectedTab == tabPropertySheet) {
- tabPropertySheetControl.updateData(true);
- }
- StringBuffer buf = new StringBuffer();
- Set<Entry<String, String>> set = attributesMap.entrySet();
- for (Map.Entry<String, String> me : set) {
- buf.append(me.getKey() + Constants.COLON_STRING + me.getValue()
- + Constants.SEMICOLON_STRING);
- }
- setNewStyle(buf.toString());
- super.okPressed();
- }
-
- /**
- * Method for creating text tab
- *
- * @param tabFolder
- * @return composite
- */
- private Control createTabTextControl(TabFolder tabFolder) {
-
- ScrolledComposite sc = new ScrolledComposite(tabFolder, SWT.H_SCROLL
- | SWT.V_SCROLL);
-
- sc.setExpandHorizontal(true);
- sc.setExpandVertical(true);
-
- tabTextControl = new TabTextControl(sc, comboMap, attributesMap, this);
- sc.setContent(tabTextControl);
-
- sc.setMinSize(tabTextControl.computeSize(SWT.DEFAULT, SWT.DEFAULT));
-
- return sc;
- }
-
- /**
- * Method for creating background tab
- *
- * @param tabFolder
- * @return composite
- */
- private Control createTabBackgroundControl(TabFolder tabFolder) {
- ScrolledComposite sc = new ScrolledComposite(tabFolder, SWT.H_SCROLL
- | SWT.V_SCROLL);
-
- sc.setExpandHorizontal(true);
- sc.setExpandVertical(true);
-
- tabBackgroundControl = new TabBackgroundControl(sc, comboMap,
- attributesMap, this);
- sc.setContent(tabBackgroundControl);
- sc.setMinSize(tabBackgroundControl
- .computeSize(SWT.DEFAULT, SWT.DEFAULT));
-
- return sc;
- }
-
- /**
- * Method for creating boxes tab
- *
- * @param tabFolder
- * @return composite
- */
- private Control createTabBoxesControl(TabFolder tabFolder) {
-
- ScrolledComposite sc = new ScrolledComposite(tabFolder, SWT.H_SCROLL
- | SWT.V_SCROLL);
-
- sc.setExpandHorizontal(true);
- sc.setExpandVertical(true);
-
- tabBoxesControl = new TabBoxesControl(sc, comboMap, attributesMap, this);
- sc.setContent(tabBoxesControl);
- sc.setMinSize(tabBoxesControl.computeSize(SWT.DEFAULT, SWT.DEFAULT));
-
- return sc;
- }
-
- /**
- *
- * Method for creating property sheet tab
- *
- * @param tabFolder
- * @return
- */
- private Control createTabPropertySheetControl(TabFolder tabFolder) {
- tabPropertySheetControl = new TabPropertySheetControl(tabFolder,
- elementsMap, comboMap, attributesMap, this);
- return tabPropertySheetControl;
- }
-
- /**
- *
- * Method for creating quick edit tab
- *
- * @param tabFolder
- * @return
- */
- private Control createTabQuickEditContol(TabFolder tabFolder) {
-
- ScrolledComposite sc = new ScrolledComposite(tabFolder, SWT.H_SCROLL
- | SWT.V_SCROLL);
-
- sc.setExpandHorizontal(true);
- sc.setExpandVertical(true);
-
- tabQuickEditControl = new TabQuickEditControl(sc, comboMap,
- attributesMap, this);
- sc.setContent(tabQuickEditControl);
-
- sc
- .setMinSize(tabQuickEditControl.computeSize(SWT.DEFAULT,
- SWT.DEFAULT));
- return sc;
- }
-
- @Override
- protected IDialogSettings getDialogBoundsSettings() {
- return JspEditorPlugin.getDefault().getDialogSettings();
- }
-
- /**
- *
- * Set style for preview
- */
- public void setStyleForPreview() {
-
- String styleForSpan = "";
- String html = "";
-
- Set<String> keySet = attributesMap.keySet();
-
- for (String key : keySet)
- styleForSpan += key + Constants.COLON_STRING
- + attributesMap.get(key) + Constants.SEMICOLON_STRING;
-
- html = Constants.OPEN_SPAN_TAG + styleForSpan
- + Constants.TEXT_FOR_PREVIEW + Constants.CLOSE_SPAN_TAG;
- browser.setText(html);
- }
-}
\ No newline at end of file
Copied:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/CSSStyleDialog.java
(from rev 10421,
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/CSSDialog.java)
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/CSSStyleDialog.java
(rev 0)
+++
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/CSSStyleDialog.java 2008-09-30
19:15:18 UTC (rev 10577)
@@ -0,0 +1,125 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Exadel, Inc. and Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.jst.jsp.outline.cssdialog;
+
+import java.util.Set;
+
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.dialogs.IDialogSettings;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.browser.Browser;
+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.jboss.tools.jst.jsp.JspEditorPlugin;
+import org.jboss.tools.jst.jsp.outline.cssdialog.common.Constants;
+import org.jboss.tools.jst.jsp.outline.cssdialog.common.MessageUtil;
+import org.jboss.tools.jst.jsp.outline.cssdialog.events.ChangeStyleEvent;
+import org.jboss.tools.jst.jsp.outline.cssdialog.events.ChangeStyleListener;
+import org.jboss.tools.jst.jsp.outline.cssdialog.events.StyleAttributes;
+
+/**
+ * Class for CSS editor dialog
+ *
+ * @author Dzmitry Sakovich (dsakovich(a)exadel.com)
+ */
+public class CSSStyleDialog extends Dialog {
+
+
+ //TODO Dzmitry Sakovich
+ private Browser browser = null;
+ private StyleComposite styleComposite = null;
+ private String oldStyle;
+ private StyleAttributes styleAttributes = new StyleAttributes();
+
+
+ final static int MIN_HEIGHT_FOR_BROWSER = 60;
+
+ public CSSStyleDialog(final Shell parentShell, String oldStyle) {
+ super(parentShell);
+ setShellStyle(getShellStyle() | SWT.RESIZE | SWT.MAX
+ | SWT.APPLICATION_MODAL);
+ this.oldStyle = oldStyle;
+ }
+
+ /**
+ * Getter for newStyle attribute
+ *
+ * @return
+ */
+ public String getNewStyle() {
+ return styleComposite==null?oldStyle:styleComposite.getNewStyle();
+ }
+
+ /**
+ * Method for creating dialog area
+ *
+ * @param parent
+ */
+ protected Control createDialogArea(final Composite parent) {
+
+
+ final Composite composite = (Composite) super.createDialogArea(parent);
+
+ GridLayout layout = new GridLayout();
+ layout.numColumns = 1;
+ browser = new Browser(composite,SWT.BORDER);
+
+ composite.setLayout(layout);
+
+ styleAttributes.addChangeStyleListener(new ChangeStyleListener() {
+ public void styleChanged(ChangeStyleEvent event) {
+ String styleForSpan = "";
+ String html = "";
+
+ Set<String> keySet = styleAttributes.keySet();
+
+ for (String key : keySet)
+ styleForSpan += key + Constants.COLON_STRING
+ + styleAttributes.getAttribute(key) + Constants.SEMICOLON_STRING;
+
+ html = Constants.OPEN_SPAN_TAG + styleForSpan
+ + Constants.TEXT_FOR_PREVIEW + Constants.CLOSE_SPAN_TAG;
+ browser.setText(html);
+ }
+ });
+ styleComposite = new StyleComposite(composite,styleAttributes,oldStyle);
+
+ GridData gridData = new GridData(GridData.FILL, GridData.FILL, true,
+ true);
+ gridData.minimumHeight = MIN_HEIGHT_FOR_BROWSER;
+ browser.setLayoutData(gridData);
+
+ return composite;
+ }
+
+ /**
+ * Method for setting title for dialog
+ *
+ * @param newShell
+ */
+ protected void configureShell(Shell newShell) {
+ super.configureShell(newShell);
+ newShell.setText(MessageUtil.getString("CSS_STYLE_DIALOG_TITLE"));
+ }
+
+ protected void okPressed() {
+ styleComposite.updateStyle();
+ super.okPressed();
+ }
+
+ @Override
+ protected IDialogSettings getDialogBoundsSettings() {
+ return JspEditorPlugin.getDefault().getDialogSettings();
+ }
+}
\ No newline at end of file
Modified:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/ImageSelectionDialog.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/ImageSelectionDialog.java 2008-09-30
18:45:39 UTC (rev 10576)
+++
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/ImageSelectionDialog.java 2008-09-30
19:15:18 UTC (rev 10577)
@@ -18,12 +18,8 @@
import java.util.List;
import java.util.Set;
-import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IFolder;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.jface.dialogs.IDialogConstants;
@@ -37,7 +33,6 @@
import org.eclipse.jface.viewers.SelectionChangedEvent;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.jface.viewers.TreeViewer;
-import org.eclipse.jface.viewers.Viewer;
import org.eclipse.jface.viewers.ViewerComparator;
import org.eclipse.jface.viewers.ViewerFilter;
import org.eclipse.jface.viewers.ViewerSorter;
@@ -70,7 +65,7 @@
import org.eclipse.ui.dialogs.ISelectionStatusValidator;
import org.eclipse.ui.dialogs.SelectionStatusDialog;
import org.eclipse.ui.internal.WorkbenchMessages;
-import org.jboss.tools.jst.jsp.JspEditorPlugin;
+import org.jboss.tools.jst.jsp.outline.cssdialog.common.FileExtensionFilter;
import org.jboss.tools.jst.jsp.outline.cssdialog.common.MessageUtil;
/**
@@ -687,45 +682,4 @@
}
return elements.length == 0;
}
-
- /**
- * Class for creates filter by file extensions
- *
- * @author dsakovich
- */
- private class FileExtensionFilter extends ViewerFilter {
-
- private String[] fTargetExtension;
-
- public FileExtensionFilter(String[] targetExtension) {
- fTargetExtension = targetExtension;
- }
-
- public boolean select(Viewer viewer, Object parent, Object element) {
- if (element instanceof IFile) {
- for (int i = 0; i < fTargetExtension.length; i++) {
- if (((IFile) element).getName().toLowerCase().endsWith(
- "." + fTargetExtension[i])) {
- return true;
- }
- }
- return false;
- }
- if (element instanceof IProject && ((IProject) element).isOpen())
- return true;
- if (element instanceof IContainer) { // i.e. IProject, IFolder
- try {
- IResource[] resources = ((IContainer) element).members();
- for (int i = 0; i < resources.length; i++) {
- if (select(viewer, parent, resources[i]))
- return true;
- }
- } catch (CoreException e) {
- JspEditorPlugin.getPluginLog().logError(e);
- }
- }
- return false;
- }
- }
-
}
Added:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/StyleComposite.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/StyleComposite.java
(rev 0)
+++
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/StyleComposite.java 2008-09-30
19:15:18 UTC (rev 10577)
@@ -0,0 +1,375 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Exadel, Inc. and Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.jst.jsp.outline.cssdialog;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Set;
+import java.util.Map.Entry;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.ScrolledComposite;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+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.TabFolder;
+import org.eclipse.swt.widgets.TabItem;
+import org.jboss.tools.jst.jsp.outline.cssdialog.common.Constants;
+import org.jboss.tools.jst.jsp.outline.cssdialog.common.MessageUtil;
+import org.jboss.tools.jst.jsp.outline.cssdialog.events.StyleAttributes;
+import org.jboss.tools.jst.jsp.outline.cssdialog.parsers.BaseListener;
+import org.jboss.tools.jst.jsp.outline.cssdialog.parsers.CSSElementsParser;
+import org.jboss.tools.jst.jsp.outline.cssdialog.parsers.ComboParser;
+import org.jboss.tools.jst.jsp.outline.cssdialog.parsers.Parser;
+import org.jboss.tools.jst.jsp.outline.cssdialog.parsers.ParserListener;
+import org.jboss.tools.jst.jsp.outline.cssdialog.tabs.TabBackgroundControl;
+import org.jboss.tools.jst.jsp.outline.cssdialog.tabs.TabBoxesControl;
+import org.jboss.tools.jst.jsp.outline.cssdialog.tabs.TabPropertySheetControl;
+import org.jboss.tools.jst.jsp.outline.cssdialog.tabs.TabQuickEditControl;
+import org.jboss.tools.jst.jsp.outline.cssdialog.tabs.TabTextControl;
+import org.xml.sax.Attributes;
+
+/**
+ * Class for creating style tabs
+ *
+ * @author Dzmitry Sakovich (dsakovich(a)exadel.com)
+ */
+public class StyleComposite extends Composite {
+
+ private String newStyle;
+ private String oldStyle;
+
+ private TabTextControl tabTextControl;
+ private TabBackgroundControl tabBackgroundControl;
+ private TabBoxesControl tabBoxesControl;
+ private TabPropertySheetControl tabPropertySheetControl;
+ private TabQuickEditControl tabQuickEditControl;
+
+ private TabFolder tabFolder;
+ private TabItem tabTextFont;
+ private TabItem tabBackground;
+ private TabItem tabBoxes;
+ private TabItem tabPropertySheet;
+ private TabItem tabQuickEdit;
+
+ private TabItem lastSelectedTab = null;
+
+ private StyleAttributes styleAttributes;
+ private Parser parser;
+ private HashMap<String, ArrayList<String>> comboMap = new
HashMap<String, ArrayList<String>>();
+ private HashMap<String, ArrayList<String>> elementsMap = new
HashMap<String, ArrayList<String>>();
+
+ private static String NODE_NAME_ELEMENTS = "elements";
+ private static String NODE_NAME_VALUE = "value";
+ private static String NODE_NAME_ELEMENT = "element";
+ private static String NODE_ATTRIBUTE_NAME = "name";
+ private static int TAB_TEXT_FONT_NUMBER = 0;
+ private static int TAB_QUICK_EDIT_NUMBER = 4;
+ private static int FIRST_SELECTION = 0;
+ private static int SIZE_NULL = 0;
+
+ public StyleComposite(Composite parent, StyleAttributes styleAttributes,
+ String oldStyle) {
+ super(parent, SWT.NONE);
+ this.oldStyle = oldStyle;
+ this.styleAttributes = styleAttributes;
+ createTabs();
+
+ }
+
+ /**
+ *
+ * @return
+ */
+ public String getNewStyle() {
+ return newStyle;
+ }
+
+ public void updateStyle() {
+ if (lastSelectedTab == tabTextFont) {
+ tabTextControl.updateData(true);
+ } else if (lastSelectedTab == tabBackground) {
+ tabBackgroundControl.updateData(true);
+ } else if (lastSelectedTab == tabBoxes) {
+ tabBoxesControl.updateData(true);
+ } else if (lastSelectedTab == tabPropertySheet) {
+ tabPropertySheetControl.updateData(true);
+ }
+ StringBuffer buf = new StringBuffer();
+ Set<Entry<String, String>> set = styleAttributes.entrySet();
+ for (Map.Entry<String, String> me : set) {
+ buf.append(me.getKey() + Constants.COLON_STRING + me.getValue()
+ + Constants.SEMICOLON_STRING);
+ }
+ newStyle = buf.toString();
+ }
+
+ /**
+ * Method for creating text tab
+ *
+ * @param tabFolder
+ * @return composite
+ */
+ private Control createTabTextControl(TabFolder tabFolder) {
+
+ ScrolledComposite sc = new ScrolledComposite(tabFolder, SWT.H_SCROLL
+ | SWT.V_SCROLL);
+
+ sc.setExpandHorizontal(true);
+ sc.setExpandVertical(true);
+
+ tabTextControl = new TabTextControl(sc, comboMap, styleAttributes);
+ sc.setContent(tabTextControl);
+
+ sc.setMinSize(tabTextControl.computeSize(SWT.DEFAULT, SWT.DEFAULT));
+
+ return sc;
+ }
+
+ /**
+ * Method for creating background tab
+ *
+ * @param tabFolder
+ * @return composite
+ */
+ private Control createTabBackgroundControl(TabFolder tabFolder) {
+ ScrolledComposite sc = new ScrolledComposite(tabFolder, SWT.H_SCROLL
+ | SWT.V_SCROLL);
+
+ sc.setExpandHorizontal(true);
+ sc.setExpandVertical(true);
+
+ tabBackgroundControl = new TabBackgroundControl(sc, comboMap,
+ styleAttributes);
+ sc.setContent(tabBackgroundControl);
+ sc.setMinSize(tabBackgroundControl
+ .computeSize(SWT.DEFAULT, SWT.DEFAULT));
+
+ return sc;
+ }
+
+ /**
+ * Method for creating boxes tab
+ *
+ * @param tabFolder
+ * @return composite
+ */
+ private Control createTabBoxesControl(TabFolder tabFolder) {
+
+ ScrolledComposite sc = new ScrolledComposite(tabFolder, SWT.H_SCROLL
+ | SWT.V_SCROLL);
+
+ sc.setExpandHorizontal(true);
+ sc.setExpandVertical(true);
+
+ tabBoxesControl = new TabBoxesControl(sc, comboMap, styleAttributes);
+ sc.setContent(tabBoxesControl);
+ sc.setMinSize(tabBoxesControl.computeSize(SWT.DEFAULT, SWT.DEFAULT));
+
+ return sc;
+ }
+
+ private void createTabs() {
+ ComboParser comboParser = new ComboParser();
+ comboParser.setListener(new BaseListener(comboMap) {
+
+ private ArrayList<String> list = null;
+
+ public void startElement(String uri, String localName,
+ String nodeName, Attributes attrs) {
+
+ if (nodeName.trim().equalsIgnoreCase(NODE_NAME_ELEMENTS))
+ return;
+
+ if (!nodeName.trim().equalsIgnoreCase(NODE_NAME_VALUE)) {
+ String name = nodeName;
+ list = new ArrayList<String>();
+ map.put(name, list);
+ } else {
+ list.add(attrs.getValue(NODE_ATTRIBUTE_NAME));
+ }
+ }
+
+ });
+ comboParser.parse();
+
+ CSSElementsParser cssParser = new CSSElementsParser();
+ cssParser.setListener(new BaseListener(elementsMap) {
+
+ private ArrayList<String> list = null;
+
+ public void startElement(String uri, String localName,
+ String nodeName, Attributes attrs) {
+
+ if (nodeName.trim().equalsIgnoreCase(NODE_NAME_ELEMENTS))
+ return;
+
+ if (!nodeName.trim().equalsIgnoreCase(NODE_NAME_ELEMENT)) {
+ String name = nodeName;
+ list = new ArrayList<String>();
+ map.put(name, list);
+ } else {
+ list.add(attrs.getValue(NODE_ATTRIBUTE_NAME));
+ }
+ }
+
+ });
+ cssParser.parse();
+
+ // HashMap<String, String> attributesMap = new HashMap<String,
+ // String>();
+ ParserListener listener = new ParserListener(styleAttributes);
+ parser = new Parser(elementsMap);
+ parser.addListener(listener);
+ parser.parse(this.oldStyle);
+
+ final GridLayout gridLayout = new GridLayout();
+ gridLayout.numColumns = 1;
+ setLayout(gridLayout);
+ setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, true));
+
+ tabFolder = new TabFolder(this, SWT.NONE);
+ tabFolder.setLayoutData(new GridData(GridData.FILL, GridData.FILL,
+ true, true));
+
+ // Create each tab and set its text, tool tip text,
+ tabTextFont = new TabItem(tabFolder, SWT.NONE);
+ tabTextFont.setText(MessageUtil.getString("TEXT_FONT_TAB_NAME"));
+ tabTextFont.setToolTipText(MessageUtil.getString("TEXT_FONT_TAB_NAME"));
+ tabTextFont.setControl(createTabTextControl(tabFolder));
+ lastSelectedTab = tabTextFont;
+
+ tabBackground = new TabItem(tabFolder, SWT.NONE);
+ tabBackground.setText(MessageUtil.getString("BACKGROUND_TAB_NAME"));
+ tabBackground.setToolTipText(MessageUtil
+ .getString("BACKGROUND_TAB_NAME"));
+ tabBackground.setControl(createTabBackgroundControl(tabFolder));
+
+ tabBoxes = new TabItem(tabFolder, SWT.NONE);
+ tabBoxes.setText(MessageUtil.getString("BOXES_TAB_NAME"));
+ tabBoxes.setToolTipText(MessageUtil.getString("BOXES_TAB_NAME"));
+ tabBoxes.setControl(createTabBoxesControl(tabFolder));
+
+ tabPropertySheet = new TabItem(tabFolder, SWT.NONE);
+ tabPropertySheet.setText(MessageUtil
+ .getString("PROPERTY_SHEET_TAB_NAME"));
+ tabPropertySheet.setToolTipText(MessageUtil
+ .getString("PROPERTY_SHEET_TAB_NAME"));
+ tabPropertySheet.setControl(createTabPropertySheetControl(tabFolder));
+
+ tabFolder.setSelection(TAB_TEXT_FONT_NUMBER);
+ if (styleAttributes.getAttributeMap().size() > SIZE_NULL) {
+ tabQuickEdit = new TabItem(tabFolder, SWT.NONE);
+ tabQuickEdit.setText(MessageUtil.getString("QUICK_EDIT_TAB-NAME"));
+ tabQuickEdit.setToolTipText(MessageUtil
+ .getString("QUICK_EDIT_TAB-NAME"));
+ tabQuickEdit.setControl(createTabQuickEditContol(tabFolder));
+ tabFolder.setSelection(TAB_QUICK_EDIT_NUMBER);
+ lastSelectedTab = tabQuickEdit;
+ }
+ tabFolder.addSelectionListener(new SelectionAdapter() {
+
+ public void widgetSelected(SelectionEvent se) {
+
+ if (tabFolder.getSelection()[FIRST_SELECTION] == tabQuickEdit) {
+ tabQuickEditControl.dispose();
+ tabQuickEdit
+ .setControl(createTabQuickEditContol(tabFolder));
+ lastSelectedTab = tabQuickEdit;
+ } else if (tabFolder.getSelection()[FIRST_SELECTION] == tabTextFont) {
+ tabTextControl.updateData(false);
+ lastSelectedTab = tabTextFont;
+ } else if (tabFolder.getSelection()[FIRST_SELECTION] == tabBackground) {
+ tabBackgroundControl.updateData(false);
+ lastSelectedTab = tabBackground;
+ } else if (tabFolder.getSelection()[FIRST_SELECTION] == tabBoxes) {
+ tabBoxesControl.updateData(false);
+ lastSelectedTab = tabBoxes;
+ } else if (tabFolder.getSelection()[FIRST_SELECTION] == tabPropertySheet) {
+ tabPropertySheetControl.updateData(false);
+ lastSelectedTab = tabPropertySheet;
+ }
+ }
+ });
+ }
+
+ /**
+ *
+ * Method for creating property sheet tab
+ *
+ * @param tabFolder
+ * @return
+ */
+ private Control createTabPropertySheetControl(TabFolder tabFolder) {
+ tabPropertySheetControl = new TabPropertySheetControl(tabFolder,
+ elementsMap, comboMap, styleAttributes);
+ return tabPropertySheetControl;
+ }
+
+ public void recreateStyleComposite(String style) {
+ styleAttributes.clear();
+ parser.parse(style);
+
+ tabBackgroundControl.updateData(false);
+ tabBoxesControl.updateData(false);
+ tabPropertySheetControl.updateData(false);
+ tabTextControl.updateData(false);
+ if (styleAttributes.getAttributeMap().size() > SIZE_NULL) {
+ if (tabQuickEdit == null || tabQuickEdit.isDisposed()) {
+ tabQuickEdit = new TabItem(tabFolder, SWT.NONE);
+ tabQuickEdit.setText(MessageUtil
+ .getString("QUICK_EDIT_TAB-NAME"));
+ tabQuickEdit.setToolTipText(MessageUtil
+ .getString("QUICK_EDIT_TAB-NAME"));
+ tabQuickEdit.setControl(createTabQuickEditContol(tabFolder));
+ } else {
+ // update quick edit
+ tabQuickEditControl.updateData();
+ }
+ tabFolder.setSelection(TAB_QUICK_EDIT_NUMBER);
+ lastSelectedTab = tabQuickEdit;
+ } else {
+ if (tabQuickEdit != null || !tabQuickEdit.isDisposed()) {
+ tabQuickEdit.dispose();
+ tabFolder.redraw();
+ }
+ }
+ }
+
+ /**
+ *
+ * Method for creating quick edit tab
+ *
+ * @param tabFolder
+ * @return
+ */
+ private Control createTabQuickEditContol(TabFolder tabFolder) {
+
+ ScrolledComposite sc = new ScrolledComposite(tabFolder, SWT.H_SCROLL
+ | SWT.V_SCROLL);
+
+ sc.setExpandHorizontal(true);
+ sc.setExpandVertical(true);
+
+ tabQuickEditControl = new TabQuickEditControl(sc, comboMap,
+ styleAttributes);
+ sc.setContent(tabQuickEditControl);
+
+ sc
+ .setMinSize(tabQuickEditControl.computeSize(SWT.DEFAULT,
+ SWT.DEFAULT));
+ return sc;
+ }
+}
Added:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/common/CSSModel.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/common/CSSModel.java
(rev 0)
+++
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/common/CSSModel.java 2008-09-30
19:15:18 UTC (rev 10577)
@@ -0,0 +1,143 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Exadel, Inc. and Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.jst.jsp.outline.cssdialog.common;
+
+import java.io.IOException;
+import java.io.UnsupportedEncodingException;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.wst.css.core.internal.format.FormatProcessorCSS;
+import org.eclipse.wst.css.core.internal.provisional.document.ICSSDocument;
+import org.eclipse.wst.css.core.internal.provisional.document.ICSSModel;
+import org.eclipse.wst.sse.core.StructuredModelManager;
+import org.eclipse.wst.sse.core.internal.provisional.IModelManager;
+import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel;
+import org.jboss.tools.jst.jsp.JspEditorPlugin;
+import org.w3c.dom.css.CSSRuleList;
+import org.w3c.dom.css.CSSStyleDeclaration;
+import org.w3c.dom.css.CSSStyleRule;
+import org.w3c.dom.css.CSSStyleSheet;
+
+
+public class CSSModel {
+
+ private FormatProcessorCSS formatProcessorCSS = null;
+ private CSSStyleSheet styleSheet = null;
+ private IStructuredModel model = null;
+
+ private static String startBraces = "{";
+ private static String endBraces = "}";
+
+ public CSSModel(IFile styleFile) {
+
+ try {
+ formatProcessorCSS = new FormatProcessorCSS();
+ IModelManager modelManager = StructuredModelManager
+ .getModelManager();
+ model = modelManager.getModelForEdit(styleFile);
+ if (model instanceof ICSSModel) {
+ ICSSModel cssModel = (ICSSModel) model;
+ ICSSDocument document = cssModel.getDocument();
+ if (document instanceof CSSStyleSheet) {
+ styleSheet = (CSSStyleSheet) document;
+ }
+ }
+
+ } catch (IOException e) {
+ JspEditorPlugin.getPluginLog().logError(e.getMessage());
+ } catch (CoreException e) {
+ JspEditorPlugin.getPluginLog().logError(e.getMessage());
+ }
+ }
+
+ /**
+ * Get selectors
+ *
+ * @return List<String>
+ */
+ public List<String> getSelectors() {
+ List<String> selectors = new ArrayList<String>();
+ if (styleSheet != null) {
+ CSSRuleList list = styleSheet.getCssRules();
+ if (list != null) {
+ for (int i = 0; i < list.getLength(); i++) {
+ if (list.item(i) instanceof CSSStyleRule) {
+ selectors.add(((CSSStyleRule)list.item(i)).getSelectorText());
+ }
+ }
+ }
+ }
+ return selectors;
+ }
+
+ /**
+ * Get style by selectorName
+ *
+ * @param selectorName
+ * @return style
+ */
+ public String getStyle(String selectorName) {
+ if (styleSheet != null) {
+ CSSRuleList list = styleSheet.getCssRules();
+ if (list != null) {
+ for (int i = 0; i < list.getLength(); i++) {
+ if (list.item(i) instanceof CSSStyleRule &&
((CSSStyleRule)list.item(i)).getSelectorText().equals(selectorName)) {
+ return ((CSSStyleRule)list.item(i)).getStyle().getCssText();
+ }
+ }
+ }
+ }
+ return null;
+ }
+
+ /**
+ *
+ * @param selector
+ * @param style
+ */
+ public void setCSS(String selector,String style) {
+ if (styleSheet != null) {
+ CSSRuleList list = styleSheet.getCssRules();
+ if (list != null) {
+ for (int i = 0; i < list.getLength(); i++) {
+ if (list.item(i) instanceof CSSStyleRule &&
((CSSStyleRule)list.item(i)).getSelectorText().equals(selector)) {
+ CSSStyleRule rule = (CSSStyleRule) list.item(i);
+ CSSStyleDeclaration declaration = rule.getStyle();
+ declaration.setCssText(style);
+ return;
+ }
+ }
+ styleSheet.insertRule(selector+startBraces+style+endBraces, list.getLength());
+ }
+ }
+ }
+
+ /**
+ * Save model to file
+ */
+ public void saveModel() {
+ if (formatProcessorCSS!=null)
+ formatProcessorCSS.formatModel(model);
+ try {
+ model.save();
+ } catch (UnsupportedEncodingException e) {
+ JspEditorPlugin.getPluginLog().logError(e.getMessage());
+ } catch (IOException e) {
+ JspEditorPlugin.getPluginLog().logError(e.getMessage());
+ } catch (CoreException e) {
+ JspEditorPlugin.getPluginLog().logError(e.getMessage());
+ }
+ }
+
+}
Added:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/common/FileExtensionFilter.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/common/FileExtensionFilter.java
(rev 0)
+++
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/common/FileExtensionFilter.java 2008-09-30
19:15:18 UTC (rev 10577)
@@ -0,0 +1,60 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Exadel, Inc. and Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.jst.jsp.outline.cssdialog.common;
+
+import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.viewers.ViewerFilter;
+import org.jboss.tools.jst.jsp.JspEditorPlugin;
+
+/**
+ * Class for creates filter by file extensions
+ *
+ * @author dsakovich
+ */
+public class FileExtensionFilter extends ViewerFilter {
+
+ private String[] fTargetExtension;
+
+ public FileExtensionFilter(String[] targetExtension) {
+ fTargetExtension = targetExtension;
+ }
+
+ public boolean select(Viewer viewer, Object parent, Object element) {
+ if (element instanceof IFile) {
+ for (int i = 0; i < fTargetExtension.length; i++) {
+ if (((IFile) element).getName().toLowerCase().endsWith(
+ "." + fTargetExtension[i])) {
+ return true;
+ }
+ }
+ return false;
+ }
+ if (element instanceof IProject && ((IProject) element).isOpen())
+ return true;
+ if (element instanceof IContainer) { // i.e. IProject, IFolder
+ try {
+ IResource[] resources = ((IContainer) element).members();
+ for (int i = 0; i < resources.length; i++) {
+ if (select(viewer, parent, resources[i]))
+ return true;
+ }
+ } catch (CoreException e) {
+ JspEditorPlugin.getPluginLog().logError(e);
+ }
+ }
+ return false;
+ }
+}
\ No newline at end of file
Modified:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/common/Util.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/common/Util.java 2008-09-30
18:45:39 UTC (rev 10576)
+++
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/common/Util.java 2008-09-30
19:15:18 UTC (rev 10577)
@@ -7,14 +7,21 @@
*
* Contributors:
* Exadel, Inc. and Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
+ ******************************************************************************/
package org.jboss.tools.jst.jsp.outline.cssdialog.common;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Set;
import java.util.StringTokenizer;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
import org.eclipse.swt.graphics.RGB;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.IFileEditorInput;
+import org.jboss.tools.jst.jsp.JspEditorPlugin;
import org.jboss.tools.jst.jsp.outline.cssdialog.parsers.ColorParser;
/**
@@ -65,7 +72,7 @@
* Method for checking contain or not css attribute folder
*
* @param name
- * Name css attribute
+ * Name css attribute
* @return true - contain, or else - dont contain
*/
public static boolean containFolder(String name) {
@@ -80,9 +87,9 @@
* Method for search css attribute in block elements (Aural, Boxes,....)
*
* @param name
- * Name css attribute
+ * Name css attribute
* @param set
- * Set of block elemnts
+ * Set of block elemnts
* @return true - find, or else - dont find
*/
public static boolean searchOnBlock(String name, Set<String> set) {
@@ -99,9 +106,9 @@
* font-weight,....)
*
* @param name
- * Name css attribute
+ * Name css attribute
* @param set
- * Set of combo elemnts
+ * Set of combo elemnts
* @return true - find, or else - dont find
*/
public static boolean searchInCombo(String name, Set<String> set) {
@@ -117,9 +124,9 @@
* Method for search string into css attributes
*
* @param name
- * Name
+ * Name
* @param elementMap
- * Map of css attributes
+ * Map of css attributes
* @return true - find, or else - dont find
*/
public static boolean searchInElement(String name,
@@ -142,7 +149,7 @@
* Method for get RGB from string
*
* @param color
- * Color string
+ * Color string
* @return RGB color, or null, if color invalid
*/
public static RGB getColor(String color) {
@@ -189,7 +196,8 @@
if (j == COUNT_COLORS)
return convertColorRGB(color);
} else {
- HashMap<String, String> colorMap = ColorParser.getInstance().getMap();
+ HashMap<String, String> colorMap = ColorParser.getInstance()
+ .getMap();
for (String key : colorMap.keySet())
if (colorMap.get(key).equalsIgnoreCase(color))
@@ -203,7 +211,7 @@
* Method for convert string(123px) into two string (123 and px)
*
* @param str
- * String for convert
+ * String for convert
* @return Array two strings, or null, if str uncorrect
*/
public static String[] convertExtString(String str) {
@@ -241,7 +249,7 @@
* Method for search css attribute into extElements
*
* @param name
- * Name of css attribute
+ * Name of css attribute
* @return true - find, or else - dont find
*/
public static boolean searchInExtElement(String name) {
@@ -256,7 +264,7 @@
* Method for getting RGB color from string color
*
* @param color
- * String color
+ * String color
* @return RGB color
*/
public static RGB convertColorRGB(String color) {
@@ -280,7 +288,7 @@
* Method for getting RGB color from hex string
*
* @param color
- * String color
+ * String color
* @return RGB color
*/
public static RGB convertColorHEX(String color) {
@@ -302,7 +310,7 @@
* Method for convert RGB to String
*
* @param rgb
- * RGB color
+ * RGB color
* @return String color
*/
public static String createColorString(RGB rgb) {
@@ -322,4 +330,25 @@
return ColorParser.getInstance().getMap().get(colorStr);
return colorStr;
}
+
+ /**
+ * Get current project
+ *
+ * @return
+ */
+ public static IProject getCurrentProject() {
+ IEditorPart editor = JspEditorPlugin.getDefault().getWorkbench()
+ .getActiveWorkbenchWindow().getActivePage().getActiveEditor();
+ IEditorInput input = editor.getEditorInput();
+ IFile file = null;
+ if (input instanceof IFileEditorInput) {
+ file = ((IFileEditorInput) input).getFile();
+ }
+ if (file == null)
+ return null;
+
+ IProject project = file.getProject();
+ return project;
+
+ }
}
\ No newline at end of file
Modified:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/common/messages.properties
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/common/messages.properties 2008-09-30
18:45:39 UTC (rev 10576)
+++
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/common/messages.properties 2008-09-30
19:15:18 UTC (rev 10577)
@@ -1,4 +1,5 @@
-CSS_DIALOG_TITLE=CSS Editor
+CSS_STYLE_DIALOG_TITLE=CSS Style Dialog
+CSS_STYLE_CLASS_DIALOG_TITLE=CSS Style Class Dialog
TEXT_FONT_TAB_NAME=Text/Font
BOXES_TAB_NAME=Boxes
BACKGROUND_TAB_NAME=Background
Added:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/events/ChangeStyleEvent.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/events/ChangeStyleEvent.java
(rev 0)
+++
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/events/ChangeStyleEvent.java 2008-09-30
19:15:18 UTC (rev 10577)
@@ -0,0 +1,24 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Exadel, Inc. and Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.jst.jsp.outline.cssdialog.events;
+
+import java.util.EventObject;
+
+public class ChangeStyleEvent extends EventObject {
+ /**
+ *
+ */
+ private static final long serialVersionUID = 3260787731782837929L;
+
+ public ChangeStyleEvent(Object source) {
+ super(source);
+ }
+}
Added:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/events/ChangeStyleListener.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/events/ChangeStyleListener.java
(rev 0)
+++
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/events/ChangeStyleListener.java 2008-09-30
19:15:18 UTC (rev 10577)
@@ -0,0 +1,15 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Exadel, Inc. and Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.jst.jsp.outline.cssdialog.events;
+
+public interface ChangeStyleListener {
+ public void styleChanged(ChangeStyleEvent event);
+}
Added:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/events/StyleAttributes.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/events/StyleAttributes.java
(rev 0)
+++
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/events/StyleAttributes.java 2008-09-30
19:15:18 UTC (rev 10577)
@@ -0,0 +1,81 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Exadel, Inc. and Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.jst.jsp.outline.cssdialog.events;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Set;
+import java.util.Map.Entry;
+
+public class StyleAttributes {
+
+ private HashMap<String, String> attributeMap;
+ private ArrayList<ChangeStyleListener> listeners = new
ArrayList<ChangeStyleListener>();
+
+ public StyleAttributes() {
+ this.attributeMap = new HashMap<String, String>();
+ }
+
+ public HashMap<String, String> getAttributeMap() {
+ return attributeMap;
+ }
+
+ public void setAttributeMap(HashMap<String, String> attributeMap) {
+ this.attributeMap = attributeMap;
+ addNewListener();
+ }
+
+ public void addChangeStyleListener(ChangeStyleListener listener) {
+ listeners.add(listener);
+ }
+
+ public ChangeStyleListener[] getChangeStyleListeners() {
+ return listeners.toArray(new ChangeStyleListener[listeners.size()]);
+ }
+
+ public void removeChangeStyleListener(ChangeStyleListener listener) {
+ listeners.remove(listener);
+ }
+
+ private void addNewListener() {
+ ChangeStyleEvent event = new ChangeStyleEvent(this);
+ for (ChangeStyleListener listener : listeners)
+ listener.styleChanged(event);
+ }
+
+ public void addAttribute(String name, String value) {
+ attributeMap.put(name, value);
+ addNewListener();
+ }
+
+ public void removeAttribute(String name) {
+ attributeMap.remove(name);
+ addNewListener();
+ }
+
+ public Set<Entry<String, String>> entrySet() {
+ return attributeMap.entrySet();
+ }
+
+ public String getAttribute(String name) {
+ return attributeMap.get(name);
+ }
+
+ public Set<String> keySet() {
+ return attributeMap.keySet();
+ }
+
+ public void clear() {
+ attributeMap.clear();
+ addNewListener();
+ }
+
+}
Modified:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/events/TabPropertySheetMouseAdapter.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/events/TabPropertySheetMouseAdapter.java 2008-09-30
18:45:39 UTC (rev 10576)
+++
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/events/TabPropertySheetMouseAdapter.java 2008-09-30
19:15:18 UTC (rev 10577)
@@ -40,13 +40,9 @@
import org.eclipse.swt.widgets.Text;
import org.eclipse.swt.widgets.Tree;
import org.eclipse.swt.widgets.TreeItem;
-import org.eclipse.ui.IEditorInput;
-import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.IFileEditorInput;
import org.eclipse.ui.model.WorkbenchContentProvider;
import org.eclipse.ui.model.WorkbenchLabelProvider;
import org.jboss.tools.jst.jsp.JspEditorPlugin;
-import org.jboss.tools.jst.jsp.outline.cssdialog.CSSDialog;
import org.jboss.tools.jst.jsp.outline.cssdialog.FontFamilyDialog;
import org.jboss.tools.jst.jsp.outline.cssdialog.ImageSelectionDialog;
import org.jboss.tools.jst.jsp.outline.cssdialog.common.CSSConstants;
@@ -81,18 +77,18 @@
private static int GRID_MARGIN_WIDTH = 0;
private static int GRID_HORIZONTAL_SPASING = 0;
- private CSSDialog cssDialog;
+ //Dzmitry Sakovich
+ //private CSSDialog cssDialog;
private TabPropertySheetControl tabPropertySheetControl;
public TabPropertySheetMouseAdapter(Tree tree,
HashMap<String, ArrayList<String>> elementsMap,
HashMap<String, ArrayList<String>> comboMap,
- TabPropertySheetControl tabPropertySheetControl,
- CSSDialog dialog) {
+ TabPropertySheetControl tabPropertySheetControl) {
this.tabPropertySheetControl = tabPropertySheetControl;
- this.cssDialog = dialog;
+ //this.cssDialog = dialog;
this.tree = tree;
this.comboMap = comboMap;
this.elementsMap = elementsMap;
@@ -183,7 +179,8 @@
item.setText(Constants.SECOND_COLUMN, colorCombo.getText());
panel.dispose();
tabPropertySheetControl.updateData(true);
- cssDialog.setStyleForPreview();
+ //Dzmitry Sakovich
+ //cssDialog.setStyleForPreview();
}
});
@@ -191,7 +188,8 @@
public void modifyText(ModifyEvent event) {
item.setText(Constants.SECOND_COLUMN, colorCombo.getText());
tabPropertySheetControl.updateData(true);
- cssDialog.setStyleForPreview();
+ //TODO Dzmitry Sakovich
+ //cssDialog.setStyleForPreview();
}
});
@@ -235,7 +233,8 @@
item.setText(Constants.SECOND_COLUMN, str);
tabPropertySheetControl.updateData(true);
- cssDialog.setStyleForPreview();
+ //TODO Dzmitry Sakovich
+ //cssDialog.setStyleForPreview();
}
panel.dispose();
}
@@ -261,7 +260,7 @@
btn.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
- IProject project = getCurrentProject();
+ IProject project = Util.getCurrentProject();
ImageSelectionDialog dialog = new ImageSelectionDialog(tree
.getShell(), new WorkbenchLabelProvider(),
@@ -281,7 +280,8 @@
item.setText(Constants.SECOND_COLUMN, value);
panel.dispose();
tabPropertySheetControl.updateData(true);
- cssDialog.setStyleForPreview();
+ //TODO Dzmitry Sakovich
+ //cssDialog.setStyleForPreview();
}
}
});
@@ -320,7 +320,8 @@
item.setText(col, combo.getText());
panel.dispose();
tabPropertySheetControl.updateData(true);
- cssDialog.setStyleForPreview();
+ //TODO Dzmitry Sakovich
+ //cssDialog.setStyleForPreview();
}
});
@@ -328,7 +329,8 @@
public void modifyText(ModifyEvent event) {
item.setText(col, combo.getText());
tabPropertySheetControl.updateData(true);
- cssDialog.setStyleForPreview();
+ //TODO Dzmitry Sakovich
+ //cssDialog.setStyleForPreview();
}
});
} else {
@@ -400,7 +402,8 @@
.getFontFamily());
panel.dispose();
tabPropertySheetControl.updateData(true);
- cssDialog.setStyleForPreview();
+ //TODO Dzmitry Sakovich
+ //cssDialog.setStyleForPreview();
}
}
});
@@ -439,28 +442,9 @@
// into the cell
item.setText(col, text.getText());
tabPropertySheetControl.updateData(true);
- cssDialog.setStyleForPreview();
+ //TODO Dzmitry Sakovich
+ //cssDialog.setStyleForPreview();
}
});
}
-
- /**
- * Method for get current project
- *
- * @return IProject
- */
- public static IProject getCurrentProject() {
- IEditorPart editor = JspEditorPlugin.getDefault().getWorkbench()
- .getActiveWorkbenchWindow().getActivePage().getActiveEditor();
- IEditorInput input = editor.getEditorInput();
- IFile file = null;
- if (input instanceof IFileEditorInput) {
- file = ((IFileEditorInput) input).getFile();
- }
- if (file == null)
- return null;
-
- IProject project = file.getProject();
- return project;
- }
}
\ No newline at end of file
Modified:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/parsers/ParserListener.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/parsers/ParserListener.java 2008-09-30
18:45:39 UTC (rev 10576)
+++
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/parsers/ParserListener.java 2008-09-30
19:15:18 UTC (rev 10577)
@@ -10,7 +10,7 @@
******************************************************************************/
package org.jboss.tools.jst.jsp.outline.cssdialog.parsers;
-import java.util.HashMap;
+import org.jboss.tools.jst.jsp.outline.cssdialog.events.StyleAttributes;
/**
*
@@ -21,17 +21,17 @@
*/
public class ParserListener implements IListener {
- private HashMap<String, String> map;
+ private StyleAttributes attributes;
- public ParserListener(HashMap<String, String> map) {
- this.map = map;
+ public ParserListener(StyleAttributes styleAttributes) {
+ this.attributes = styleAttributes;
}
public void nextElement(String name, String value) {
- map.put(name, value);
+ attributes.addAttribute(name, value);
}
- public HashMap<String, String> getMap() {
- return map;
+ public StyleAttributes getStyleAttributes() {
+ return attributes;
}
}
\ No newline at end of file
Modified:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/tabs/TabBackgroundControl.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/tabs/TabBackgroundControl.java 2008-09-30
18:45:39 UTC (rev 10576)
+++
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/tabs/TabBackgroundControl.java 2008-09-30
19:15:18 UTC (rev 10577)
@@ -15,6 +15,7 @@
import java.util.Map;
import java.util.Set;
import java.util.Map.Entry;
+
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.jface.resource.ImageDescriptor;
@@ -34,19 +35,16 @@
import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Label;
-import org.eclipse.ui.IEditorInput;
-import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.IFileEditorInput;
import org.eclipse.ui.model.WorkbenchContentProvider;
import org.eclipse.ui.model.WorkbenchLabelProvider;
import org.jboss.tools.jst.jsp.JspEditorPlugin;
-import org.jboss.tools.jst.jsp.outline.cssdialog.CSSDialog;
import org.jboss.tools.jst.jsp.outline.cssdialog.ImageSelectionDialog;
import org.jboss.tools.jst.jsp.outline.cssdialog.common.CSSConstants;
import org.jboss.tools.jst.jsp.outline.cssdialog.common.Constants;
import org.jboss.tools.jst.jsp.outline.cssdialog.common.ImageCombo;
import org.jboss.tools.jst.jsp.outline.cssdialog.common.MessageUtil;
import org.jboss.tools.jst.jsp.outline.cssdialog.common.Util;
+import org.jboss.tools.jst.jsp.outline.cssdialog.events.StyleAttributes;
import org.jboss.tools.jst.jsp.outline.cssdialog.parsers.ColorParser;
@@ -63,18 +61,20 @@
private Combo backgroundImageCombo;
private Combo backgroundRepeatCombo;
- private HashMap<String, String> attributesMap;
+ private StyleAttributes styleAttributes;
private static final int numColumns = 3;
- private CSSDialog cssDialog;
+ //TODO Dzmitry Sakovich
+ //private CSSDialog cssDialog;
public TabBackgroundControl(final Composite composite,
HashMap<String, ArrayList<String>> comboMap,
- final HashMap<String, String> attributesMap, CSSDialog dialog) {
+ final StyleAttributes styleAttributes) {
super(composite, SWT.NONE);
- this.attributesMap = attributesMap;
- this.cssDialog = dialog;
+ this.styleAttributes = styleAttributes;
+ //TODO Dzmitry Sakovich
+ //this.cssDialog = dialog;
final GridLayout gridLayout = new GridLayout();
gridLayout.numColumns = numColumns;
@@ -102,11 +102,12 @@
String tmp = colorCombo.getText();
if (tmp != null) {
if (tmp.trim().length() > 0)
- attributesMap.put(CSSConstants.BACKGROUND_COLOR, tmp);
+ styleAttributes.addAttribute(CSSConstants.BACKGROUND_COLOR, tmp);
else
- attributesMap.remove(CSSConstants.BACKGROUND_COLOR);
+ styleAttributes.removeAttribute(CSSConstants.BACKGROUND_COLOR);
}
- cssDialog.setStyleForPreview();
+ //TODO Dzmitry Sakovich
+ //cssDialog.setStyleForPreview();
}
});
@@ -157,11 +158,12 @@
String tmp = backgroundImageCombo.getText();
if (tmp != null) {
if (tmp.trim().length() > 0)
- attributesMap.put(CSSConstants.BACKGROUND_IMAGE, tmp);
+ styleAttributes.addAttribute(CSSConstants.BACKGROUND_IMAGE, tmp);
else
- attributesMap.remove(CSSConstants.BACKGROUND_IMAGE);
+ styleAttributes.removeAttribute(CSSConstants.BACKGROUND_IMAGE);
}
- cssDialog.setStyleForPreview();
+ //TODO Dzmitry Sakovich
+ //cssDialog.setStyleForPreview();
}
});
@@ -181,7 +183,7 @@
});
button.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
- IProject project = getCurrentProject();
+ IProject project = Util.getCurrentProject();
ImageSelectionDialog dialog = new ImageSelectionDialog(
getShell(), new WorkbenchLabelProvider(),
new WorkbenchContentProvider());
@@ -216,11 +218,12 @@
String tmp = backgroundRepeatCombo.getText();
if (tmp != null) {
if (tmp.trim().length() > 0)
- attributesMap.put(CSSConstants.BACKGROUND_REPEAT, tmp);
+ styleAttributes.addAttribute(CSSConstants.BACKGROUND_REPEAT, tmp);
else
- attributesMap.remove(CSSConstants.BACKGROUND_REPEAT);
+ styleAttributes.removeAttribute(CSSConstants.BACKGROUND_REPEAT);
}
- cssDialog.setStyleForPreview();
+ //TODO Dzmitry Sakovich
+ //cssDialog.setStyleForPreview();
}
});
@@ -240,22 +243,8 @@
*
* @return IProject
*/
- public static IProject getCurrentProject() {
- IEditorPart editor = JspEditorPlugin.getDefault().getWorkbench()
- .getActiveWorkbenchWindow().getActivePage().getActiveEditor();
- IEditorInput input = editor.getEditorInput();
- IFile file = null;
- if (input instanceof IFileEditorInput) {
- file = ((IFileEditorInput) input).getFile();
- }
- if (file == null)
- return null;
+
- IProject project = file.getProject();
- return project;
-
- }
-
/**
* Method for get data in controls (if param equal true ), or set data (if
* param equal false).
@@ -264,15 +253,15 @@
*/
public void updateData(boolean param) {
String tmp;
- if ((tmp = attributesMap.get(CSSConstants.BACKGROUND_COLOR)) != null)
+ if ((tmp = styleAttributes.getAttribute(CSSConstants.BACKGROUND_COLOR)) != null)
colorCombo.setText(tmp);
else
colorCombo.setText(Constants.EMPTY_STRING);
- if ((tmp = attributesMap.get(CSSConstants.BACKGROUND_IMAGE)) != null)
+ if ((tmp = styleAttributes.getAttribute(CSSConstants.BACKGROUND_IMAGE)) != null)
backgroundImageCombo.setText(tmp);
else
backgroundImageCombo.setText(Constants.EMPTY_STRING);
- if ((tmp = attributesMap.get(CSSConstants.BACKGROUND_REPEAT)) != null)
+ if ((tmp = styleAttributes.getAttribute(CSSConstants.BACKGROUND_REPEAT)) != null)
backgroundRepeatCombo.setText(tmp);
else
backgroundRepeatCombo.setText(Constants.EMPTY_STRING);
Modified:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/tabs/TabBoxesControl.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/tabs/TabBoxesControl.java 2008-09-30
18:45:39 UTC (rev 10576)
+++
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/tabs/TabBoxesControl.java 2008-09-30
19:15:18 UTC (rev 10577)
@@ -15,6 +15,7 @@
import java.util.Map;
import java.util.Set;
import java.util.Map.Entry;
+
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.resource.JFaceResources;
import org.eclipse.swt.SWT;
@@ -35,15 +36,14 @@
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Text;
import org.jboss.tools.jst.jsp.JspEditorPlugin;
-import org.jboss.tools.jst.jsp.outline.cssdialog.CSSDialog;
import org.jboss.tools.jst.jsp.outline.cssdialog.common.CSSConstants;
import org.jboss.tools.jst.jsp.outline.cssdialog.common.Constants;
import org.jboss.tools.jst.jsp.outline.cssdialog.common.ImageCombo;
import org.jboss.tools.jst.jsp.outline.cssdialog.common.MessageUtil;
import org.jboss.tools.jst.jsp.outline.cssdialog.common.Util;
+import org.jboss.tools.jst.jsp.outline.cssdialog.events.StyleAttributes;
import org.jboss.tools.jst.jsp.outline.cssdialog.parsers.ColorParser;
-
/**
* Class for creating control in Box tab
*
@@ -68,11 +68,12 @@
private Text paddingText;
private ArrayList<String> list;
- private HashMap<String, String> attributesMap;
+ private StyleAttributes styleAttributes;
private static final int numColumns = 3;
- private CSSDialog cssDialog;
+ // TODO Dzmitry Sakovich
+ // private CSSDialog cssDialog;
/**
* Constructor for creating controls
@@ -81,11 +82,13 @@
*/
public TabBoxesControl(final Composite composite,
final HashMap<String, ArrayList<String>> comboMap,
- final HashMap<String, String> attributesMap, CSSDialog dialog) {
+ final StyleAttributes styleAttributes) {
super(composite, SWT.NONE);
- this.attributesMap = attributesMap;
- this.cssDialog = dialog;
+ this.styleAttributes = styleAttributes;
+ // TODO Dzmitry Sakovich
+ // this.cssDialog = dialog;
+
final GridLayout gridLayout = new GridLayout();
gridLayout.numColumns = numColumns;
setLayout(gridLayout);
@@ -113,15 +116,18 @@
if (tmp.trim().length() > 0) {
String extWidth = extWidthCombo.getText().trim();
if (extWidth != null)
- attributesMap.put(CSSConstants.WIDTH, tmp
- + extWidth);
+ styleAttributes.addAttribute(CSSConstants.WIDTH,
+ tmp + extWidth);
else
- attributesMap.put(CSSConstants.WIDTH, tmp);
+ styleAttributes.addAttribute(CSSConstants.WIDTH,
+ tmp);
} else
- attributesMap.remove(CSSConstants.WIDTH);
+ styleAttributes.removeAttribute(CSSConstants.WIDTH);
} else
- attributesMap.remove(CSSConstants.WIDTH);
- cssDialog.setStyleForPreview();
+ styleAttributes.removeAttribute(CSSConstants.WIDTH);
+
+ // TODO Dzmitry Sakovich
+ // cssDialog.setStyleForPreview();
}
});
@@ -141,8 +147,10 @@
String tmp = extWidthCombo.getText();
if (tmp != null) {
- attributesMap.put(CSSConstants.WIDTH, width + tmp);
- cssDialog.setStyleForPreview();
+ styleAttributes.addAttribute(CSSConstants.WIDTH, width
+ + tmp);
+ // TODO Dzmitry Sakovich
+ // cssDialog.setStyleForPreview();
}
}
});
@@ -168,15 +176,17 @@
if (tmp.trim().length() > 0) {
String extHeight = extHeightCombo.getText().trim();
if (extHeight != null)
- attributesMap.put(CSSConstants.HEIGHT, tmp
- + extHeight);
+ styleAttributes.addAttribute(CSSConstants.HEIGHT,
+ tmp + extHeight);
else
- attributesMap.put(CSSConstants.HEIGHT, tmp);
+ styleAttributes.addAttribute(CSSConstants.HEIGHT,
+ tmp);
} else
- attributesMap.remove(CSSConstants.HEIGHT);
+ styleAttributes.removeAttribute(CSSConstants.HEIGHT);
} else
- attributesMap.remove(CSSConstants.HEIGHT);
- cssDialog.setStyleForPreview();
+ styleAttributes.removeAttribute(CSSConstants.HEIGHT);
+ // TODO Dzmitry Sakovich
+ // cssDialog.setStyleForPreview();
}
});
@@ -196,8 +206,10 @@
String tmp = extHeightCombo.getText();
if (tmp != null) {
- attributesMap.put(CSSConstants.HEIGHT, height + tmp);
- cssDialog.setStyleForPreview();
+ styleAttributes.addAttribute(CSSConstants.HEIGHT, height
+ + tmp);
+ // TODO Dzmitry Sakovich
+ // cssDialog.setStyleForPreview();
}
}
});
@@ -228,12 +240,15 @@
String tmp = borderStyleCombo.getText().trim();
if (tmp != null)
if (!tmp.equals(Constants.EMPTY_STRING)) {
- attributesMap.put(CSSConstants.BORDER_STYLE, tmp);
- cssDialog.setStyleForPreview();
+ styleAttributes.addAttribute(CSSConstants.BORDER_STYLE,
+ tmp);
+ // TODO Dzmitry Sakovich
+ // cssDialog.setStyleForPreview();
return;
}
- attributesMap.remove(CSSConstants.BORDER_STYLE);
- cssDialog.setStyleForPreview();
+ styleAttributes.removeAttribute(CSSConstants.BORDER_STYLE);
+ // TODO Dzmitry Sakovich
+ // cssDialog.setStyleForPreview();
}
});
@@ -262,12 +277,16 @@
String tmp = borderColorCombo.getText().trim();
if (tmp != null)
if (!tmp.equals(Constants.EMPTY_STRING)) {
- attributesMap.put(CSSConstants.BORDER_COLOR, tmp);
- cssDialog.setStyleForPreview();
+ styleAttributes.addAttribute(CSSConstants.BORDER_COLOR,
+ tmp);
+
+ // TODO Dzmitry Sakovich
+ // cssDialog.setStyleForPreview();
return;
}
- attributesMap.remove(CSSConstants.BORDER_COLOR);
- cssDialog.setStyleForPreview();
+ styleAttributes.removeAttribute(CSSConstants.BORDER_COLOR);
+ // TODO Dzmitry Sakovich
+ // cssDialog.setStyleForPreview();
}
});
@@ -329,9 +348,10 @@
if (currentText.equals(str)) {
extBorderWidthCombo.select(0);
extBorderWidthCombo.setEnabled(false);
- attributesMap.put(CSSConstants.BORDER_WIDTH,
+ styleAttributes.addAttribute(CSSConstants.BORDER_WIDTH,
currentText);
- cssDialog.setStyleForPreview();
+ // TODO Dzmitry Sakovich
+ // cssDialog.setStyleForPreview();
return;
}
}
@@ -344,15 +364,20 @@
String extBorderWidth = extBorderWidthCombo.getText()
.trim();
if (extBorderWidth != null)
- attributesMap.put(CSSConstants.BORDER_WIDTH, tmp
- + extBorderWidth);
+ styleAttributes.addAttribute(
+ CSSConstants.BORDER_WIDTH, tmp
+ + extBorderWidth);
else
- attributesMap.put(CSSConstants.BORDER_WIDTH, tmp);
+ styleAttributes.addAttribute(
+ CSSConstants.BORDER_WIDTH, tmp);
} else
- attributesMap.remove(CSSConstants.BORDER_WIDTH);
+ styleAttributes
+ .removeAttribute(CSSConstants.BORDER_WIDTH);
} else
- attributesMap.remove(CSSConstants.BORDER_WIDTH);
- cssDialog.setStyleForPreview();
+ styleAttributes.removeAttribute(CSSConstants.BORDER_WIDTH);
+
+ // TODO Dzmitry Sakovich
+ // cssDialog.setStyleForPreview();
}
});
@@ -377,9 +402,10 @@
String tmp = extBorderWidthCombo.getText();
if (tmp != null) {
- attributesMap.put(CSSConstants.BORDER_WIDTH, borderWidth
- + tmp);
- cssDialog.setStyleForPreview();
+ styleAttributes.addAttribute(CSSConstants.BORDER_WIDTH,
+ borderWidth + tmp);
+ // TODO Dzmitry Sakovich
+ // cssDialog.setStyleForPreview();
}
}
});
@@ -430,15 +456,17 @@
if (tmp.trim().length() > 0) {
String extMargin = extMarginCombo.getText().trim();
if (extMargin != null)
- attributesMap.put(CSSConstants.MARGIN, tmp
- + extMargin);
+ styleAttributes.addAttribute(CSSConstants.MARGIN,
+ tmp + extMargin);
else
- attributesMap.put(CSSConstants.MARGIN, tmp);
+ styleAttributes.addAttribute(CSSConstants.MARGIN,
+ tmp);
} else
- attributesMap.remove(CSSConstants.MARGIN);
+ styleAttributes.removeAttribute(CSSConstants.MARGIN);
} else
- attributesMap.remove(CSSConstants.MARGIN);
- cssDialog.setStyleForPreview();
+ styleAttributes.removeAttribute(CSSConstants.MARGIN);
+ // TODO Dzmitry Sakovich
+ // cssDialog.setStyleForPreview();
}
});
@@ -458,8 +486,10 @@
String tmp = extMarginCombo.getText();
if (tmp != null) {
- attributesMap.put(CSSConstants.MARGIN, margin + tmp);
- cssDialog.setStyleForPreview();
+ styleAttributes.addAttribute(CSSConstants.MARGIN, margin
+ + tmp);
+ // TODO Dzmitry Sakovich
+ // cssDialog.setStyleForPreview();
}
}
});
@@ -486,15 +516,17 @@
if (tmp.trim().length() > 0) {
String extPadding = extPaddingCombo.getText().trim();
if (extPadding != null)
- attributesMap.put(CSSConstants.PADDING, tmp
- + extPadding);
+ styleAttributes.addAttribute(CSSConstants.PADDING,
+ tmp + extPadding);
else
- attributesMap.put(CSSConstants.PADDING, tmp);
+ styleAttributes.addAttribute(CSSConstants.PADDING,
+ tmp);
} else
- attributesMap.remove(CSSConstants.PADDING);
+ styleAttributes.removeAttribute(CSSConstants.PADDING);
} else
- attributesMap.remove(CSSConstants.PADDING);
- cssDialog.setStyleForPreview();
+ styleAttributes.removeAttribute(CSSConstants.PADDING);
+ // TODO Dzmitry Sakovich
+ // cssDialog.setStyleForPreview();
}
});
@@ -514,8 +546,10 @@
String tmp = extPaddingCombo.getText();
if (tmp != null) {
- attributesMap.put(CSSConstants.PADDING, padding + tmp);
- cssDialog.setStyleForPreview();
+ styleAttributes.addAttribute(CSSConstants.PADDING, padding
+ + tmp);
+ // TODO Dzmitry Sakovich
+ // cssDialog.setStyleForPreview();
}
}
});
@@ -535,7 +569,7 @@
*/
public void updateData(boolean param) {
String tmp;
- if ((tmp = attributesMap.get(CSSConstants.WIDTH)) != null) {
+ if ((tmp = styleAttributes.getAttribute(CSSConstants.WIDTH)) != null) {
String[] str = Util.convertExtString(tmp);
widthText.setText(str[0]);
if (extWidthCombo.indexOf(str[1]) != -1) {
@@ -547,7 +581,7 @@
widthText.setText(Constants.EMPTY_STRING);
extWidthCombo.select(0);
}
- if ((tmp = attributesMap.get(CSSConstants.HEIGHT)) != null) {
+ if ((tmp = styleAttributes.getAttribute(CSSConstants.HEIGHT)) != null) {
String[] str = Util.convertExtString(tmp);
heightText.setText(str[0]);
if (extHeightCombo.indexOf(str[1]) != -1) {
@@ -559,15 +593,15 @@
heightText.setText(Constants.EMPTY_STRING);
extHeightCombo.select(0);
}
- if ((tmp = attributesMap.get(CSSConstants.BORDER_STYLE)) != null)
+ if ((tmp = styleAttributes.getAttribute(CSSConstants.BORDER_STYLE)) != null)
borderStyleCombo.setText(tmp);
else
borderStyleCombo.setText(Constants.EMPTY_STRING);
- if ((tmp = attributesMap.get(CSSConstants.BORDER_COLOR)) != null)
+ if ((tmp = styleAttributes.getAttribute(CSSConstants.BORDER_COLOR)) != null)
borderColorCombo.setText(tmp);
else
borderColorCombo.setText(Constants.EMPTY_STRING);
- if ((tmp = attributesMap.get(CSSConstants.BORDER_WIDTH)) != null) {
+ if ((tmp = styleAttributes.getAttribute(CSSConstants.BORDER_WIDTH)) != null) {
String[] str = Util.convertExtString(tmp);
borderWidthCombo.setText(str[0]);
if (extBorderWidthCombo.indexOf(str[1]) != -1) {
@@ -579,7 +613,7 @@
borderWidthCombo.setText(Constants.EMPTY_STRING);
extBorderWidthCombo.select(0);
}
- if ((tmp = attributesMap.get(CSSConstants.MARGIN)) != null) {
+ if ((tmp = styleAttributes.getAttribute(CSSConstants.MARGIN)) != null) {
String[] str = Util.convertExtString(tmp);
marginText.setText(str[0]);
if (extMarginCombo.indexOf(str[1]) != -1) {
@@ -591,7 +625,7 @@
marginText.setText(Constants.EMPTY_STRING);
extMarginCombo.select(0);
}
- if ((tmp = attributesMap.get(CSSConstants.PADDING)) != null) {
+ if ((tmp = styleAttributes.getAttribute(CSSConstants.PADDING)) != null) {
String[] str = Util.convertExtString(tmp);
paddingText.setText(str[0]);
if (extPaddingCombo.indexOf(str[1]) != -1) {
Modified:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/tabs/TabPropertySheetControl.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/tabs/TabPropertySheetControl.java 2008-09-30
18:45:39 UTC (rev 10576)
+++
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/tabs/TabPropertySheetControl.java 2008-09-30
19:15:18 UTC (rev 10577)
@@ -22,8 +22,8 @@
import org.eclipse.swt.widgets.Tree;
import org.eclipse.swt.widgets.TreeColumn;
import org.eclipse.swt.widgets.TreeItem;
-import org.jboss.tools.jst.jsp.outline.cssdialog.CSSDialog;
import org.jboss.tools.jst.jsp.outline.cssdialog.common.Constants;
+import org.jboss.tools.jst.jsp.outline.cssdialog.events.StyleAttributes;
import org.jboss.tools.jst.jsp.outline.cssdialog.events.TabPropertySheetMouseAdapter;
/**
@@ -39,8 +39,8 @@
private Tree tree;
- private HashMap<String, String> attributesMap;
-
+ private StyleAttributes styleAttributes;
+
/**
* Constructor for creating controls
*
@@ -50,11 +50,10 @@
public TabPropertySheetControl(TabFolder tabFolder,
HashMap<String, ArrayList<String>> elementMap,
HashMap<String, ArrayList<String>> comboMap,
- HashMap<String, String> attributesMap,
- CSSDialog dialog) {
+ StyleAttributes styleAttributes) {
super(tabFolder, SWT.NONE);
- this.attributesMap = attributesMap;
+ this.styleAttributes = styleAttributes;
setLayout(new FillLayout());
@@ -87,7 +86,7 @@
updateData(false);
tree.addMouseListener(new TabPropertySheetMouseAdapter(tree,
- elementMap, comboMap, this, dialog));
+ elementMap, comboMap, this));
for (int i = 0; i < tree.getColumnCount(); i++)
tree.getColumn(i).pack();
@@ -106,15 +105,15 @@
for (int j = 0; j < tree.getItem(i).getItemCount(); j++) {
if (tree.getItem(i).getItem(j).getText(
Constants.SECOND_COLUMN) == null) {
- attributesMap.remove(tree.getItem(i).getItem(j)
+ styleAttributes.removeAttribute(tree.getItem(i).getItem(j)
.getText(Constants.FIRST_COLUMN));
} else if (tree.getItem(i).getItem(j).getText(
Constants.SECOND_COLUMN).trim().equals(
Constants.EMPTY_STRING)) {
- attributesMap.remove(tree.getItem(i).getItem(j)
+ styleAttributes.removeAttribute(tree.getItem(i).getItem(j)
.getText(Constants.FIRST_COLUMN));
} else {
- attributesMap.put(tree.getItem(i).getItem(j).getText(
+ styleAttributes.addAttribute(tree.getItem(i).getItem(j).getText(
Constants.FIRST_COLUMN), tree.getItem(i)
.getItem(j).getText(Constants.SECOND_COLUMN));
}
@@ -127,7 +126,7 @@
tree.getItem(i).getItem(j).setText(Constants.SECOND_COLUMN,
Constants.EMPTY_STRING);
- Set<String> set = attributesMap.keySet();
+ Set<String> set = styleAttributes.keySet();
for (String str : set) {
for (int i = 0; i < tree.getItemCount(); i++)
@@ -136,7 +135,7 @@
Constants.FIRST_COLUMN).equals(str))
tree.getItem(i).getItem(j).setText(
Constants.SECOND_COLUMN,
- attributesMap.get(str));
+ styleAttributes.getAttribute(str));
}
setExpanded();
}
@@ -153,7 +152,7 @@
for (int i = 0; i < tree.getItemCount(); i++)
tree.getItem(i).setExpanded(false);
- Set<String> set = attributesMap.keySet();
+ Set<String> set = styleAttributes.keySet();
for (String attr : set)
if ((item = find(attr)) != null) {
Modified:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/tabs/TabQuickEditControl.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/tabs/TabQuickEditControl.java 2008-09-30
18:45:39 UTC (rev 10576)
+++
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/tabs/TabQuickEditControl.java 2008-09-30
19:15:18 UTC (rev 10577)
@@ -14,6 +14,7 @@
import java.util.Collections;
import java.util.HashMap;
import java.util.StringTokenizer;
+
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.jface.resource.ImageDescriptor;
@@ -33,15 +34,12 @@
import org.eclipse.swt.widgets.ColorDialog;
import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Text;
-import org.eclipse.ui.IEditorInput;
-import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.IFileEditorInput;
import org.eclipse.ui.model.WorkbenchContentProvider;
import org.eclipse.ui.model.WorkbenchLabelProvider;
import org.jboss.tools.jst.jsp.JspEditorPlugin;
-import org.jboss.tools.jst.jsp.outline.cssdialog.CSSDialog;
import org.jboss.tools.jst.jsp.outline.cssdialog.FontFamilyDialog;
import org.jboss.tools.jst.jsp.outline.cssdialog.ImageSelectionDialog;
import org.jboss.tools.jst.jsp.outline.cssdialog.common.CSSConstants;
@@ -49,6 +47,7 @@
import org.jboss.tools.jst.jsp.outline.cssdialog.common.ImageCombo;
import org.jboss.tools.jst.jsp.outline.cssdialog.common.MessageUtil;
import org.jboss.tools.jst.jsp.outline.cssdialog.common.Util;
+import org.jboss.tools.jst.jsp.outline.cssdialog.events.StyleAttributes;
import org.jboss.tools.jst.jsp.outline.cssdialog.parsers.ColorParser;
@@ -77,10 +76,11 @@
private Label label = null;
private HashMap<String, ArrayList<String>> comboMap;
- private HashMap<String, String> attributesMap;
+ private StyleAttributes styleAttributes;
+
+ //TODO Dzmitry Sakovich
+ //private CSSDialog dialog;
- private CSSDialog dialog;
-
/**
* Constructor for creating controls
*
@@ -89,11 +89,12 @@
*/
public TabQuickEditControl(Composite sc,
HashMap<String, ArrayList<String>> comboMap,
- HashMap<String, String> attributesMap, CSSDialog dialog) {
+ StyleAttributes styleAttributes) {
super(sc, SWT.NONE);
- this.dialog = dialog;
- this.attributesMap = attributesMap;
+ //TODO Dzmitry Sakovich
+ //this.dialog = dialog;
+ this.styleAttributes = styleAttributes;
this.comboMap = comboMap;
GridLayout gridLayout = new GridLayout();
gridLayout.numColumns = GRID_NUM_COLUMNS;
@@ -101,7 +102,7 @@
ArrayList<String> listKeys = new ArrayList<String>();
- for (String key : attributesMap.keySet())
+ for (String key : styleAttributes.keySet())
listKeys.add(key);
Collections.sort(listKeys);
@@ -113,12 +114,45 @@
label.setLayoutData(new GridData(GridData.END, GridData.CENTER,
false, false));
if (Util.searchInCombo(key, comboMap.keySet()))
- createCombo(this, key, attributesMap.get(key));
+ createCombo(this, key, styleAttributes.getAttribute(key));
else
- createText(this, key, attributesMap.get(key));
+ createText(this, key, styleAttributes.getAttribute(key));
}
}
+
+ public void updateData() {
+
+ Control[] controls = this.getChildren();
+ if (controls!= null) {
+ for (int i=0; i<controls.length; i++) {
+ if (!controls[i].isDisposed()) {
+ controls[i].dispose();
+ }
+ }
+ }
+
+
+ ArrayList<String> listKeys = new ArrayList<String>();
+ for (String key : styleAttributes.keySet())
+ listKeys.add(key);
+
+ Collections.sort(listKeys);
+
+ for (String key : listKeys) {
+
+ label = new Label(this, SWT.LEFT);
+ label.setText(format(key));
+ label.setLayoutData(new GridData(GridData.END, GridData.CENTER,
+ false, false));
+ if (Util.searchInCombo(key, comboMap.keySet()))
+ createCombo(this, key, styleAttributes.getAttribute(key));
+ else
+ createText(this, key, styleAttributes.getAttribute(key));
+ }
+ this.layout();
+ }
+
/**
* Method for creating combo controls
*
@@ -192,11 +226,11 @@
if (!colorCombo.getText().trim().equals(
Constants.EMPTY_STRING))
- attributesMap.put(key, colorCombo.getText().trim());
+ styleAttributes.addAttribute(key, colorCombo.getText().trim());
else
- attributesMap.remove(key);
-
- dialog.setStyleForPreview();
+ styleAttributes.removeAttribute(key);
+ //TODO Dzmitry Sakovich
+ //dialog.setStyleForPreview();
}
});
@@ -238,7 +272,7 @@
btn.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
- IProject project = getCurrentProject();
+ IProject project = Util.getCurrentProject();
ImageSelectionDialog dialog = new ImageSelectionDialog(
composite.getShell(), new WorkbenchLabelProvider(),
new WorkbenchContentProvider());
@@ -266,11 +300,12 @@
public void modifyText(ModifyEvent event) {
if (!combo.getText().trim().equals(Constants.EMPTY_STRING))
- attributesMap.put(key, combo.getText().trim());
+ styleAttributes.addAttribute(key, combo.getText().trim());
else
- attributesMap.remove(key);
+ styleAttributes.removeAttribute(key);
- dialog.setStyleForPreview();
+ //TODO Dzmitry Sakovich
+ //dialog.setStyleForPreview();
}
});
@@ -310,8 +345,9 @@
String tmpExt = extCombo.getText();
if (tmpExt != null) {
- attributesMap.put(key, tmpCombo + tmpExt);
- dialog.setStyleForPreview();
+ styleAttributes.addAttribute(key, tmpCombo + tmpExt);
+ //TODO Dzmitry Sakovich
+ //dialog.setStyleForPreview();
}
}
});
@@ -330,8 +366,9 @@
if (currentText.equalsIgnoreCase(items[i])) {
extCombo.select(VALUE_NUMBER);
extCombo.setEnabled(false);
- attributesMap.put(key, currentText);
- dialog.setStyleForPreview();
+ styleAttributes.addAttribute(key, currentText);
+ //TODO Dzmitry Sakovich
+ //dialog.setStyleForPreview();
return;
}
}
@@ -342,15 +379,16 @@
if (!tmp.equals(Constants.EMPTY_STRING)) {
String extTmp = extCombo.getText().trim();
if (extTmp != null)
- attributesMap.put(key, tmp + extTmp);
+ styleAttributes.addAttribute(key, tmp + extTmp);
else
- attributesMap.put(key, tmp);
+ styleAttributes.addAttribute(key, tmp);
} else
- attributesMap.remove(key);
+ styleAttributes.removeAttribute(key);
} else
- attributesMap.remove(key);
- dialog.setStyleForPreview();
+ styleAttributes.removeAttribute(key);
+ //TODO Dzmitry Sakovich
+ //dialog.setStyleForPreview();
}
});
@@ -365,11 +403,12 @@
if (!combo.getText().trim().equals(
Constants.EMPTY_STRING))
- attributesMap.put(key, combo.getText().trim());
+ styleAttributes.addAttribute(key, combo.getText().trim());
else
- attributesMap.remove(key);
+ styleAttributes.removeAttribute(key);
- dialog.setStyleForPreview();
+ //TODO Dzmitry Sakovich
+ //dialog.setStyleForPreview();
}
});
}
@@ -432,11 +471,12 @@
public void modifyText(ModifyEvent event) {
if (!text.getText().trim().equals(Constants.EMPTY_STRING))
- attributesMap.put(key, text.getText().trim());
+ styleAttributes.addAttribute(key, text.getText().trim());
else
- attributesMap.remove(key);
+ styleAttributes.removeAttribute(key);
- dialog.setStyleForPreview();
+ //TODO Dzmitry Sakovich
+ //dialog.setStyleForPreview();
}
});
}
@@ -469,8 +509,9 @@
String tmpExt = extCombo.getText();
if (tmpExt != null) {
- attributesMap.put(key, tmpCombo + tmpExt);
- dialog.setStyleForPreview();
+ styleAttributes.addAttribute(key, tmpCombo + tmpExt);
+ //TODO Dzmitry Sakovich
+ //dialog.setStyleForPreview();
}
}
});
@@ -486,15 +527,16 @@
if (!tmp.equals(Constants.EMPTY_STRING)) {
String extTmp = extCombo.getText().trim();
if (extTmp != null)
- attributesMap.put(key, tmp + extTmp);
+ styleAttributes.addAttribute(key, tmp + extTmp);
else
- attributesMap.put(key, tmp);
+ styleAttributes.addAttribute(key, tmp);
} else
- attributesMap.remove(key);
+ styleAttributes.removeAttribute(key);
} else
- attributesMap.remove(key);
- dialog.setStyleForPreview();
+ styleAttributes.removeAttribute(key);
+ //TODO Dzmitry Sakovich
+ //dialog.setStyleForPreview();
}
});
@@ -510,11 +552,12 @@
if (!text.getText().trim().equals(
Constants.EMPTY_STRING))
- attributesMap.put(key, text.getText().trim());
+ styleAttributes.addAttribute(key, text.getText().trim());
else
- attributesMap.remove(key);
+ styleAttributes.removeAttribute(key);
- dialog.setStyleForPreview();
+ //TODO Dzmitry Sakovich
+ //dialog.setStyleForPreview();
}
});
@@ -528,27 +571,6 @@
}
/**
- * Method for get current project
- *
- * @return IProject
- */
- public static IProject getCurrentProject() {
- IEditorPart editor = JspEditorPlugin.getDefault().getWorkbench()
- .getActiveWorkbenchWindow().getActivePage().getActiveEditor();
- IEditorInput input = editor.getEditorInput();
- IFile file = null;
- if (input instanceof IFileEditorInput) {
- file = ((IFileEditorInput) input).getFile();
- }
- if (file == null)
- return null;
-
- IProject project = file.getProject();
- return project;
-
- }
-
- /**
* Method for format css names (text-decoration : Text Decoration)
*
* @param str
Modified:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/tabs/TabTextControl.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/tabs/TabTextControl.java 2008-09-30
18:45:39 UTC (rev 10576)
+++
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/tabs/TabTextControl.java 2008-09-30
19:15:18 UTC (rev 10577)
@@ -15,6 +15,7 @@
import java.util.Map;
import java.util.Set;
import java.util.Map.Entry;
+
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.window.Window;
import org.eclipse.swt.SWT;
@@ -35,13 +36,13 @@
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Text;
import org.jboss.tools.jst.jsp.JspEditorPlugin;
-import org.jboss.tools.jst.jsp.outline.cssdialog.CSSDialog;
import org.jboss.tools.jst.jsp.outline.cssdialog.FontFamilyDialog;
import org.jboss.tools.jst.jsp.outline.cssdialog.common.CSSConstants;
import org.jboss.tools.jst.jsp.outline.cssdialog.common.Constants;
import org.jboss.tools.jst.jsp.outline.cssdialog.common.ImageCombo;
import org.jboss.tools.jst.jsp.outline.cssdialog.common.MessageUtil;
import org.jboss.tools.jst.jsp.outline.cssdialog.common.Util;
+import org.jboss.tools.jst.jsp.outline.cssdialog.events.StyleAttributes;
import org.jboss.tools.jst.jsp.outline.cssdialog.parsers.ColorParser;
@@ -65,12 +66,15 @@
private ArrayList<String> list;
- private HashMap<String, String> attributesMap;
+
+ private StyleAttributes styleAttributes;
+ //private HashMap<String, String> attributesMap;
private static final int numColumns = 3;
+
+ //TODO Dzmitry Sakovich
+ //private Browser browser = null;
- private CSSDialog cssDialog;
-
/**
* Constructor for creating controls
*
@@ -78,10 +82,11 @@
*/
public TabTextControl(final Composite composite,
final HashMap<String, ArrayList<String>> comboMap,
- final HashMap<String, String> attributesMap, CSSDialog dialog) {
+ final StyleAttributes styleAttributes) {
super(composite, SWT.NONE);
- this.attributesMap = attributesMap;
- this.cssDialog = dialog;
+ this.styleAttributes = styleAttributes;
+ //TODO Dzmitry Sakovich
+ //this.browser = dialog;
final GridLayout gridLayout = new GridLayout();
gridLayout.numColumns = numColumns;
@@ -101,11 +106,12 @@
String tmp = fontFamilyText.getText();
if (tmp != null) {
if (tmp.trim().length() > 0)
- attributesMap.put(CSSConstants.FONT_FAMILY, tmp);
+ styleAttributes.addAttribute(CSSConstants.FONT_FAMILY, tmp);
else
- attributesMap.remove(CSSConstants.FONT_FAMILY);
+ styleAttributes.removeAttribute(CSSConstants.FONT_FAMILY);
}
- cssDialog.setStyleForPreview();
+ //TODO Dzmitry Sakovich
+ //cssDialog.setStyleForPreview();
}
});
@@ -146,11 +152,12 @@
String tmp = colorCombo.getText();
if (tmp != null) {
if (tmp.trim().length() > 0)
- attributesMap.put(CSSConstants.COLOR, tmp);
+ styleAttributes.addAttribute(CSSConstants.COLOR, tmp);
else
- attributesMap.remove(CSSConstants.COLOR);
+ styleAttributes.removeAttribute(CSSConstants.COLOR);
}
- cssDialog.setStyleForPreview();
+ //TODO Dzmitry Sakovich
+ //cssDialog.setStyleForPreview();
}
});
@@ -225,8 +232,9 @@
String tmp = extFontSizeCombo.getText();
if (tmp != null) {
- attributesMap.put(CSSConstants.FONT_SIZE, fontSize + tmp);
- cssDialog.setStyleForPreview();
+ styleAttributes.addAttribute(CSSConstants.FONT_SIZE, fontSize + tmp);
+ //TODO Dzmitry Sakovich
+ //cssDialog.setStyleForPreview();
}
}
});
@@ -247,8 +255,9 @@
if (currentText.equals(str)) {
extFontSizeCombo.select(0);
extFontSizeCombo.setEnabled(false);
- attributesMap.put(CSSConstants.FONT_SIZE, currentText);
- cssDialog.setStyleForPreview();
+ styleAttributes.addAttribute(CSSConstants.FONT_SIZE, currentText);
+ //TODO Dzmitry Sakovich
+ //cssDialog.setStyleForPreview();
return;
}
}
@@ -260,15 +269,16 @@
if (tmp.trim().length() > 0) {
String extFont = extFontSizeCombo.getText().trim();
if (extFont != null)
- attributesMap.put(CSSConstants.FONT_SIZE, tmp
+ styleAttributes.addAttribute(CSSConstants.FONT_SIZE, tmp
+ extFont);
else
- attributesMap.put(CSSConstants.FONT_SIZE, tmp);
+ styleAttributes.addAttribute(CSSConstants.FONT_SIZE, tmp);
} else
- attributesMap.remove(CSSConstants.FONT_SIZE);
+ styleAttributes.removeAttribute(CSSConstants.FONT_SIZE);
} else
- attributesMap.remove(CSSConstants.FONT_SIZE);
- cssDialog.setStyleForPreview();
+ styleAttributes.removeAttribute(CSSConstants.FONT_SIZE);
+ //TODO Dzmitry Sakovich
+ //cssDialog.setStyleForPreview();
}
});
@@ -284,11 +294,12 @@
String tmp = fontStyleCombo.getText();
if (tmp != null) {
if (tmp.trim().length() > 0)
- attributesMap.put(CSSConstants.FONT_STYLE, tmp);
+ styleAttributes.addAttribute(CSSConstants.FONT_STYLE, tmp);
else
- attributesMap.remove(CSSConstants.FONT_STYLE);
+ styleAttributes.removeAttribute(CSSConstants.FONT_STYLE);
}
- cssDialog.setStyleForPreview();
+ //TODO Dzmitry Sakovich
+ //cssDialog.setStyleForPreview();
}
});
@@ -317,11 +328,12 @@
String tmp = fontWeigthCombo.getText();
if (tmp != null) {
if (tmp.trim().length() > 0)
- attributesMap.put(CSSConstants.FONT_WEIGHT, tmp);
+ styleAttributes.addAttribute(CSSConstants.FONT_WEIGHT, tmp);
else
- attributesMap.remove(CSSConstants.FONT_WEIGHT);
+ styleAttributes.removeAttribute(CSSConstants.FONT_WEIGHT);
}
- cssDialog.setStyleForPreview();
+ //TODO Dzmitry Sakovich
+ //cssDialog.setStyleForPreview();
}
});
@@ -350,11 +362,12 @@
String tmp = textDecorationCombo.getText();
if (tmp != null) {
if (tmp.trim().length() > 0)
- attributesMap.put(CSSConstants.TEXT_DECORATION, tmp);
+ styleAttributes.addAttribute(CSSConstants.TEXT_DECORATION, tmp);
else
- attributesMap.remove(CSSConstants.TEXT_DECORATION);
+ styleAttributes.removeAttribute(CSSConstants.TEXT_DECORATION);
}
- cssDialog.setStyleForPreview();
+ //TODO Dzmitry Sakovich
+ //cssDialog.setStyleForPreview();
}
});
@@ -383,11 +396,12 @@
String tmp = textAlignCombo.getText();
if (tmp != null) {
if (tmp.trim().length() > 0)
- attributesMap.put(CSSConstants.TEXT_ALIGN, tmp);
+ styleAttributes.addAttribute(CSSConstants.TEXT_ALIGN, tmp);
else
- attributesMap.remove(CSSConstants.TEXT_ALIGN);
+ styleAttributes.removeAttribute(CSSConstants.TEXT_ALIGN);
}
- cssDialog.setStyleForPreview();
+ //TODO Dzmitry Sakovich
+ //cssDialog.setStyleForPreview();
}
});
@@ -415,15 +429,15 @@
public void updateData(boolean param) {
String tmp;
- if ((tmp = attributesMap.get(CSSConstants.FONT_FAMILY)) != null)
+ if ((tmp = styleAttributes.getAttribute(CSSConstants.FONT_FAMILY)) != null)
fontFamilyText.setText(tmp);
else
fontFamilyText.setText(Constants.EMPTY_STRING);
- if ((tmp = attributesMap.get(CSSConstants.COLOR)) != null)
+ if ((tmp = styleAttributes.getAttribute(CSSConstants.COLOR)) != null)
colorCombo.setText(tmp);
else
colorCombo.setText(Constants.EMPTY_STRING);
- if ((tmp = attributesMap.get(CSSConstants.FONT_SIZE)) != null) {
+ if ((tmp = styleAttributes.getAttribute(CSSConstants.FONT_SIZE)) != null) {
String[] str = Util.convertExtString(tmp);
fontSizeCombo.setText(str[0]);
if (extFontSizeCombo.indexOf(str[1]) != -1) {
@@ -435,19 +449,19 @@
fontSizeCombo.setText(Constants.EMPTY_STRING);
extFontSizeCombo.select(0);
}
- if ((tmp = attributesMap.get(CSSConstants.TEXT_DECORATION)) != null)
+ if ((tmp = styleAttributes.getAttribute(CSSConstants.TEXT_DECORATION)) != null)
textDecorationCombo.setText(tmp);
else
textDecorationCombo.setText(Constants.EMPTY_STRING);
- if ((tmp = attributesMap.get(CSSConstants.FONT_STYLE)) != null)
+ if ((tmp = styleAttributes.getAttribute(CSSConstants.FONT_STYLE)) != null)
fontStyleCombo.setText(tmp);
else
fontStyleCombo.setText(Constants.EMPTY_STRING);
- if ((tmp = attributesMap.get(CSSConstants.FONT_WEIGHT)) != null)
+ if ((tmp = styleAttributes.getAttribute(CSSConstants.FONT_WEIGHT)) != null)
fontWeigthCombo.setText(tmp);
else
fontWeigthCombo.setText(Constants.EMPTY_STRING);
- if ((tmp = attributesMap.get(CSSConstants.TEXT_ALIGN)) != null)
+ if ((tmp = styleAttributes.getAttribute(CSSConstants.TEXT_ALIGN)) != null)
textAlignCombo.setText(tmp);
else
textAlignCombo.setText(Constants.EMPTY_STRING);