Author: izhukov
Date: 2008-12-05 08:42:06 -0500 (Fri, 05 Dec 2008)
New Revision: 12308
Added:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/events/AttributeModifyListener.java
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/tabs/BaseTabControl.java
Modified:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/CSSClassDialog.java
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/events/TabPropertySheetMouseAdapter.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/TabPreviewControl.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:
JBIDE-3340 - css dialog tab control refactoring;
set delay to key press event on classStyle combo component: changes applied with 1 second
delay
Modified:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/CSSClassDialog.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/CSSClassDialog.java 2008-12-05
13:41:34 UTC (rev 12307)
+++
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/CSSClassDialog.java 2008-12-05
13:42:06 UTC (rev 12308)
@@ -20,8 +20,10 @@
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IWorkspaceRoot;
import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jface.dialogs.TitleAreaDialog;
import org.eclipse.jface.fieldassist.ComboContentAdapter;
@@ -54,14 +56,17 @@
import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.MessageBox;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.dialogs.ElementTreeSelectionDialog;
import org.eclipse.ui.fieldassist.ContentAssistCommandAdapter;
import org.eclipse.ui.model.BaseWorkbenchContentProvider;
import org.eclipse.ui.model.WorkbenchLabelProvider;
+import org.eclipse.ui.progress.UIJob;
import org.jboss.tools.common.model.ui.widgets.Split;
import org.jboss.tools.jst.jsp.JspEditorPlugin;
import org.jboss.tools.jst.jsp.messages.JstUIMessages;
@@ -130,8 +135,16 @@
// an array of subscribed message dialog listener
private ArrayList<MessageDialogListener> errorListeners = new
ArrayList<MessageDialogListener>();
+ // parameter indicates if dialog was opened from Wizard
private final boolean callFromWizard;
+ // this job is used to correctly process change style class combo text with delay
+ private UIJob uiJob = null;
+ // the job name
+ private String jobName = "Update CSS Composite"; //$NON-NLS-1$
+ // delay for job in milliseconds
+ private int delay = 1000;
+
/**
* Constructor.
*
@@ -443,12 +456,11 @@
// add key modified listener
classCombo.addKeyListener(new KeyAdapter() {
public void keyReleased(KeyEvent e) {
- if (currentClassStyle != null &&
currentClassStyle.equals(classCombo.getText().trim())) {
+ if ((currentClassStyle != null &&
currentClassStyle.equals(classCombo.getText().trim()))
+ || (currentClassStyle == null &&
classCombo.getText().trim().equals(Constants.EMPTY))) {
return;
}
- cssStyleClassChanged();
- applyButton.setEnabled(true);
- keyInputSelector = true;
+ notifyKeyChanged();
}
});
// this listener is responsible for processing dialog header message events
@@ -469,6 +481,44 @@
}
/**
+ * This method is invoked to correctly process class style combo key event.
+ */
+ private void notifyKeyChanged() {
+ Display display = null;
+ if (PlatformUI.isWorkbenchRunning()) {
+ display = PlatformUI.getWorkbench().getDisplay();
+ }
+ if (display != null && (Thread.currentThread() == display.getThread())) {
+ if (uiJob == null) {
+ uiJob = new UIJob(jobName) {
+ @Override
+ public IStatus runInUIThread(IProgressMonitor monitor) {
+ if (monitor.isCanceled()) {
+ return Status.CANCEL_STATUS;
+ }
+ monitor.beginTask(jobName, IProgressMonitor.UNKNOWN);
+
+ // start operation
+ cssStyleClassChanged();
+ applyButton.setEnabled(true);
+ keyInputSelector = true;
+ // end operation
+
+ monitor.done();
+
+ return Status.OK_STATUS;
+ }
+ };
+ }
+
+ uiJob.setPriority(Job.SHORT);
+ uiJob.schedule(delay);
+
+ return;
+ }
+ }
+
+ /**
* This method is used to create custom button panel.
*
* @param parent Composite component
Added:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/events/AttributeModifyListener.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/events/AttributeModifyListener.java
(rev 0)
+++
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/events/AttributeModifyListener.java 2008-12-05
13:42:06 UTC (rev 12308)
@@ -0,0 +1,197 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2008 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
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.jst.jsp.outline.cssdialog.events;
+
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.widgets.Combo;
+import org.eclipse.swt.widgets.Text;
+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.tabs.BaseTabControl;
+
+/**
+ * Defines an object which listens for ModifyEvent.
+ */
+public class AttributeModifyListener implements ModifyListener {
+
+ public static final int MODIFY_SIMPLE_ATTRIBUTE_FIELD = 0;
+ public static final int MODIFY_SIMPLE_ATTRIBUTE_FIELD_WITH_COMBO_EXTENSION = 1;
+ public static final int MODIFY_COMBO_ATTRIBUTE_FIELD_WITH_COMBO_EXTENSION = 2;
+ public static final int MODIFY_COMBO_EXTENSION_ATTRIBUTE_FIELD = 3;
+
+ private int modifyMode;
+ private BaseTabControl baseTabControl = null;
+ private String attributeName = null;
+
+ private Text dependentTextAttribute = null;
+ private Combo dependentComboAttribute = null;
+
+ /**
+ * Constructor.
+ *
+ * @param baseTabControl BaseTabControl composite object
+ * @param attributeName CSS name of the first parameter
+ * @param modifyMode this parameter indicates the way how modify action should be
process
+ */
+ public AttributeModifyListener(BaseTabControl baseTabControl, String attributeName, int
modifyMode) {
+ this.baseTabControl = baseTabControl;
+ this.attributeName = attributeName;
+ this.modifyMode = modifyMode;
+ }
+
+ /**
+ * Constructor.
+ *
+ * @param baseTabControl BaseTabControl composite object
+ * @param dependentComboAttribute
+ * @param attributeName CSS name of the first parameter
+ * @param modifyMode this parameter indicates the way how modify action should be
process
+ */
+ public AttributeModifyListener(BaseTabControl baseTabControl, Combo
dependentComboAttribute, String attributeName,
+ int modifyMode) {
+ this.baseTabControl = baseTabControl;
+ this.dependentComboAttribute = dependentComboAttribute;
+ this.attributeName = attributeName;
+ this.modifyMode = modifyMode;
+ }
+
+ /**
+ * Constructor.
+ *
+ * @param baseTabControl BaseTabControl composite object
+ * @param dependentTextAttribute
+ * @param attributeName CSS name of the first parameter
+ * @param modifyMode this parameter indicates the way how modify action should be
process
+ */
+ public AttributeModifyListener(BaseTabControl baseTabControl, Text
dependentTextAttribute, String attributeName,
+ int modifyMode) {
+ this.baseTabControl = baseTabControl;
+ this.dependentTextAttribute = dependentTextAttribute;
+ this.attributeName = attributeName;
+ this.modifyMode = modifyMode;
+ }
+
+ /**
+ * Method is used to correctly process modify event occurred on specify CSS attribute
control.
+ *
+ * @param e ModifyEvent event object
+ * @see
org.eclipse.swt.events.ModifyListener#modifyText(org.eclipse.swt.events.ModifyEvent)
+ */
+ public void modifyText(ModifyEvent e) {
+ String attributeValue = null;
+ if (e.getSource() instanceof Text) {
+ attributeValue = ((Text)e.getSource()).getText();
+ } else if (e.getSource() instanceof Combo) {
+ attributeValue = ((Combo)e.getSource()).getText();
+ } else if (e.getSource() instanceof ImageCombo) {
+ attributeValue = ((ImageCombo)e.getSource()).getText();
+ }
+ switch (this.modifyMode) {
+ case MODIFY_SIMPLE_ATTRIBUTE_FIELD:
+ modifySimpleAttribute(attributeValue);
+ break;
+ case MODIFY_SIMPLE_ATTRIBUTE_FIELD_WITH_COMBO_EXTENSION:
+ modifySimpleAttributeWithComboExtension(attributeValue);
+ break;
+ case MODIFY_COMBO_ATTRIBUTE_FIELD_WITH_COMBO_EXTENSION:
+ modifyComboAttributeWithComboExtension(attributeValue, (Combo)e.getSource());
+ break;
+ case MODIFY_COMBO_EXTENSION_ATTRIBUTE_FIELD:
+ if (dependentComboAttribute != null) {
+ attributeValue = dependentComboAttribute.getText();
+ } else if (dependentTextAttribute != null) {
+ attributeValue = dependentTextAttribute.getText();
+ }
+ modifyExtAttribute(attributeValue, (Combo)e.getSource());
+ break;
+ }
+ if (!baseTabControl.isUpdateDataFromStyleAttributes()) {
+ baseTabControl.notifyListeners();
+ }
+ }
+
+ /**
+ * Method is used to correctly process modify event occurred on specify text CSS
attribute control.
+ */
+ protected void modifySimpleAttribute(String attributeValue) {
+ if (attributeValue != null &&
!attributeValue.trim().equals(Constants.EMPTY)) {
+ baseTabControl.getStyleAttributes().addAttribute(attributeName,
adjustAttributeValue(attributeValue.trim()));
+ } else {
+ baseTabControl.getStyleAttributes().removeAttribute(attributeName);
+ }
+ }
+
+ /**
+ * Method is used to correctly process modify event occurred on specify text CSS
attribute control
+ * that have combo extension control.
+ */
+ protected void modifySimpleAttributeWithComboExtension(String attributeValue) {
+ if (attributeValue != null &&
!attributeValue.trim().equals(Constants.EMPTY)) {
+ String extValue = dependentComboAttribute.getText();
+ if (extValue != null) {
+ attributeValue += extValue;
+ }
+ baseTabControl.getStyleAttributes().addAttribute(attributeName, attributeValue);
+ } else {
+ baseTabControl.getStyleAttributes().removeAttribute(attributeName);
+ dependentComboAttribute.select(0);
+ }
+ }
+
+ /**
+ * Method is used to correctly process modify event occurred on specify combo CSS
attribute control
+ * that have combo extension control.
+ */
+ protected void modifyComboAttributeWithComboExtension(String attributeValue, Combo
attribute) {
+ boolean found = false;
+ for (String str : attribute.getItems()) {
+ if (attributeValue.equals(str)) {
+ dependentComboAttribute.select(0);
+ dependentComboAttribute.setEnabled(false);
+ baseTabControl.getStyleAttributes().addAttribute(attributeName,
attributeValue);
+ found = true;
+ break;
+ }
+ }
+ if (!found) {
+ dependentComboAttribute.setEnabled(true);
+ modifySimpleAttributeWithComboExtension(attributeValue);
+ }
+ }
+
+ /**
+ * Method is used to correctly process modify event occurred on specify CSS extension
attribute control.
+ */
+ protected void modifyExtAttribute(String attributeValue, Combo extAttribute) {
+ if (attributeValue != null &&
!attributeValue.trim().equals(Constants.EMPTY)) {
+ String extValue = extAttribute.getText();
+ if (extValue != null) {
+ baseTabControl.getStyleAttributes().addAttribute(attributeName,
attributeValue + extValue);
+ }
+ } else {
+ if (extAttribute.getSelectionIndex() > 0) {
+ extAttribute.select(0);
+ }
+ return;
+ }
+ }
+
+ /**
+ * This is wrapper method that can be override by inherited class.
+ *
+ * @param attribute the attribute that should be wrapped
+ * @return the wrapped value passed by parameter
+ */
+ protected String adjustAttributeValue(String attribute) {
+ return attribute;
+ }
+}
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-12-05
13:41:34 UTC (rev 12307)
+++
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/events/TabPropertySheetMouseAdapter.java 2008-12-05
13:42:06 UTC (rev 12308)
@@ -115,7 +115,6 @@
if
(elementsMap.keySet().contains(item.getText(Constants.FIRST_COLUMN).trim())) {
return;
}
-
if (comboMap.keySet().contains(item.getText(Constants.FIRST_COLUMN).trim()))
{
createCombo(item, Constants.SECOND_COLUMN);
} else {
@@ -168,7 +167,7 @@
item.setText(Constants.SECOND_COLUMN, colorCombo.getText());
panel.dispose();
tabPropertySheetControl.updateData(true);
- if (!tabPropertySheetControl.getUpdateDataFromStyleAttributes())
{
+ if (!tabPropertySheetControl.isUpdateDataFromStyleAttributes())
{
notifyListeners();
}
}
@@ -177,7 +176,7 @@
public void modifyText(ModifyEvent event) {
item.setText(Constants.SECOND_COLUMN, colorCombo.getText());
tabPropertySheetControl.updateData(true);
- if (!tabPropertySheetControl.getUpdateDataFromStyleAttributes())
{
+ if (!tabPropertySheetControl.isUpdateDataFromStyleAttributes())
{
notifyListeners();
}
}
@@ -216,7 +215,7 @@
item.setText(Constants.SECOND_COLUMN, str);
}
tabPropertySheetControl.updateData(true);
- if
(!tabPropertySheetControl.getUpdateDataFromStyleAttributes()) {
+ if
(!tabPropertySheetControl.isUpdateDataFromStyleAttributes()) {
notifyListeners();
}
}
@@ -258,7 +257,7 @@
item.setText(Constants.SECOND_COLUMN, value);
panel.dispose();
tabPropertySheetControl.updateData(true);
- if
(!tabPropertySheetControl.getUpdateDataFromStyleAttributes()) {
+ if
(!tabPropertySheetControl.isUpdateDataFromStyleAttributes()) {
notifyListeners();
}
}
@@ -267,7 +266,6 @@
} else {
combo = new Combo(panel, SWT.NONE);
}
-
// add items
if (!color) {
ArrayList<String> list =
comboMap.get(item.getText(Constants.FIRST_COLUMN).trim());
@@ -295,7 +293,7 @@
item.setText(col, combo.getText());
panel.dispose();
tabPropertySheetControl.updateData(true);
- if (!tabPropertySheetControl.getUpdateDataFromStyleAttributes())
{
+ if (!tabPropertySheetControl.isUpdateDataFromStyleAttributes())
{
notifyListeners();
}
}
@@ -303,7 +301,7 @@
combo.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent event) {
item.setText(col, combo.getText());
- if (!tabPropertySheetControl.getUpdateDataFromStyleAttributes())
{
+ if (!tabPropertySheetControl.isUpdateDataFromStyleAttributes())
{
notifyListeners();
}
}
@@ -315,8 +313,7 @@
}
// Compute the width for the editor
- // Also, compute the column width, so that the dropdown
- // fits
+ // Also, compute the column width, so that the dropdown fits
editor.minimumWidth = panel.computeSize(SWT.DEFAULT, SWT.DEFAULT).x;
editor.minimumHeight = panel.computeSize(SWT.DEFAULT, SWT.DEFAULT).y;
@@ -329,10 +326,8 @@
/**
* Method for create text editor
*
- * @param item
- * Tree item for editing
- * @param column
- * Number of column for editing
+ * @param item Tree item for editing
+ * @param column Number of column for editing
*/
private void createText(final TreeItem item, int column) {
final Composite panel = new Composite(tree, SWT.NONE);
@@ -367,7 +362,7 @@
item.setText(Constants.SECOND_COLUMN,
dialog.getFontFamily());
panel.dispose();
tabPropertySheetControl.updateData(true);
- if
(!tabPropertySheetControl.getUpdateDataFromStyleAttributes()) {
+ if
(!tabPropertySheetControl.isUpdateDataFromStyleAttributes()) {
notifyListeners();
}
}
@@ -382,8 +377,7 @@
text.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false));
// Compute the width for the editor
- // Also, compute the column width, so that the dropdown
- // fits
+ // Also, compute the column width, so that the dropdown fits
editor.minimumWidth = panel.computeSize(SWT.DEFAULT, SWT.DEFAULT).x;
editor.minimumHeight = panel.computeSize(SWT.DEFAULT, SWT.DEFAULT).y;
@@ -392,21 +386,19 @@
// Set the focus on the dropdown and set into the editor
editor.setEditor(panel, item, column);
- // Transfer any text from the cell to the Text control,
- // set the color to match this row, select the text,
+ // Transfer any text from the cell to the Text control, set the color to match
this row, select the text,
// and set focus to the control
text.setText(item.getText(column));
text.setFocus();
- // Add a handler to transfer the text back to the cell
- // any time it's modified
+ // Add a handler to transfer the text back to the cell any time it's
modified
final int col = column;
text.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent event) {
// Set the text of the editor's control back into the cell
item.setText(col, text.getText());
tabPropertySheetControl.updateData(true);
- if (!tabPropertySheetControl.getUpdateDataFromStyleAttributes()) {
+ if (!tabPropertySheetControl.isUpdateDataFromStyleAttributes()) {
notifyListeners();
}
}
Added:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/tabs/BaseTabControl.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/tabs/BaseTabControl.java
(rev 0)
+++
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/tabs/BaseTabControl.java 2008-12-05
13:42:06 UTC (rev 12308)
@@ -0,0 +1,95 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2008 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
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.jst.jsp.outline.cssdialog.tabs;
+
+import java.util.ArrayList;
+
+import org.eclipse.swt.widgets.Composite;
+import org.jboss.tools.jst.jsp.outline.cssdialog.events.ChangeStyleEvent;
+import org.jboss.tools.jst.jsp.outline.cssdialog.events.ManualChangeStyleListener;
+import org.jboss.tools.jst.jsp.outline.cssdialog.events.StyleAttributes;
+
+/**
+ * This is base tab control component that should be re-implemented by successor.
+ *
+ * @author Igor Zhukov
+ */
+public abstract class BaseTabControl extends Composite {
+
+ protected StyleAttributes styleAttributes = null;
+ protected boolean updateDataFromStyleAttributes = false;
+
+ private ArrayList<ManualChangeStyleListener> listeners = new
ArrayList<ManualChangeStyleListener>();
+
+ /**
+ * Constructs a new instance of this class given its parent
+ * and a style value describing its behavior and appearance.
+ *
+ * @param parent a widget which will be the parent of the new instance (cannot be null)
+ * @param style the style of widget to construct
+ */
+ public BaseTabControl(Composite parent, int style) {
+ super(parent, style);
+ }
+
+ /**
+ * Sets updateDataFromStyleAttributes parameter.
+ *
+ * @return the updateDataFromStyleAttributes value
+ */
+ public boolean isUpdateDataFromStyleAttributes() {
+ return updateDataFromStyleAttributes;
+ }
+
+ /**
+ * @return the styleAttributes
+ */
+ public StyleAttributes getStyleAttributes() {
+ return styleAttributes;
+ }
+
+ /**
+ * Add ManualChangeStyleListener object.
+ *
+ * @param listener ManualChangeStyleListener object to be added
+ */
+ public void addManualChangeStyleListener(ManualChangeStyleListener listener) {
+ listeners.add(listener);
+ }
+
+ /**
+ * Gets an array of ChangeStyleListener object.
+ *
+ * @return an array of ChangeStyleListener object
+ */
+ public ManualChangeStyleListener[] getManualChangeStyleListeners() {
+ return listeners.toArray(new ManualChangeStyleListener[listeners.size()]);
+ }
+
+ /**
+ * Remove ManualChangeStyleListener object passed by parameter.
+ *
+ * @param listener ManualChangeStyleListener object to be removed
+ */
+ public void removeManualChangeStyleListener(ManualChangeStyleListener listener) {
+ listeners.remove(listener);
+ }
+
+ /**
+ * Method is used to notify all subscribed listeners about any changes within style
attribute map.
+ */
+ public void notifyListeners() {
+ ChangeStyleEvent event = new ChangeStyleEvent(this);
+ for (ManualChangeStyleListener listener : listeners) {
+ listener.styleChanged(event);
+ }
+ }
+}
\ 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-12-05
13:41:34 UTC (rev 12307)
+++
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/tabs/TabBackgroundControl.java 2008-12-05
13:42:06 UTC (rev 12308)
@@ -22,8 +22,6 @@
import org.eclipse.swt.SWT;
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.graphics.Image;
@@ -44,8 +42,7 @@
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.Util;
-import org.jboss.tools.jst.jsp.outline.cssdialog.events.ChangeStyleEvent;
-import org.jboss.tools.jst.jsp.outline.cssdialog.events.ManualChangeStyleListener;
+import org.jboss.tools.jst.jsp.outline.cssdialog.events.AttributeModifyListener;
import org.jboss.tools.jst.jsp.outline.cssdialog.events.StyleAttributes;
import org.jboss.tools.jst.jsp.outline.cssdialog.parsers.ColorParser;
@@ -53,23 +50,21 @@
/**
* Class for creating control in Background tab
*
- * @author dsakovich(a)exadel.com
+ * @author Igor Zhukov (izhukov(a)exadel.com)
*/
-public class TabBackgroundControl extends Composite {
+public class TabBackgroundControl extends BaseTabControl {
private static final int numColumns = 3;
private ImageCombo colorCombo;
private Combo backgroundImageCombo;
private Combo backgroundRepeatCombo;
- private StyleAttributes styleAttributes;
- private ArrayList<ManualChangeStyleListener> listeners = new
ArrayList<ManualChangeStyleListener>();
- private boolean updateDataFromStyleAttributes = false;
-
/**
* Constructor for creating controls
*
* @param composite Composite element
+ * @param comboMap
+ * @param styleAttributes the StyleAttributes object
*/
public TabBackgroundControl(final Composite composite, HashMap<String,
ArrayList<String>> comboMap,
final StyleAttributes styleAttributes) {
@@ -89,11 +84,8 @@
colorCombo = new ImageCombo(this, SWT.BORDER);
colorCombo.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true,
false));
- colorCombo.addModifyListener(new ModifyListener() {
- public void modifyText(ModifyEvent event) {
- modifyAttribute(colorCombo.getText(), CSSConstants.BACKGROUND_COLOR);
- }
- });
+ colorCombo.addModifyListener(new AttributeModifyListener(this,
CSSConstants.BACKGROUND_COLOR,
+ AttributeModifyListener.MODIFY_SIMPLE_ATTRIBUTE_FIELD));
Set<Entry<String, String>> set =
ColorParser.getInstance().getMap().entrySet();
for (Map.Entry<String, String> me : set) {
RGB rgb = Util.getColor(me.getKey());
@@ -140,18 +132,11 @@
final GridData backgroundImageGridData = new GridData(GridData.FILL,
GridData.CENTER, true, false);
backgroundImageCombo.setLayoutData(backgroundImageGridData);
backgroundImageCombo.add(Constants.NONE);
- backgroundImageCombo.addModifyListener(new ModifyListener() {
- public void modifyText(ModifyEvent event) {
- String tmp = backgroundImageCombo.getText();
- if (tmp != null && !tmp.trim().equals(Constants.EMPTY)) {
- tmp = adjustBackgroundURL(tmp);
- styleAttributes.addAttribute(CSSConstants.BACKGROUND_IMAGE, tmp.trim());
- } else {
- styleAttributes.removeAttribute(CSSConstants.BACKGROUND_IMAGE);
- }
- if (!updateDataFromStyleAttributes) {
- notifyListeners();
- }
+ backgroundImageCombo.addModifyListener(new AttributeModifyListener(this,
CSSConstants.BACKGROUND_IMAGE,
+ AttributeModifyListener.MODIFY_SIMPLE_ATTRIBUTE_FIELD) {
+ @Override
+ protected String adjustAttributeValue(String attribute) {
+ return adjustBackgroundURL(attribute);
}
});
@@ -200,11 +185,8 @@
gridData.horizontalSpan = 2;
backgroundRepeatCombo = new Combo(this, SWT.BORDER);
backgroundRepeatCombo.setLayoutData(gridData);
- backgroundRepeatCombo.addModifyListener(new ModifyListener() {
- public void modifyText(ModifyEvent event) {
- modifyAttribute(backgroundRepeatCombo.getText(),
CSSConstants.BACKGROUND_REPEAT);
- }
- });
+ backgroundRepeatCombo.addModifyListener(new AttributeModifyListener(this,
CSSConstants.BACKGROUND_REPEAT,
+ AttributeModifyListener.MODIFY_SIMPLE_ATTRIBUTE_FIELD));
ArrayList<String> list = comboMap.get(CSSConstants.BACKGROUND_REPEAT);
for (String str : list) {
backgroundRepeatCombo.add(str);
@@ -237,67 +219,14 @@
updateDataFromStyleAttributes = false;
}
- /**
- * Method is used to correctly process modify event occurred on specify CSS attribute
control.
- *
- * @param attributeValue changed value of control were action takes place
- * @param attributeName CSS name of the first parameter
- */
- private void modifyAttribute(String attributeValue, String attributeName) {
- if (attributeValue != null &&
!attributeValue.trim().equals(Constants.EMPTY)) {
- styleAttributes.addAttribute(attributeName, attributeValue.trim());
- } else {
- styleAttributes.removeAttribute(attributeName);
- }
- if (!updateDataFromStyleAttributes) {
- notifyListeners();
- }
- }
-
// Fix for JBIDE-3084
// in css background image should always be wrapped into url(*);
private static String adjustBackgroundURL(String backgroundURL) {
- if ((backgroundURL != null) &&
(backgroundURL.matches("(url)\\(.*\\)") == false)) { //$NON-NLS-1$
+ if ((backgroundURL != null &&
!backgroundURL.trim().equals(Constants.EMPTY))
+ && (backgroundURL.matches("(url)\\(.*\\)") == false)) {
//$NON-NLS-1$
return "url(" + backgroundURL + ")";
//$NON-NLS-1$//$NON-NLS-2$
}
return backgroundURL;
}
-
- /**
- * Add ManualChangeStyleListener object.
- *
- * @param listener ManualChangeStyleListener object to be added
- */
- public void addManualChangeStyleListener(ManualChangeStyleListener listener) {
- listeners.add(listener);
- }
-
- /**
- * Gets an array of ChangeStyleListener object.
- *
- * @return an array of ChangeStyleListener object
- */
- public ManualChangeStyleListener[] getManualChangeStyleListeners() {
- return listeners.toArray(new ManualChangeStyleListener[listeners.size()]);
- }
-
- /**
- * Remove ManualChangeStyleListener object passed by parameter.
- *
- * @param listener ManualChangeStyleListener object to be removed
- */
- public void removeManualChangeStyleListener(ManualChangeStyleListener listener) {
- listeners.remove(listener);
- }
-
- /**
- * Method is used to notify all subscribed listeners about any changes within style
attribute map.
- */
- private void notifyListeners() {
- ChangeStyleEvent event = new ChangeStyleEvent(this);
- for (ManualChangeStyleListener listener : listeners) {
- listener.styleChanged(event);
- }
- }
}
\ No newline at end of file
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-12-05
13:41:34 UTC (rev 12307)
+++
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/tabs/TabBoxesControl.java 2008-12-05
13:42:06 UTC (rev 12308)
@@ -21,8 +21,6 @@
import org.eclipse.swt.SWT;
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.graphics.Image;
@@ -41,18 +39,16 @@
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.Util;
-import org.jboss.tools.jst.jsp.outline.cssdialog.events.ChangeStyleEvent;
-import org.jboss.tools.jst.jsp.outline.cssdialog.events.ManualChangeStyleListener;
+import org.jboss.tools.jst.jsp.outline.cssdialog.events.AttributeModifyListener;
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
+ * Class for creating control in Boxes tab
*
- * @author dsakovich(a)exadel.com
+ * @author Igor Zhukov (izhukov(a)exadel.com)
*/
-public class TabBoxesControl extends Composite {
+public class TabBoxesControl extends BaseTabControl {
private static final int numColumns = 3;
private Combo extWidthCombo;
@@ -67,16 +63,13 @@
private Text heightText;
private Text marginText;
private Text paddingText;
- private ArrayList<String> list;
- private StyleAttributes styleAttributes;
- private ArrayList<ManualChangeStyleListener> listeners = new
ArrayList<ManualChangeStyleListener>();
- private boolean updateDataFromStyleAttributes = false;
-
/**
* Constructor for creating controls
*
- * @param composite
+ * @param composite Composite element
+ * @param comboMap
+ * @param styleAttributes the StyleAttributes object
*/
public TabBoxesControl(final Composite composite, final HashMap<String,
ArrayList<String>> comboMap,
final StyleAttributes styleAttributes) {
@@ -101,18 +94,12 @@
widthText = new Text(this, SWT.BORDER | SWT.SINGLE);
widthText.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true,
false));
- widthText.addModifyListener(new ModifyListener() {
- public void modifyText(ModifyEvent e) {
- modifyAttribute(widthText.getText(), extWidthCombo, CSSConstants.WIDTH);
- }
- });
extWidthCombo = new Combo(this, SWT.BORDER | SWT.READ_ONLY);
extWidthCombo.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, false,
false));
- extWidthCombo.addModifyListener(new ModifyListener() {
- public void modifyText(ModifyEvent event) {
- modifyExtAttribute(widthText.getText(), extWidthCombo, CSSConstants.WIDTH);
- }
- });
+ widthText.addModifyListener(new AttributeModifyListener(this, extWidthCombo,
CSSConstants.WIDTH,
+ AttributeModifyListener.MODIFY_SIMPLE_ATTRIBUTE_FIELD_WITH_COMBO_EXTENSION));
+ extWidthCombo.addModifyListener(new AttributeModifyListener(this, widthText,
CSSConstants.WIDTH,
+ AttributeModifyListener.MODIFY_COMBO_EXTENSION_ATTRIBUTE_FIELD));
for (int i = 0; i < Constants.extSizes.length; i++) {
extWidthCombo.add(Constants.extSizes[i]);
}
@@ -126,18 +113,12 @@
heightText = new Text(this, SWT.BORDER | SWT.SINGLE);
heightText.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true,
false));
- heightText.addModifyListener(new ModifyListener() {
- public void modifyText(ModifyEvent e) {
- modifyAttribute(heightText.getText(), extHeightCombo, CSSConstants.HEIGHT);
- }
- });
extHeightCombo = new Combo(this, SWT.BORDER | SWT.READ_ONLY);
extHeightCombo.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, false,
false));
- extHeightCombo.addModifyListener(new ModifyListener() {
- public void modifyText(ModifyEvent event) {
- modifyExtAttribute(heightText.getText(), extHeightCombo, CSSConstants.HEIGHT);
- }
- });
+ heightText.addModifyListener(new AttributeModifyListener(this, extHeightCombo,
CSSConstants.HEIGHT,
+ AttributeModifyListener.MODIFY_SIMPLE_ATTRIBUTE_FIELD_WITH_COMBO_EXTENSION));
+ extHeightCombo.addModifyListener(new AttributeModifyListener(this, heightText,
CSSConstants.HEIGHT,
+ AttributeModifyListener.MODIFY_COMBO_EXTENSION_ATTRIBUTE_FIELD));
for (int i = 0; i < Constants.extSizes.length; i++) {
extHeightCombo.add(Constants.extSizes[i]);
}
@@ -158,12 +139,9 @@
gridData.horizontalSpan = 2;
borderStyleCombo = new Combo(this, SWT.BORDER);
borderStyleCombo.setLayoutData(gridData);
- borderStyleCombo.addModifyListener(new ModifyListener() {
- public void modifyText(ModifyEvent event) {
- modifyAttribute(borderStyleCombo.getText(), CSSConstants.BORDER_STYLE);
- }
- });
- list = comboMap.get(CSSConstants.BORDER_STYLE);
+ borderStyleCombo.addModifyListener(new AttributeModifyListener(this,
CSSConstants.BORDER_STYLE,
+ AttributeModifyListener.MODIFY_SIMPLE_ATTRIBUTE_FIELD));
+ ArrayList<String> list = comboMap.get(CSSConstants.BORDER_STYLE);
for (String str : list) {
borderStyleCombo.add(str);
}
@@ -178,11 +156,8 @@
Composite tmpComposite = getCompositeElement();
borderColorCombo = new ImageCombo(tmpComposite, SWT.BORDER);
borderColorCombo.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true,
false));
- borderColorCombo.addModifyListener(new ModifyListener() {
- public void modifyText(ModifyEvent event) {
- modifyAttribute(borderColorCombo.getText(), CSSConstants.BORDER_COLOR);
- }
- });
+ borderColorCombo.addModifyListener(new AttributeModifyListener(this,
CSSConstants.BORDER_COLOR,
+ AttributeModifyListener.MODIFY_SIMPLE_ATTRIBUTE_FIELD));
Set<Entry<String, String>> set =
ColorParser.getInstance().getMap().entrySet();
for (Map.Entry<String, String> me : set) {
RGB rgb = Util.getColor(me.getKey());
@@ -225,36 +200,16 @@
borderWidthCombo = new Combo(this, SWT.BORDER | SWT.SINGLE);
borderWidthCombo.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true,
false));
- borderWidthCombo.addModifyListener(new ModifyListener() {
- public void modifyText(ModifyEvent e) {
- String currentText = borderWidthCombo.getText();
- list = comboMap.get(CSSConstants.BORDER_WIDTH);
- for (String str : list) {
- if (currentText.equals(str)) {
- extBorderWidthCombo.select(0);
- extBorderWidthCombo.setEnabled(false);
- styleAttributes.addAttribute(CSSConstants.BORDER_WIDTH,
currentText);
- if (!updateDataFromStyleAttributes) {
- notifyListeners();
- }
- return;
- }
- }
- extBorderWidthCombo.setEnabled(true);
- modifyAttribute(borderWidthCombo.getText(), extBorderWidthCombo,
CSSConstants.BORDER_WIDTH);
- }
- });
list = comboMap.get(CSSConstants.BORDER_WIDTH);
for (String str : list) {
borderWidthCombo.add(str);
}
extBorderWidthCombo = new Combo(this, SWT.BORDER | SWT.READ_ONLY);
extBorderWidthCombo.setLayoutData(new GridData(GridData.FILL, GridData.CENTER,
false, false));
- extBorderWidthCombo.addModifyListener(new ModifyListener() {
- public void modifyText(ModifyEvent event) {
- modifyExtAttribute(borderWidthCombo.getText(), extBorderWidthCombo,
CSSConstants.BORDER_WIDTH);
- }
- });
+ borderWidthCombo.addModifyListener(new AttributeModifyListener(this,
extBorderWidthCombo,
+ CSSConstants.BORDER_WIDTH,
AttributeModifyListener.MODIFY_COMBO_ATTRIBUTE_FIELD_WITH_COMBO_EXTENSION));
+ extBorderWidthCombo.addModifyListener(new AttributeModifyListener(this,
borderWidthCombo,
+ CSSConstants.BORDER_WIDTH,
AttributeModifyListener.MODIFY_COMBO_EXTENSION_ATTRIBUTE_FIELD));
for (int i = 0; i < Constants.extSizes.length; i++) {
extBorderWidthCombo.add(Constants.extSizes[i]);
}
@@ -273,19 +228,12 @@
marginText = new Text(this, SWT.BORDER | SWT.SINGLE);
marginText.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true,
false));
- marginText.addModifyListener(new ModifyListener() {
- public void modifyText(ModifyEvent e) {
- modifyAttribute(marginText.getText(), extMarginCombo, CSSConstants.MARGIN);
- }
- });
-
extMarginCombo = new Combo(this, SWT.BORDER | SWT.READ_ONLY);
extMarginCombo.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, false,
false));
- extMarginCombo.addModifyListener(new ModifyListener() {
- public void modifyText(ModifyEvent event) {
- modifyExtAttribute(marginText.getText(), extMarginCombo, CSSConstants.MARGIN);
- }
- });
+ marginText.addModifyListener(new AttributeModifyListener(this, extMarginCombo,
CSSConstants.MARGIN,
+ AttributeModifyListener.MODIFY_SIMPLE_ATTRIBUTE_FIELD_WITH_COMBO_EXTENSION));
+ extMarginCombo.addModifyListener(new AttributeModifyListener(this, marginText,
CSSConstants.MARGIN,
+ AttributeModifyListener.MODIFY_COMBO_EXTENSION_ATTRIBUTE_FIELD));
for (int i = 0; i < Constants.extSizes.length; i++) {
extMarginCombo.add(Constants.extSizes[i]);
}
@@ -299,18 +247,12 @@
paddingText = new Text(this, SWT.BORDER | SWT.SINGLE);
paddingText.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true,
false));
- paddingText.addModifyListener(new ModifyListener() {
- public void modifyText(ModifyEvent e) {
- modifyAttribute(paddingText.getText(), extPaddingCombo, CSSConstants.PADDING);
- }
- });
extPaddingCombo = new Combo(this, SWT.BORDER | SWT.READ_ONLY);
extPaddingCombo.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, false,
false));
- extPaddingCombo.addModifyListener(new ModifyListener() {
- public void modifyText(ModifyEvent event) {
- modifyExtAttribute(paddingText.getText(), extPaddingCombo,
CSSConstants.PADDING);
- }
- });
+ paddingText.addModifyListener(new AttributeModifyListener(this, extPaddingCombo,
CSSConstants.PADDING,
+ AttributeModifyListener.MODIFY_SIMPLE_ATTRIBUTE_FIELD_WITH_COMBO_EXTENSION));
+ extPaddingCombo.addModifyListener(new AttributeModifyListener(this, paddingText,
CSSConstants.PADDING,
+ AttributeModifyListener.MODIFY_COMBO_EXTENSION_ATTRIBUTE_FIELD));
for (int i = 0; i < Constants.extSizes.length; i++) {
extPaddingCombo.add(Constants.extSizes[i]);
}
@@ -401,105 +343,4 @@
}
updateDataFromStyleAttributes = false;
}
-
- /**
- * Method is used to correctly process modify event occurred on specify CSS attribute
control.
- *
- * @param attributeValue changed value of control were action takes place
- * @param extAttribute the attribute extension control that might be also affected
- * @param attributeName CSS name of the first parameter
- */
- private void modifyAttribute(String attributeValue, Combo extAttribute, String
attributeName) {
- if (attributeValue != null &&
!attributeValue.trim().equals(Constants.EMPTY)) {
- String extWidth = extAttribute.getText();
- if (extWidth != null) {
- attributeValue += extWidth;
- }
- styleAttributes.addAttribute(attributeName, attributeValue);
- } else {
- styleAttributes.removeAttribute(attributeName);
- extAttribute.select(0);
- }
- if (!updateDataFromStyleAttributes) {
- notifyListeners();
- }
- }
-
- /**
- * Method is used to correctly process modify event occurred on specify CSS extension
attribute control.
- *
- * @param attributeValue current value of attribute control
- * @param extAttribute the attribute extension control were action takes place
- * @param attributeName CSS name of the first parameter
- */
- private void modifyExtAttribute(String attributeValue, Combo extAttribute, String
attributeName) {
- if (attributeValue != null &&
!attributeValue.trim().equals(Constants.EMPTY)) {
- String tmp = extAttribute.getText();
- if (tmp != null) {
- styleAttributes.addAttribute(attributeName, attributeValue + tmp);
- }
- } else {
- if (extAttribute.getSelectionIndex() > 0) {
- extAttribute.select(0);
- }
- return;
- }
- if (!updateDataFromStyleAttributes) {
- notifyListeners();
- }
- }
-
- /**
- * Method is used to correctly process modify event occurred on specify CSS attribute
control.
- *
- * @param attributeValue changed value of control were action takes place
- * @param attributeName CSS name of the first parameter
- */
- private void modifyAttribute(String attributeValue, String attributeName) {
- if (attributeValue != null &&
!attributeValue.trim().equals(Constants.EMPTY)) {
- styleAttributes.addAttribute(attributeName, attributeValue.trim());
- } else {
- styleAttributes.removeAttribute(attributeName);
- }
- if (!updateDataFromStyleAttributes) {
- notifyListeners();
- }
- }
-
- /**
- * Add ManualChangeStyleListener object.
- *
- * @param listener ManualChangeStyleListener object to be added
- */
- public void addManualChangeStyleListener(ManualChangeStyleListener listener) {
- listeners.add(listener);
- }
-
- /**
- * Gets an array of ChangeStyleListener object.
- *
- * @return an array of ChangeStyleListener object
- */
- public ManualChangeStyleListener[] getManualChangeStyleListeners() {
- return listeners.toArray(new ManualChangeStyleListener[listeners.size()]);
- }
-
- /**
- * Remove ManualChangeStyleListener object passed by parameter.
- *
- * @param listener ManualChangeStyleListener object to be removed
- */
- public void removeManualChangeStyleListener(ManualChangeStyleListener listener) {
- listeners.remove(listener);
- }
-
- /**
- * Method is used to notify all subscribed listeners about any changes within style
attribute map.
- */
- private void notifyListeners() {
- ChangeStyleEvent event = new ChangeStyleEvent(this);
- for (ManualChangeStyleListener listener : listeners) {
- listener.styleChanged(event);
- }
- }
}
\ No newline at end of file
Modified:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/tabs/TabPreviewControl.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/tabs/TabPreviewControl.java 2008-12-05
13:41:34 UTC (rev 12307)
+++
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/tabs/TabPreviewControl.java 2008-12-05
13:42:06 UTC (rev 12308)
@@ -45,6 +45,7 @@
* Constructor for creating controls
*
* @param composite The parent composite for tab
+ * @param styleAttributes the StyleAttributes object
*/
public TabPreviewControl(Composite tabFolder, StyleAttributes styleAttributes) {
super(tabFolder, SWT.NONE);
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-12-05
13:41:34 UTC (rev 12307)
+++
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/tabs/TabPropertySheetControl.java 2008-12-05
13:42:06 UTC (rev 12308)
@@ -14,7 +14,6 @@
import java.util.HashMap;
import java.util.Set;
-import org.eclipse.jface.resource.JFaceResources;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.widgets.Composite;
@@ -31,23 +30,24 @@
*
* @author Evgeny Zheleznyakov
*/
-public class TabPropertySheetControl extends Composite {
+public class TabPropertySheetControl extends BaseTabControl {
private String[] columns = new String[] { "Attribute", "Value" };
private Tree tree;
- private StyleAttributes styleAttributes;
private TabPropertySheetMouseAdapter propertySheetMouseAdapter = null;
- boolean updateDataFromStyleAttributes = false;
/**
* Constructor for creating controls
*
* @param composite The parent composite for tab
+ * @param elementMap
+ * @param comboMap
+ * @param styleAttributes the StyleAttributes object
*/
- public TabPropertySheetControl(Composite tabFolder, HashMap<String,
ArrayList<String>> elementMap,
+ public TabPropertySheetControl(Composite parent, HashMap<String,
ArrayList<String>> elementMap,
HashMap<String, ArrayList<String>> comboMap, StyleAttributes
styleAttributes) {
- super(tabFolder, SWT.NONE);
+ super(parent, SWT.NONE);
this.styleAttributes = styleAttributes;
setLayout(new FillLayout());
@@ -172,15 +172,6 @@
}
/**
- * Gets the getUpdateDataFromStyleAttributes parameter value.
- *
- * @return boolean value
- */
- public boolean getUpdateDataFromStyleAttributes() {
- return updateDataFromStyleAttributes;
- }
-
- /**
* Add ManualChangeStyleListener object.
*
* @param listener ChangeStyleListener object to be added
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-12-05
13:41:34 UTC (rev 12307)
+++
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/tabs/TabQuickEditControl.java 2008-12-05
13:42:06 UTC (rev 12308)
@@ -22,8 +22,6 @@
import org.eclipse.swt.SWT;
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.graphics.Image;
@@ -47,8 +45,7 @@
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.Util;
-import org.jboss.tools.jst.jsp.outline.cssdialog.events.ChangeStyleEvent;
-import org.jboss.tools.jst.jsp.outline.cssdialog.events.ManualChangeStyleListener;
+import org.jboss.tools.jst.jsp.outline.cssdialog.events.AttributeModifyListener;
import org.jboss.tools.jst.jsp.outline.cssdialog.events.StyleAttributes;
import org.jboss.tools.jst.jsp.outline.cssdialog.parsers.ColorParser;
@@ -57,7 +54,7 @@
*
* @author Evgeny Zheleznyakov
*/
-public class TabQuickEditControl extends Composite {
+public class TabQuickEditControl extends BaseTabControl {
private static int FIRST_INDEX = 0;
private static int SECOND_INDEX = 1;
@@ -66,15 +63,13 @@
private static int EXT_VALUE_NUMBER = 1;
private Label label = null;
private HashMap<String, ArrayList<String>> comboMap;
- private StyleAttributes styleAttributes;
- private ArrayList<ManualChangeStyleListener> listeners = new
ArrayList<ManualChangeStyleListener>();
- private boolean updateDataFromStyleAttributes = false;
-
/**
* Constructor for creating controls
*
* @param composite The parent composite for tab
+ * @param comboMap
+ * @param styleAttributes the StyleAttributes object
*/
public TabQuickEditControl(Composite sc, HashMap<String,
ArrayList<String>> comboMap,
StyleAttributes styleAttributes) {
@@ -194,19 +189,8 @@
}
colorCombo.setText(value);
- colorCombo.addModifyListener(new ModifyListener() {
- String key = name;
- public void modifyText(ModifyEvent event) {
- if (!colorCombo.getText().trim().equals(Constants.EMPTY)) {
- styleAttributes.addAttribute(key, colorCombo.getText().trim());
- } else {
- styleAttributes.removeAttribute(key);
- }
- if (!updateDataFromStyleAttributes) {
- notifyListeners();
- }
- }
- });
+ colorCombo.addModifyListener(new AttributeModifyListener(this, name,
+ AttributeModifyListener.MODIFY_SIMPLE_ATTRIBUTE_FIELD));
// if css attribute contain choose_folder button
} else if (Util.containFolder(name)) {
Composite tmpComposite = getCompositeElement();
@@ -254,20 +238,8 @@
});
combo.setText(value);
- combo.addModifyListener(new ModifyListener() {
- String key = name;
-
- public void modifyText(ModifyEvent event) {
- if (!combo.getText().trim().equals(Constants.EMPTY)) {
- styleAttributes.addAttribute(key, combo.getText().trim());
- } else {
- styleAttributes.removeAttribute(key);
- }
- if (!updateDataFromStyleAttributes) {
- notifyListeners();
- }
- }
- });
+ combo.addModifyListener(new AttributeModifyListener(this, name,
+ AttributeModifyListener.MODIFY_SIMPLE_ATTRIBUTE_FIELD));
} else {
final Combo combo = new Combo(this, SWT.CENTER);
GridData gridData = new GridData(GridData.FILL, GridData.CENTER, true,
false);
@@ -288,83 +260,18 @@
values = Util.convertExtString(value);
extCombo = new Combo(this, SWT.BORDER | SWT.READ_ONLY);
extCombo.setLayoutData(new GridData(GridData.END, GridData.CENTER, false,
false));
-
for (int i = 0; i < Constants.extSizes.length; i++) {
extCombo.add(Constants.extSizes[i]);
}
extCombo.select(extCombo.indexOf(values[EXT_VALUE_NUMBER]));
- extCombo.addModifyListener(new ModifyListener() {
- String key = name;
-
- public void modifyText(ModifyEvent event) {
- String tmpCombo = combo.getText();
- if (tmpCombo != null &&
!tmpCombo.trim().equals(Constants.EMPTY)) {
- String tmpExt = extCombo.getText();
- if (tmpExt != null) {
- styleAttributes.addAttribute(key, tmpCombo +
tmpExt);
- }
- } else {
- if (extCombo.getSelectionIndex() > 0) {
- extCombo.select(0);
- }
- return;
- }
- if (!updateDataFromStyleAttributes) {
- notifyListeners();
- }
- }
- });
-
- combo.addModifyListener(new ModifyListener() {
- String key = name;
-
- public void modifyText(ModifyEvent e) {
- String currentText = combo.getText();
- String[] items = combo.getItems();
- for (int i = 0; i < items.length; i++) {
- if (currentText.equalsIgnoreCase(items[i])) {
- extCombo.select(VALUE_NUMBER);
- extCombo.setEnabled(false);
- styleAttributes.addAttribute(key, currentText);
- if (!updateDataFromStyleAttributes) {
- notifyListeners();
- }
- return;
- }
- }
-
- extCombo.setEnabled(true);
- String tmp = combo.getText();
- if (tmp != null &&
!tmp.trim().equals(Constants.EMPTY)) {
- String extTmp = extCombo.getText();
- if (extTmp != null) {
- tmp += extTmp;
- }
- styleAttributes.addAttribute(key, tmp);
- } else {
- styleAttributes.removeAttribute(key);
- }
- if (!updateDataFromStyleAttributes) {
- notifyListeners();
- }
- }
- });
+ extCombo.addModifyListener(new AttributeModifyListener(this, combo,
name,
+ AttributeModifyListener.MODIFY_COMBO_EXTENSION_ATTRIBUTE_FIELD));
+ combo.addModifyListener(new AttributeModifyListener(this, extCombo,
name,
+
AttributeModifyListener.MODIFY_COMBO_ATTRIBUTE_FIELD_WITH_COMBO_EXTENSION));
} else {
- combo.addModifyListener(new ModifyListener() {
- String key = name;
-
- public void modifyText(ModifyEvent event) {
- if (!combo.getText().trim().equals(Constants.EMPTY)) {
- styleAttributes.addAttribute(key,
combo.getText().trim());
- } else {
- styleAttributes.removeAttribute(key);
- }
- if (!updateDataFromStyleAttributes) {
- notifyListeners();
- }
- }
- });
+ combo.addModifyListener(new AttributeModifyListener(this, name,
+ AttributeModifyListener.MODIFY_SIMPLE_ATTRIBUTE_FIELD));
}
if (ext) {
combo.setText(values[VALUE_NUMBER]);
@@ -415,21 +322,8 @@
}
}
});
-
- text.addModifyListener(new ModifyListener() {
- String key = name;
-
- public void modifyText(ModifyEvent event) {
- if (!text.getText().trim().equals(Constants.EMPTY)) {
- styleAttributes.addAttribute(key, text.getText().trim());
- } else {
- styleAttributes.removeAttribute(key);
- }
- if (!updateDataFromStyleAttributes) {
- notifyListeners();
- }
- }
- });
+ text.addModifyListener(new AttributeModifyListener(this, name,
+ AttributeModifyListener.MODIFY_SIMPLE_ATTRIBUTE_FIELD));
} else {
if (Util.searchInExtElement(name)) {
text = new Text(this, SWT.BORDER);
@@ -445,66 +339,16 @@
}
extCombo.select(extCombo.indexOf(values[EXT_VALUE_NUMBER]));
-
- extCombo.addModifyListener(new ModifyListener() {
- String key = name;
-
- public void modifyText(ModifyEvent event) {
- String tmpCombo = text.getText().trim();
- if (tmpCombo != null &&
!tmpCombo.equals(Constants.EMPTY)) {
- String tmpExt = extCombo.getText();
- if (tmpExt != null) {
- styleAttributes.addAttribute(key, tmpCombo +
tmpExt);
- }
- } else {
- if (extCombo.getSelectionIndex() > 0) {
- extCombo.select(0);
- }
- return;
- }
- if (!updateDataFromStyleAttributes) {
- notifyListeners();
- }
- }
- });
- text.addModifyListener(new ModifyListener() {
- String key = name;
-
- public void modifyText(ModifyEvent e) {
- String tmp = text.getText();
- if (tmp != null &&
!tmp.trim().equals(Constants.EMPTY)) {
- String extTmp = extCombo.getText();
- if (extTmp != null) {
- tmp += extTmp;
- }
- styleAttributes.addAttribute(key, tmp);
- } else {
- styleAttributes.removeAttribute(key);
- }
- if (!updateDataFromStyleAttributes) {
- notifyListeners();
- }
- }
- });
+ extCombo.addModifyListener(new AttributeModifyListener(this, text, name,
+ AttributeModifyListener.MODIFY_COMBO_EXTENSION_ATTRIBUTE_FIELD));
+ text.addModifyListener(new AttributeModifyListener(this, extCombo, name,
+
AttributeModifyListener.MODIFY_SIMPLE_ATTRIBUTE_FIELD_WITH_COMBO_EXTENSION));
} else {
Composite tmpComposite = getCompositeElement();
text = new Text(tmpComposite, SWT.BORDER);
text.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true,
false));
-
- text.addModifyListener(new ModifyListener() {
- String key = name;
-
- public void modifyText(ModifyEvent event) {
- if (!text.getText().trim().equals(Constants.EMPTY)) {
- styleAttributes.addAttribute(key,
text.getText().trim());
- } else {
- styleAttributes.removeAttribute(key);
- }
- if (!updateDataFromStyleAttributes) {
- notifyListeners();
- }
- }
- });
+ text.addModifyListener(new AttributeModifyListener(this, name,
+ AttributeModifyListener.MODIFY_SIMPLE_ATTRIBUTE_FIELD));
}
}
@@ -556,41 +400,4 @@
return finalStr;
}
-
- /**
- * Add ManualChangeStyleListener object.
- *
- * @param listener ManualChangeStyleListener object to be added
- */
- public void addManualChangeStyleListener(ManualChangeStyleListener listener) {
- listeners.add(listener);
- }
-
- /**
- * Gets an array of ChangeStyleListener object.
- *
- * @return an array of ChangeStyleListener object
- */
- public ManualChangeStyleListener[] getManualChangeStyleListeners() {
- return listeners.toArray(new ManualChangeStyleListener[listeners.size()]);
- }
-
- /**
- * Remove ManualChangeStyleListener object passed by parameter.
- *
- * @param listener ManualChangeStyleListener object to be removed
- */
- public void removeManualChangeStyleListener(ManualChangeStyleListener listener) {
- listeners.remove(listener);
- }
-
- /**
- * Method is used to notify all subscribed listeners about any changes within style
attribute map.
- */
- private void notifyListeners() {
- ChangeStyleEvent event = new ChangeStyleEvent(this);
- for (ManualChangeStyleListener listener : listeners) {
- listener.styleChanged(event);
- }
- }
-}
+}
\ No newline at end of file
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-12-05
13:41:34 UTC (rev 12307)
+++
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/tabs/TabTextControl.java 2008-12-05
13:42:06 UTC (rev 12308)
@@ -21,8 +21,6 @@
import org.eclipse.swt.SWT;
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.graphics.Image;
@@ -42,19 +40,17 @@
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.Util;
-import org.jboss.tools.jst.jsp.outline.cssdialog.events.ChangeStyleEvent;
-import org.jboss.tools.jst.jsp.outline.cssdialog.events.ManualChangeStyleListener;
+import org.jboss.tools.jst.jsp.outline.cssdialog.events.AttributeModifyListener;
import org.jboss.tools.jst.jsp.outline.cssdialog.events.StyleAttributes;
import org.jboss.tools.jst.jsp.outline.cssdialog.parsers.ColorParser;
/**
* Class for creating Text tab controls
*
- * @author dsakovich(a)exadel.com
+ * @author Igor Zhukov (izhukov(a)exadel.com)
*/
-public class TabTextControl extends Composite {
+public class TabTextControl extends BaseTabControl {
- //private HashMap<String, String> attributesMap;
private static final int numColumns = 3;
private Text fontFamilyText;
private ImageCombo colorCombo;
@@ -65,15 +61,13 @@
private Combo textDecorationCombo;
private Combo textAlignCombo;
private ArrayList<String> list;
- private StyleAttributes styleAttributes;
- private ArrayList<ManualChangeStyleListener> listeners = new
ArrayList<ManualChangeStyleListener>();
- private boolean updateDataFromStyleAttributes = false;
-
/**
* Constructor for creating controls
*
* @param composite Composite element
+ * @param comboMap
+ * @param styleAttributes the StyleAttributes object
*/
public TabTextControl(final Composite composite, final HashMap<String,
ArrayList<String>> comboMap,
final StyleAttributes styleAttributes) {
@@ -93,11 +87,8 @@
fontFamilyText = new Text(this, SWT.BORDER | SWT.SINGLE);
fontFamilyText.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true,
false));
- fontFamilyText.addModifyListener(new ModifyListener() {
- public void modifyText(ModifyEvent event) {
- modifyAttribute(fontFamilyText.getText(), CSSConstants.FONT_FAMILY);
- }
- });
+ fontFamilyText.addModifyListener(new AttributeModifyListener(this,
CSSConstants.FONT_FAMILY,
+ AttributeModifyListener.MODIFY_SIMPLE_ATTRIBUTE_FIELD));
Button button = new Button(this, SWT.PUSH);
button.setLayoutData(new GridData(GridData.END, GridData.CENTER, false, false));
button.setToolTipText(JstUIMessages.FONT_FAMILY_TIP);
@@ -129,11 +120,8 @@
colorCombo = new ImageCombo(this, SWT.BORDER);
colorCombo.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true,
false));
- colorCombo.addModifyListener(new ModifyListener() {
- public void modifyText(ModifyEvent event) {
- modifyAttribute(colorCombo.getText(), CSSConstants.COLOR);
- }
- });
+ colorCombo.addModifyListener(new AttributeModifyListener(this,
CSSConstants.COLOR,
+ AttributeModifyListener.MODIFY_SIMPLE_ATTRIBUTE_FIELD));
Set<Entry<String, String>> set =
ColorParser.getInstance().getMap().entrySet();
for (Map.Entry<String, String> me : set) {
RGB rgb = Util.getColor(me.getKey());
@@ -184,35 +172,14 @@
extFontSizeCombo = new Combo(tmpComposite, SWT.BORDER | SWT.READ_ONLY);
extFontSizeCombo.setLayoutData(new GridData(GridData.FILL, GridData.CENTER,
false, false));
- extFontSizeCombo.addModifyListener(new ModifyListener() {
- public void modifyText(ModifyEvent event) {
- modifyExtAttribute(fontSizeCombo.getText(), extFontSizeCombo,
CSSConstants.FONT_SIZE);
- }
- });
+ extFontSizeCombo.addModifyListener(new AttributeModifyListener(this,
fontSizeCombo, CSSConstants.FONT_SIZE,
+ AttributeModifyListener.MODIFY_COMBO_EXTENSION_ATTRIBUTE_FIELD));
for (int i = 0; i < Constants.extSizes.length; i++) {
extFontSizeCombo.add(Constants.extSizes[i]);
}
- fontSizeCombo.addModifyListener(new ModifyListener() {
- public void modifyText(ModifyEvent e) {
- String currentText = fontSizeCombo.getText();
- list = comboMap.get(CSSConstants.FONT_SIZE);
- for (String str : list) {
- if (currentText.equals(str)) {
- extFontSizeCombo.select(0);
- extFontSizeCombo.setEnabled(false);
- styleAttributes.addAttribute(CSSConstants.FONT_SIZE,
currentText);
- if (!updateDataFromStyleAttributes) {
- notifyListeners();
- }
- return;
- }
- }
-
- extFontSizeCombo.setEnabled(true);
- modifyAttribute(fontSizeCombo.getText(), extFontSizeCombo,
CSSConstants.BORDER_WIDTH);
- }
- });
+ fontSizeCombo.addModifyListener(new AttributeModifyListener(this,
extFontSizeCombo, CSSConstants.FONT_SIZE,
+ AttributeModifyListener.MODIFY_COMBO_ATTRIBUTE_FIELD_WITH_COMBO_EXTENSION));
list = comboMap.get(CSSConstants.FONT_SIZE);
for (String str : list) {
fontSizeCombo.add(str);
@@ -229,11 +196,8 @@
gridData.horizontalSpan = 2;
fontStyleCombo = new Combo(this, SWT.BORDER);
fontStyleCombo.setLayoutData(gridData);
- fontStyleCombo.addModifyListener(new ModifyListener() {
- public void modifyText(ModifyEvent event) {
- modifyAttribute(fontStyleCombo.getText(), CSSConstants.FONT_STYLE);
- }
- });
+ fontStyleCombo.addModifyListener(new AttributeModifyListener(this,
CSSConstants.FONT_STYLE,
+ AttributeModifyListener.MODIFY_SIMPLE_ATTRIBUTE_FIELD));
list = comboMap.get(CSSConstants.FONT_STYLE);
for (String str : list) {
fontStyleCombo.add(str);
@@ -250,11 +214,8 @@
gridData.horizontalSpan = 2;
fontWeigthCombo = new Combo(this, SWT.BORDER);
fontWeigthCombo.setLayoutData(gridData);
- fontWeigthCombo.addModifyListener(new ModifyListener() {
- public void modifyText(ModifyEvent event) {
- modifyAttribute(fontWeigthCombo.getText(), CSSConstants.FONT_WEIGHT);
- }
- });
+ fontWeigthCombo.addModifyListener(new AttributeModifyListener(this,
CSSConstants.FONT_WEIGHT,
+ AttributeModifyListener.MODIFY_SIMPLE_ATTRIBUTE_FIELD));
list = comboMap.get(CSSConstants.FONT_WEIGHT);
for (String str : list) {
fontWeigthCombo.add(str);
@@ -271,11 +232,8 @@
gridData.horizontalSpan = 2;
textDecorationCombo = new Combo(this, SWT.BORDER);
textDecorationCombo.setLayoutData(gridData);
- textDecorationCombo.addModifyListener(new ModifyListener() {
- public void modifyText(ModifyEvent event) {
- modifyAttribute(textDecorationCombo.getText(), CSSConstants.TEXT_DECORATION);
- }
- });
+ textDecorationCombo.addModifyListener(new AttributeModifyListener(this,
CSSConstants.TEXT_DECORATION,
+ AttributeModifyListener.MODIFY_SIMPLE_ATTRIBUTE_FIELD));
list = comboMap.get(CSSConstants.TEXT_DECORATION);
for (String str : list) {
textDecorationCombo.add(str);
@@ -292,11 +250,8 @@
gridData.horizontalSpan = 2;
textAlignCombo = new Combo(this, SWT.BORDER);
textAlignCombo.setLayoutData(gridData);
- textAlignCombo.addModifyListener(new ModifyListener() {
- public void modifyText(ModifyEvent event) {
- modifyAttribute(textAlignCombo.getText(), CSSConstants.TEXT_ALIGN);
- }
- });
+ textAlignCombo.addModifyListener(new AttributeModifyListener(this,
CSSConstants.TEXT_ALIGN,
+ AttributeModifyListener.MODIFY_SIMPLE_ATTRIBUTE_FIELD));
list = comboMap.get(CSSConstants.TEXT_ALIGN);
for (String str : list) {
textAlignCombo.add(str);
@@ -368,105 +323,4 @@
}
updateDataFromStyleAttributes = false;
}
-
- /**
- * Method is used to correctly process modify event occurred on specify CSS attribute
control.
- *
- * @param attributeValue changed value of control were action takes place
- * @param extAttribute the attribute extension control that might be also affected
- * @param attributeName CSS name of the first parameter
- */
- private void modifyAttribute(String attributeValue, Combo extAttribute, String
attributeName) {
- if (attributeValue != null &&
!attributeValue.trim().equals(Constants.EMPTY)) {
- String extWidth = extAttribute.getText();
- if (extWidth != null) {
- attributeValue += extWidth;
- }
- styleAttributes.addAttribute(attributeName, attributeValue);
- } else {
- styleAttributes.removeAttribute(attributeName);
- extAttribute.select(0);
- }
- if (!updateDataFromStyleAttributes) {
- notifyListeners();
- }
- }
-
- /**
- * Method is used to correctly process modify event occurred on specify CSS extension
attribute control.
- *
- * @param attributeValue current value of attribute control
- * @param extAttribute the attribute extension control were action takes place
- * @param attributeName CSS name of the first parameter
- */
- private void modifyExtAttribute(String attributeValue, Combo extAttribute, String
attributeName) {
- if (attributeValue != null &&
!attributeValue.trim().equals(Constants.EMPTY)) {
- String tmp = extAttribute.getText();
- if (tmp != null) {
- styleAttributes.addAttribute(attributeName, attributeValue + tmp);
- }
- } else {
- if (extAttribute.getSelectionIndex() > 0) {
- extAttribute.select(0);
- }
- return;
- }
- if (!updateDataFromStyleAttributes) {
- notifyListeners();
- }
- }
-
- /**
- * Method is used to correctly process modify event occurred on specify CSS attribute
control.
- *
- * @param attributeValue changed value of control were action takes place
- * @param attributeName CSS name of the first parameter
- */
- private void modifyAttribute(String attributeValue, String attributeName) {
- if (attributeValue != null &&
!attributeValue.trim().equals(Constants.EMPTY)) {
- styleAttributes.addAttribute(attributeName, attributeValue.trim());
- } else {
- styleAttributes.removeAttribute(attributeName);
- }
- if (!updateDataFromStyleAttributes) {
- notifyListeners();
- }
- }
-
- /**
- * Add ManualChangeStyleListener object.
- *
- * @param listener ManualChangeStyleListener object to be added
- */
- public void addManualChangeStyleListener(ManualChangeStyleListener listener) {
- listeners.add(listener);
- }
-
- /**
- * Gets an array of ChangeStyleListener object.
- *
- * @return an array of ChangeStyleListener object
- */
- public ManualChangeStyleListener[] getManualChangeStyleListeners() {
- return listeners.toArray(new ManualChangeStyleListener[listeners.size()]);
- }
-
- /**
- * Remove ManualChangeStyleListener object passed by parameter.
- *
- * @param listener ManualChangeStyleListener object to be removed
- */
- public void removeManualChangeStyleListener(ManualChangeStyleListener listener) {
- listeners.remove(listener);
- }
-
- /**
- * Method is used to notify all subscribed listeners about any changes within style
attribute map.
- */
- private void notifyListeners() {
- ChangeStyleEvent event = new ChangeStyleEvent(this);
- for (ManualChangeStyleListener listener : listeners) {
- listener.styleChanged(event);
- }
- }
-}
+}
\ No newline at end of file