JBoss Tools SVN: r11953 - in trunk/jst/plugins: org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/wizards/css and 1 other directory.
by jbosstools-commits@lists.jboss.org
Author: izhukov
Date: 2008-11-21 11:21:06 -0500 (Fri, 21 Nov 2008)
New Revision: 11953
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.web.ui/src/org/jboss/tools/jst/web/ui/wizards/css/NewCSSClassWizard.java
Log:
CSS Style Dialog: remove @Override annotations
Modified: trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/CSSClassDialog.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/CSSClassDialog.java 2008-11-21 16:12:35 UTC (rev 11952)
+++ trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/CSSClassDialog.java 2008-11-21 16:21:06 UTC (rev 11953)
@@ -253,7 +253,6 @@
text.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false));
text.setEditable(false);
text.addModifyListener(new ModifyListener() {
- @Override
public void modifyText(ModifyEvent e) {
String cssFile = text.getText().trim();
// Initialize a variable with the no error status
@@ -434,7 +433,6 @@
}
});
classCombo.addModifyListener(new ModifyListener() {
- @Override
public void modifyText(ModifyEvent e) {
String cssClass = classCombo.getText().trim();
// Initialize a variable with the no error status
@@ -694,7 +692,6 @@
/**
* @see org.eclipse.swt.events.MouseListener#mouseDoubleClick(org.eclipse.swt.events.MouseEvent)
*/
- @Override
public void mouseDoubleClick(MouseEvent e) {
if (e.widget == browser) {
browser.removeMouseListener(this);
@@ -714,7 +711,6 @@
/**
* @see org.eclipse.swt.events.FocusListener#focusLost(org.eclipse.swt.events.FocusEvent)
*/
- @Override
public void focusLost(FocusEvent e) {
if (e.widget == textBrowser) {
previewBrowserValue = textBrowser.getText();
@@ -729,7 +725,6 @@
/* (non-Javadoc)
* @see org.eclipse.swt.events.MouseListener#mouseDown(org.eclipse.swt.events.MouseEvent)
*/
- @Override
public void mouseDown(MouseEvent e) {
// TODO Auto-generated method stub
}
@@ -737,7 +732,6 @@
/* (non-Javadoc)
* @see org.eclipse.swt.events.MouseListener#mouseUp(org.eclipse.swt.events.MouseEvent)
*/
- @Override
public void mouseUp(MouseEvent e) {
// TODO Auto-generated method stub
}
@@ -745,7 +739,6 @@
/* (non-Javadoc)
* @see org.eclipse.swt.events.FocusListener#focusGained(org.eclipse.swt.events.FocusEvent)
*/
- @Override
public void focusGained(FocusEvent e) {
// TODO Auto-generated method stub
}
Modified: trunk/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/wizards/css/NewCSSClassWizard.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/wizards/css/NewCSSClassWizard.java 2008-11-21 16:12:35 UTC (rev 11952)
+++ trunk/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/wizards/css/NewCSSClassWizard.java 2008-11-21 16:21:06 UTC (rev 11953)
@@ -127,7 +127,6 @@
// Also it can be used separately without integration to wizard component.
dialog = new CSSClassDialog(getShell(), selection, true);
dialog.addMessageDialogListener(new MessageDialogListener() {
- @Override
public void throwMessage(MessageDialogEvent event) {
if (event != null) {
IStatus status = event.getOperationStatus();
17 years, 5 months
JBoss Tools SVN: r11952 - trunk/documentation/qa/docs/test-cases.
by jbosstools-commits@lists.jboss.org
Author: anis
Date: 2008-11-21 11:12:35 -0500 (Fri, 21 Nov 2008)
New Revision: 11952
Removed:
trunk/documentation/qa/docs/test-cases/JBossDevStudioSmokeTests.doc
trunk/documentation/qa/docs/test-cases/JBossDevStudioTestcases.rar
trunk/documentation/qa/docs/test-cases/JBossToolsTestcases.rar
Log:
Removed file/folder
Deleted: trunk/documentation/qa/docs/test-cases/JBossDevStudioSmokeTests.doc
===================================================================
(Binary files differ)
Deleted: trunk/documentation/qa/docs/test-cases/JBossDevStudioTestcases.rar
===================================================================
(Binary files differ)
Deleted: trunk/documentation/qa/docs/test-cases/JBossToolsTestcases.rar
===================================================================
(Binary files differ)
17 years, 5 months
JBoss Tools SVN: r11951 - trunk/seam/tests/org.jboss.tools.seam.core.test/src/org/jboss/tools/seam/core/test.
by jbosstools-commits@lists.jboss.org
Author: scabanovich
Date: 2008-11-21 11:01:46 -0500 (Fri, 21 Nov 2008)
New Revision: 11951
Modified:
trunk/seam/tests/org.jboss.tools.seam.core.test/src/org/jboss/tools/seam/core/test/ScannerTest.java
Log:
JBIDE-2957
Modified: trunk/seam/tests/org.jboss.tools.seam.core.test/src/org/jboss/tools/seam/core/test/ScannerTest.java
===================================================================
--- trunk/seam/tests/org.jboss.tools.seam.core.test/src/org/jboss/tools/seam/core/test/ScannerTest.java 2008-11-21 15:54:42 UTC (rev 11950)
+++ trunk/seam/tests/org.jboss.tools.seam.core.test/src/org/jboss/tools/seam/core/test/ScannerTest.java 2008-11-21 16:01:46 UTC (rev 11951)
@@ -11,7 +11,6 @@
package org.jboss.tools.seam.core.test;
import java.util.List;
-import java.util.Properties;
import java.util.Set;
import junit.framework.TestCase;
@@ -44,13 +43,11 @@
import org.jboss.tools.seam.core.event.ISeamValueMapEntry;
import org.jboss.tools.seam.core.event.ISeamValueString;
import org.jboss.tools.seam.internal.core.SeamProject;
-import org.jboss.tools.seam.internal.core.el.SeamPromptingProvider;
import org.jboss.tools.seam.internal.core.scanner.IFileScanner;
import org.jboss.tools.seam.internal.core.scanner.LoadedDeclarations;
import org.jboss.tools.seam.internal.core.scanner.lib.ClassPath;
import org.jboss.tools.seam.internal.core.scanner.lib.LibraryScanner;
import org.jboss.tools.test.util.JUnitUtils;
-import org.jboss.tools.test.util.ResourcesUtils;
public class ScannerTest extends TestCase {
IProject project = null;
@@ -98,7 +95,7 @@
ISeamFactory[] fs = null;
try {
- LoadedDeclarations ds = scanner.parse(f);
+ LoadedDeclarations ds = scanner.parse(f, seamProject);
cs = ds.getComponents().toArray(new ISeamComponentDeclaration[0]);
fs = ds.getFactories().toArray(new ISeamFactory[0]);
} catch (Exception e) {
@@ -195,7 +192,7 @@
ISeamFactory[] fs = null;
try {
- LoadedDeclarations ds = scanner.parse(f);
+ LoadedDeclarations ds = scanner.parse(f, seamProject);
cs = ds.getComponents().toArray(new ISeamComponentDeclaration[0]);
fs = ds.getFactories().toArray(new ISeamFactory[0]);
} catch (Exception e) {
@@ -285,7 +282,7 @@
ISeamJavaComponentDeclaration[] componentDeclarations = null;
try {
- LoadedDeclarations ds = scanner.parse(f);
+ LoadedDeclarations ds = scanner.parse(f, seamProject);
factories = ds.getFactories().toArray(new ISeamFactory[0]);
componentDeclarations = ds.getComponents().toArray(new ISeamJavaComponentDeclaration[0]);
} catch (Exception e) {
17 years, 5 months
JBoss Tools SVN: r11950 - trunk/seam/plugins/org.jboss.tools.seam.core/META-INF and 6 other directories.
by jbosstools-commits@lists.jboss.org
Author: scabanovich
Date: 2008-11-21 10:54:42 -0500 (Fri, 21 Nov 2008)
New Revision: 11950
Added:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/ISeamNamespace.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamNamespace.java
Modified:
branches/jbosstools-3.0.0.Beta1/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamXmlComponentDeclaration.java
trunk/seam/plugins/org.jboss.tools.seam.core/META-INF/MANIFEST.MF
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/ISeamProject.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamProject.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamResourceVisitor.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/IFileScanner.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/LoadedDeclarations.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/java/JavaScanner.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/java/SeamAnnotations.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/lib/ClassPath.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/lib/LibraryScanner.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/lib/TypeScanner.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/xml/PropertiesScanner.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/xml/XMLScanner.java
Log:
JBIDE-2957
Modified: branches/jbosstools-3.0.0.Beta1/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamXmlComponentDeclaration.java
===================================================================
--- branches/jbosstools-3.0.0.Beta1/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamXmlComponentDeclaration.java 2008-11-21 15:50:48 UTC (rev 11949)
+++ branches/jbosstools-3.0.0.Beta1/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamXmlComponentDeclaration.java 2008-11-21 15:54:42 UTC (rev 11950)
@@ -15,6 +15,7 @@
import java.util.Properties;
import org.jboss.tools.common.model.XModelObject;
+import org.jboss.tools.common.model.util.NamespaceMapping;
import org.jboss.tools.seam.core.ISeamElement;
import org.jboss.tools.seam.core.ISeamXmlComponentDeclaration;
import org.jboss.tools.seam.core.IValueInfo;
@@ -215,7 +216,11 @@
className = XMLScanner.getImpliedClassName(c, source);
isClassNameGuessed = true;
} else {
- className = XMLScanner.getDefaultClassName(c);
+ XModelObject f = c;
+ while(f != null && f.getFileType() != XModelObject.FILE) f = f.getParent();
+ NamespaceMapping nm = NamespaceMapping.load(f);
+ SeamProject sp = (SeamProject)context.get("seamProject");
+ className = XMLScanner.getDefaultClassName(c, nm, sp == null ? null : sp.getNamespaces());
isClassNameGuessed = true;
}
}
Modified: trunk/seam/plugins/org.jboss.tools.seam.core/META-INF/MANIFEST.MF
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.core/META-INF/MANIFEST.MF 2008-11-21 15:50:48 UTC (rev 11949)
+++ trunk/seam/plugins/org.jboss.tools.seam.core/META-INF/MANIFEST.MF 2008-11-21 15:54:42 UTC (rev 11950)
@@ -15,6 +15,7 @@
org.eclipse.jdt.ui,
org.jboss.tools.common.model,
org.jboss.tools.common.el.core,
+ org.jboss.tools.seam.xml,
org.eclipse.wst.common.frameworks.ui,
org.eclipse.wst.common.project.facet.core,
org.eclipse.jst.jsf.core,
Added: trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/ISeamNamespace.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/ISeamNamespace.java (rev 0)
+++ trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/ISeamNamespace.java 2008-11-21 15:54:42 UTC (rev 11950)
@@ -0,0 +1,9 @@
+package org.jboss.tools.seam.core;
+
+import org.eclipse.core.runtime.IPath;
+
+public interface ISeamNamespace {
+ public IPath getSourcePath();
+ public String getURI();
+ public String getPackage();
+}
Modified: trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/ISeamProject.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/ISeamProject.java 2008-11-21 15:50:48 UTC (rev 11949)
+++ trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/ISeamProject.java 2008-11-21 15:54:42 UTC (rev 11950)
@@ -11,6 +11,7 @@
package org.jboss.tools.seam.core;
import java.util.Collection;
+import java.util.Map;
import java.util.Set;
import org.eclipse.core.resources.IProject;
@@ -95,6 +96,12 @@
public ISeamPackage getPackage(ISeamComponent c);
/**
+ *
+ * @return
+ */
+ public Map<String, ISeamNamespace> getNamespaces();
+
+ /**
* Returns seam component. Project can have only one ISeamComponent with
* unique name. If project has a few seam components with the same name,
* then corresponding ISeamComponent will have all declarations
Added: trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamNamespace.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamNamespace.java (rev 0)
+++ trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamNamespace.java 2008-11-21 15:54:42 UTC (rev 11950)
@@ -0,0 +1,67 @@
+package org.jboss.tools.seam.internal.core;
+
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+import org.jboss.tools.common.xml.XMLUtilities;
+import org.jboss.tools.seam.core.ISeamNamespace;
+import org.w3c.dom.Element;
+
+public class SeamNamespace implements ISeamNamespace {
+ static String ATTR_URI = "uri";
+ static String ATTR_PACKAGE = "package";
+
+ protected IPath source;
+ protected String uri;
+ protected String javaPackage;
+
+ public SeamNamespace() {}
+
+ public IPath getSourcePath() {
+ return source;
+ }
+
+ public String getURI() {
+ return uri;
+ }
+
+ public String getPackage() {
+ return javaPackage;
+ }
+
+ public void setSourcePath(IPath source) {
+ this.source = source;
+
+ }
+
+ public void setURI(String uri) {
+ this.uri = uri;
+ }
+
+ public void setPackage(String javaPackage) {
+ this.javaPackage = javaPackage;
+ }
+
+ public Element toXML(Element parent) {
+ Element element = XMLUtilities.createElement(parent, "namespace");
+ if(source != null) {
+ element.setAttribute(SeamXMLConstants.ATTR_PATH, source.toString());
+ }
+ if(uri != null) {
+ element.setAttribute(ATTR_URI, uri);
+ }
+ if(javaPackage != null) {
+ element.setAttribute(ATTR_PACKAGE, javaPackage);
+ }
+ return element;
+ }
+
+ public void loadXML(Element element) {
+ String s = element.getAttribute(SeamXMLConstants.ATTR_PATH);
+ if(s != null && s.length() > 0) {
+ source = new Path(s);
+ }
+ uri = element.getAttribute(ATTR_URI);
+ javaPackage = element.getAttribute(ATTR_PACKAGE);
+ }
+
+}
Modified: trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamProject.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamProject.java 2008-11-21 15:50:48 UTC (rev 11949)
+++ trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamProject.java 2008-11-21 15:54:42 UTC (rev 11950)
@@ -42,6 +42,7 @@
import org.jboss.tools.seam.core.ISeamContextVariable;
import org.jboss.tools.seam.core.ISeamFactory;
import org.jboss.tools.seam.core.ISeamJavaComponentDeclaration;
+import org.jboss.tools.seam.core.ISeamNamespace;
import org.jboss.tools.seam.core.ISeamPackage;
import org.jboss.tools.seam.core.ISeamProject;
import org.jboss.tools.seam.core.ISeamScope;
@@ -93,6 +94,7 @@
createScopes();
}
+ NamespaceStorage namespaces = new NamespaceStorage();
ComponentStorage components = new ComponentStorage();
FactoryStorage factories = new FactoryStorage();
VariablesStorage variables = new VariablesStorage();
@@ -309,7 +311,11 @@
public void addDependentSeamProject(SeamProject p) {
usedBy.add(p);
}
-
+
+ public Map<String, ISeamNamespace> getNamespaces() {
+ return namespaces.namespacesByURI;
+ }
+
/**
*
* @param p
@@ -377,6 +383,7 @@
root = XMLUtilities.getElement(file, null);
if(root != null) {
loadProjectDependencies(root);
+ loadNamespaces(root);
if(XMLUtilities.getUniqueChild(root, "paths") != null) {
loadSourcePaths2(root);
} else {
@@ -421,6 +428,7 @@
isStorageResolved = false;
dependsOn.clear();
usedBy.clear();
+ namespaces.clear();
components.clear();
factories.clear();
variables.clear();
@@ -455,6 +463,8 @@
Element root = XMLUtilities.createDocumentElement("seam-project"); //$NON-NLS-1$
storeProjectDependencies(root);
+
+ storeNamespaces(root);
// storeSourcePaths(root);
storeSourcePaths2(root);
@@ -473,7 +483,14 @@
// pathElement.setAttribute("value", path.toString()); //$NON-NLS-1$
// }
// }
-
+
+ private void storeNamespaces(Element root) {
+ Element namespacesElement = XMLUtilities.createElement(root, "namespaces"); //$NON-NLS-1$
+ for (ISeamNamespace n : namespaces.namespacesByURI.values()) {
+ ((SeamNamespace)n).toXML(namespacesElement);
+ }
+ }
+
private void storeSourcePaths2(Element root) {
Properties context = new Properties();
Element sourcePathsElement = XMLUtilities.createElement(root, "paths"); //$NON-NLS-1$
@@ -550,9 +567,21 @@
b.visit(f);
}
}
-
+
+ private void loadNamespaces(Element root) {
+ Element namespacesElement = XMLUtilities.getUniqueChild(root, "namespaces"); //$NON-NLS-1$
+ if(namespacesElement == null) return;
+ Element[] ns = XMLUtilities.getChildren(namespacesElement, "namespace"); //$NON-NLS-1$
+ for (int i = 0; i < ns.length; i++) {
+ SeamNamespace sn = new SeamNamespace();
+ sn.loadXML(ns[i]);
+ namespaces.addNamespace(sn);
+ }
+ }
+
private void loadSourcePaths2(Element root) {
Properties context = new Properties();
+ context.put("seamProject", this);
Element sourcePathsElement = XMLUtilities.getUniqueChild(root, "paths"); //$NON-NLS-1$
if(sourcePathsElement == null) return;
Element[] paths = XMLUtilities.getChildren(sourcePathsElement, "path"); //$NON-NLS-1$
@@ -619,6 +648,13 @@
}
getClassPath().pathLoaded(path);
+
+ Set<ISeamNamespace> ns = namespaces.getNamespacesBySource(path);
+ if(ns != null) {
+ //we need that, or registering will remove them
+ ds.getNamespaces().addAll(ns);
+ }
+
registerComponents(ds, path);
long t2 = System.currentTimeMillis();
if(statistics != null) {
@@ -715,10 +751,11 @@
*/
public void registerComponents(LoadedDeclarations ds, IPath source) {
+ ISeamNamespace[] ns = ds.getNamespaces().toArray(new ISeamNamespace[0]);
ISeamComponentDeclaration[] components = ds.getComponents().toArray(new ISeamComponentDeclaration[0]);
ISeamFactory[] factories = ds.getFactories().toArray(new ISeamFactory[0]);
- if(components.length == 0 && factories.length == 0 && ds.getImports().size() == 0) {
+ if(ns.length == 0 && components.length == 0 && factories.length == 0 && ds.getImports().size() == 0) {
pathRemoved(source);
if(source.toString().endsWith(".jar")) {
if(!sourcePaths.contains(source)) sourcePaths.add(source);
@@ -728,6 +765,10 @@
}
if(!sourcePaths.contains(source)) sourcePaths.add(source);
sourcePaths2.put(source, ds);
+
+ if(ns.length > 0) {
+ namespaces.addPath(source, ns);
+ }
if(ds.getImports().size() > 0) {
setImports(source.toString(), ds.getImports());
@@ -890,6 +931,9 @@
for (SeamProject p : usedBy) {
p.resolve();
LoadedDeclarations ds1 = new LoadedDeclarations();
+ for (ISeamNamespace n: ds.getNamespaces()) {
+ ds1.getNamespaces().add(n); //no need to clone, it is read-only.
+ }
for (ISeamComponentDeclaration d: ds.getComponents()) {
ds1.getComponents().add(d.clone());
}
@@ -956,6 +1000,8 @@
if(!sourcePaths.contains(source) && !sourcePaths2.containsKey(source)) return;
sourcePaths.remove(source);
sourcePaths2.remove(source);
+
+ namespaces.removePath(source);
removeImports(source.toString());
List<Change> changes = null;
@@ -1516,6 +1562,16 @@
ds.getComponents().add(d.clone());
}
}
+ for (ISeamNamespace n : namespaces.namespacesByURI.values()) {
+ IPath p = n.getSourcePath();
+ if(p == null || p.toString().endsWith(".jar")) continue; //$NON-NLS-1$
+ LoadedDeclarations ds = map.get(p);
+ if(ds == null) {
+ ds = new LoadedDeclarations();
+ map.put(p, ds);
+ }
+ ds.getNamespaces().add(n);
+ }
for (ISeamFactory f : factories.allFactories) {
IPath p = f.getSourcePath();
if(p == null || p.toString().endsWith(".jar")) continue; //$NON-NLS-1$
@@ -1615,6 +1671,78 @@
}
+ class NamespaceStorage {
+ Map<IPath, Set<ISeamNamespace>> namespacesBySource = new HashMap<IPath, Set<ISeamNamespace>>();
+ Map<String, ISeamNamespace> namespacesByURI = new HashMap<String, ISeamNamespace>();
+
+ public void clear() {
+ namespacesBySource.clear();
+ namespacesByURI.clear();
+ }
+
+ public Set<ISeamNamespace> getNamespacesBySource(IPath path) {
+ return namespacesBySource.get(path);
+ }
+
+ public void addPath(IPath source, ISeamNamespace[] ns) {
+ Set<ISeamNamespace> sd = namespacesBySource.get(source);
+ if(sd == null && ns.length == 0) return;
+ if(ns.length == 0) {
+ removePath(source);
+ } else {
+ if(sd != null) {
+ sd.clear();
+ } else {
+ sd = new HashSet<ISeamNamespace>();
+ namespacesBySource.put(source, sd);
+ }
+ for (int i = 0; i < ns.length; i++) {
+ sd.add(ns[i]);
+ //TODO that will not remove old objects
+ namespacesByURI.put(ns[i].getURI(), ns[i]);
+ }
+ }
+ }
+
+ public void addNamespace(ISeamNamespace n) {
+ namespacesByURI.put(n.getURI(), n);
+ IPath path = n.getSourcePath();
+ if(path != null) {
+ Set<ISeamNamespace> fs = namespacesBySource.get(path);
+ if(fs == null) {
+ fs = new HashSet<ISeamNamespace>();
+ namespacesBySource.put(path, fs);
+ }
+ fs.add(n);
+ }
+ }
+
+ public void removePath(IPath path) {
+ Set<ISeamNamespace> sd = namespacesBySource.get(path);
+ if(sd == null) return;
+ for (ISeamNamespace d: sd) {
+ if(d.getURI() != null)
+ namespacesByURI.remove(d.getURI());
+ }
+ namespacesBySource.remove(path);
+ }
+
+ public void removeNamespace(ISeamNamespace n) {
+ namespacesByURI.remove(n.getURI());
+ IPath path = n.getSourcePath();
+ if(path != null) {
+ Set<ISeamNamespace> fs = namespacesBySource.get(path);
+ if(fs != null) {
+ fs.remove(n);
+ }
+ if(fs.isEmpty()) {
+ namespacesBySource.remove(fs);
+ }
+ }
+ }
+
+ }
+
class ComponentStorage {
Set<ISeamComponent> allComponentsSet = new HashSet<ISeamComponent>();
Map<String, SeamComponent> allComponents = new HashMap<String, SeamComponent>();
Modified: trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamResourceVisitor.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamResourceVisitor.java 2008-11-21 15:50:48 UTC (rev 11949)
+++ trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamResourceVisitor.java 2008-11-21 15:54:42 UTC (rev 11950)
@@ -91,7 +91,7 @@
}
LoadedDeclarations c = null;
try {
- c = scanner.parse(f);
+ c = scanner.parse(f, p);
} catch (ScannerException e) {
SeamCorePlugin.getDefault().logError(e);
}
Modified: trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/IFileScanner.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/IFileScanner.java 2008-11-21 15:50:48 UTC (rev 11949)
+++ trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/IFileScanner.java 2008-11-21 15:54:42 UTC (rev 11950)
@@ -11,6 +11,7 @@
package org.jboss.tools.seam.internal.core.scanner;
import org.eclipse.core.resources.IFile;
+import org.jboss.tools.seam.core.ISeamProject;
public interface IFileScanner {
@@ -36,6 +37,6 @@
* @return
* @throws ScannerException
*/
- public LoadedDeclarations parse(IFile f) throws ScannerException;
+ public LoadedDeclarations parse(IFile f, ISeamProject sp) throws ScannerException;
}
Modified: trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/LoadedDeclarations.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/LoadedDeclarations.java 2008-11-21 15:50:48 UTC (rev 11949)
+++ trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/LoadedDeclarations.java 2008-11-21 15:54:42 UTC (rev 11950)
@@ -15,6 +15,7 @@
import org.jboss.tools.seam.core.ISeamComponentDeclaration;
import org.jboss.tools.seam.core.ISeamFactory;
+import org.jboss.tools.seam.core.ISeamNamespace;
/**
* This object keeps all declarations loaded from one source.
@@ -25,6 +26,7 @@
List<ISeamComponentDeclaration> components = new ArrayList<ISeamComponentDeclaration>();
List<ISeamFactory> factories = new ArrayList<ISeamFactory>();
List<String> imports = new ArrayList<String>();
+ List<ISeamNamespace> namespaces = new ArrayList<ISeamNamespace>();
public List<ISeamComponentDeclaration> getComponents() {
return components;
@@ -37,12 +39,17 @@
public List<String> getImports() {
return imports;
}
+
+ public List<ISeamNamespace> getNamespaces() {
+ return namespaces;
+ }
public void add(LoadedDeclarations ds) {
if(ds == null) return;
components.addAll(ds.components);
factories.addAll(ds.factories);
imports.addAll(ds.imports);
+ namespaces.addAll(ds.namespaces);
}
}
Modified: trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/java/JavaScanner.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/java/JavaScanner.java 2008-11-21 15:50:48 UTC (rev 11949)
+++ trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/java/JavaScanner.java 2008-11-21 15:54:42 UTC (rev 11950)
@@ -30,6 +30,7 @@
import org.jboss.tools.common.model.util.EclipseJavaUtil;
import org.jboss.tools.common.model.util.EclipseResourceUtil;
import org.jboss.tools.common.util.FileUtil;
+import org.jboss.tools.seam.core.ISeamProject;
import org.jboss.tools.seam.core.SeamCoreMessages;
import org.jboss.tools.seam.internal.core.scanner.IFileScanner;
import org.jboss.tools.seam.internal.core.scanner.LoadedDeclarations;
@@ -81,7 +82,7 @@
* @return
* @throws ScannerException
*/
- public LoadedDeclarations parse(IFile f) throws ScannerException {
+ public LoadedDeclarations parse(IFile f, ISeamProject sp) throws ScannerException {
ICompilationUnit u = null;
try {
u = getCompilationUnit(f);
Modified: trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/java/SeamAnnotations.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/java/SeamAnnotations.java 2008-11-21 15:50:48 UTC (rev 11949)
+++ trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/java/SeamAnnotations.java 2008-11-21 15:54:42 UTC (rev 11950)
@@ -23,6 +23,8 @@
public static final String SCOPE_ANNOTATION_TYPE = SEAM_ANNOTATION_TYPE_PREFIX + "Scope"; //$NON-NLS-1$
public static final String INSTALL_ANNOTATION_TYPE = SEAM_ANNOTATION_TYPE_PREFIX + "Install"; //$NON-NLS-1$
+ public static final String NAMESPACE_ANNOTATION_TYPE = SEAM_ANNOTATION_TYPE_PREFIX + "Namespace"; //$NON-NLS-1$
+
public static final String IN_ANNOTATION_TYPE = SEAM_ANNOTATION_TYPE_PREFIX + "In"; //$NON-NLS-1$
public static final String OUT_ANNOTATION_TYPE = SEAM_ANNOTATION_TYPE_PREFIX + "Out"; //$NON-NLS-1$
public static final String DATA_MODEL_ANNOTATION_TYPE = SEAM_ANNOTATION_TYPE_PREFIX + "datamodel.DataModel"; //$NON-NLS-1$
Modified: trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/lib/ClassPath.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/lib/ClassPath.java 2008-11-21 15:50:48 UTC (rev 11949)
+++ trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/lib/ClassPath.java 2008-11-21 15:54:42 UTC (rev 11950)
@@ -12,9 +12,6 @@
import java.io.File;
import java.io.IOException;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.net.URLClassLoader;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
@@ -193,7 +190,7 @@
LoadedDeclarations c = null;
try {
if(scanner.isLikelyComponentSource(o)) {
- c = scanner.parse(o, new Path(p));
+ c = scanner.parse(o, new Path(p), project);
}
} catch (ScannerException e) {
SeamCorePlugin.getDefault().logError(e);
Modified: trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/lib/LibraryScanner.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/lib/LibraryScanner.java 2008-11-21 15:50:48 UTC (rev 11949)
+++ trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/lib/LibraryScanner.java 2008-11-21 15:54:42 UTC (rev 11950)
@@ -25,17 +25,21 @@
import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileReader;
+import org.eclipse.jdt.internal.compiler.env.IBinaryAnnotation;
import org.jboss.tools.common.model.XModel;
import org.jboss.tools.common.model.XModelObject;
import org.jboss.tools.common.model.filesystems.impl.FileSystemsImpl;
import org.jboss.tools.common.model.plugin.ModelPlugin;
import org.jboss.tools.common.model.util.EclipseResourceUtil;
import org.jboss.tools.common.model.util.XModelObjectUtil;
+import org.jboss.tools.seam.core.ISeamProject;
import org.jboss.tools.seam.core.SeamCoreMessages;
import org.jboss.tools.seam.internal.core.InnerModelHelper;
+import org.jboss.tools.seam.internal.core.SeamNamespace;
import org.jboss.tools.seam.internal.core.scanner.IFileScanner;
import org.jboss.tools.seam.internal.core.scanner.LoadedDeclarations;
import org.jboss.tools.seam.internal.core.scanner.ScannerException;
+import org.jboss.tools.seam.internal.core.scanner.java.SeamAnnotations;
import org.jboss.tools.seam.internal.core.scanner.xml.PropertiesScanner;
import org.jboss.tools.seam.internal.core.scanner.xml.XMLScanner;
@@ -72,7 +76,7 @@
return isLikelyComponentSource(o);
}
- public LoadedDeclarations parse(IFile f) throws ScannerException {
+ public LoadedDeclarations parse(IFile f, ISeamProject sp) throws ScannerException {
XModel model = InnerModelHelper.createXModel(f.getProject());
if(model == null) return null;
XModelObject o = EclipseResourceUtil.getObjectByResource(model, f);
@@ -82,7 +86,7 @@
o = EclipseResourceUtil.getObjectByResource(f);
if(o == null || !o.getModelEntity().getName().equals("FileSystemJar")) return null; //$NON-NLS-1$
}
- return parse(o, f.getFullPath());
+ return parse(o, f.getFullPath(), sp);
}
public boolean isLikelyComponentSource(XModelObject o) {
@@ -93,7 +97,7 @@
return false;
}
- public LoadedDeclarations parse(XModelObject o, IPath path) throws ScannerException {
+ public LoadedDeclarations parse(XModelObject o, IPath path, ISeamProject sp) throws ScannerException {
if(o == null) return null;
sourcePath = path;
XModelObject seamProperties = o.getChildByPath("META-INF/seam.properties"); //$NON-NLS-1$
@@ -110,7 +114,7 @@
}
if(componentsXML != null) {
- LoadedDeclarations ds1 = new XMLScanner().parse(componentsXML, path);
+ LoadedDeclarations ds1 = new XMLScanner().parse(componentsXML, path, sp);
if(ds1 != null) ds.add(ds1);
}
if(seamProperties != null) {
@@ -143,46 +147,104 @@
protected void process(IParent element, LoadedDeclarations ds) throws JavaModelException {
if(element == null) return;
IJavaElement[] es = element.getChildren();
+ String prefix = null;
for (int i = 0; i < es.length; i++) {
+ if(es[i] instanceof IClassFile) {
+ IClassFile typeRoot = (IClassFile)es[i];
+ if(es[i].getElementName().equals("package-info.class")) {
+ prefix = processPackageInfo(typeRoot, ds);
+ break;
+ }
+ }
+ }
+ for (int i = 0; i < es.length; i++) {
if(es[i] instanceof IPackageFragment) {
process((IPackageFragment)es[i], ds);
} else if(es[i] instanceof IClassFile) {
IClassFile typeRoot = (IClassFile)es[i];
- processWithClassReader(typeRoot, ds);
+ if(es[i].getElementName().equals("package-info.class")) {
+ continue;
+ } else {
+ processWithClassReader(typeRoot, ds, prefix);
+ }
}
}
}
- void processWithClassReader(IClassFile typeRoot, LoadedDeclarations ds) {
+ void processWithClassReader(IClassFile typeRoot, LoadedDeclarations ds, String prefix) {
IType type = typeRoot.getType();
+ ClassFileReader reader = getReader(type, typeRoot);
+
+ if(reader == null) return;
+ LoadedDeclarations ds1 = null;
+
+ //TODO use prefix
+ TypeScanner scanner = new TypeScanner();
+ if(!scanner.isLikelyComponentSource(reader)) return;
+ ds1 = scanner.parse(type, reader, sourcePath);
+
+ if(ds1 != null) {
+ ds.add(ds1);
+ }
+ }
+
+ String processPackageInfo(IClassFile typeRoot, LoadedDeclarations ds) {
+ IType type = typeRoot.getType();
+
+ ClassFileReader reader = getReader(type, typeRoot);
+
+ if(reader == null) return null;
+ IBinaryAnnotation[] as = reader.getAnnotations();
+ IBinaryAnnotation namespaceAnnotation = getNamespaceAnnotation(as);
+ if(namespaceAnnotation == null) return null;
+ String uri = TypeScanner.getValue(namespaceAnnotation, "value");
+ String prefix = TypeScanner.getValue(namespaceAnnotation, "prefix");
+ if(uri == null) return null;
+
String className = type.getFullyQualifiedName();
+ int i = className.indexOf(".package-info");
+ if(i < 0) return null;
+ String packageName = className.substring(0, i);
+
+ SeamNamespace n = new SeamNamespace();
+ n.setSourcePath(sourcePath);
+ n.setURI(uri);
+ n.setPackage(packageName);
+
+ ds.getNamespaces().add(n);
+
+ return prefix;
+ }
+
+ static IBinaryAnnotation getNamespaceAnnotation(IBinaryAnnotation[] as) {
+ if(as != null) for (int i = 0; i < as.length; i++) {
+ String type = TypeScanner.getTypeName(as[i]);
+ if(type != null && type.equals(SeamAnnotations.NAMESPACE_ANNOTATION_TYPE)) {
+ return as[i];
+ }
+ }
+ return null;
+ }
+
+ private ClassFileReader getReader(IType type, IClassFile typeRoot) {
+ String className = type.getFullyQualifiedName();
byte[] bs = null;
try {
bs = typeRoot.getBytes();
} catch (JavaModelException e) {
- return;
+ return null;
}
- ClassFileReader reader = null;
-
try {
- reader = ClassFileReader.read(new ByteArrayInputStream(bs), className, false);
+ return ClassFileReader.read(new ByteArrayInputStream(bs), className, false);
} catch (Throwable t) {
//ignore
}
-
- if(reader == null) return;
- LoadedDeclarations ds1 = null;
- TypeScanner scanner = new TypeScanner();
- if(!scanner.isLikelyComponentSource(reader)) return;
- ds1 = scanner.parse(type, reader, sourcePath);
+ return null;
+ }
- if(ds1 != null) {
- ds.add(ds1);
- }
- }
}
Modified: trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/lib/TypeScanner.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/lib/TypeScanner.java 2008-11-21 15:50:48 UTC (rev 11949)
+++ trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/lib/TypeScanner.java 2008-11-21 15:54:42 UTC (rev 11950)
@@ -104,7 +104,7 @@
return false;
}
- protected String getTypeName(IBinaryAnnotation a) {
+ public static String getTypeName(IBinaryAnnotation a) {
if(a.getTypeName() == null) return ""; //$NON-NLS-1$
String t = new String(a.getTypeName());
if(t.startsWith("L") && t.endsWith(";")) { //$NON-NLS-1$ //$NON-NLS-2$
@@ -280,7 +280,7 @@
}
}
- private String getValue(IBinaryAnnotation a, String method) {
+ public static String getValue(IBinaryAnnotation a, String method) {
try {
IBinaryElementValuePair[] ps = a.getElementValuePairs();
if(ps != null) for (int i = 0; i < ps.length; i++) {
Modified: trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/xml/PropertiesScanner.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/xml/PropertiesScanner.java 2008-11-21 15:50:48 UTC (rev 11949)
+++ trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/xml/PropertiesScanner.java 2008-11-21 15:54:42 UTC (rev 11950)
@@ -22,6 +22,7 @@
import org.jboss.tools.common.model.filesystems.impl.FolderImpl;
import org.jboss.tools.common.model.plugin.ModelPlugin;
import org.jboss.tools.common.model.util.EclipseResourceUtil;
+import org.jboss.tools.seam.core.ISeamProject;
import org.jboss.tools.seam.internal.core.InnerModelHelper;
import org.jboss.tools.seam.internal.core.SeamPropertiesDeclaration;
import org.jboss.tools.seam.internal.core.SeamProperty;
@@ -63,7 +64,7 @@
* @return
* @throws ScannerException
*/
- public LoadedDeclarations parse(IFile f) throws ScannerException {
+ public LoadedDeclarations parse(IFile f, ISeamProject sp) throws ScannerException {
XModel model = InnerModelHelper.createXModel(f.getProject());
if(model == null) return null;
XModelObject o = EclipseResourceUtil.getObjectByResource(model, f);
Modified: trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/xml/XMLScanner.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/xml/XMLScanner.java 2008-11-21 15:50:48 UTC (rev 11949)
+++ trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/xml/XMLScanner.java 2008-11-21 15:54:42 UTC (rev 11950)
@@ -11,6 +11,7 @@
package org.jboss.tools.seam.internal.core.scanner.xml;
import java.util.HashSet;
+import java.util.Map;
import java.util.Set;
import java.util.StringTokenizer;
@@ -26,6 +27,9 @@
import org.jboss.tools.common.model.filesystems.impl.FolderImpl;
import org.jboss.tools.common.model.plugin.ModelPlugin;
import org.jboss.tools.common.model.util.EclipseResourceUtil;
+import org.jboss.tools.common.model.util.NamespaceMapping;
+import org.jboss.tools.seam.core.ISeamNamespace;
+import org.jboss.tools.seam.core.ISeamProject;
import org.jboss.tools.seam.core.ISeamXmlComponentDeclaration;
import org.jboss.tools.seam.core.SeamCorePlugin;
import org.jboss.tools.seam.core.event.ISeamValue;
@@ -84,11 +88,11 @@
* @return
* @throws ScannerException
*/
- public LoadedDeclarations parse(IFile f) throws ScannerException {
+ public LoadedDeclarations parse(IFile f, ISeamProject sp) throws ScannerException {
XModel model = InnerModelHelper.createXModel(f.getProject());
if(model == null) return null;
XModelObject o = EclipseResourceUtil.getObjectByResource(model, f);
- return parse(o, f.getFullPath());
+ return parse(o, f.getFullPath(), sp);
}
static Set<String> COMMON_ATTRIBUTES = new HashSet<String>();
@@ -109,8 +113,10 @@
INTERNAL_ATTRIBUTES.add("#comment"); //$NON-NLS-1$
}
- public LoadedDeclarations parse(XModelObject o, IPath source) {
+ public LoadedDeclarations parse(XModelObject o, IPath source, ISeamProject sp) {
if(o == null) return null;
+
+ NamespaceMapping nm = NamespaceMapping.load(o);
if(o.getParent() instanceof FolderImpl) {
IFile f = ResourcesPlugin.getWorkspace().getRoot().getFile(source);
@@ -131,14 +137,14 @@
LoadedDeclarations ds = new LoadedDeclarations();
if(o.getModelEntity().getName().equals("FileSeamComponent12")) { //$NON-NLS-1$
- parseComponent(o, source, ds);
+ parseComponent(o, source, nm, sp, ds);
return ds;
}
XModelObject[] os = o.getChildren();
for (int i = 0; i < os.length; i++) {
XModelEntity componentEntity = os[i].getModelEntity();
if(componentEntity.getAttribute("class") != null) { //$NON-NLS-1$
- parseComponent(os[i], source, ds);
+ parseComponent(os[i], source, nm, sp, ds);
} else if(os[i].getModelEntity().getName().startsWith("SeamFactory")) { //$NON-NLS-1$
SeamXmlFactory factory = new SeamXmlFactory();
factory.setId(os[i]);
@@ -158,7 +164,7 @@
return ds;
}
- private void parseComponent(XModelObject c, IPath source, LoadedDeclarations ds) {
+ private void parseComponent(XModelObject c, IPath source, NamespaceMapping nm, ISeamProject sp, LoadedDeclarations ds) {
SeamXmlComponentDeclaration component = new SeamXmlComponentDeclaration();
component.setSourcePath(source);
@@ -170,7 +176,7 @@
} else if(c.getModelEntity().getName().equals("FileSeamComponent12")) { //$NON-NLS-1$
component.setClassName(getImpliedClassName(c, source));
} else {
- String className = getDefaultClassName(c);
+ String className = getDefaultClassName(c, nm, sp.getNamespaces());
if(className != null) {
component.setClassName(className);
component.setClassNameGuessed(true);
@@ -335,13 +341,25 @@
* @param c
* @return
*/
- public static String getDefaultClassName(XModelObject c) {
+ public static String getDefaultClassName(XModelObject c, NamespaceMapping nm, Map<String, ISeamNamespace> ns) {
String s = c.getModelEntity().getXMLSubPath();
int d = s.indexOf(':');
if(d < 0) return null;
String namespace = s.substring(0, d);
String tag = s.substring(d + 1);
- String className = "org.jboss.seam." + namespace + "." + toCamelCase(tag, true); //$NON-NLS-1$ //$NON-NLS-2$
+
+ String packageName = "org.jboss.seam." + namespace;
+ if(nm != null) {
+ String uri = nm.getURIForDefaultNamespace(namespace);
+ if(uri != null && ns != null) {
+ ISeamNamespace n = ns.get(uri);
+ if(n != null) {
+ String pn = n.getPackage();
+ if(pn != null && pn.length() > 0) packageName = pn;
+ }
+ }
+ }
+ String className = packageName + "." + toCamelCase(tag, true); //$NON-NLS-1$ //$NON-NLS-2$
return className;
}
17 years, 5 months
JBoss Tools SVN: r11949 - trunk/seam/plugins/org.jboss.tools.seam.xml/src/org/jboss/tools/seam/xml/components/model.
by jbosstools-commits@lists.jboss.org
Author: scabanovich
Date: 2008-11-21 10:50:48 -0500 (Fri, 21 Nov 2008)
New Revision: 11949
Modified:
trunk/seam/plugins/org.jboss.tools.seam.xml/src/org/jboss/tools/seam/xml/components/model/SeamComponentsFileLoader.java
trunk/seam/plugins/org.jboss.tools.seam.xml/src/org/jboss/tools/seam/xml/components/model/SeamNamespaces.java
Log:
JBIDE-2957
Modified: trunk/seam/plugins/org.jboss.tools.seam.xml/src/org/jboss/tools/seam/xml/components/model/SeamComponentsFileLoader.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.xml/src/org/jboss/tools/seam/xml/components/model/SeamComponentsFileLoader.java 2008-11-21 15:49:34 UTC (rev 11948)
+++ trunk/seam/plugins/org.jboss.tools.seam.xml/src/org/jboss/tools/seam/xml/components/model/SeamComponentsFileLoader.java 2008-11-21 15:50:48 UTC (rev 11949)
@@ -34,7 +34,7 @@
protected String loadNamespace(Element element, XModelObject object) {
NamespaceMapping namespaceMapping = SeamNamespaces.getInstance(object.getModel().getMetaData(), getVersionSuffix(object)).getNamespaceMapping(element);
- object.set("namespaceMapping", namespaceMapping.toString()); //$NON-NLS-1$
+ object.set(NamespaceMapping.ATTR_NAMESPACE_MAPPING, namespaceMapping.toString()); //$NON-NLS-1$
util.setNamespaceMapping(namespaceMapping);
return super.loadNamespace(element, object);
@@ -44,7 +44,7 @@
String rootName = getRootName(object);
Element element = createRootElement(rootName, null, null);
SeamNamespaces.getInstance(object.getModel().getMetaData(), getVersionSuffix(object)).validateNamespaces(object, element);
- NamespaceMapping namespaceMapping = NamespaceMapping.load(object.get("namespaceMapping")); //$NON-NLS-1$
+ NamespaceMapping namespaceMapping = NamespaceMapping.load(object);
util.setNamespaceMapping(namespaceMapping);
return serializeToElement(element, object);
}
Modified: trunk/seam/plugins/org.jboss.tools.seam.xml/src/org/jboss/tools/seam/xml/components/model/SeamNamespaces.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.xml/src/org/jboss/tools/seam/xml/components/model/SeamNamespaces.java 2008-11-21 15:49:34 UTC (rev 11948)
+++ trunk/seam/plugins/org.jboss.tools.seam.xml/src/org/jboss/tools/seam/xml/components/model/SeamNamespaces.java 2008-11-21 15:50:48 UTC (rev 11949)
@@ -19,7 +19,6 @@
import org.jboss.tools.common.meta.XModelMetaData;
import org.jboss.tools.common.model.XModelObject;
import org.jboss.tools.common.model.util.NamespaceMapping;
-import org.jboss.tools.seam.xml.SeamXMLMessages;
import org.w3c.dom.Element;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
@@ -75,7 +74,7 @@
String uri = n.getNodeValue();
String defaultNamespace = getDefaultNamespace(uri);
if(defaultNamespace == null) continue;
- mapping.addNamespace(defaultNamespace, actualNamespace);
+ mapping.addNamespace(defaultNamespace, actualNamespace, uri);
}
}
return mapping;
@@ -94,7 +93,7 @@
}
public void validateNamespaces(XModelObject object, Element element) {
- NamespaceMapping namespaceMapping = NamespaceMapping.load(object.get("namespaceMapping")); //$NON-NLS-1$
+ NamespaceMapping namespaceMapping = NamespaceMapping.load(object);
if(namespaceMapping == null) namespaceMapping = new NamespaceMapping();
StringBuffer loc = new StringBuffer();
loc.append(object.getAttributeValue("xsi:schemaLocation")); //$NON-NLS-1$
17 years, 5 months
JBoss Tools SVN: r11948 - trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/util.
by jbosstools-commits@lists.jboss.org
Author: scabanovich
Date: 2008-11-21 10:49:34 -0500 (Fri, 21 Nov 2008)
New Revision: 11948
Modified:
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/util/NamespaceMapping.java
Log:
JBIDE-2957
Modified: trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/util/NamespaceMapping.java
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/util/NamespaceMapping.java 2008-11-21 15:29:28 UTC (rev 11947)
+++ trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/util/NamespaceMapping.java 2008-11-21 15:49:34 UTC (rev 11948)
@@ -15,18 +15,24 @@
import java.util.Map;
import java.util.StringTokenizer;
+import org.jboss.tools.common.model.XModelObject;
+
public class NamespaceMapping {
+ public static String ATTR_NAMESPACE_MAPPING = "namespaceMapping";
+
Map<String, String> defaultToActual = new HashMap<String, String>();
Map<String, String> actualToDefault = new HashMap<String, String>();
+ Map<String, String> defaultToURI = new HashMap<String, String>();
Map<String, String> defaultToActualCache = new HashMap<String, String>();
Map<String, String> actualToDefaultCache = new HashMap<String, String>();
public NamespaceMapping() {}
- public void addNamespace(String defaultNamespace, String actualNamespace) {
+ public void addNamespace(String defaultNamespace, String actualNamespace, String uri) {
defaultToActual.put(defaultNamespace, actualNamespace);
actualToDefault.put(actualNamespace, defaultNamespace);
+ defaultToURI.put(defaultNamespace, uri);
}
public String getActualNamespace(String defaultNamespace) {
@@ -36,7 +42,16 @@
public String getDefaultNamespace(String actualNamespace) {
return actualToDefault.get(actualNamespace);
}
+
+ public String getURIForDefaultNamespace(String defaultNamespace) {
+ return defaultNamespace == null ? null : defaultToURI.get(defaultNamespace);
+ }
+ public String getURIForActualNamespace(String actualNamespace) {
+ String defaultNamespace = getDefaultNamespace(actualNamespace);
+ return getURIForDefaultNamespace(defaultNamespace);
+ }
+
public String convertToDefault(String name) {
if(name.indexOf(':') < 0) return name;
String value = actualToDefaultCache.get(name);
@@ -99,12 +114,18 @@
while(i.hasNext()) {
String d = i.next();
String a = defaultToActual.get(d);
- sb.append(d).append(' ').append(a).append(' ');
+ String u = defaultToURI.get(d);
+ sb.append(d).append(' ').append(a).append(' ').append(u).append(' ');
}
return sb.toString();
}
-
+
+ public static NamespaceMapping load(XModelObject file) {
+ String nms = file.get(ATTR_NAMESPACE_MAPPING);
+ return nms == null ? null : load(nms);
+ }
+
public static NamespaceMapping load(String s) {
if(s == null || s.length() == 0) return null;
NamespaceMapping m = new NamespaceMapping();
@@ -112,7 +133,8 @@
while(st.hasMoreTokens()) {
String d = st.nextToken();
String a = st.hasMoreTokens() ? st.nextToken() : d;
- m.addNamespace(d, a);
+ String u = st.hasMoreTokens() ? st.nextToken() : "http://";
+ m.addNamespace(d, a, u);
}
return m;
}
17 years, 5 months
JBoss Tools SVN: r11947 - trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/project/facet.
by jbosstools-commits@lists.jboss.org
Author: akazakov
Date: 2008-11-21 10:29:28 -0500 (Fri, 21 Nov 2008)
New Revision: 11947
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/project/facet/ISeamFacetDataModelProperties.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/project/facet/SeamFacetAbstractInstallDelegate.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/project/facet/SeamProjectCreator.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-2967 Fixed
Modified: trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/project/facet/ISeamFacetDataModelProperties.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/project/facet/ISeamFacetDataModelProperties.java 2008-11-21 14:51:05 UTC (rev 11946)
+++ trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/project/facet/ISeamFacetDataModelProperties.java 2008-11-21 15:29:28 UTC (rev 11947)
@@ -277,4 +277,13 @@
*/
String JBOSS_AS_TARGET_RUNTIME = "seam.project.deployment.runtime"; //$NON-NLS-1$
+ /**
+ * Default action source folder name;
+ */
+ String DEFAULT_ACTION_SRC_FOLDER_NAME = "hot"; //$NON-NLS-1$
+
+ /**
+ * Default model source folder name;
+ */
+ String DEFAULT_MODEL_SRC_FOLDER_NAME = "main"; //$NON-NLS-1$
}
\ No newline at end of file
Modified: trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/project/facet/SeamFacetAbstractInstallDelegate.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/project/facet/SeamFacetAbstractInstallDelegate.java 2008-11-21 14:51:05 UTC (rev 11946)
+++ trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/project/facet/SeamFacetAbstractInstallDelegate.java 2008-11-21 15:29:28 UTC (rev 11947)
@@ -321,7 +321,7 @@
webInfClassesMetaInf = new File(webInfClasses, "META-INF"); //$NON-NLS-1$
webInfClassesMetaInf.mkdirs();
webLibFolder = new File(webContentFolder, WEB_LIBRARIES_RELATED_PATH);
- srcFolder = isWarConfiguration(model) ? new File(warSrcRootFolder.getUnderlyingFolder().getLocation().toFile(), "model") : warSrcRootFolder.getUnderlyingFolder().getLocation().toFile(); //$NON-NLS-1$
+ srcFolder = isWarConfiguration(model) ? new File(warSrcRootFolder.getUnderlyingFolder().getLocation().toFile(), DEFAULT_MODEL_SRC_FOLDER_NAME) : warSrcRootFolder.getUnderlyingFolder().getLocation().toFile();
Object runtimeName = model.getProperty(ISeamFacetDataModelProperties.SEAM_RUNTIME_NAME);
if(runtimeName!=null) {
copyFilesToWarProject(project, fv, model, monitor);
@@ -410,8 +410,8 @@
// Copy seam project indicator
// ********************************************************************************************
- IPath actionSrcPath = new Path(source.getFullPath().removeFirstSegments(1) + "/action"); //$NON-NLS-1$
- IPath modelSrcPath = new Path(source.getFullPath().removeFirstSegments(1) + "/model"); //$NON-NLS-1$
+ IPath actionSrcPath = new Path(source.getFullPath().removeFirstSegments(1) + "/" + DEFAULT_ACTION_SRC_FOLDER_NAME); //$NON-NLS-1$
+ IPath modelSrcPath = new Path(source.getFullPath().removeFirstSegments(1) + "/" + DEFAULT_MODEL_SRC_FOLDER_NAME); //$NON-NLS-1$
warSrcRootFolder.delete(IVirtualFolder.FORCE, monitor);
WtpUtils.createSourceFolder(project, actionSrcPath, source.getFullPath().removeFirstSegments(1), webRootFolder.getFullPath().removeFirstSegments(1).append("WEB-INF/dev")); //$NON-NLS-1$
@@ -420,7 +420,7 @@
warSrcRootFolder.createLink(actionSrcPath, 0, null);
warSrcRootFolder.createLink(modelSrcPath, 0, null);
- File actionsSrc = new File(project.getLocation().toFile(), source.getFullPath().removeFirstSegments(1) + "/action/"); //$NON-NLS-1$
+ File actionsSrc = new File(project.getLocation().toFile(), source.getFullPath().removeFirstSegments(1) + "/" + DEFAULT_ACTION_SRC_FOLDER_NAME + "/"); //$NON-NLS-1$
//AntCopyUtils.copyFileToFolder(new File(seamGenResFolder, "seam.properties"), actionsSrc, true); //$NON-NLS-1$
Modified: trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/project/facet/SeamProjectCreator.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/project/facet/SeamProjectCreator.java 2008-11-21 14:51:05 UTC (rev 11946)
+++ trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/project/facet/SeamProjectCreator.java 2008-11-21 15:29:28 UTC (rev 11947)
@@ -473,8 +473,8 @@
IVirtualFolder rootFolder = component.getRootFolder();
IPath srcRootFolder = rootFolder.getFolder(new Path("/WEB-INF/classes")).getUnderlyingFolder().getParent().getFullPath(); //$NON-NLS-1$
- prefs.put(ISeamFacetDataModelProperties.ENTITY_BEAN_SOURCE_FOLDER, srcRootFolder.append("model").toString());
- prefs.put(ISeamFacetDataModelProperties.SESSION_BEAN_SOURCE_FOLDER, srcRootFolder.append("action").toString());
+ prefs.put(ISeamFacetDataModelProperties.ENTITY_BEAN_SOURCE_FOLDER, srcRootFolder.append(ISeamFacetDataModelProperties.DEFAULT_MODEL_SRC_FOLDER_NAME).toString());
+ prefs.put(ISeamFacetDataModelProperties.SESSION_BEAN_SOURCE_FOLDER, srcRootFolder.append(ISeamFacetDataModelProperties.DEFAULT_ACTION_SRC_FOLDER_NAME).toString());
}
try {
17 years, 5 months
JBoss Tools SVN: r11946 - in trunk/seam/plugins/org.jboss.tools.seam.pages.xml: schemas and 1 other directory.
by jbosstools-commits@lists.jboss.org
Author: scabanovich
Date: 2008-11-21 09:51:05 -0500 (Fri, 21 Nov 2008)
New Revision: 11946
Added:
trunk/seam/plugins/org.jboss.tools.seam.pages.xml/schemas/pages-2.1.xsd
Modified:
trunk/seam/plugins/org.jboss.tools.seam.pages.xml/plugin.xml
Log:
pages-2.1.xsd contributed
Modified: trunk/seam/plugins/org.jboss.tools.seam.pages.xml/plugin.xml
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.pages.xml/plugin.xml 2008-11-21 13:53:11 UTC (rev 11945)
+++ trunk/seam/plugins/org.jboss.tools.seam.pages.xml/plugin.xml 2008-11-21 14:51:05 UTC (rev 11946)
@@ -109,6 +109,10 @@
name="http://jboss.com/products/seam/pages-2.0.xsd"
uri="schemas/pages-2.0.xsd"/>
+ <uri
+ name="http://jboss.com/products/seam/pages-2.1.xsd"
+ uri="schemas/pages-2.1.xsd"/>
+
</catalogContribution>
</extension>
</plugin>
\ No newline at end of file
Added: trunk/seam/plugins/org.jboss.tools.seam.pages.xml/schemas/pages-2.1.xsd
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.pages.xml/schemas/pages-2.1.xsd (rev 0)
+++ trunk/seam/plugins/org.jboss.tools.seam.pages.xml/schemas/pages-2.1.xsd 2008-11-21 14:51:05 UTC (rev 11946)
@@ -0,0 +1,613 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
+ elementFormDefault="qualified"
+ targetNamespace="http://jboss.com/products/seam/pages"
+ xmlns:pages="http://jboss.com/products/seam/pages">
+
+ <xs:annotation>
+ <xs:documentation>About this format ...</xs:documentation>
+ </xs:annotation>
+
+ <xs:element name="pages">
+ <xs:annotation>
+ <xs:documentation>The root of a pages.xml file</xs:documentation>
+ </xs:annotation>
+ <xs:complexType>
+ <xs:choice minOccurs="0" maxOccurs="unbounded">
+ <xs:element ref="pages:conversation"/>
+ <xs:element ref="pages:page"/>
+ <xs:element ref="pages:exception"/>
+ </xs:choice>
+ <xs:attributeGroup ref="pages:attlist.pages"/>
+ </xs:complexType>
+ <xs:key name="conversation-key">
+ <xs:annotation>
+ <xs:documentation><p>You can read this as:</p>
+ <p>The pages element has a bunch of conversation elements, and for each of those conversation elements, they must have a unique name within this document.</p>
+ </xs:documentation>
+ </xs:annotation>
+ <xs:selector xpath="conversation"/>
+ <xs:field xpath="name"/>
+ </xs:key>
+ </xs:element>
+
+ <xs:attributeGroup name="attlist.pages">
+ <xs:attribute name="no-conversation-view-id" type="pages:view-id" />
+ <xs:attribute name="login-view-id" type="pages:view-id"/>
+ <xs:attribute name="http-port" type="xs:unsignedLong"/>
+ <xs:attribute name="https-port" type="xs:unsignedLong"/>
+ </xs:attributeGroup>
+
+ <xs:element name="exception">
+ <xs:annotation>
+ <xs:documentation>A Seam exception handler</xs:documentation>
+ </xs:annotation>
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element minOccurs="0" ref="pages:end-conversation"/>
+ <xs:choice>
+ <xs:element ref="pages:http-error"/>
+ <xs:element ref="pages:redirect"/>
+ </xs:choice>
+ </xs:sequence>
+ <xs:attributeGroup ref="pages:attlist.exception"/>
+ </xs:complexType>
+ </xs:element>
+ <xs:attributeGroup name="attlist.exception">
+ <xs:attribute name="class" type="xs:token"/>
+ <xs:attribute name="log" type="pages:tf-boolean"/>
+ <xs:attribute name="logLevel" type="pages:loglevel-values"/>
+ </xs:attributeGroup>
+
+ <xs:element name="conversation">
+ <xs:annotation>
+ <xs:documentation>Natural conversation configuration</xs:documentation>
+ </xs:annotation>
+ <xs:complexType>
+ <xs:attributeGroup ref="pages:attlist.conversation"/>
+ </xs:complexType>
+ </xs:element>
+ <xs:attributeGroup name="attlist.conversation">
+ <xs:attribute name="name" use="required" type="xs:token" />
+ <xs:attribute name="parameter-name" use="required" type="xs:token" />
+ <xs:attribute name="parameter-value" type="xs:token" />
+ </xs:attributeGroup>
+
+ <xs:element name="page">
+ <xs:annotation>
+ <xs:documentation>Configuration for a specific page or set up pages</xs:documentation>
+ </xs:annotation>
+ <xs:complexType>
+ <xs:choice minOccurs="0" maxOccurs="unbounded">
+ <xs:element ref="pages:restrict"/>
+ <xs:element ref="pages:description"/>
+ <xs:element ref="pages:param"/>
+ <xs:element ref="pages:header" />
+ <xs:element ref="pages:rewrite" />
+ <xs:element ref="pages:begin-conversation"/>
+ <xs:element ref="pages:end-conversation"/>
+ <xs:element ref="pages:start-task"/>
+ <xs:element ref="pages:begin-task"/>
+ <xs:element ref="pages:end-task"/>
+ <xs:element ref="pages:create-process"/>
+ <xs:element ref="pages:resume-process"/>
+ <xs:element ref="pages:in"/>
+ <xs:element ref="pages:raise-event"/>
+ <xs:element ref="pages:action"/>
+ <xs:element ref="pages:navigation"/>
+ </xs:choice>
+ <xs:attributeGroup ref="pages:attlist.page"/>
+ </xs:complexType>
+ </xs:element>
+ <xs:attributeGroup name="attlist.page">
+ <xs:attribute name="action" type="xs:token" />
+ <xs:attribute name="view-id" type="pages:view-id"/>
+ <xs:attribute name="switch" default="enabled" type="pages:ableness"/>
+ <xs:attribute name="no-conversation-view-id" type="pages:view-id" />
+ <xs:attribute name="conversation-required" default="false" type="pages:tf-boolean"/>
+ <xs:attribute name="login-required" default="false" type="pages:tf-boolean"/>
+ <xs:attribute name="scheme" type="pages:schemes" />
+ <xs:attribute name="timeout" type="xs:unsignedLong" />
+ <xs:attribute name="concurrent-request-timeout" type="xs:unsignedLong" >
+ <xs:annotation>
+ <xs:documentation>
+ Requests to conversations are serialized by default, and if
+ a lock cannot be acquired in time, the request will be
+ dropped. You can set the timeout on a page-by-page basis
+ here.
+ </xs:documentation>
+ </xs:annotation>
+ </xs:attribute>
+ <xs:attribute name="bundle" type="xs:token" />
+ <xs:attribute name="conversation" type="xs:token" />
+ <xs:attribute name="expires" type="xs:unsignedLong" />
+ </xs:attributeGroup>
+
+ <xs:element name="param">
+ <xs:annotation>
+ <xs:documentation>A page parameter</xs:documentation>
+ </xs:annotation>
+ <xs:complexType>
+ <xs:attributeGroup ref="pages:attlist.param"/>
+ </xs:complexType>
+ </xs:element>
+
+ <xs:attributeGroup name="attlist.param">
+ <xs:attribute name="name" type="xs:token" />
+ <xs:attribute name="value" type="xs:token" />
+ <xs:attribute name="converter" type="xs:token" />
+ <xs:attribute name="converterId" type="xs:token" />
+ <xs:attribute name="validator" type="xs:token" />
+ <xs:attribute name="validatorId" type="xs:token" />
+ <xs:attribute name="required" type="pages:tf-boolean"/>
+ </xs:attributeGroup>
+
+ <xs:element name="header">
+ <xs:annotation>
+ <xs:documentation>HTTP headers to be added</xs:documentation>
+ </xs:annotation>
+ <xs:complexType>
+ <xs:attributeGroup ref="pages:attlist.header"/>
+ </xs:complexType>
+ </xs:element>
+
+ <xs:attributeGroup name="attlist.header">
+ <xs:attribute name="name" use="required" type="xs:token" />
+ <xs:attribute name="value" type="xs:token" />
+ </xs:attributeGroup>
+
+ <xs:element name="rewrite">
+ <xs:annotation>
+ <xs:documentation>URL rewriting pattern for this view</xs:documentation>
+ </xs:annotation>
+ <xs:complexType>
+ <xs:attributeGroup ref="pages:attlist.rewrite"/>
+ </xs:complexType>
+ </xs:element>
+
+ <xs:attributeGroup name="attlist.rewrite">
+ <xs:attribute name="pattern" use="required" type="xs:token" />
+ </xs:attributeGroup>
+
+ <xs:element name="action">
+ <xs:annotation>
+ <xs:documentation>Page action</xs:documentation>
+ </xs:annotation>
+ <xs:complexType>
+ <xs:attributeGroup ref="pages:attlist.action"/>
+ </xs:complexType>
+ </xs:element>
+ <xs:attributeGroup name="attlist.action">
+ <xs:attribute name="if" type="pages:boolean-value-expression" />
+ <xs:attribute name="on-postback" default="true" type="pages:tf-boolean"/>
+ <xs:attribute name="execute" use="required" type="pages:method-expression" />
+ </xs:attributeGroup>
+
+ <xs:element name="restrict" type="pages:value-expression">
+ <xs:annotation>
+ <xs:documentation>Security restrictions</xs:documentation>
+ </xs:annotation>
+ </xs:element>
+
+ <xs:element name="navigation">
+ <xs:annotation>
+ <xs:documentation>Page navigation</xs:documentation>
+ </xs:annotation>
+ <xs:complexType>
+ <xs:choice maxOccurs="2">
+ <xs:sequence>
+ <xs:choice minOccurs="0">
+ <xs:element ref="pages:begin-conversation"/>
+ <xs:element ref="pages:end-conversation"/>
+ <xs:element ref="pages:start-task"/>
+ <xs:element ref="pages:begin-task"/>
+ <xs:element ref="pages:end-task"/>
+ <xs:element ref="pages:create-process"/>
+ <xs:element ref="pages:resume-process"/>
+ </xs:choice>
+ <xs:element minOccurs="0" maxOccurs="unbounded" ref="pages:out"/>
+ <xs:element minOccurs="0" ref="pages:raise-event" maxOccurs="1"/>
+ <xs:choice minOccurs="0">
+ <xs:element ref="pages:render"/>
+ <xs:element ref="pages:redirect"/>
+ </xs:choice>
+ </xs:sequence>
+ <xs:element minOccurs="0" maxOccurs="unbounded" ref="pages:rule"/>
+ </xs:choice>
+ <xs:attributeGroup ref="pages:attlist.navigation"/>
+ </xs:complexType>
+ </xs:element>
+ <xs:attributeGroup name="attlist.navigation">
+ <xs:attribute name="from-action" type="pages:method-expression" />
+ <xs:attribute name="evaluate" type="pages:method-expression" />
+ </xs:attributeGroup>
+
+ <xs:element name="rule">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:choice minOccurs="0">
+ <xs:element ref="pages:begin-conversation"/>
+ <xs:element ref="pages:end-conversation"/>
+ <xs:element ref="pages:start-task"/>
+ <xs:element ref="pages:begin-task"/>
+ <xs:element ref="pages:end-task"/>
+ <xs:element ref="pages:create-process"/>
+ <xs:element ref="pages:resume-process"/>
+ </xs:choice>
+ <xs:element minOccurs="0" maxOccurs="unbounded" ref="pages:out"/>
+ <xs:element minOccurs="0" ref="pages:raise-event"/>
+ <xs:choice minOccurs="0">
+ <xs:element ref="pages:render"/>
+ <xs:element ref="pages:redirect"/>
+ </xs:choice>
+ </xs:sequence>
+ <xs:attributeGroup ref="pages:attlist.rule"/>
+ </xs:complexType>
+ </xs:element>
+ <xs:attributeGroup name="attlist.rule">
+ <xs:attribute name="if-outcome" type="pages:value-expression" />
+ <xs:attribute name="if" type="pages:boolean-value-expression" />
+ </xs:attributeGroup>
+
+ <xs:element name="raise-event">
+ <xs:annotation>
+ <xs:documentation>Event to be raised</xs:documentation>
+ </xs:annotation>
+ <xs:complexType>
+ <xs:attributeGroup ref="pages:attlist.raise-event"/>
+ </xs:complexType>
+ </xs:element>
+ <xs:attributeGroup name="attlist.raise-event">
+ <xs:attribute name="type" use="required" type="xs:token" />
+ </xs:attributeGroup>
+
+ <xs:element name="begin-conversation">
+ <xs:annotation>
+ <xs:documentation>This page begins a new conversation</xs:documentation>
+ </xs:annotation>
+ <xs:complexType>
+ <xs:attributeGroup ref="pages:attlist.begin-conversation"/>
+ </xs:complexType>
+ </xs:element>
+ <xs:attributeGroup name="attlist.begin-conversation">
+ <xs:attribute name="join" default="false" type="pages:tf-boolean"/>
+ <xs:attribute name="nested" default="false" type="pages:tf-boolean"/>
+ <xs:attribute name="pageflow" type="xs:token" />
+ <xs:attribute name="flush-mode" type="pages:flush-modes" />
+ <xs:attribute name="if" type="pages:boolean-value-expression" />
+ <xs:attribute name="conversation" type="xs:token" />
+ </xs:attributeGroup>
+
+ <xs:element name="end-conversation">
+ <xs:annotation>
+ <xs:documentation>This page ends a conversation</xs:documentation>
+ </xs:annotation>
+ <xs:complexType>
+ <xs:attributeGroup ref="pages:attlist.end-conversation"/>
+ </xs:complexType>
+ </xs:element>
+ <xs:attributeGroup name="attlist.end-conversation">
+ <xs:attribute name="before-redirect" default="false" type="pages:tf-boolean"/>
+ <xs:attribute name="root" default="false" type="pages:tf-boolean"/>
+ <xs:attribute name="if" type="pages:boolean-value-expression" />
+ </xs:attributeGroup>
+
+ <xs:element name="begin-task">
+ <xs:annotation>
+ <xs:documentation>Begin a BPM task</xs:documentation>
+ </xs:annotation>
+ <xs:complexType>
+ <xs:attributeGroup ref="pages:attlist.begin-task"/>
+ </xs:complexType>
+ </xs:element>
+ <xs:attributeGroup name="attlist.begin-task">
+ <xs:attribute name="task-id" type="xs:token" />
+ <xs:attribute name="pageflow" type="xs:token" />
+ <xs:attribute name="flush-mode" type="pages:flush-modes" />
+ </xs:attributeGroup>
+
+ <xs:element name="start-task">
+ <xs:annotation>
+ <xs:documentation>Start a BPM task</xs:documentation>
+ </xs:annotation>
+ <xs:complexType>
+ <xs:attributeGroup ref="pages:attlist.start-task"/>
+ </xs:complexType>
+ </xs:element>
+ <xs:attributeGroup name="attlist.start-task">
+ <xs:attribute name="task-id" type="xs:token" />
+ <xs:attribute name="pageflow" type="xs:token" />
+ <xs:attribute name="flush-mode" type="pages:flush-modes" />
+ </xs:attributeGroup>
+
+ <xs:element name="end-task">
+ <xs:annotation>
+ <xs:documentation>Add a BPM task</xs:documentation>
+ </xs:annotation>
+ <xs:complexType>
+ <xs:attributeGroup ref="pages:attlist.end-task"/>
+ </xs:complexType>
+ </xs:element>
+ <xs:attributeGroup name="attlist.end-task">
+ <xs:attribute name="transition" type="xs:token" />
+ <xs:attribute name="before-redirect" default="false" type="pages:tf-boolean" />
+ </xs:attributeGroup>
+
+ <xs:element name="create-process">
+ <xs:annotation>
+ <xs:documentation>Create a BPM process</xs:documentation>
+ </xs:annotation>
+ <xs:complexType>
+ <xs:attributeGroup ref="pages:attlist.create-process"/>
+ </xs:complexType>
+ </xs:element>
+ <xs:attributeGroup name="attlist.create-process">
+ <xs:attribute name="definition" type="xs:token" />
+ </xs:attributeGroup>
+
+ <xs:element name="resume-process">
+ <xs:annotation>
+ <xs:documentation>Resume a BPM process instance</xs:documentation>
+ </xs:annotation>
+ <xs:complexType>
+ <xs:attributeGroup ref="pages:attlist.resume-process"/>
+ </xs:complexType>
+ </xs:element>
+ <xs:attributeGroup name="attlist.resume-process">
+ <xs:attribute name="process-id" type="xs:token" />
+ </xs:attributeGroup>
+
+ <xs:element name="in">
+ <xs:annotation>
+ <xs:documentation>A page input</xs:documentation>
+ </xs:annotation>
+ <xs:complexType>
+ <xs:attributeGroup ref="pages:attlist.in"/>
+ </xs:complexType>
+ </xs:element>
+ <xs:attributeGroup name="attlist.in">
+ <xs:attribute name="name" use="required" type="xs:token" />
+ <xs:attribute name="scope" type="pages:allowed-scopes" />
+ <xs:attribute name="value" use="required" type="xs:token" />
+ </xs:attributeGroup>
+
+ <xs:element name="out">
+ <xs:annotation>
+ <xs:documentation>A contextual output for a navigation rule</xs:documentation>
+ </xs:annotation>
+ <xs:complexType>
+ <xs:attributeGroup ref="pages:attlist.out"/>
+ </xs:complexType>
+ </xs:element>
+ <xs:attributeGroup name="attlist.out">
+ <xs:attribute name="name" use="required" type="xs:token" />
+ <xs:attribute name="scope" default="CONVERSATION" type="pages:allowed-scopes" />
+ <xs:attribute name="value" use="required" type="xs:token" />
+ </xs:attributeGroup>
+
+ <xs:element name="render">
+ <xs:annotation>
+ <xs:documentation>Render a view</xs:documentation>
+ </xs:annotation>
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element minOccurs="0" ref="pages:message"/>
+ </xs:sequence>
+ <xs:attributeGroup ref="pages:attlist.render"/>
+ </xs:complexType>
+ </xs:element>
+ <xs:attributeGroup name="attlist.render">
+ <xs:attribute name="view-id" type="pages:view-id" />
+ </xs:attributeGroup>
+
+ <xs:element name="redirect">
+ <xs:annotation>
+ <xs:documentation>Redirect to another view or URL</xs:documentation>
+ </xs:annotation>
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element minOccurs="0" ref="pages:message"/>
+ <xs:element minOccurs="0" maxOccurs="unbounded" ref="pages:param"/>
+ </xs:sequence>
+
+ <xs:attributeGroup ref="pages:attlist.redirect"/>
+ </xs:complexType>
+ </xs:element>
+ <xs:attributeGroup name="attlist.redirect">
+ <xs:attribute name="view-id" type="pages:view-id" />
+ <xs:attribute name="url" type="pages:url" />
+ </xs:attributeGroup>
+
+ <xs:element name="http-error">
+ <xs:annotation>
+ <xs:documentation>Send an HTTP error code</xs:documentation>
+ </xs:annotation>
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element minOccurs="0" ref="pages:message"/>
+ </xs:sequence>
+ <xs:attributeGroup ref="pages:attlist.http-error"/>
+ </xs:complexType>
+ </xs:element>
+ <xs:attributeGroup name="attlist.http-error">
+ <xs:attribute name="error-code" use="required" type="xs:unsignedLong" />
+ </xs:attributeGroup>
+
+ <xs:element name="message">
+ <xs:annotation>
+ <xs:documentation>Add a message to the faces messages</xs:documentation>
+ </xs:annotation>
+ <xs:complexType>
+ <xs:simpleContent>
+ <xs:extension base="xs:string">
+ <xs:attributeGroup ref="pages:attlist.message"/>
+ </xs:extension>
+ </xs:simpleContent>
+ </xs:complexType>
+ </xs:element>
+ <xs:attributeGroup name="attlist.message">
+ <xs:attribute name="for" type="xs:token"/>
+ <xs:attribute name="severity" default="INFO" type="pages:loglevel-values" />
+ </xs:attributeGroup>
+
+ <xs:element name="description" type="xs:string">
+ <xs:annotation>
+ <xs:documentation>A page description for workflow switching</xs:documentation>
+ </xs:annotation>
+ </xs:element>
+
+ <xs:simpleType name="url">
+ <xs:restriction base="xs:token">
+ <xs:pattern value="http://.*|https://.*"/>
+ </xs:restriction>
+ </xs:simpleType>
+
+ <xs:simpleType name="schemes">
+ <xs:restriction base="xs:token">
+ <xs:enumeration value="https"/>
+ <xs:enumeration value="http"/>
+ </xs:restriction>
+ </xs:simpleType>
+
+ <xs:simpleType name="view-id">
+ <xs:restriction base="xs:string">
+ <xs:pattern value="(/.*)|\*"/>
+ </xs:restriction>
+ </xs:simpleType>
+
+ <xs:simpleType name="ableness">
+ <xs:restriction base="xs:token">
+ <xs:enumeration value="enabled"/>
+ <xs:enumeration value="disabled"/>
+ </xs:restriction>
+ </xs:simpleType>
+
+ <xs:simpleType name="tf-boolean">
+ <xs:annotation>
+ <xs:documentation>
+ <p>Allows for the following values:</p>
+ <ul>
+ <li>true</li>
+ <li>false</li>
+ </ul>
+ </xs:documentation>
+ </xs:annotation>
+ <xs:restriction base="xs:boolean">
+ <xs:pattern value="true"/>
+ <xs:pattern value="false"/>
+ </xs:restriction>
+ </xs:simpleType>
+
+ <xs:simpleType name="allowed-scopes">
+ <xs:restriction base="xs:token">
+ <xs:enumeration value="stateless"/>
+ <xs:enumeration value="event"/>
+ <xs:enumeration value="page"/>
+ <xs:enumeration value="conversation"/>
+ <xs:enumeration value="session"/>
+ <xs:enumeration value="business_process"/>
+ <xs:enumeration value="application"/>
+ <xs:enumeration value="STATELESS"/>
+ <xs:enumeration value="EVENT"/>
+ <xs:enumeration value="PAGE"/>
+ <xs:enumeration value="CONVERSATION"/>
+ <xs:enumeration value="SESSION"/>
+ <xs:enumeration value="BUSINESS_PROCESS"/>
+ <xs:enumeration value="APPLICATION"/>
+ </xs:restriction>
+ </xs:simpleType>
+
+ <xs:simpleType name="loglevel-values">
+ <xs:restriction base="xs:token">
+ <xs:enumeration value="info"/>
+ <xs:enumeration value="warn"/>
+ <xs:enumeration value="error"/>
+ <xs:enumeration value="fatal"/>
+ <xs:enumeration value="debug"/>
+ <xs:enumeration value="trace"/>
+ <xs:enumeration value="INFO"/>
+ <xs:enumeration value="WARN"/>
+ <xs:enumeration value="ERROR"/>
+ <xs:enumeration value="FATAL"/>
+ <xs:enumeration value="DEBUG"/>
+ <xs:enumeration value="TRACE"/>
+ </xs:restriction>
+ </xs:simpleType>
+
+ <xs:simpleType name="http-error-codes">
+ <xs:annotation>
+ <xs:documentation><p><b>Note:</b> These do not include the HTTP extensions.</p></xs:documentation>
+ </xs:annotation>
+ <xs:restriction base="xs:token">
+ <xs:enumeration value="100"/>
+ <xs:enumeration value="101"/>
+ <xs:enumeration value="200"/>
+ <xs:enumeration value="201"/>
+ <xs:enumeration value="202"/>
+ <xs:enumeration value="203"/>
+ <xs:enumeration value="204"/>
+ <xs:enumeration value="205"/>
+ <xs:enumeration value="206"/>
+ <xs:enumeration value="300"/>
+ <xs:enumeration value="301"/>
+ <xs:enumeration value="302"/>
+ <xs:enumeration value="303"/>
+ <xs:enumeration value="304"/>
+ <xs:enumeration value="305"/>
+ <xs:enumeration value="306"/>
+ <xs:enumeration value="307"/>
+ <xs:enumeration value="400"/>
+ <xs:enumeration value="401"/>
+ <xs:enumeration value="402"/>
+ <xs:enumeration value="403"/>
+ <xs:enumeration value="404"/>
+ <xs:enumeration value="405"/>
+ <xs:enumeration value="406"/>
+ <xs:enumeration value="407"/>
+ <xs:enumeration value="408"/>
+ <xs:enumeration value="409"/>
+ <xs:enumeration value="410"/>
+ <xs:enumeration value="411"/>
+ <xs:enumeration value="412"/>
+ <xs:enumeration value="413"/>
+ <xs:enumeration value="414"/>
+ <xs:enumeration value="415"/>
+ <xs:enumeration value="416"/>
+ <xs:enumeration value="417"/>
+ <xs:enumeration value="500"/>
+ <xs:enumeration value="501"/>
+ <xs:enumeration value="502"/>
+ <xs:enumeration value="503"/>
+ <xs:enumeration value="504"/>
+ <xs:enumeration value="505"/>
+ </xs:restriction>
+ </xs:simpleType>
+
+ <xs:simpleType name="flush-modes">
+ <xs:restriction base="xs:token">
+ <xs:enumeration value="manual"/>
+ <xs:enumeration value="auto"/>
+ <xs:enumeration value="commit"/>
+ <xs:enumeration value="MANUAL"/>
+ <xs:enumeration value="AUTO"/>
+ <xs:enumeration value="COMMIT"/>
+ </xs:restriction>
+ </xs:simpleType>
+
+ <xs:simpleType name="method-expression">
+ <xs:restriction base="xs:token">
+ <xs:pattern value="#\{.*\}"/>
+ </xs:restriction>
+ </xs:simpleType>
+
+ <xs:simpleType name="value-expression">
+ <xs:restriction base="xs:token"/>
+ </xs:simpleType>
+
+ <xs:simpleType name="boolean-value-expression">
+ <xs:restriction base="xs:token">
+ <xs:pattern value="true|false|#\{.*\}"/>
+ </xs:restriction>
+ </xs:simpleType>
+
+</xs:schema>
17 years, 5 months
JBoss Tools SVN: r11945 - in trunk/jst/plugins: org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline and 5 other directories.
by jbosstools-commits@lists.jboss.org
Author: izhukov
Date: 2008-11-21 08:53:11 -0500 (Fri, 21 Nov 2008)
New Revision: 11945
Added:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/common/Selector.java
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/events/ManualChangeStyleListener.java
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/events/MessageDialogEvent.java
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/events/MessageDialogListener.java
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/tabs/TabPreviewControl.java
Modified:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/messages/JstUIMessages.java
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/messages/messages.properties
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/JSPDialogCellEditor.java
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/JSPPropertySourceAdapter.java
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/CSSConstants.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/Constants.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/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
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/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
trunk/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/wizards/css/NewCSSClassWizard.java
Log:
CSS Style Dialog refactoring
Modified: trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/messages/JstUIMessages.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/messages/JstUIMessages.java 2008-11-21 10:35:47 UTC (rev 11944)
+++ trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/messages/JstUIMessages.java 2008-11-21 13:53:11 UTC (rev 11945)
@@ -46,6 +46,7 @@
public static String CSS_CLASS_DIALOG_FILE_LABEL;
public static String CSS_BROWSE_BUTTON_TOOLTIP;
public static String CSS_CLASS_DIALOG_STYLE_CLASS_LABEL;
+ public static String CSS_CLEAR_STYLE_SHEET;
public static String ADD_FONT_FAMILY_TIP;
public static String REMOVE_FONT_FAMILY_TIP;
public static String FONT_SIZE;
@@ -86,4 +87,6 @@
public static String COLOR_TIP;
public static String TEXT_DECORATION;
public static String TEXT_ALIGN;
+ public static String BUTTON_CLEAR;
+ public static String PREVIEW_SHEET_TAB_NAME;
}
Modified: trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/messages/messages.properties
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/messages/messages.properties 2008-11-21 10:35:47 UTC (rev 11944)
+++ trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/messages/messages.properties 2008-11-21 13:53:11 UTC (rev 11945)
@@ -8,10 +8,13 @@
CSS_CLASS_DIALOG_STYLE_CLASS_LABEL=Style class:
CSS_BROWSE_BUTTON_TOOLTIP=Browse
+CSS_CLEAR_STYLE_SHEET=Clear style sheet
+
ADD_FONT_FAMILY_TIP=Add font family
REMOVE_FONT_FAMILY_TIP=Remove font family
FONT_FAMILY_DIALOG_TITLE=Choose font family
+BUTTON_CLEAR=Clear
IMAGE_COMBO_TABLE_TOOL_TIP=Double click to select color
@@ -35,6 +38,7 @@
BOXES_TAB_NAME=Boxes
PROPERTY_SHEET_TAB_NAME=Property Sheet
QUICK_EDIT_TAB_NAME=Quick Edit
+PREVIEW_SHEET_TAB_NAME=Preview
TEXT_DECORATION=Text Decoration:
TEXT_ALIGN=Text Align:
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-11-21 10:35:47 UTC (rev 11944)
+++ trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/JSPDialogCellEditor.java 2008-11-21 13:53:11 UTC (rev 11945)
@@ -28,129 +28,158 @@
import org.jboss.tools.jst.jsp.drop.treeviewer.model.RootElement;
import org.jboss.tools.jst.jsp.outline.cssdialog.CSSClassDialog;
import org.jboss.tools.jst.jsp.outline.cssdialog.CSSStyleDialog;
+import org.jboss.tools.jst.jsp.outline.cssdialog.common.CSSConstants;
+import org.jboss.tools.jst.jsp.outline.cssdialog.common.Constants;
/**
* @author Kabanovich Cell Editor for JSP attributes, of which values can be
* provided by prompting knoledgebase.
*/
+public class JSPDialogCellEditor extends DialogCellEditorEx implements ExtendedCellEditorProvider.StoppableCellEditor {
+ Properties context;
-public class JSPDialogCellEditor extends DialogCellEditorEx implements
- ExtendedCellEditorProvider.StoppableCellEditor {
- Properties context;
// ValueHelper valueHelper;
JSPDialogCellEditorContentAssistProcessor contentAssistentProcessor;
ContentAssistHandler handler = null;
-
boolean hasProposals = false;
-
+ /**
+ * Constructor.
+ * @param parent
+ * @param context
+ */
public JSPDialogCellEditor(Composite parent, Properties context) {
- super(parent);
- this.context = context;
- ValueHelper valueHelper = (ValueHelper) context.get("valueHelper");
+ super(parent);
+ this.context = context;
- contentAssistentProcessor = new JSPDialogCellEditorContentAssistProcessor();
- if (valueHelper != null)
- contentAssistentProcessor.setContext(context);
- handler = ContentAssistHandler.createHandlerForText(getTextField(),
- ControlContentAssistHelper
- .createJavaContentAssistant(contentAssistentProcessor));
+ ValueHelper valueHelper = (ValueHelper) context.get("valueHelper");
+
+ contentAssistentProcessor = new JSPDialogCellEditorContentAssistProcessor();
+
+ if (valueHelper != null) {
+ contentAssistentProcessor.setContext(context);
+ }
+
+ handler = ContentAssistHandler.createHandlerForText(getTextField(),
+ ControlContentAssistHelper.createJavaContentAssistant(contentAssistentProcessor));
}
public void activate() {
- checkHasProposals();
- checkButtonEnablement();
- super.activate();
+ checkHasProposals();
+ checkButtonEnablement();
+ super.activate();
}
- void checkHasProposals() {
- hasProposals = false;
- if (context == null)
- return;
- // valueHelper = (ValueHelper)context.get("valueHelper");
- // if(valueHelper == null) return;
- ValueHelper valueHelper = new ValueHelper();
- String attributeName = "" + context.getProperty("attributeName");
- String nodeName = "" + context.getProperty("nodeName");
- String query = "/";
- if (valueHelper.isFacetets() && nodeName.indexOf(':') < 0) {
- query += FaceletsHtmlContentAssistProcessor.faceletHtmlPrefixStart;
- }
- query += nodeName + "@" + attributeName;
- RootElement root = (RootElement) valueHelper.getInitalInput(query);
- hasProposals = (root != null && root.getChildren().length > 0) || attributeName.equals("style");
+ private void checkHasProposals() {
+ hasProposals = false;
+
+ if (context == null) {
+ return;
+ }
+
+ // valueHelper = (ValueHelper)context.get("valueHelper");
+ // if(valueHelper == null) return;
+ ValueHelper valueHelper = new ValueHelper();
+ String attributeName = Constants.EMPTY + context.getProperty("attributeName");
+ String nodeName = Constants.EMPTY + context.getProperty("nodeName");
+ String query = Constants.SLASH;
+
+ if (valueHelper.isFacetets() && (nodeName.indexOf(':') < 0)) {
+ query += FaceletsHtmlContentAssistProcessor.faceletHtmlPrefixStart;
+ }
+
+ query += (nodeName + "@" + attributeName);
+
+ RootElement root = (RootElement) valueHelper.getInitalInput(query);
+ hasProposals = ((root != null) && (root.getChildren().length > 0))
+ || attributeName.equalsIgnoreCase(CSSConstants.STYLE)
+ || attributeName.equalsIgnoreCase(CSSConstants.CLASS);
}
private void checkButtonEnablement() {
- if (context == null)
- return;
- // valueHelper = (ValueHelper)context.get("valueHelper");
- // if(valueHelper == null) return;
- ValueHelper valueHelper = new ValueHelper();
- Button button = getButtonControl();
- if (button == null || button.isDisposed())
- return;
- button.setVisible(hasProposals);
- handler.setEnabled(hasProposals);
+ if (context == null) {
+ return;
+ }
+
+// valueHelper = (ValueHelper)context.get("valueHelper");
+// if(valueHelper == null) return;
+// ValueHelper valueHelper = new ValueHelper();
+ Button button = getButtonControl();
+
+ if ((button == null) || button.isDisposed()) {
+ return;
+ }
+
+ button.setVisible(hasProposals);
+ handler.setEnabled(hasProposals);
}
protected Object openDialogBox(Control cellEditorWindow) {
- externalEditing = true;
- String attributeName = "" + context.getProperty("attributeName");
- String nodeName = "" + context.getProperty("nodeName");
- String query = "/";
- ValueHelper valueHelper = new ValueHelper();
- if (valueHelper != null && valueHelper.isFacetets()
- && nodeName.indexOf(":") < 0) {
- query += FaceletsHtmlContentAssistProcessor.faceletHtmlPrefixStart;
- }
- query += nodeName + "@" + attributeName;
- context.setProperty("query", query);
- context.setProperty("help", query);
- context.setProperty("title", "Edit "
- + WizardKeys.toDisplayName(attributeName));
- context.setProperty("subtitle", "<" + context.getProperty("nodeName")
- + ">");
+ externalEditing = true;
- String value = (getValue() instanceof String) ? getValue().toString()
- : getValue() instanceof AttributeWrapper ? ((AttributeWrapper) getValue()).value
- : "";
+ String attributeName = Constants.EMPTY + context.getProperty("attributeName");
+ String nodeName = Constants.EMPTY + context.getProperty("nodeName");
+ String query = Constants.SLASH;
+ ValueHelper valueHelper = new ValueHelper();
- context.put("value", value);
- 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 if (attributeName.endsWith("Class") || attributeName.endsWith("class") ) {
- CSSClassDialog dialog = new CSSClassDialog(cellEditorWindow.getShell(),false);
- if (dialog.open() == Window.OK) {
- externalEditing = false;
- return dialog.getSelectorName();
- }
- }
- else {
+ if ((valueHelper != null) && valueHelper.isFacetets() && (nodeName.indexOf(Constants.COLON) < 0)) {
+ query += FaceletsHtmlContentAssistProcessor.faceletHtmlPrefixStart;
+ }
- JSPTreeDialog dialog = new JSPTreeDialog();
- dialog.setObject(context);
- if (dialog.execute() != 0) {
- externalEditing = false;
- return null;
- }
- }
- externalEditing = false;
- value = context.getProperty("value");
- return value;
+ query += (nodeName + "@" + attributeName);
+ context.setProperty("query", query);
+ context.setProperty("help", query);
+ context.setProperty("title", "Edit " + WizardKeys.toDisplayName(attributeName));
+ context.setProperty("subtitle", "<" + context.getProperty("nodeName") + ">");
+
+ String value = (getValue() instanceof String) ? getValue().toString()
+ : ((getValue() instanceof AttributeWrapper)
+ ? ((AttributeWrapper) getValue()).value : Constants.EMPTY);
+
+ context.put("value", value);
+
+ if (attributeName.equalsIgnoreCase(CSSConstants.STYLE)
+ || attributeName.endsWith(CSSConstants.STYLE.toLowerCase())) {
+ CSSStyleDialog dialog = new CSSStyleDialog(cellEditorWindow.getShell(),
+ ((value == null) ? Constants.EMPTY : value));
+
+ if (dialog.open() == Window.OK) {
+ externalEditing = false;
+
+ return dialog.getNewStyle();
+ }
+ } else if (attributeName.equalsIgnoreCase(CSSConstants.CLASS)
+ || attributeName.endsWith(CSSConstants.CLASS.toLowerCase())) {
+ CSSClassDialog dialog = new CSSClassDialog(cellEditorWindow.getShell(), null, false);
+ dialog.setCurrentStyleClass(value);
+
+ if (dialog.open() == Window.OK) {
+ externalEditing = false;
+
+ return dialog.getSelectorName();
+ }
+ } else {
+ JSPTreeDialog dialog = new JSPTreeDialog();
+ dialog.setObject(context);
+
+ if (dialog.execute() != 0) {
+ externalEditing = false;
+
+ return null;
+ }
+ }
+
+ externalEditing = false;
+ value = context.getProperty("value");
+
+ return value;
}
public void stopEditing() {
- super.fireApplyEditorValue();
+ super.fireApplyEditorValue();
}
protected Text getTextField() {
- return text;
+ return text;
}
}
Modified: trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/JSPPropertySourceAdapter.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/JSPPropertySourceAdapter.java 2008-11-21 10:35:47 UTC (rev 11944)
+++ trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/JSPPropertySourceAdapter.java 2008-11-21 13:53:11 UTC (rev 11945)
@@ -157,7 +157,9 @@
} else {
if (namesLow.contains(attrName.toLowerCase())) continue;
}
- if(valueHelper.isAvailable(getQuery(attrName)) || attrName.equals("style")) {
+ if(valueHelper.isAvailable(getQuery(attrName))
+ || attrName.equals("style")
+ || attrName.equals("class")) {
descriptor = createJSPPropertyDescriptor(d, attrName, false);
} else {
descriptor = createTextPropertyDescriptor(attrName, CATEGORY_ATTRIBUTES, 0);
Modified: trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/CSSClassDialog.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/CSSClassDialog.java 2008-11-21 10:35:47 UTC (rev 11944)
+++ trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/CSSClassDialog.java 2008-11-21 13:53:11 UTC (rev 11945)
@@ -10,27 +10,37 @@
******************************************************************************/
package org.jboss.tools.jst.jsp.outline.cssdialog;
+import java.util.ArrayList;
+import java.util.Iterator;
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.core.resources.IWorkspace;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.core.resources.IWorkspaceRoot;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.dialogs.TitleAreaDialog;
import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.window.Window;
+import org.eclipse.jface.wizard.WizardPage;
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.FocusEvent;
+import org.eclipse.swt.events.FocusListener;
+import org.eclipse.swt.events.KeyAdapter;
+import org.eclipse.swt.events.KeyEvent;
import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.events.MouseEvent;
+import org.eclipse.swt.events.MouseListener;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
@@ -39,69 +49,195 @@
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
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.dialogs.ElementTreeSelectionDialog;
import org.eclipse.ui.model.BaseWorkbenchContentProvider;
import org.eclipse.ui.model.WorkbenchLabelProvider;
+import org.jboss.tools.common.model.ui.widgets.Split;
import org.jboss.tools.jst.jsp.JspEditorPlugin;
import org.jboss.tools.jst.jsp.messages.JstUIMessages;
import org.jboss.tools.jst.jsp.outline.cssdialog.common.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.Selector;
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.ManualChangeStyleListener;
+import org.jboss.tools.jst.jsp.outline.cssdialog.events.MessageDialogEvent;
+import org.jboss.tools.jst.jsp.outline.cssdialog.events.MessageDialogListener;
import org.jboss.tools.jst.jsp.outline.cssdialog.events.StyleAttributes;
/**
* This dialog represents CSSClass dialog.
*/
-public class CSSClassDialog extends Dialog {
+public class CSSClassDialog extends TitleAreaDialog implements MouseListener, FocusListener {
- final static int MIN_HEIGHT_FOR_BROWSER = 60;
+ // TODO: take out to the property manager file
+ public final static String WIZARD_TITLE = "CSS Class";
+ public final static String WIZARD_DESCRIPTION = "Create New CSS Class.";
+ public final static String EMPTY_CSS_FILE_PATH_MESSAGE = "Choose any CSS file";
+ public final static String EMPTY_STYLE_CLASS_MESSAGE = "Style class is empty";
- final static String[] fileExtensions = { "css" }; //$NON-NLS-1$
+ private static final String CSS_FILE_EXTENTION = "css"; //$NON-NLS-1$
+ final static String[] fileExtensions = { CSS_FILE_EXTENTION };
final static String SKIP_FIRST_CHAR = "."; //$NON-NLS-1$
+ private Composite browserContainer = null;
private Browser browser = null;
+ private Text textBrowser = null;
+ private String previewBrowserValue = Constants.TEXT_FOR_PREVIEW;
+
private StyleComposite styleComposite = null;
private StyleAttributes styleAttributes = null;
+ // css file path
private Text text;
- private IFile file;
+ // css style classes
private Combo classCombo;
+
+ // model is the core of the CSS Class Dialog, it manages style attributes
private CSSModel cssModel;
- private String selectorName;
- private boolean allProject;
+ // file is "current" in case of the following priority order:
+ // 1 - this is selected css file in eclipse project tree
+ // 2 - this is opened and active css file
+ private IFile currentFile;
+ private String currentClassStyle = null;
+
+ // workbench selection when the wizard was started
+ protected IStructuredSelection selection;
+
+ private boolean styleChanged = false;
+
+ // Status variables for the possible errors on this page.
+ // 1. timeStatus holds an error if CSS file is not specified
+ private IStatus filePathStatus = null;
+ // 2. holds an error if the destination class style is empty
+ private IStatus classNameStatus = null;
+
+ // an array of subscribed message dialog listener
+ private ArrayList<MessageDialogListener> errorListeners = new ArrayList<MessageDialogListener>();
+
+ private final boolean callFromWizard;
+
/**
* Constructor.
*
* @param parentShell Shell object
* @param allProject (if allProject is true - browse css file in all projects, else only in current project)
+ * @param callFromWizard indicates if CSS dialog is created within Wizard page
*/
- public CSSClassDialog(Shell parentShell, boolean allProject) {
+ public CSSClassDialog(Shell parentShell, IStructuredSelection selection, boolean callFromWizard) {
super(parentShell);
- this.allProject = allProject;
+
setShellStyle(getShellStyle() | SWT.RESIZE | SWT.MAX | SWT.APPLICATION_MODAL);
+
+ filePathStatus = new Status(IStatus.ERROR, "not_used", 0, EMPTY_CSS_FILE_PATH_MESSAGE, null); //$NON-NLS-1$
+ classNameStatus = new Status(IStatus.ERROR, "not_used", 0, EMPTY_STYLE_CLASS_MESSAGE, null); //$NON-NLS-1$
+
styleAttributes = new StyleAttributes();
+ this.callFromWizard = callFromWizard;
+ this.selection = selection;
+ init();
}
/**
+ * Initialize method.
+ */
+ private void init() {
+ if (selection != null && !selection.isEmpty()) {
+ for (Iterator<?> iterator = selection.iterator(); iterator.hasNext();) {
+ Object element = iterator.next();
+ if (element instanceof IResource) {
+ if (element instanceof IFile) {
+ if (((IFile) element).getName().toLowerCase().endsWith(CSS_FILE_EXTENTION)) {
+ currentFile = (IFile)element;
+ }
+ }
+ }
+ }
+ }
+ // if any CSS file is currently opened and has active page status this method should return style class
+ // within this file where cursor is located
+ if (currentFile == null) {
+ currentFile = Util.getActiveCssFile();
+ currentClassStyle = Util.getActivePageCSSSelectorIfAny();
+ }
+ }
+
+ /**
+ * Sets current style class value.
+ *
+ * @param currentClassStyle String value
+ */
+ public void setCurrentStyleClass(String currentClassStyle) {
+ if (currentClassStyle != null && !currentClassStyle.equals(Constants.EMPTY)) {
+ String[] styleClasses = currentClassStyle.split("\\s++"); //$NON-NLS-1$
+ StringBuffer sb = new StringBuffer();
+ for (int i = 0; i < styleClasses.length; i++) {
+ String value = styleClasses[i];
+ // check if first symbol doesn't specify some special CSS symbols
+ if (!value.startsWith("#")) { //$NON-NLS-1$
+ sb.append(SKIP_FIRST_CHAR);
+ }
+ sb.append(value);
+ if (i != (styleClasses.length - 1)) {
+ sb.append(Constants.WHITE_SPACE);
+ }
+ }
+ this.currentClassStyle = sb.toString().trim();
+ }
+ }
+
+ /**
+ * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(Composite)
+ */
+ @Override
+ protected Control createDialogArea(final Composite parent) {
+ final Composite composite = (Composite) super.createDialogArea(parent);
+ return createDialogComposite(composite);
+ }
+
+ /**
+ * @see org.eclipse.jface.dialogs.Dialog#createButtonsForButtonBar(Composite)
+ */
+ @Override
+ protected void createButtonsForButtonBar(Composite parent) {
+ super.createButtonsForButtonBar(parent);
+ updateOKButtonState();
+ }
+
+ /**
* Create the dialog itself.
*
* @param composite parent window
* @return eclipse Control object
*/
public Control createDialogComposite(Composite composite) {
- GridLayout layout = new GridLayout();
+ if (!this.callFromWizard) {
+ setTitle(WIZARD_TITLE);
+ setMessage(WIZARD_DESCRIPTION);
+ }
+
+ Split split = new Split(composite, SWT.VERTICAL);
+
+ GridLayout layout = new GridLayout();
layout.numColumns = 1;
composite.setLayout(layout);
- browser = new Browser(composite, SWT.BORDER);
+ // initialize browser container
+ browserContainer = getCompositeElement(split);
+ createBrowserComponent();
+
/* ============================================= */
- Composite classComposite = new Composite(composite, SWT.BORDER);
- GridData gridData = new GridData(GridData.FILL, GridData.FILL, true, false);
+ Composite downSplitPane = getCompositeElement(split);
+ Color veryLightGray = new Color(null, 127, 127, 127);
+ downSplitPane.setForeground(veryLightGray);
+
+ Composite classComposite = new Composite(downSplitPane, SWT.BORDER);
+ GridData gridData = new GridData(GridData.FILL, GridData.BEGINNING, true, false);
classComposite.setLayoutData(gridData);
final GridLayout gridLayout = new GridLayout();
@@ -112,38 +248,26 @@
label.setLayoutData(new GridData(GridData.END, GridData.CENTER, false, false));
label.setText(JstUIMessages.CSS_CLASS_DIALOG_FILE_LABEL);
+ // Text field contains path to the CSS file
text = new Text(classComposite, SWT.BORDER);
text.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false));
+ text.setEditable(false);
text.addModifyListener(new ModifyListener() {
- public void modifyText(ModifyEvent e) {
- IResource res = null;
- if (allProject) {
- IWorkspace workspace = ResourcesPlugin.getWorkspace();
- res = workspace.getRoot().findMember(text.getText());
- } else {
- IProject project = Util.getCurrentProject();
+ @Override
+ public void modifyText(ModifyEvent e) {
+ String cssFile = text.getText().trim();
+ // Initialize a variable with the no error status
+ filePathStatus = new Status(IStatus.ERROR, "not_used", 0, EMPTY_CSS_FILE_PATH_MESSAGE, null); //$NON-NLS-1$
+ if (cssFile != null && !cssFile.equals(Constants.EMPTY)) {
+ filePathStatus = new Status(IStatus.OK, "not_used", 0, WIZARD_DESCRIPTION, null); //$NON-NLS-1$
+ }
+ // show corresponding message
+ IStatus status = findMostSevere();
+ notifyListeners(text, status);
+ applyToStatusLine(status);
+ }
+ });
- if (project != null) {
- 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));
@@ -159,30 +283,50 @@
});
button.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
- IAdaptable project = ResourcesPlugin.getWorkspace();
+ IResource project = Util.getCurrentProject();
- if (!allProject) {
- project = Util.getCurrentProject();
- }
+ ElementTreeSelectionDialog dialog = new ElementTreeSelectionDialog(getShell(),
+ new WorkbenchLabelProvider(), new BaseWorkbenchContentProvider());
+ dialog.addFilter(new FileExtensionFilter(fileExtensions));
+ dialog.setTitle(JstUIMessages.CSS_FILE_SELECT_DIALOG_TITLE);
+ dialog.setMessage(JstUIMessages.CSS_FILE_SELECT_DIALOG_LABEL);
+ dialog.setInput(project);
+ dialog.setAllowMultiple(false);
+ dialog.setDoubleClickSelects(false);
+ dialog.setEmptyListMessage(JstUIMessages.CSS_FILE_SELECT_DIALOG_EMPTY_MESSAGE);
- ElementTreeSelectionDialog dialog = new ElementTreeSelectionDialog(getShell(),
- new WorkbenchLabelProvider(), new BaseWorkbenchContentProvider());
- dialog.addFilter(new FileExtensionFilter(fileExtensions));
- dialog.setTitle(JstUIMessages.CSS_FILE_SELECT_DIALOG_TITLE);
- dialog.setMessage(JstUIMessages.CSS_FILE_SELECT_DIALOG_LABEL);
- dialog.setInput(project);
- dialog.setAllowMultiple(false);
- dialog.setEmptyListMessage(JstUIMessages.CSS_FILE_SELECT_DIALOG_EMPTY_MESSAGE);
-
- if (dialog.open() == Window.OK) {
- IResource res = (IResource) dialog.getFirstResult();
-
- if (allProject) {
- text.setText(res.getFullPath().toOSString());
- } else {
- text.setText(res.getProjectRelativePath().toOSString());
- }
- }
+ if (dialog.open() == Window.OK) {
+ // make some important saving actions
+ if (styleChanged && currentFile != null) {
+ MessageBox messageBox = new MessageBox(getParentShell(), SWT.YES | SWT.NO | SWT.ICON_QUESTION);
+ messageBox.setText("Save CSS file");
+ messageBox.setMessage("'" + currentFile + "'" + //$NON-NLS-1$ //$NON-NLS-2$
+ " CSS file has been changed.\nWould you like to save changes?");
+ int result = messageBox.open();
+ if (result == SWT.YES) {
+ saveChanges();
+ } else {
+ styleComposite.closePreview(false);
+ if (cssModel != null) {
+ cssModel.releaseModel();
+ }
+ updateStyleComposite();
+ styleComposite.updatePreviewCssFile(currentFile);
+ }
+ }
+ // open new CSS file and initialize dialog
+ IResource res = (IResource) dialog.getFirstResult();
+ if (res instanceof IFile) {
+ boolean useRelativePath = true;
+ if (project instanceof IWorkspaceRoot) {
+ useRelativePath = false;
+ }
+ currentFile = (IFile)res;
+ initCSSModel(currentFile, useRelativePath);
+ updateOKButtonState();
+ }
+ styleChanged = false;
+ }
}
});
@@ -192,67 +336,319 @@
gridData = new GridData(GridData.FILL, GridData.CENTER, true, false);
gridData.horizontalSpan = 2;
+
+// classCombo = new ComboViewer(classComposite, SWT.BORDER);
classCombo = new Combo(classComposite, SWT.BORDER);
classCombo.setLayoutData(gridData);
+ classCombo.setEnabled(false);
+// classCombo.setLabelProvider(new LabelProvider() {
+// @Override
+// public String getText(Object element) {
+// return ((Selector)element).getValue();
+// }
+// });
+// classCombo.addSelectionChangedListener(new ISelectionChangedListener() {
+// public void widgetSelected(SelectionEvent e) {
+// if (currentFile != null && !currentFile.equals(Constants.EMPTY)) {
+// if (styleChanged) {
+// if (currentClassStyle != null && !currentClassStyle.equals(Constants.EMPTY)) {
+// String newStyle = styleComposite.updateStyle();
+// if (newStyle != null) {
+// cssModel.setCSS(currentClassStyle, newStyle);
+// // update ComboBox element list
+// int currentIndex = classCombo.indexOf(currentClassStyle);
+// if (currentIndex == -1) {
+// classCombo.add(currentClassStyle);
+// }
+// }
+// }
+// }
+// // update current class style value
+// currentClassStyle = classCombo.getText();
+// updateStyleComposite();
+// updateOKButtonState();
+// styleChanged = false;
+// } else {
+// currentClassStyle = classCombo.getText();
+// }
+// }
+// @Override
+// public void selectionChanged(SelectionChangedEvent event) {
+// if (currentFile != null && !currentFile.equals(Constants.EMPTY)) {
+// if (styleChanged) {
+// if (currentClassStyle != null && !currentClassStyle.equals(Constants.EMPTY)) {
+// String newStyle = styleComposite.updateStyle();
+// if (newStyle != null) {
+// cssModel.setCSS(currentClassStyle, newStyle);
+// // update ComboBox element list
+// int currentIndex = classCombo.getCombo().indexOf(currentClassStyle);
+// if (currentIndex == -1) {
+// classCombo.add(currentClassStyle);
+// }
+// }
+// }
+// }
+// // update current class style value
+// currentClassStyle = classCombo.getInput() != null ? classCombo.getInput().toString() : null;
+// updateStyleComposite();
+// updateOKButtonState();
+// styleChanged = false;
+// } else {
+// currentClassStyle = classCombo.getInput().toString();
+// }
+// }
+// });
- classCombo.addSelectionListener(new SelectionListener() {
- public void widgetDefaultSelected(SelectionEvent e) {
- }
- public void widgetSelected(SelectionEvent e) {
- String style = cssModel.getStyle(classCombo.getText());
- classCombo.setToolTipText(cssModel.getCSSText(classCombo.getText()));
- styleComposite.recreateStyleComposite(style);
- }
- });
+ classCombo.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ if (currentFile != null && !currentFile.equals(Constants.EMPTY)) {
+ if (styleChanged) {
+ if (currentClassStyle != null && !currentClassStyle.equals(Constants.EMPTY)) {
+ String newStyle = styleComposite.updateStyle();
+ if (newStyle != null) {
+ cssModel.setCSS(currentClassStyle, newStyle);
+ // update ComboBox element list
+ int currentIndex = classCombo.indexOf(currentClassStyle);
+ if (currentIndex == -1) {
+ classCombo.add(currentClassStyle);
+ }
+ }
+ }
+ }
+ // update current class style value
+ currentClassStyle = classCombo.getText();
+ updateStyleComposite();
+ updateOKButtonState();
+ styleChanged = false;
+ } else {
+ currentClassStyle = classCombo.getText();
+ }
+ }
+ });
+ classCombo.addKeyListener(new KeyAdapter() {
+ @Override
+ public void keyReleased(KeyEvent e) {
+ // update current class style value
+ currentClassStyle = classCombo.getText().trim();
+ updateOKButtonState();
+ }
+ });
+ classCombo.addModifyListener(new ModifyListener() {
+ @Override
+ public void modifyText(ModifyEvent e) {
+ String cssClass = classCombo.getText().trim();
+ // Initialize a variable with the no error status
+ classNameStatus = new Status(IStatus.ERROR, "not_used", 0, EMPTY_STYLE_CLASS_MESSAGE, null); //$NON-NLS-1$
+ if (cssClass != null && !cssClass.equals(Constants.EMPTY)) {
+ classNameStatus = new Status(IStatus.OK, "not_used", 0, WIZARD_DESCRIPTION, null); //$NON-NLS-1$
+ }
+ // show corresponding message
+ IStatus status = findMostSevere();
+ notifyListeners(classCombo, status);
+ applyToStatusLine(status);
+ }
+ });
/* ============================================ */
styleAttributes.addChangeStyleListener(new ChangeStyleListener() {
public void styleChanged(ChangeStyleEvent event) {
- String styleForSpan = Constants.EMPTY;
- String html = Constants.EMPTY;
-
- Set<String> keySet = styleAttributes.keySet();
- for (String key : keySet) {
- styleForSpan += (key + Constants.COLON + styleAttributes.getAttribute(key) +
- Constants.SEMICOLON);
- }
-
- html = Constants.OPEN_DIV_TAG + styleForSpan + Constants.TEXT_FOR_PREVIEW +
- Constants.CLOSE_DIV_TAG;
- browser.setText(html);
+ if (!browser.isDisposed()) {
+ browser.setText(getTextForBrowser());
+ }
+ if (cssModel != null && currentClassStyle != null) {
+ classCombo.setToolTipText(cssModel.getCSSText(currentClassStyle));
+ }
}
});
- styleComposite = new StyleComposite(composite, styleAttributes, Constants.EMPTY);
+ // create style composite component
+ styleComposite = new StyleComposite(downSplitPane, styleAttributes, Constants.EMPTY);
+ styleComposite.addManualChangeStyleListener(new ManualChangeStyleListener() {
+ public void styleChanged(ChangeStyleEvent event) {
+ styleChanged = true;
+ if (currentClassStyle != null && !currentClassStyle.equals(Constants.EMPTY)
+ && currentFile != null && !currentFile.equals(Constants.EMPTY)) {
+ String newStyle = styleComposite.updateStyle();
+ if (newStyle != null) {
+ cssModel.setCSS(currentClassStyle, newStyle);
+ }
+ }
+ }
+ });
- gridData = new GridData(GridData.FILL, GridData.FILL, true, true);
- gridData.minimumHeight = MIN_HEIGHT_FOR_BROWSER;
- browser.setLayoutData(gridData);
+ // add clear button
+ Button clearButton = new Button(downSplitPane, SWT.PUSH);
+ clearButton.setText(JstUIMessages.BUTTON_CLEAR);
+ clearButton.setLayoutData(new GridData(GridData.END, GridData.CENTER, false, false));
+ clearButton.setToolTipText(JstUIMessages.CSS_CLEAR_STYLE_SHEET);
+ clearButton.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent event) {
+ styleComposite.clearStyleComposite();
+ styleChanged = true;
+ }
+ });
+ if (currentFile != null) {
+ initCSSModel(currentFile, true);
+ } else if (currentClassStyle != null) {
+ classCombo.setText(currentClassStyle);
+ }
+
+ split.setWeights(new int[]{15, 85});
+ split.setLayoutData(new GridData(GridData.FILL, GridData.BEGINNING, true, true));
+
return composite;
}
- public void saveChanges() {
- styleComposite.updateStyle();
+ /**
+ * Initialize CSS model with active opened CSS file.
+ *
+ * @param file IFile object
+ * @param useRelativePathPath
+ */
+ private void initCSSModel(IFile file, boolean useRelativePathPath) {
+ if (file != null) {
+ // create CSS Model
+ cssModel = new CSSModel(file);
+ classCombo.setEnabled(true);
+ classCombo.removeAll();
+ boolean useCurrentStyleSettings = false;
+ if (text.getText() == null || text.getText().equals(Constants.EMPTY)) {
+ useCurrentStyleSettings = true;
+ }
+ if (useRelativePathPath) {
+ text.setText(file.getProjectRelativePath().toOSString());
+ } else {
+ text.setText(file.getFullPath().toOSString());
+ }
- String newStyle = styleComposite.getNewStyle();
- cssModel.setCSS(classCombo.getText(), newStyle);
- cssModel.saveModel();
+ List<Selector> selectors = cssModel.getSelectors();
+ int selectedIndex = -1;
+ for (int i = 0; i < selectors.size(); i++) {
+ Selector value = selectors.get(i);
+ classCombo.add(value.getValue());
+ if (currentClassStyle != null && currentClassStyle.equals(value.getValue())) {
+ selectedIndex = i;
+ }
+ }
+// if (useCurrentStyleSettings && currentClassStyle != null && selectedIndex == -1) {
+// classCombo.setText(currentClassStyle);
+// } else {
+// classCombo.select(selectedIndex);
+// }
+// if (currentClassStyle != null) {
+// classCombo.setInput(currentClassStyle);
+// }
+ classCombo.select(selectedIndex);
+
+ updateStyleComposite();
+ styleComposite.updatePreviewCssFile(currentFile);
+ }
}
- public String getSelectorName() {
- return selectorName;
+ /**
+ * Method return the most serious error occurs on the page and that should be displayed.
+ *
+ * @return IStatus object
+ */
+ private IStatus findMostSevere() {
+ if (filePathStatus.matches(IStatus.ERROR)) {
+ return filePathStatus;
+ }
+ if (classNameStatus.matches(IStatus.ERROR)) {
+ return classNameStatus;
+ }
+ if (filePathStatus.getSeverity() > classNameStatus.getSeverity()) {
+ return filePathStatus;
+ }
+ else return classNameStatus;
+ }
+
+ /**
+ * This method takes affect to OK button when dialog is opened in "dialog" mode and not in "wizard".
+ * In case of "wizard" mode OK button is not available.
+ */
+ private void updateOKButtonState() {
+ Button okButton = getButton(IDialogConstants.OK_ID);
+ if (okButton != null) {
+ if (currentClassStyle == null || currentClassStyle.equals(Constants.EMPTY) || currentFile == null) {
+ okButton.setEnabled(false);
+ } else {
+ okButton.setEnabled(true);
+ }
+ }
}
/**
- * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(Composite)
+ * Method is used to create browser component to display preview html.
*/
- @Override
- protected Control createDialogArea(final Composite parent) {
- final Composite composite = (Composite) super.createDialogArea(parent);
- return createDialogComposite(composite);
+ private void createBrowserComponent() {
+ GridData gridData = new GridData(GridData.FILL, GridData.FILL, true, true);
+ browser = new Browser(browserContainer, SWT.BORDER | SWT.MOZILLA);
+ browser.setText(getTextForBrowser());
+ browser.addMouseListener(this);
+ browser.setLayoutData(gridData);
}
/**
+ * Update style composite component in accordance with the attributes of selected CSS selector.
+ */
+ private void updateStyleComposite() {
+ String style = cssModel.getStyle(currentClassStyle);
+// classCombo.setToolTipText(cssModel.getCSSText(currentClassStyle));
+ styleComposite.recreateStyleComposite(style);
+ }
+
+ /**
+ * Method is used to build html body that is appropriate to browse.
+ *
+ * @return String html text representation
+ */
+ private String getTextForBrowser() {
+ String styleForSpan = Constants.EMPTY;
+ Set<String> keySet = styleAttributes.keySet();
+ for (String key : keySet) {
+ styleForSpan += (key + Constants.COLON + styleAttributes.getAttribute(key) + Constants.SEMICOLON);
+ }
+ String html = Constants.OPEN_DIV_TAG + styleForSpan + "\">" + previewBrowserValue + Constants.CLOSE_DIV_TAG; //$NON-NLS-1$
+
+ return html;
+ }
+
+ /**
+ * Create container that take up 2 cells and contains fontSizeCombo and extFontSizeCombo elements.
+ */
+ private Composite getCompositeElement(Composite parent) {
+ GridData gridData = new GridData(GridData.FILL, GridData.FILL, true, true);
+ GridLayout gridLayoutTmp = new GridLayout();
+ gridLayoutTmp.marginHeight = 0;
+ gridLayoutTmp.marginWidth = 0;
+ Composite classComposite = new Composite(parent, SWT.FILL);
+ classComposite.setLayout(gridLayoutTmp);
+ classComposite.setLayoutData(gridData);
+
+ return classComposite;
+ }
+
+ /**
+ * Method should be called in case of dialog closure operation.
+ */
+ public void saveChanges() {
+ String newStyle = styleComposite.updateStyle();
+ cssModel.setCSS(currentClassStyle, newStyle);
+ cssModel.saveModel();
+ styleComposite.closePreview(true);
+ }
+
+ /**
+ * Gets current selected style class value.
+ *
+ * @return selector name
+ */
+ public String getSelectorName() {
+ return currentClassStyle;
+ }
+
+ /**
* Method for setting title for dialog
*
* @param newShell Shell object
@@ -265,18 +661,150 @@
}
/**
- * @see org.eclipse.jface.dialogs.Dialog#okPressed()
+ * This method close the dialog.
+ *
+ * @return true if dialog was closed, false - otherwise
*/
- @Override
- protected void okPressed() {
- saveChanges();
+ public boolean closeDialog() {
+ setReturnCode(Window.CANCEL);
+ return close();
+ }
- String sel = classCombo.getText();
- if (sel.trim().startsWith(SKIP_FIRST_CHAR)) {
- sel = sel.substring(1);
+ /**
+ * @see org.eclipse.jface.dialogs.Dialog#close()
+ */
+ public boolean close() {
+ int code = getReturnCode();
+ switch (code) {
+ case OK:
+ saveChanges();
+ super.okPressed();
+ break;
+ case CANCEL:
+ default:
+ // make some closure operation
+ styleComposite.closePreview(false);
+ if (cssModel != null) {
+ cssModel.releaseModel();
+ }
+ }
+ return super.close();
+ }
+
+ /**
+ * @see org.eclipse.swt.events.MouseListener#mouseDoubleClick(org.eclipse.swt.events.MouseEvent)
+ */
+ @Override
+ public void mouseDoubleClick(MouseEvent e) {
+ if (e.widget == browser) {
+ browser.removeMouseListener(this);
+ browser.dispose();
+ // create Text area component instead of HTML Browser
+ GridData gridData = new GridData(GridData.FILL, GridData.FILL, true, true);
+ textBrowser = new Text(browserContainer, SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL);
+ textBrowser.setText(previewBrowserValue);
+ textBrowser.addFocusListener(this);
+ textBrowser.setLayoutData(gridData);
+ textBrowser.setEditable(true);
+ textBrowser.setFocus();
+ }
+ browserContainer.layout();
+ }
+
+ /**
+ * @see org.eclipse.swt.events.FocusListener#focusLost(org.eclipse.swt.events.FocusEvent)
+ */
+ @Override
+ public void focusLost(FocusEvent e) {
+ if (e.widget == textBrowser) {
+ previewBrowserValue = textBrowser.getText();
+ textBrowser.removeFocusListener(this);
+ textBrowser.dispose();
+ // create Browse component instead of text area
+ createBrowserComponent();
+ }
+ browserContainer.layout();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.swt.events.MouseListener#mouseDown(org.eclipse.swt.events.MouseEvent)
+ */
+ @Override
+ public void mouseDown(MouseEvent e) {
+ // TODO Auto-generated method stub
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.swt.events.MouseListener#mouseUp(org.eclipse.swt.events.MouseEvent)
+ */
+ @Override
+ public void mouseUp(MouseEvent e) {
+ // TODO Auto-generated method stub
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.swt.events.FocusListener#focusGained(org.eclipse.swt.events.FocusEvent)
+ */
+ @Override
+ public void focusGained(FocusEvent e) {
+ // TODO Auto-generated method stub
+ }
+
+ /**
+ * Add MessageDialogListener object.
+ *
+ * @param listener MessageDialogListener object to be added
+ */
+ public void addMessageDialogListener(MessageDialogListener listener) {
+ errorListeners.add(listener);
+ }
+
+ /**
+ * Remove ManualChangeStyleListener object passed by parameter.
+ *
+ * @param listener ManualChangeStyleListener object to be removed
+ */
+ public void removeMessageDialogListener(MessageDialogListener listener) {
+ errorListeners.remove(listener);
+ }
+
+ /**
+ * Method is used to notify all subscribed listeners about possible any errors on the page.
+ */
+ private void notifyListeners(Object source, IStatus operationStatus) {
+ MessageDialogEvent event = new MessageDialogEvent(source, operationStatus);
+ for (MessageDialogListener listener : errorListeners) {
+ listener.throwMessage(event);
}
+ }
- selectorName = sel;
- super.okPressed();
- }
+ /**
+ * Applies the status to the status line of a dialog page.
+ */
+ private void applyToStatusLine(IStatus status) {
+ if (!callFromWizard) {
+ String message= status.getMessage();
+ if (message.length() == 0) {
+ message = null;
+ }
+ switch (status.getSeverity()) {
+ case IStatus.OK:
+ setErrorMessage(null);
+ setMessage(message);
+ break;
+ case IStatus.WARNING:
+ setErrorMessage(null);
+ setMessage(message, WizardPage.WARNING);
+ break;
+ case IStatus.INFO:
+ setErrorMessage(null);
+ setMessage(message, WizardPage.INFORMATION);
+ break;
+ default:
+ setErrorMessage(message);
+ setMessage(null);
+ break;
+ }
+ }
+ }
}
Modified: trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/CSSStyleDialog.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/CSSStyleDialog.java 2008-11-21 10:35:47 UTC (rev 11944)
+++ trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/CSSStyleDialog.java 2008-11-21 13:53:11 UTC (rev 11945)
@@ -37,6 +37,8 @@
final static int MIN_HEIGHT_FOR_BROWSER = 60;
+ private String previewBrowserValue = Constants.TEXT_FOR_PREVIEW;
+
private Browser browser = null;
private StyleComposite styleComposite = null;
private StyleAttributes styleAttributes = null;
@@ -73,17 +75,7 @@
styleAttributes.addChangeStyleListener(new ChangeStyleListener() {
public void styleChanged(ChangeStyleEvent event) {
- String styleForSpan = Constants.EMPTY;
- String html = Constants.EMPTY;
-
- Set<String> keySet = styleAttributes.keySet();
- for (String key : keySet) {
- styleForSpan += (key + Constants.COLON + styleAttributes.getAttribute(key) +
- Constants.SEMICOLON);
- }
- html = Constants.OPEN_DIV_TAG + styleForSpan + Constants.TEXT_FOR_PREVIEW +
- Constants.CLOSE_DIV_TAG;
- browser.setText(html);
+ browser.setText(getTextForBrowser());
}
});
styleComposite = new StyleComposite(composite, styleAttributes, oldStyle);
@@ -91,11 +83,28 @@
GridData gridData = new GridData(GridData.FILL, GridData.FILL, true, true);
gridData.minimumHeight = MIN_HEIGHT_FOR_BROWSER;
browser.setLayoutData(gridData);
+ browser.setText(getTextForBrowser());
return composite;
}
/**
+ * Method is used to build html body that is appropriate to browse.
+ *
+ * @return String html text representation
+ */
+ private String getTextForBrowser() {
+ String styleForSpan = Constants.EMPTY;
+ Set<String> keySet = styleAttributes.keySet();
+ for (String key : keySet) {
+ styleForSpan += (key + Constants.COLON + styleAttributes.getAttribute(key) + Constants.SEMICOLON);
+ }
+ String html = Constants.OPEN_DIV_TAG + styleForSpan + "\">" + previewBrowserValue + Constants.CLOSE_DIV_TAG;
+
+ return html;
+ }
+
+ /**
* Method for setting title for dialog
*
* @param newShell Shell object
Modified: 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 2008-11-21 10:35:47 UTC (rev 11944)
+++ trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/StyleComposite.java 2008-11-21 13:53:11 UTC (rev 11945)
@@ -16,6 +16,7 @@
import java.util.Set;
import java.util.Map.Entry;
+import org.eclipse.core.resources.IFile;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.ScrolledComposite;
import org.eclipse.swt.events.SelectionAdapter;
@@ -28,6 +29,7 @@
import org.eclipse.swt.widgets.TabItem;
import org.jboss.tools.jst.jsp.messages.JstUIMessages;
import org.jboss.tools.jst.jsp.outline.cssdialog.common.Constants;
+import org.jboss.tools.jst.jsp.outline.cssdialog.events.ManualChangeStyleListener;
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;
@@ -36,6 +38,7 @@
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.TabPreviewControl;
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;
@@ -54,23 +57,27 @@
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 TAB_QUICK_EDIT_NUMBER = 5;
private static int FIRST_SELECTION = 0;
private static int SIZE_NULL = 0;
private String newStyle;
private String oldStyle;
+
private TabTextControl tabTextControl;
private TabBackgroundControl tabBackgroundControl;
private TabBoxesControl tabBoxesControl;
private TabPropertySheetControl tabPropertySheetControl;
private TabQuickEditControl tabQuickEditControl;
+ private TabPreviewControl tabPreviewControl;
+
private TabFolder tabFolder;
private TabItem tabTextFont;
private TabItem tabBackground;
private TabItem tabBoxes;
private TabItem tabPropertySheet;
private TabItem tabQuickEdit;
+ private TabItem tabPreview;
private TabItem lastSelectedTab = null;
private StyleAttributes styleAttributes;
private Parser parser;
@@ -99,7 +106,12 @@
return newStyle;
}
- public void updateStyle() {
+ /**
+ * Update new style in accordance with the style attribute values.
+ *
+ * @return string representation of attribute of current CSS selector
+ */
+ public String updateStyle() {
if (lastSelectedTab == tabTextFont) {
tabTextControl.updateData(true);
} else if (lastSelectedTab == tabBackground) {
@@ -117,65 +129,12 @@
}
newStyle = buf.toString();
+ return newStyle;
}
/**
- * Method for creating text tab
- *
- * @param tabFolder
- * @return composite
+ * Method is used to create it child subtabs.
*/
- 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) {
@@ -217,8 +176,7 @@
});
cssParser.parse();
- // HashMap<String, String> attributesMap = new HashMap<String,
- // String>();
+ // HashMap<String, String> attributesMap = new HashMap<String, String>();
ParserListener listener = new ParserListener(styleAttributes);
parser = new Parser(elementsMap);
parser.addListener(listener);
@@ -254,6 +212,11 @@
tabPropertySheet.setToolTipText(JstUIMessages.PROPERTY_SHEET_TAB_NAME);
tabPropertySheet.setControl(createTabPropertySheetControl(tabFolder));
+ tabPreview = new TabItem(tabFolder, SWT.NONE);
+ tabPreview.setText(JstUIMessages.PREVIEW_SHEET_TAB_NAME);
+ tabPreview.setToolTipText(JstUIMessages.PREVIEW_SHEET_TAB_NAME);
+ tabPreview.setControl(createPreviewContol(tabFolder));
+
tabFolder.setSelection(TAB_TEXT_FONT_NUMBER);
if (styleAttributes.getAttributeMap().size() > SIZE_NULL) {
@@ -280,8 +243,10 @@
} else if (tabFolder.getSelection()[FIRST_SELECTION] == tabBoxes) {
tabBoxesControl.updateData(false);
lastSelectedTab = tabBoxes;
+ } else if (tabFolder.getSelection()[FIRST_SELECTION] == tabPreview) {
+ lastSelectedTab = tabPreview;
} else if (tabFolder.getSelection()[FIRST_SELECTION] == tabPropertySheet) {
- tabPropertySheetControl.updateData(false);
+// tabPropertySheetControl.updateData(false);
lastSelectedTab = tabPropertySheet;
}
}
@@ -289,19 +254,144 @@
}
/**
+ * 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;
+ }
+
+ /**
+ * Method for creating quick edit tab
+ *
+ * @param tabFolder
+ * @return
+ */
+ private Control createPreviewContol(TabFolder tabFolder) {
+ ScrolledComposite sc = new ScrolledComposite(tabFolder, SWT.H_SCROLL | SWT.V_SCROLL);
+
+ sc.setExpandHorizontal(true);
+ sc.setExpandVertical(true);
+
+ tabPreviewControl = new TabPreviewControl(sc, styleAttributes);
+ sc.setContent(tabPreviewControl);
+
+ sc.setMinSize(tabPreviewControl.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,
- styleAttributes);
+ tabPropertySheetControl = new TabPropertySheetControl(tabFolder, elementsMap, comboMap, styleAttributes);
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, styleAttributes);
+ sc.setContent(tabQuickEditControl);
+
+ sc.setMinSize(tabQuickEditControl.computeSize(SWT.DEFAULT, SWT.DEFAULT));
+
+ return sc;
+ }
+
+ /**
+ * Clear whole style composite component.
+ */
+ public void clearStyleComposite() {
+ styleAttributes.clear();
+
+ tabBackgroundControl.updateData(false);
+ tabBoxesControl.updateData(false);
+ tabPropertySheetControl.updateData(false);
+ tabTextControl.updateData(false);
+
+ if (tabQuickEdit != null) {
+ tabQuickEditControl.updateData();
+ }
+ }
+
+ /**
+ * Update Preview tab with content from the passed CSS file.
+ *
+ * @param cssFile CSS file to be shown on Preview tab
+ */
+ public void updatePreviewCssFile(IFile cssFile) {
+ tabPreviewControl.updateDataFile(cssFile);
+ }
+
+ /**
+ * Recreate style composite tab widgets.
+ *
+ * @param style CSS style
+ */
public void recreateStyleComposite(String style) {
styleAttributes.clear();
parser.parse(style);
@@ -317,6 +407,10 @@
tabQuickEdit.setText(JstUIMessages.QUICK_EDIT_TAB_NAME);
tabQuickEdit.setToolTipText(JstUIMessages.QUICK_EDIT_TAB_NAME);
tabQuickEdit.setControl(createTabQuickEditContol(tabFolder));
+ ManualChangeStyleListener[] listeners = tabBackgroundControl.getManualChangeStyleListeners();
+ if (listeners != null && listeners.length > 0) {
+ tabQuickEditControl.addManualChangeStyleListener(listeners[0]);
+ }
} else {
// update quick edit
tabQuickEditControl.updateData();
@@ -325,30 +419,36 @@
tabFolder.setSelection(TAB_QUICK_EDIT_NUMBER);
lastSelectedTab = tabQuickEdit;
} else {
- if ((tabQuickEdit != null) || !tabQuickEdit.isDisposed()) {
+ if (tabQuickEdit != null && !tabQuickEdit.isDisposed()) {
tabQuickEdit.dispose();
- tabFolder.redraw();
}
+ tabFolder.redraw();
}
}
/**
- * Method for creating quick edit tab
+ * Method is used to close preview tab correctly.
*
- * @param tabFolder
- * @return
+ * @param save close editor with saving or not
*/
- private Control createTabQuickEditContol(TabFolder tabFolder) {
- ScrolledComposite sc = new ScrolledComposite(tabFolder, SWT.H_SCROLL | SWT.V_SCROLL);
+ public void closePreview(boolean save) {
+ if (tabPreviewControl != null) {
+ tabPreviewControl.closeEditor(save);
+ }
+ }
- 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;
+ /**
+ * Add ManualChangeStyleListener object.
+ *
+ * @param listener ChangeStyleListener object to be added
+ */
+ public void addManualChangeStyleListener(ManualChangeStyleListener listener) {
+ tabBackgroundControl.addManualChangeStyleListener(listener);
+ tabBoxesControl.addManualChangeStyleListener(listener);
+ tabPropertySheetControl.addManualChangeStyleListener(listener);
+ tabTextControl.addManualChangeStyleListener(listener);
+ if (tabQuickEditControl != null) {
+ tabQuickEditControl.addManualChangeStyleListener(listener);
+ }
}
}
Modified: trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/common/CSSConstants.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/common/CSSConstants.java 2008-11-21 10:35:47 UTC (rev 11944)
+++ trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/common/CSSConstants.java 2008-11-21 13:53:11 UTC (rev 11945)
@@ -34,4 +34,7 @@
public static final String TEXT_ALIGN = "text-align"; //$NON-NLS-1$
public static final String FONT_FAMILY = "font-family"; //$NON-NLS-1$
public static final String COLOR = "color"; //$NON-NLS-1$
+
+ public static final String STYLE = "style"; //$NON-NLS-1$
+ public static final String CLASS = "class"; //$NON-NLS-1$
}
Modified: 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 2008-11-21 10:35:47 UTC (rev 11944)
+++ trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/common/CSSModel.java 2008-11-21 13:53:11 UTC (rev 11945)
@@ -1,158 +1,196 @@
-/*******************************************************************************
- * 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;
- }
-
-
- public String getCSSText(String selector) {
- 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)) {
- return ((CSSStyleRule)list.item(i)).getCssText();
- }
- }
- }
- }
- return null;
- }
-
- /**
- * 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());
- }
- }
-
-}
+/*******************************************************************************
+ * 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.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;
+
+/**
+ * CSS class model.
+ */
+public class CSSModel {
+
+ private static String startBraces = "{"; //$NON-NLS-1$
+ private static String endBraces = "}"; //$NON-NLS-1$
+ private FormatProcessorCSS formatProcessorCSS = null;
+ private CSSStyleSheet styleSheet = null;
+ private IStructuredModel model = null;
+ private IFile styleFile = null;
+
+ /**
+ * Constructor.
+ *
+ * @param styleFile CSS style class that should initialize CSS model
+ */
+ public CSSModel(IFile styleFile) {
+ try {
+ this.styleFile = styleFile;
+
+ 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<Selector> getSelectors() {
+ List<Selector> selectors = new ArrayList<Selector>();
+
+ 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 rule = ((CSSStyleRule) list.item(i));
+ Selector selector = new Selector(rule.toString(), rule.getSelectorText());
+// selectors.add(((CSSStyleRule) list.item(i)).getSelectorText());
+ selectors.add(selector);
+ }
+ }
+ }
+ }
+
+ return selectors;
+ }
+
+ /**
+ *
+ * @param selector
+ * @return
+ */
+ public String getCSSText(String selector) {
+ 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)) {
+ return ((CSSStyleRule) list.item(i)).getCssText();
+ }
+ }
+ }
+ }
+
+ return null;
+ }
+
+ /**
+ * 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) {
+ // check if selector passed by parameter already exists in CSS
+ 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;
+ }
+ }
+ // insert NEW selector to style sheet
+ styleSheet.insertRule(selector + startBraces + style + endBraces, list.getLength());
+ formatProcessorCSS.formatModel(model);
+ }
+ }
+ }
+
+ /**
+ * Save model to file
+ */
+ public void releaseModel() {
+ model.releaseFromEdit();
+ }
+
+ /**
+ * Save model to file
+ */
+ public void saveModel() {
+// ICSSModel cssModel = (ICSSModel) model;
+// ICSSDocument document = cssModel.getDocument();
+
+// if (document instanceof CSSStyleSheet) {
+// styleSheet = (CSSStyleSheet) document;
+// }
+// formatProcessorCSS.formatModel(model);
+ try {
+ formatProcessorCSS.formatFile(styleFile);
+ model.save();
+ } catch (IOException e) {
+ JspEditorPlugin.getPluginLog().logError(e.getMessage());
+ } catch (CoreException e) {
+ JspEditorPlugin.getPluginLog().logError(e.getMessage());
+ }
+ }
+}
Modified: trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/common/Constants.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/common/Constants.java 2008-11-21 10:35:47 UTC (rev 11944)
+++ trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/common/Constants.java 2008-11-21 13:53:11 UTC (rev 11945)
@@ -63,8 +63,9 @@
public static final String WHITE_SPACE = " "; //$NON-NLS-1$
public static String COLON = ":"; //$NON-NLS-1$
public static String SEMICOLON = ";"; //$NON-NLS-1$
- public static String COMMA = ";"; //$NON-NLS-1$
+ public static String COMMA = ","; //$NON-NLS-1$
public static String DASH = "-"; //$NON-NLS-1$
+ public static String SLASH = "/"; //$NON-NLS-1$
public static final RGB RGB_BLACK = new RGB(0,0,0);
public static final RGB RGB_WHITE = new RGB(0xFF, 0xFF, 0xFF);
@@ -76,5 +77,5 @@
public static String OPEN_DIV_TAG = "<div style=\"width: 100%;";
public static String CLOSE_DIV_TAG = "</div>";
- public static String TEXT_FOR_PREVIEW = "\">Text for preview";
+ public static String TEXT_FOR_PREVIEW = "Double click to edit preview.";
}
\ No newline at end of file
Added: trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/common/Selector.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/common/Selector.java (rev 0)
+++ trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/common/Selector.java 2008-11-21 13:53:11 UTC (rev 11945)
@@ -0,0 +1,78 @@
+/*******************************************************************************
+ * 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.common;
+
+/**
+ * Selector class.
+ */
+public class Selector {
+
+ private String value = null;
+ private String id = null;
+
+ /**
+ * Constructor.
+ *
+ * @param id
+ * @param value
+ */
+ public Selector(String id, String value) {
+ this.id = id;
+ this.value = value;
+ }
+
+ /**
+ * @return the value
+ */
+ public String getValue() {
+ return value;
+ }
+
+ /**
+ * @param value the value to set
+ */
+ public void setValue(String value) {
+ this.value = value;
+ }
+
+ /**
+ * @return the id
+ */
+ public String getId() {
+ return id;
+ }
+
+ /**
+ * @return
+ * @see java.lang.String#toString()
+ */
+ public String toString() {
+ return id;
+ }
+
+ /* (non-Javadoc)
+ * @see java.lang.Object#equals(java.lang.Object)
+ */
+ @Override
+ public boolean equals(Object obj) {
+ if (obj == null || !(obj instanceof Selector)) {
+ return false;
+ }
+ Selector selector = (Selector) obj;
+ if (id == null || selector.getId() == null) {
+ return false;
+ }
+ if (id.equals(selector.getId())) {
+ return true;
+ }
+ return super.equals(obj);
+ }
+}
\ 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-11-21 10:35:47 UTC (rev 11944)
+++ trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/common/Util.java 2008-11-21 13:53:11 UTC (rev 11945)
@@ -12,15 +12,23 @@
import java.util.ArrayList;
import java.util.HashMap;
+import java.util.Iterator;
import java.util.Set;
import java.util.StringTokenizer;
import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.swt.graphics.RGB;
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.IFileEditorInput;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.wst.css.core.internal.provisional.document.ICSSNode;
+import org.eclipse.wst.css.core.internal.provisional.document.ICSSStyleRule;
+import org.eclipse.wst.css.core.internal.provisional.document.ICSSStyleSheet;
import org.jboss.tools.jst.jsp.JspEditorPlugin;
import org.jboss.tools.jst.jsp.outline.cssdialog.parsers.ColorParser;
@@ -275,15 +283,76 @@
*
* @return IProject object
*/
- public static IProject getCurrentProject() {
- IEditorPart editor = JspEditorPlugin.getDefault().getWorkbench()
- .getActiveWorkbenchWindow().getActivePage().getActiveEditor();
- IEditorInput input = editor.getEditorInput();
- IProject project = null;
- if (input instanceof IFileEditorInput) {
- IFile file = ((IFileEditorInput) input).getFile();
- project = file.getProject();
+ public static IResource getCurrentProject() {
+ IResource result = null;
+ IWorkbenchPage page = JspEditorPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getActivePage();
+ if (page != null && page.getActiveEditor() != null) {
+ IEditorPart editor = page.getActiveEditor();
+ IEditorInput input = editor.getEditorInput();
+ if (input instanceof IFileEditorInput) {
+ IFile file = ((IFileEditorInput) input).getFile();
+ result = file.getProject();
+ }
+ } else {
+ result = ResourcesPlugin.getWorkspace().getRoot();
}
- return project;
+ return result;
}
+
+ /**
+ * Get current opened CSS file. If file is not CSS file - return null instead.
+ *
+ * @return IFile CSS file
+ */
+ public static IFile getActiveCssFile() {
+ IWorkbenchPage page = JspEditorPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getActivePage();
+ if (page != null && page.getActiveEditor() != null) {
+ IEditorInput input = page.getActiveEditor().getEditorInput();
+ if (input instanceof IFileEditorInput) {
+ IFile file = ((IFileEditorInput) input).getFile();
+ if (file.getName().toLowerCase().endsWith("css")) {
+ return file;
+ }
+ }
+ }
+ return null;
+ }
+
+ /**
+ *
+ */
+ public static String getActivePageCSSSelectorIfAny() {
+ IWorkbenchPage page = JspEditorPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getActivePage();
+ ISelection selection = page.getSelection();
+ String sText = null;
+ if (selection instanceof IStructuredSelection) {
+ IStructuredSelection ss = (IStructuredSelection)selection;
+ for (Iterator iterator = ss.iterator(); iterator.hasNext();) {
+ Object node = iterator.next();
+ if (node instanceof ICSSNode) {
+ return getSelector((ICSSNode)node);
+ }
+ }
+ }
+ return null;
+ }
+
+ /**
+ *
+ */
+ private static String getSelector(ICSSNode node) {
+ if (node != null) {
+ short nodeType = node.getNodeType();
+ if (nodeType == ICSSNode.STYLESHEET_NODE) {
+ ICSSStyleSheet styleSheet = (ICSSStyleSheet) node;
+ return getSelector(styleSheet.getFirstChild());
+ } else if (nodeType == ICSSNode.STYLERULE_NODE) {
+ ICSSStyleRule styleRule = (ICSSStyleRule) node;
+ return styleRule.getSelectorText();
+ } else {
+ return getSelector(node.getParentNode());
+ }
+ }
+ return null;
+ }
}
\ No newline at end of file
Modified: 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 2008-11-21 10:35:47 UTC (rev 11944)
+++ trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/events/ChangeStyleEvent.java 2008-11-21 13:53:11 UTC (rev 11945)
@@ -1,24 +1,30 @@
-/*******************************************************************************
- * 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);
- }
-}
+/*******************************************************************************
+ * 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;
+
+/**
+ * An event which indicates that a style change action occurred.
+ */
+public class ChangeStyleEvent extends EventObject {
+
+ private static final long serialVersionUID = 3260787731782837929L;
+
+ /**
+ * Constructor.
+ *
+ * @param source the Component that originated the event
+ */
+ public ChangeStyleEvent(Object source) {
+ super(source);
+ }
+}
Modified: 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 2008-11-21 10:35:47 UTC (rev 11944)
+++ trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/events/ChangeStyleListener.java 2008-11-21 13:53:11 UTC (rev 11945)
@@ -10,6 +10,14 @@
******************************************************************************/
package org.jboss.tools.jst.jsp.outline.cssdialog.events;
+/**
+ * Defines an object which listens for ChangeStyleEvent.
+ */
public interface ChangeStyleListener {
+
+ /**
+ * Invoked when the target of the listener has changed its state.
+ * @param event a ChangeEvent object
+ */
public void styleChanged(ChangeStyleEvent event);
}
Added: trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/events/ManualChangeStyleListener.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/events/ManualChangeStyleListener.java (rev 0)
+++ trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/events/ManualChangeStyleListener.java 2008-11-21 13:53:11 UTC (rev 11945)
@@ -0,0 +1,23 @@
+/*******************************************************************************
+ * 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;
+
+/**
+ * Defines an object which listens for ManualChangeStyleEvent.
+ */
+public interface ManualChangeStyleListener {
+
+ /**
+ * Invoked when the target of the listener has changed its state.
+ * @param event a ChangeEvent object
+ */
+ public void styleChanged(ChangeStyleEvent event);
+}
Added: trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/events/MessageDialogEvent.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/events/MessageDialogEvent.java (rev 0)
+++ trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/events/MessageDialogEvent.java 2008-11-21 13:53:11 UTC (rev 11945)
@@ -0,0 +1,45 @@
+/*******************************************************************************
+ * 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 java.util.EventObject;
+
+import org.eclipse.core.runtime.IStatus;
+
+/**
+ * An event which indicates that any dialog contains empty mandatory fields.
+ */
+public class MessageDialogEvent extends EventObject {
+
+ private static final long serialVersionUID = -5978788274463066057L;
+
+ private IStatus operationStatus = null;
+
+ /**
+ * Constructor.
+ *
+ * @param source the Component that originated the event
+ */
+ public MessageDialogEvent(Object source, IStatus operationStatus) {
+ super(source);
+ this.operationStatus = operationStatus;
+ }
+
+ /**
+ * Gets operation status.
+ *
+ * @return the operationStatus
+ */
+ public IStatus getOperationStatus() {
+ return operationStatus;
+ }
+
+}
Added: trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/events/MessageDialogListener.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/events/MessageDialogListener.java (rev 0)
+++ trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/events/MessageDialogListener.java 2008-11-21 13:53:11 UTC (rev 11945)
@@ -0,0 +1,23 @@
+/*******************************************************************************
+ * 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;
+
+/**
+ * Defines an object which listens for MessageDialogEvent.
+ */
+public interface MessageDialogListener {
+
+ /**
+ * Invoked when the target of the listener has changed its state.
+ * @param event a MessageDialogEvent object
+ */
+ public void throwMessage(MessageDialogEvent event);
+}
Modified: 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 2008-11-21 10:35:47 UTC (rev 11944)
+++ trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/events/StyleAttributes.java 2008-11-21 13:53:11 UTC (rev 11945)
@@ -1,81 +1,141 @@
-/*******************************************************************************
- * 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();
- }
-
-}
+/*******************************************************************************
+ * 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.Map.Entry;
+import java.util.Set;
+
+/**
+ * Class is used to store an array of style attributes and support listeners.
+ */
+public class StyleAttributes {
+
+ private HashMap<String, String> attributeMap;
+ private ArrayList<ChangeStyleListener> listeners = new ArrayList<ChangeStyleListener>();
+
+ /**
+ * Default constructor.
+ */
+ public StyleAttributes() {
+ this.attributeMap = new HashMap<String, String>();
+ }
+
+ /**
+ * Gets attribute map.
+ *
+ * @return map of attributes
+ */
+ public HashMap<String, String> getAttributeMap() {
+ return attributeMap;
+ }
+
+ /**
+ * Sets attribute map.
+ *
+ * @param attributeMap value
+ */
+ public void setAttributeMap(HashMap<String, String> attributeMap) {
+ this.attributeMap = attributeMap;
+ notifyListeners();
+ }
+
+ /**
+ * Add ChangeStyleListener object.
+ *
+ * @param listener ChangeStyleListener object to be added
+ */
+ public void addChangeStyleListener(ChangeStyleListener listener) {
+ listeners.add(listener);
+ }
+
+ /**
+ * Gets an array of ChangeStyleListener object.
+ *
+ * @return an array of ChangeStyleListener object
+ */
+ public ChangeStyleListener[] getChangeStyleListeners() {
+ return listeners.toArray(new ChangeStyleListener[listeners.size()]);
+ }
+
+ /**
+ * Remove ChangeStyleListener object passed by parameter.
+ *
+ * @param listener ChangeStyleListener object to be removed
+ */
+ public void removeChangeStyleListener(ChangeStyleListener listener) {
+ listeners.remove(listener);
+ }
+
+ /**
+ * Add attribute with the given name and value.
+ *
+ * @param name the name of attribute
+ * @param value the value of attribute
+ */
+ public void addAttribute(String name, String value) {
+ attributeMap.put(name, value);
+ notifyListeners();
+ }
+
+ /**
+ * Remove attribute with the given name.
+ *
+ * @param name the name of attribute to be removed
+ */
+ public void removeAttribute(String name) {
+ attributeMap.remove(name);
+ notifyListeners();
+ }
+
+ /**
+ * @see java.util.HashMap#entrySet()
+ */
+ public Set<Entry<String, String>> entrySet() {
+ return attributeMap.entrySet();
+ }
+
+ /**
+ * Get attribute value with the given name.
+ *
+ * @param name the name of attribute to be returned
+ * @return attribute value
+ */
+ public String getAttribute(String name) {
+ return attributeMap.get(name);
+ }
+
+ /**
+ * @see java.util.HashMap#keySet()
+ */
+ public Set<String> keySet() {
+ return attributeMap.keySet();
+ }
+
+ /**
+ * Clear cache of attributes.
+ */
+ public void clear() {
+ attributeMap.clear();
+ notifyListeners();
+ }
+
+ /**
+ * Method is used to notify all subscribed listeners about any changes within style attribute map.
+ */
+ private void notifyListeners() {
+ ChangeStyleEvent event = new ChangeStyleEvent(this);
+ for (ChangeStyleListener listener : listeners) {
+ listener.styleChanged(event);
+ }
+ }
+}
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-11-21 10:35:47 UTC (rev 11944)
+++ trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/events/TabPropertySheetMouseAdapter.java 2008-11-21 13:53:11 UTC (rev 11945)
@@ -10,12 +10,13 @@
******************************************************************************/
package org.jboss.tools.jst.jsp.outline.cssdialog.events;
+import java.util.ArrayList;
+import java.util.HashMap;
+
import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IProject;
-
+import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.window.Window;
-
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.TreeEditor;
import org.eclipse.swt.events.DisposeEvent;
@@ -39,10 +40,8 @@
import org.eclipse.swt.widgets.Text;
import org.eclipse.swt.widgets.Tree;
import org.eclipse.swt.widgets.TreeItem;
-
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.messages.JstUIMessages;
import org.jboss.tools.jst.jsp.outline.cssdialog.FontFamilyDialog;
@@ -54,9 +53,6 @@
import org.jboss.tools.jst.jsp.outline.cssdialog.parsers.ColorParser;
import org.jboss.tools.jst.jsp.outline.cssdialog.tabs.TabPropertySheetControl;
-import java.util.ArrayList;
-import java.util.HashMap;
-
/**
* Listener for tree in tab property sheet
*
@@ -75,10 +71,18 @@
private HashMap<String, ArrayList<String>> comboMap;
private HashMap<String, ArrayList<String>> elementsMap;
- //Dzmitry Sakovich
- //private CSSDialog cssDialog;
private TabPropertySheetControl tabPropertySheetControl;
+ private ArrayList<ManualChangeStyleListener> listeners = new ArrayList<ManualChangeStyleListener>();
+
+ /**
+ * Constructor.
+ *
+ * @param tree
+ * @param elementsMap
+ * @param comboMap
+ * @param tabPropertySheetControl
+ */
public TabPropertySheetMouseAdapter(Tree tree, HashMap<String, ArrayList<String>> elementsMap,
HashMap<String, ArrayList<String>> comboMap, TabPropertySheetControl tabPropertySheetControl) {
this.tabPropertySheetControl = tabPropertySheetControl;
@@ -164,19 +168,18 @@
item.setText(Constants.SECOND_COLUMN, colorCombo.getText());
panel.dispose();
tabPropertySheetControl.updateData(true);
-
- //Dzmitry Sakovich
- //cssDialog.setStyleForPreview();
+ if (!tabPropertySheetControl.getUpdateDataFromStyleAttributes()) {
+ notifyListeners();
+ }
}
});
-
colorCombo.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent event) {
item.setText(Constants.SECOND_COLUMN, colorCombo.getText());
tabPropertySheetControl.updateData(true);
-
- //TODO Dzmitry Sakovich
- //cssDialog.setStyleForPreview();
+ if (!tabPropertySheetControl.getUpdateDataFromStyleAttributes()) {
+ notifyListeners();
+ }
}
});
@@ -193,12 +196,9 @@
}
});
btn.setToolTipText(JstUIMessages.COLOR_DIALOG_TITLE);
-
btn.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
- RGB startRgb = Util.getColor(item.getText(Constants.SECOND_COLUMN).toLowerCase()
- .trim());
-
+ RGB startRgb = Util.getColor(item.getText(Constants.SECOND_COLUMN).toLowerCase().trim());
if (startRgb == null) {
startRgb = Constants.RGB_BLACK;
}
@@ -210,18 +210,15 @@
RGB rgb = colorDialog.open();
if (rgb != null) {
String str = Util.createColorString(rgb);
-
if (ColorParser.getInstance().getMap().get(str) != null) {
- item.setText(Constants.SECOND_COLUMN,
- ColorParser.getInstance().getMap().get(str));
+ item.setText(Constants.SECOND_COLUMN, ColorParser.getInstance().getMap().get(str));
} else {
item.setText(Constants.SECOND_COLUMN, str);
}
-
tabPropertySheetControl.updateData(true);
-
- //TODO Dzmitry Sakovich
- //cssDialog.setStyleForPreview();
+ if (!tabPropertySheetControl.getUpdateDataFromStyleAttributes()) {
+ notifyListeners();
+ }
}
panel.dispose();
@@ -243,10 +240,9 @@
}
});
btn.setToolTipText(JstUIMessages.IMAGE_DIALOG_MESSAGE);
-
btn.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
- IProject project = Util.getCurrentProject();
+ IAdaptable project = Util.getCurrentProject();
ImageSelectionDialog dialog = new ImageSelectionDialog(tree.getShell(),
new WorkbenchLabelProvider(), new WorkbenchContentProvider());
@@ -262,9 +258,9 @@
item.setText(Constants.SECOND_COLUMN, value);
panel.dispose();
tabPropertySheetControl.updateData(true);
-
- //TODO Dzmitry Sakovich
- //cssDialog.setStyleForPreview();
+ if (!tabPropertySheetControl.getUpdateDataFromStyleAttributes()) {
+ notifyListeners();
+ }
}
}
});
@@ -276,17 +272,15 @@
if (!color) {
ArrayList<String> list = comboMap.get(item.getText(Constants.FIRST_COLUMN).trim());
- for (String str : list)
+ for (String str : list) {
combo.add(str);
-
+ }
if (btn != null) {
btn.setLayoutData(new GridData(GridData.END, GridData.CENTER, false, false));
}
combo.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false));
-
combo.setFocus();
-
if ((combo.indexOf(item.getText(column)) == Constants.DONT_CONTAIN) &&
!item.getText(column).equals(Constants.EMPTY)) {
combo.setText(item.getText(column));
@@ -294,34 +288,29 @@
combo.select(combo.indexOf(item.getText(column)));
}
- // Add a listener to set the selected item back into the
- // cell
+ // Add a listener to set the selected item back into the cell
final int col = column;
combo.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
item.setText(col, combo.getText());
panel.dispose();
tabPropertySheetControl.updateData(true);
-
- //TODO Dzmitry Sakovich
- //cssDialog.setStyleForPreview();
+ if (!tabPropertySheetControl.getUpdateDataFromStyleAttributes()) {
+ notifyListeners();
+ }
}
});
-
combo.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent event) {
item.setText(col, combo.getText());
- tabPropertySheetControl.updateData(true);
-
- //TODO Dzmitry Sakovich
- //cssDialog.setStyleForPreview();
+ if (!tabPropertySheetControl.getUpdateDataFromStyleAttributes()) {
+ notifyListeners();
+ }
}
});
} else {
colorCombo.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false));
-
btn.setLayoutData(new GridData(GridData.END, GridData.CENTER, false, false));
-
colorCombo.setFocus();
}
@@ -357,7 +346,6 @@
Button btn = null;
final Text text = new Text(panel, SWT.BORDER);
-
if (item.getText(Constants.FIRST_COLUMN).trim().equalsIgnoreCase(CSSConstants.FONT_FAMILY)) {
btn = new Button(panel, SWT.NONE);
@@ -371,19 +359,17 @@
}
});
btn.setToolTipText(JstUIMessages.FONT_FAMILY_TIP);
-
btn.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
FontFamilyDialog dialog = new FontFamilyDialog(tree.getShell(),
item.getText(Constants.SECOND_COLUMN));
-
if (dialog.open() == Window.OK) {
item.setText(Constants.SECOND_COLUMN, dialog.getFontFamily());
panel.dispose();
tabPropertySheetControl.updateData(true);
-
- //TODO Dzmitry Sakovich
- //cssDialog.setStyleForPreview();
+ if (!tabPropertySheetControl.getUpdateDataFromStyleAttributes()) {
+ notifyListeners();
+ }
}
}
});
@@ -417,14 +403,50 @@
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
+ // Set the text of the editor's control back into the cell
item.setText(col, text.getText());
tabPropertySheetControl.updateData(true);
-
- //TODO Dzmitry Sakovich
- //cssDialog.setStyleForPreview();
+ if (!tabPropertySheetControl.getUpdateDataFromStyleAttributes()) {
+ 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);
+ }
+ }
}
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-11-21 10:35:47 UTC (rev 11944)
+++ trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/tabs/TabBackgroundControl.java 2008-11-21 13:53:11 UTC (rev 11945)
@@ -17,7 +17,7 @@
import java.util.Map.Entry;
import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.DisposeEvent;
@@ -44,6 +44,8 @@
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.StyleAttributes;
import org.jboss.tools.jst.jsp.outline.cssdialog.parsers.ColorParser;
@@ -61,8 +63,8 @@
private Combo backgroundRepeatCombo;
private StyleAttributes styleAttributes;
- //TODO Dzmitry Sakovich
- //private CSSDialog cssDialog;
+ private ArrayList<ManualChangeStyleListener> listeners = new ArrayList<ManualChangeStyleListener>();
+ private boolean updateDataFromStyleAttributes = false;
/**
* Constructor for creating controls
@@ -74,8 +76,6 @@
super(composite, SWT.NONE);
this.styleAttributes = styleAttributes;
- //TODO Dzmitry Sakovich
- //this.cssDialog = dialog;
final GridLayout gridLayout = new GridLayout();
gridLayout.numColumns = numColumns;
setLayout(gridLayout);
@@ -89,19 +89,17 @@
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) {
String tmp = colorCombo.getText();
- if (tmp != null) {
- if (tmp.trim().length() > 0) {
- styleAttributes.addAttribute(CSSConstants.BACKGROUND_COLOR, tmp);
- } else {
- styleAttributes.removeAttribute(CSSConstants.BACKGROUND_COLOR);
- }
+ if (tmp != null && tmp.trim().length() > 0) {
+ styleAttributes.addAttribute(CSSConstants.BACKGROUND_COLOR, tmp);
+ } else {
+ styleAttributes.removeAttribute(CSSConstants.BACKGROUND_COLOR);
}
- //TODO Dzmitry Sakovich
- //cssDialog.setStyleForPreview();
+ if (!updateDataFromStyleAttributes) {
+ notifyListeners();
+ }
}
});
Set<Entry<String, String>> set = ColorParser.getInstance().getMap().entrySet();
@@ -132,7 +130,6 @@
dlg.setText(JstUIMessages.COLOR_DIALOG_TITLE);
RGB rgb = dlg.open();
-
if (rgb != null) {
String colorStr = Util.createColorString(rgb);
colorCombo.setText(colorStr);
@@ -148,25 +145,21 @@
label.setText(JstUIMessages.BACKGROUND_IMAGE);
backgroundImageCombo = new Combo(this, SWT.BORDER);
-
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) {
- if (tmp.trim().length() > 0) {
- tmp = adjustBackgroundURL(tmp);
- styleAttributes.addAttribute(CSSConstants.BACKGROUND_IMAGE, tmp);
- } else {
- styleAttributes.removeAttribute(CSSConstants.BACKGROUND_IMAGE);
- }
+ if (tmp != null && tmp.trim().length() > 0) {
+ tmp = adjustBackgroundURL(tmp);
+ styleAttributes.addAttribute(CSSConstants.BACKGROUND_IMAGE, tmp);
+ } else {
+ styleAttributes.removeAttribute(CSSConstants.BACKGROUND_IMAGE);
}
- //TODO Dzmitry Sakovich
- //cssDialog.setStyleForPreview();
+ if (!updateDataFromStyleAttributes) {
+ notifyListeners();
+ }
}
});
@@ -185,7 +178,7 @@
});
button.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
- IProject project = Util.getCurrentProject();
+ IAdaptable project = Util.getCurrentProject();
ImageSelectionDialog dialog = new ImageSelectionDialog(getShell(),
new WorkbenchLabelProvider(), new WorkbenchContentProvider());
dialog.setTitle(JstUIMessages.IMAGE_DIALOG_TITLE);
@@ -215,20 +208,17 @@
gridData.horizontalSpan = 2;
backgroundRepeatCombo = new Combo(this, SWT.BORDER);
backgroundRepeatCombo.setLayoutData(gridData);
-
backgroundRepeatCombo.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent event) {
String tmp = backgroundRepeatCombo.getText();
-
- if (tmp != null) {
- if (tmp.trim().length() > 0) {
- styleAttributes.addAttribute(CSSConstants.BACKGROUND_REPEAT, tmp);
- } else {
- styleAttributes.removeAttribute(CSSConstants.BACKGROUND_REPEAT);
- }
+ if (tmp != null && tmp.trim().length() > 0) {
+ styleAttributes.addAttribute(CSSConstants.BACKGROUND_REPEAT, tmp);
+ } else {
+ styleAttributes.removeAttribute(CSSConstants.BACKGROUND_REPEAT);
}
- //TODO Dzmitry Sakovich
- //cssDialog.setStyleForPreview();
+ if (!updateDataFromStyleAttributes) {
+ notifyListeners();
+ }
}
});
ArrayList<String> list = comboMap.get(CSSConstants.BACKGROUND_REPEAT);
@@ -244,25 +234,27 @@
* @param param
*/
public void updateData(boolean param) {
+ updateDataFromStyleAttributes = true;
String tmp;
-
+ // set BACKGROUND_COLOR attribute
if ((tmp = styleAttributes.getAttribute(CSSConstants.BACKGROUND_COLOR)) != null) {
colorCombo.setText(tmp);
} else {
colorCombo.setText(Constants.EMPTY);
}
-
+ // set BACKGROUND_IMAGE attribute
if ((tmp = styleAttributes.getAttribute(CSSConstants.BACKGROUND_IMAGE)) != null) {
backgroundImageCombo.setText(tmp);
} else {
backgroundImageCombo.setText(Constants.EMPTY);
}
-
+ // set BACKGROUND_REPEAT attribute
if ((tmp = styleAttributes.getAttribute(CSSConstants.BACKGROUND_REPEAT)) != null) {
backgroundRepeatCombo.setText(tmp);
} else {
backgroundRepeatCombo.setText(Constants.EMPTY);
}
+ updateDataFromStyleAttributes = false;
}
//Fix for JBIDE-3084
@@ -275,4 +267,41 @@
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-11-21 10:35:47 UTC (rev 11944)
+++ trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/tabs/TabBoxesControl.java 2008-11-21 13:53:11 UTC (rev 11945)
@@ -37,6 +37,8 @@
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.StyleAttributes;
import org.jboss.tools.jst.jsp.outline.cssdialog.parsers.ColorParser;
@@ -70,8 +72,8 @@
private ArrayList<String> list;
private StyleAttributes styleAttributes;
- // TODO Dzmitry Sakovich
- // private CSSDialog cssDialog;
+ private ArrayList<ManualChangeStyleListener> listeners = new ArrayList<ManualChangeStyleListener>();
+ private boolean updateDataFromStyleAttributes = false;
/**
* Constructor for creating controls
@@ -103,50 +105,38 @@
widthText = new Text(this, SWT.BORDER | SWT.SINGLE);
widthText.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false));
-
- extWidthCombo = new Combo(this, SWT.BORDER | SWT.READ_ONLY);
- extWidthCombo.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, false, false));
-
widthText.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent event) {
String tmp = widthText.getText();
-
- if (tmp != null) {
- if (tmp.trim().length() > 0) {
- String extWidth = extWidthCombo.getText().trim();
-
- if (extWidth != null) {
- styleAttributes.addAttribute(CSSConstants.WIDTH, tmp + extWidth);
- } else {
- styleAttributes.addAttribute(CSSConstants.WIDTH, tmp);
- }
- } else {
- styleAttributes.removeAttribute(CSSConstants.WIDTH);
- }
+ if (tmp != null && tmp.trim().length() > 0) {
+ String extWidth = extWidthCombo.getText().trim();
+ if (extWidth != null) {
+ styleAttributes.addAttribute(CSSConstants.WIDTH, tmp + extWidth);
+ } else {
+ styleAttributes.addAttribute(CSSConstants.WIDTH, tmp);
+ }
} else {
styleAttributes.removeAttribute(CSSConstants.WIDTH);
}
-
- // TODO Dzmitry Sakovich
- // cssDialog.setStyleForPreview();
+ if (!updateDataFromStyleAttributes) {
+ notifyListeners();
+ }
}
});
+ 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) {
String width = widthText.getText().trim();
- if (width == null) {
- return;
+ if (width != null && !width.equals(Constants.EMPTY)) {
+ String tmp = extWidthCombo.getText();
+ if (tmp != null) {
+ styleAttributes.addAttribute(CSSConstants.WIDTH, width + tmp);
+ }
}
- if (width.equals(Constants.EMPTY)) {
- return;
+ if (!updateDataFromStyleAttributes) {
+ notifyListeners();
}
- String tmp = extWidthCombo.getText();
- if (tmp != null) {
- styleAttributes.addAttribute(CSSConstants.WIDTH, width + tmp);
-
- // TODO Dzmitry Sakovich
- // cssDialog.setStyleForPreview();
- }
}
});
for (int i = 0; i < Constants.extSizes.length; i++) {
@@ -162,47 +152,38 @@
heightText = new Text(this, SWT.BORDER | SWT.SINGLE);
heightText.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false));
-
- extHeightCombo = new Combo(this, SWT.BORDER | SWT.READ_ONLY);
- extHeightCombo.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, false, false));
-
heightText.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent event) {
String tmp = heightText.getText();
- if (tmp != null) {
- if (tmp.trim().length() > 0) {
- String extHeight = extHeightCombo.getText().trim();
- if (extHeight != null) {
- styleAttributes.addAttribute(CSSConstants.HEIGHT, tmp + extHeight);
- } else {
- styleAttributes.addAttribute(CSSConstants.HEIGHT, tmp);
- }
+ if (tmp != null && tmp.trim().length() > 0) {
+ String extHeight = extHeightCombo.getText().trim();
+ if (extHeight != null) {
+ styleAttributes.addAttribute(CSSConstants.HEIGHT, tmp + extHeight);
} else {
- styleAttributes.removeAttribute(CSSConstants.HEIGHT);
+ styleAttributes.addAttribute(CSSConstants.HEIGHT, tmp);
}
} else {
styleAttributes.removeAttribute(CSSConstants.HEIGHT);
}
-
- // TODO Dzmitry Sakovich
- // cssDialog.setStyleForPreview();
+ if (!updateDataFromStyleAttributes) {
+ notifyListeners();
+ }
}
});
+ 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) {
String height = heightText.getText().trim();
- if (height == null) {
- return;
+ if (height != null && !height.equals(Constants.EMPTY)) {
+ String tmp = extHeightCombo.getText();
+ if (tmp != null) {
+ styleAttributes.addAttribute(CSSConstants.HEIGHT, height + tmp);
+ }
}
- if (height.equals(Constants.EMPTY)) {
- return;
+ if (!updateDataFromStyleAttributes) {
+ notifyListeners();
}
- String tmp = extHeightCombo.getText();
- if (tmp != null) {
- styleAttributes.addAttribute(CSSConstants.HEIGHT, height + tmp);
- // TODO Dzmitry Sakovich
- // cssDialog.setStyleForPreview();
- }
}
});
for (int i = 0; i < Constants.extSizes.length; i++) {
@@ -225,21 +206,17 @@
gridData.horizontalSpan = 2;
borderStyleCombo = new Combo(this, SWT.BORDER);
borderStyleCombo.setLayoutData(gridData);
-
borderStyleCombo.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent event) {
String tmp = borderStyleCombo.getText().trim();
- if (tmp != null) {
- if (!tmp.equals(Constants.EMPTY)) {
- styleAttributes.addAttribute(CSSConstants.BORDER_STYLE, tmp);
- // TODO Dzmitry Sakovich
- // cssDialog.setStyleForPreview();
- return;
- }
+ if (tmp != null && !tmp.equals(Constants.EMPTY)) {
+ styleAttributes.addAttribute(CSSConstants.BORDER_STYLE, tmp);
+ } else {
+ styleAttributes.removeAttribute(CSSConstants.BORDER_STYLE);
}
- styleAttributes.removeAttribute(CSSConstants.BORDER_STYLE);
- // TODO Dzmitry Sakovich
- // cssDialog.setStyleForPreview();
+ if (!updateDataFromStyleAttributes) {
+ notifyListeners();
+ }
}
});
list = comboMap.get(CSSConstants.BORDER_STYLE);
@@ -257,21 +234,17 @@
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) {
String tmp = borderColorCombo.getText().trim();
- if (tmp != null) {
- if (!tmp.equals(Constants.EMPTY)) {
- styleAttributes.addAttribute(CSSConstants.BORDER_COLOR, tmp);
- // TODO Dzmitry Sakovich
- // cssDialog.setStyleForPreview();
- return;
- }
+ if (tmp != null && !tmp.equals(Constants.EMPTY)) {
+ styleAttributes.addAttribute(CSSConstants.BORDER_COLOR, tmp);
+ } else {
+ styleAttributes.removeAttribute(CSSConstants.BORDER_COLOR);
}
- styleAttributes.removeAttribute(CSSConstants.BORDER_COLOR);
- // TODO Dzmitry Sakovich
- // cssDialog.setStyleForPreview();
+ if (!updateDataFromStyleAttributes) {
+ notifyListeners();
+ }
}
});
Set<Entry<String, String>> set = ColorParser.getInstance().getMap().entrySet();
@@ -299,7 +272,6 @@
dlg.setRGB((Util.getColor((borderColorCombo.getText().trim())) == null)
? Constants.RGB_BLACK : Util.getColor((borderColorCombo.getText().trim())));
dlg.setText(JstUIMessages.COLOR_DIALOG_TITLE);
-
RGB rgb = dlg.open();
if (rgb != null) {
String colorStr = Util.createColorString(rgb);
@@ -317,10 +289,6 @@
borderWidthCombo = new Combo(this, SWT.BORDER | SWT.SINGLE);
borderWidthCombo.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false));
-
- extBorderWidthCombo = new Combo(this, SWT.BORDER | SWT.READ_ONLY);
- extBorderWidthCombo.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, false, false));
-
borderWidthCombo.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent e) {
String currentText = borderWidthCombo.getText();
@@ -330,54 +298,47 @@
extBorderWidthCombo.select(0);
extBorderWidthCombo.setEnabled(false);
styleAttributes.addAttribute(CSSConstants.BORDER_WIDTH, currentText);
- // TODO Dzmitry Sakovich
- // cssDialog.setStyleForPreview();
+ if (!updateDataFromStyleAttributes) {
+ notifyListeners();
+ }
return;
}
}
-
extBorderWidthCombo.setEnabled(true);
-
String tmp = borderWidthCombo.getText();
- if (tmp != null) {
- if (tmp.trim().length() > 0) {
- String extBorderWidth = extBorderWidthCombo.getText().trim();
-
- if (extBorderWidth != null) {
- styleAttributes.addAttribute(CSSConstants.BORDER_WIDTH,
- tmp + extBorderWidth);
- } else {
- styleAttributes.addAttribute(CSSConstants.BORDER_WIDTH, tmp);
- }
+ if (tmp != null && tmp.trim().length() > 0) {
+ String extBorderWidth = extBorderWidthCombo.getText();
+ if (extBorderWidth != null) {
+ styleAttributes.addAttribute(CSSConstants.BORDER_WIDTH, tmp + extBorderWidth);
} else {
- styleAttributes.removeAttribute(CSSConstants.BORDER_WIDTH);
+ styleAttributes.addAttribute(CSSConstants.BORDER_WIDTH, tmp);
}
} else {
styleAttributes.removeAttribute(CSSConstants.BORDER_WIDTH);
}
- // TODO Dzmitry Sakovich
- // cssDialog.setStyleForPreview();
+ if (!updateDataFromStyleAttributes) {
+ notifyListeners();
+ }
}
});
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) {
String borderWidth = borderWidthCombo.getText().trim();
- if (borderWidth == null) {
- return;
+ if (borderWidth != null && !borderWidth.equals(Constants.EMPTY)) {
+ String tmp = extBorderWidthCombo.getText();
+ if (tmp != null) {
+ styleAttributes.addAttribute(CSSConstants.BORDER_WIDTH, borderWidth + tmp);
+ }
}
- if (borderWidth.equals(Constants.EMPTY)) {
- return;
+ if (!updateDataFromStyleAttributes) {
+ notifyListeners();
}
- String tmp = extBorderWidthCombo.getText();
- if (tmp != null) {
- styleAttributes.addAttribute(CSSConstants.BORDER_WIDTH, borderWidth + tmp);
- // TODO Dzmitry Sakovich
- // cssDialog.setStyleForPreview();
- }
}
});
for (int i = 0; i < Constants.extSizes.length; i++) {
@@ -398,54 +359,38 @@
marginText = new Text(this, SWT.BORDER | SWT.SINGLE);
marginText.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false));
-
- extMarginCombo = new Combo(this, SWT.BORDER | SWT.READ_ONLY);
- extMarginCombo.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, false, false));
-
marginText.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent event) {
String tmp = marginText.getText();
-
- if (tmp != null) {
- if (tmp.trim().length() > 0) {
- String extMargin = extMarginCombo.getText().trim();
-
- if (extMargin != null) {
- styleAttributes.addAttribute(CSSConstants.MARGIN, tmp + extMargin);
- } else {
- styleAttributes.addAttribute(CSSConstants.MARGIN, tmp);
- }
- } else {
- styleAttributes.removeAttribute(CSSConstants.MARGIN);
- }
+ if (tmp != null && tmp.trim().length() > 0) {
+ String extMargin = extMarginCombo.getText().trim();
+ if (extMargin != null) {
+ styleAttributes.addAttribute(CSSConstants.MARGIN, tmp + extMargin);
+ } else {
+ styleAttributes.addAttribute(CSSConstants.MARGIN, tmp);
+ }
} else {
styleAttributes.removeAttribute(CSSConstants.MARGIN);
}
-
- // TODO Dzmitry Sakovich
- // cssDialog.setStyleForPreview();
+ if (!updateDataFromStyleAttributes) {
+ notifyListeners();
+ }
}
});
+ 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) {
String margin = marginText.getText().trim();
-
- if (margin == null) {
- return;
+ if (margin != null && !margin.equals(Constants.EMPTY)) {
+ String tmp = extMarginCombo.getText();
+ if (tmp != null) {
+ styleAttributes.addAttribute(CSSConstants.MARGIN, margin + tmp);
+ }
}
-
- if (margin.equals(Constants.EMPTY)) {
- return;
+ if (!updateDataFromStyleAttributes) {
+ notifyListeners();
}
-
- String tmp = extMarginCombo.getText();
-
- if (tmp != null) {
- styleAttributes.addAttribute(CSSConstants.MARGIN, margin + tmp);
-
- // TODO Dzmitry Sakovich
- // cssDialog.setStyleForPreview();
- }
}
});
for (int i = 0; i < Constants.extSizes.length; i++) {
@@ -461,54 +406,38 @@
paddingText = new Text(this, SWT.BORDER | SWT.SINGLE);
paddingText.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false));
-
- extPaddingCombo = new Combo(this, SWT.BORDER | SWT.READ_ONLY);
- extPaddingCombo.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, false, false));
-
paddingText.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent event) {
String tmp = paddingText.getText();
-
- if (tmp != null) {
- if (tmp.trim().length() > 0) {
- String extPadding = extPaddingCombo.getText().trim();
-
- if (extPadding != null) {
- styleAttributes.addAttribute(CSSConstants.PADDING, tmp + extPadding);
- } else {
- styleAttributes.addAttribute(CSSConstants.PADDING, tmp);
- }
- } else {
- styleAttributes.removeAttribute(CSSConstants.PADDING);
- }
+ if (tmp != null && tmp.trim().length() > 0) {
+ String extPadding = extPaddingCombo.getText().trim();
+ if (extPadding != null) {
+ styleAttributes.addAttribute(CSSConstants.PADDING, tmp + extPadding);
+ } else {
+ styleAttributes.addAttribute(CSSConstants.PADDING, tmp);
+ }
} else {
styleAttributes.removeAttribute(CSSConstants.PADDING);
}
-
- // TODO Dzmitry Sakovich
- // cssDialog.setStyleForPreview();
+ if (!updateDataFromStyleAttributes) {
+ notifyListeners();
+ }
}
});
+ 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) {
String padding = paddingText.getText().trim();
-
- if (padding == null) {
- return;
+ if (padding != null && !padding.equals(Constants.EMPTY)) {
+ String tmp = extPaddingCombo.getText();
+ if (tmp != null) {
+ styleAttributes.addAttribute(CSSConstants.PADDING, padding + tmp);
+ }
}
-
- if (padding.equals(Constants.EMPTY)) {
- return;
+ if (!updateDataFromStyleAttributes) {
+ notifyListeners();
}
-
- String tmp = extPaddingCombo.getText();
-
- if (tmp != null) {
- styleAttributes.addAttribute(CSSConstants.PADDING, padding + tmp);
-
- // TODO Dzmitry Sakovich
- // cssDialog.setStyleForPreview();
- }
}
});
for (int i = 0; i < Constants.extSizes.length; i++) {
@@ -533,18 +462,17 @@
}
/**
- * Method for get data in controls (if param equal true ), or set data (if
- * param equal false).
+ * Method for get data in controls (if parameter equals true ), or set data (if parameter equals false).
*
* @param param
*/
public void updateData(boolean param) {
+ updateDataFromStyleAttributes = true;
String tmp;
-
+ // set WIDTH and EXTENSION_WIDTH attributes
if ((tmp = styleAttributes.getAttribute(CSSConstants.WIDTH)) != null) {
String[] str = Util.convertExtString(tmp);
widthText.setText(str[0]);
-
if (extWidthCombo.indexOf(str[1]) != -1) {
extWidthCombo.setText(str[1]);
extWidthCombo.select(extWidthCombo.indexOf(str[1]));
@@ -555,7 +483,7 @@
widthText.setText(Constants.EMPTY);
extWidthCombo.select(0);
}
-
+ // set HEIGHT and EXTENSION_HEIGHT attributes
if ((tmp = styleAttributes.getAttribute(CSSConstants.HEIGHT)) != null) {
String[] str = Util.convertExtString(tmp);
heightText.setText(str[0]);
@@ -570,19 +498,19 @@
heightText.setText(Constants.EMPTY);
extHeightCombo.select(0);
}
-
+ // set BORDER_STYLE attribute
if ((tmp = styleAttributes.getAttribute(CSSConstants.BORDER_STYLE)) != null) {
borderStyleCombo.setText(tmp);
} else {
borderStyleCombo.setText(Constants.EMPTY);
}
-
+ // set BORDER_COLOR attribute
if ((tmp = styleAttributes.getAttribute(CSSConstants.BORDER_COLOR)) != null) {
borderColorCombo.setText(tmp);
} else {
borderColorCombo.setText(Constants.EMPTY);
}
-
+ // set BORDER_WIDTH and EXTENSION_BORDER_WIDTH attributes
if ((tmp = styleAttributes.getAttribute(CSSConstants.BORDER_WIDTH)) != null) {
String[] str = Util.convertExtString(tmp);
borderWidthCombo.setText(str[0]);
@@ -597,7 +525,7 @@
borderWidthCombo.setText(Constants.EMPTY);
extBorderWidthCombo.select(0);
}
-
+ // set MARGIN and EXTENSION_MARGIN attributes
if ((tmp = styleAttributes.getAttribute(CSSConstants.MARGIN)) != null) {
String[] str = Util.convertExtString(tmp);
marginText.setText(str[0]);
@@ -612,7 +540,7 @@
marginText.setText(Constants.EMPTY);
extMarginCombo.select(0);
}
-
+ // set PADDING and EXTENSION_PADDING attributes
if ((tmp = styleAttributes.getAttribute(CSSConstants.PADDING)) != null) {
String[] str = Util.convertExtString(tmp);
paddingText.setText(str[0]);
@@ -627,5 +555,43 @@
paddingText.setText(Constants.EMPTY);
extPaddingCombo.select(0);
}
+ updateDataFromStyleAttributes = false;
}
-}
+
+ /**
+ * 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
Added: 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 (rev 0)
+++ trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/tabs/TabPreviewControl.java 2008-11-21 13:53:11 UTC (rev 11945)
@@ -0,0 +1,92 @@
+/*******************************************************************************
+ * 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.tabs;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.browser.Browser;
+import org.eclipse.swt.layout.FillLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IEditorReference;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.internal.EditorAreaHelper;
+import org.eclipse.ui.internal.EditorManager;
+import org.eclipse.ui.internal.WorkbenchPage;
+import org.eclipse.ui.internal.WorkbenchWindow;
+import org.eclipse.ui.part.FileEditorInput;
+import org.eclipse.wst.sse.ui.StructuredTextEditor;
+import org.jboss.tools.jst.jsp.outline.cssdialog.events.StyleAttributes;
+
+/**
+ * Class for creating Preview sheet tab
+ */
+public class TabPreviewControl extends Composite {
+
+ /** Editor in which we open visual page. */
+ protected final static String EDITOR_ID = "org.eclipse.wst.css.core.csssource.source"; //$NON-NLS-1$
+
+ private IFile cssFile = null;
+ private StructuredTextEditor editor = null;
+
+ /**
+ * Constructor for creating controls
+ *
+ * @param composite The parent composite for tab
+ */
+ public TabPreviewControl(Composite tabFolder, StyleAttributes styleAttributes) {
+ super(tabFolder, SWT.NONE);
+ setLayout(new FillLayout());
+ }
+
+ /**
+ *
+ */
+ public void updateDataFile(IFile cssFile) {
+ if (cssFile != null) {
+ this.cssFile = cssFile;
+ IEditorInput input = new FileEditorInput(cssFile);
+
+ try {
+ WorkbenchWindow workbenchWindow = (WorkbenchWindow)PlatformUI.getWorkbench().getActiveWorkbenchWindow();
+ EditorAreaHelper editorPresentation = new EditorAreaHelper((WorkbenchPage) workbenchWindow.getActivePage());
+ EditorManager editorManager = new EditorManager(workbenchWindow, (WorkbenchPage) workbenchWindow.getActivePage(), editorPresentation);
+
+ IEditorReference ref = editorManager.openEditor(EDITOR_ID, input, true, null);
+
+ if (ref != null) {
+// if (getChildren() != null && getChildren().length > 0) {
+ if (editor != null) {
+// editor.doRevertToSaved();
+// editor.dispose();
+ getChildren()[0].dispose();
+ }
+ editor = (StructuredTextEditor)ref.getEditor(true);
+ editor.createPartControl(this);
+ editor.getTextViewer().setEditable(false);
+ }
+
+ layout();
+ } catch (PartInitException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+ }
+
+ public void closeEditor(boolean save) {
+ if (editor != null) {
+ editor.close(save);
+ editor.doRevertToSaved();
+ }
+ }
+}
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-11-21 10:35:47 UTC (rev 11944)
+++ trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/tabs/TabPropertySheetControl.java 2008-11-21 13:53:11 UTC (rev 11945)
@@ -18,11 +18,11 @@
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.TabFolder;
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.common.Constants;
+import org.jboss.tools.jst.jsp.outline.cssdialog.events.ManualChangeStyleListener;
import org.jboss.tools.jst.jsp.outline.cssdialog.events.StyleAttributes;
import org.jboss.tools.jst.jsp.outline.cssdialog.events.TabPropertySheetMouseAdapter;
@@ -37,12 +37,15 @@
private Tree tree;
private StyleAttributes styleAttributes;
+ private TabPropertySheetMouseAdapter propertySheetMouseAdapter = null;
+ boolean updateDataFromStyleAttributes = false;
+
/**
* Constructor for creating controls
*
* @param composite The parent composite for tab
*/
- public TabPropertySheetControl(TabFolder tabFolder, HashMap<String, ArrayList<String>> elementMap,
+ public TabPropertySheetControl(Composite tabFolder, HashMap<String, ArrayList<String>> elementMap,
HashMap<String, ArrayList<String>> comboMap, StyleAttributes styleAttributes) {
super(tabFolder, SWT.NONE);
this.styleAttributes = styleAttributes;
@@ -65,7 +68,6 @@
item.setFont(Constants.FIRST_COLUMN, JFaceResources.getFontRegistry().get(JFaceResources.TEXT_FONT));
ArrayList<String> list = elementMap.get(str);
-
for (String strList : list) {
TreeItem subItem = new TreeItem(item, SWT.NONE);
subItem.setText(Constants.FIRST_COLUMN, strList);
@@ -74,8 +76,8 @@
updateData(false);
- tree.addMouseListener(new TabPropertySheetMouseAdapter(tree, elementMap, comboMap, this));
-
+ propertySheetMouseAdapter = new TabPropertySheetMouseAdapter(tree, elementMap, comboMap, this);
+ tree.addMouseListener(propertySheetMouseAdapter);
for (int i = 0; i < tree.getColumnCount(); i++) {
tree.getColumn(i).pack();
}
@@ -105,9 +107,12 @@
}
}
} else {
- for (int i = 0; i < tree.getItemCount(); i++)
- for (int j = 0; j < tree.getItem(i).getItemCount(); j++)
+ updateDataFromStyleAttributes = true;
+ for (int i = 0; i < tree.getItemCount(); i++) {
+ for (int j = 0; j < tree.getItem(i).getItemCount(); j++) {
tree.getItem(i).getItem(j).setText(Constants.SECOND_COLUMN, Constants.EMPTY);
+ }
+ }
Set<String> set = styleAttributes.keySet();
for (String str : set) {
@@ -121,6 +126,7 @@
}
}
setExpanded();
+ updateDataFromStyleAttributes = false;
}
}
@@ -129,18 +135,15 @@
*/
private void setExpanded() {
TreeItem item = null;
-
for (int i = 0; i < tree.getItemCount(); i++) {
tree.getItem(i).setExpanded(false);
}
-
Set<String> set = styleAttributes.keySet();
for (String attr : set) {
if ((item = find(attr)) != null) {
item.setExpanded(true);
}
}
-
for (int i = 0; i < tree.getColumnCount(); i++) {
tree.getColumn(i).pack();
}
@@ -155,13 +158,10 @@
private TreeItem find(String attr) {
TreeItem item = null;
TreeItem subItem = null;
-
for (int i = 0; i < tree.getItemCount(); i++) {
item = tree.getItem(i);
-
for (int j = 0; j < item.getItemCount(); j++) {
subItem = item.getItem(j);
-
if (subItem.getText().equals(attr)) {
return item;
}
@@ -170,4 +170,24 @@
return null;
}
+
+ /**
+ * Gets the getUpdateDataFromStyleAttributes parameter value.
+ *
+ * @return boolean value
+ */
+ public boolean getUpdateDataFromStyleAttributes() {
+ return updateDataFromStyleAttributes;
+ }
+
+ /**
+ * Add ManualChangeStyleListener object.
+ *
+ * @param listener ChangeStyleListener object to be added
+ */
+ public void addManualChangeStyleListener(ManualChangeStyleListener listener) {
+ if (propertySheetMouseAdapter != null) {
+ propertySheetMouseAdapter.addManualChangeStyleListener(listener);
+ }
+ }
}
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-11-21 10:35:47 UTC (rev 11944)
+++ trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/tabs/TabQuickEditControl.java 2008-11-21 13:53:11 UTC (rev 11945)
@@ -10,12 +10,15 @@
******************************************************************************/
package org.jboss.tools.jst.jsp.outline.cssdialog.tabs;
+import java.util.ArrayList;
+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.core.runtime.IAdaptable;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.window.Window;
-
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.DisposeEvent;
import org.eclipse.swt.events.DisposeListener;
@@ -34,10 +37,8 @@
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Text;
-
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.messages.JstUIMessages;
import org.jboss.tools.jst.jsp.outline.cssdialog.FontFamilyDialog;
@@ -46,14 +47,11 @@
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.StyleAttributes;
import org.jboss.tools.jst.jsp.outline.cssdialog.parsers.ColorParser;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.StringTokenizer;
-
/**
* Class for creating control in Quick edit tab
*
@@ -70,8 +68,9 @@
private HashMap<String, ArrayList<String>> comboMap;
private StyleAttributes styleAttributes;
- //TODO Dzmitry Sakovich
- //private CSSDialog dialog;
+ private ArrayList<ManualChangeStyleListener> listeners = new ArrayList<ManualChangeStyleListener>();
+ private boolean updateDataFromStyleAttributes = false;
+
/**
* Constructor for creating controls
*
@@ -81,8 +80,6 @@
StyleAttributes styleAttributes) {
super(sc, SWT.NONE);
- //TODO Dzmitry Sakovich
- //this.dialog = dialog;
this.styleAttributes = styleAttributes;
this.comboMap = comboMap;
@@ -90,22 +87,7 @@
gridLayout.numColumns = GRID_NUM_COLUMNS;
setLayout(gridLayout);
- 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 (comboMap.keySet().contains(key)) {
- createCombo(key, styleAttributes.getAttribute(key));
- } else {
- createText(key, styleAttributes.getAttribute(key));
- }
- }
+ init();
}
/**
@@ -113,7 +95,6 @@
*/
public void updateData() {
Control[] controls = this.getChildren();
-
if (controls != null) {
for (int i = 0; i < controls.length; i++) {
if (!controls[i].isDisposed()) {
@@ -122,25 +103,32 @@
}
}
+ init();
+ this.layout();
+ }
+
+ /**
+ * Initialize method.
+ */
+ private void init() {
ArrayList<String> listKeys = new ArrayList<String>();
for (String key : styleAttributes.keySet()) {
listKeys.add(key);
}
-
Collections.sort(listKeys);
+ updateDataFromStyleAttributes = true;
for (String key : listKeys) {
label = new Label(this, SWT.LEFT);
label.setText(format(key));
label.setLayoutData(new GridData(GridData.END, GridData.CENTER, false, false));
-
+ // each attribute might be represented in two ways
if (comboMap.keySet().contains(key)) {
createCombo(key, styleAttributes.getAttribute(key));
} else {
createText(key, styleAttributes.getAttribute(key));
}
}
-
- this.layout();
+ updateDataFromStyleAttributes = false;
}
/**
@@ -176,7 +164,6 @@
btn.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
RGB startRgb = Util.getColor((colorCombo.getText().toLowerCase().trim()));
-
if (startRgb == null) {
startRgb = Constants.RGB_BLACK;
}
@@ -188,7 +175,6 @@
RGB rgb = colorDialog.open();
if (rgb != null) {
String str = Util.createColorString(rgb);
-
if (ColorParser.getInstance().getMap().get(str) != null) {
colorCombo.setText(ColorParser.getInstance().getMap().get(str));
} else {
@@ -206,24 +192,21 @@
} else {
styleAttributes.removeAttribute(key);
}
- //TODO Dzmitry Sakovich
- //dialog.setStyleForPreview();
+ if (!updateDataFromStyleAttributes) {
+ notifyListeners();
+ }
}
});
-
HashMap<String, String> colorMap = ColorParser.getInstance().getMap();
-
for (String key : colorMap.keySet()) {
RGB rgb = Util.getColor(key);
colorCombo.add(colorMap.get(key), rgb);
}
-
if (btn == null) {
new Label(this, SWT.NONE);
}
colorCombo.setText(value);
-
//if css attribute contain choose_folder button
} else if (Util.containFolder(name)) {
Composite tmpComposite = getCompositeElement();
@@ -251,7 +234,7 @@
btn.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
- IProject project = Util.getCurrentProject();
+ IAdaptable project = Util.getCurrentProject();
ImageSelectionDialog dialog = new ImageSelectionDialog(getShell(),
new WorkbenchLabelProvider(), new WorkbenchContentProvider());
String title = JstUIMessages.IMAGE_DIALOG_TITLE;
@@ -279,8 +262,9 @@
} else {
styleAttributes.removeAttribute(key);
}
- //TODO Dzmitry Sakovich
- //dialog.setStyleForPreview();
+ if (!updateDataFromStyleAttributes) {
+ notifyListeners();
+ }
}
});
} else {
@@ -309,24 +293,20 @@
}
extCombo.select(extCombo.indexOf(values[EXT_VALUE_NUMBER]));
-
extCombo.addModifyListener(new ModifyListener() {
String key = name;
public void modifyText(ModifyEvent event) {
String tmpCombo = combo.getText().trim();
- if (tmpCombo == null) {
- return;
+ if (tmpCombo != null && !tmpCombo.equals(Constants.EMPTY)) {
+ String tmpExt = extCombo.getText();
+ if (tmpExt != null) {
+ styleAttributes.addAttribute(key, tmpCombo + tmpExt);
+ }
}
- if (tmpCombo.equals(Constants.EMPTY)) {
- return;
+ if (!updateDataFromStyleAttributes) {
+ notifyListeners();
}
- String tmpExt = extCombo.getText();
- if (tmpExt != null) {
- styleAttributes.addAttribute(key, tmpCombo + tmpExt);
- //TODO Dzmitry Sakovich
- //dialog.setStyleForPreview();
- }
}
});
@@ -335,54 +315,49 @@
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);
- //TODO Dzmitry Sakovich
- //dialog.setStyleForPreview();
+ if (!updateDataFromStyleAttributes) {
+ notifyListeners();
+ }
return;
}
}
extCombo.setEnabled(true);
-
String tmp = combo.getText().trim();
- if (tmp != null) {
- if (!tmp.equals(Constants.EMPTY)) {
- String extTmp = extCombo.getText().trim();
-
- if (extTmp != null) {
- styleAttributes.addAttribute(key, tmp + extTmp);
- } else {
- styleAttributes.addAttribute(key, tmp);
- }
- } else {
- styleAttributes.removeAttribute(key);
- }
+ if (tmp != null && !tmp.equals(Constants.EMPTY)) {
+ String extTmp = extCombo.getText().trim();
+ if (extTmp != null) {
+ styleAttributes.addAttribute(key, tmp + extTmp);
+ } else {
+ styleAttributes.addAttribute(key, tmp);
+ }
} else {
styleAttributes.removeAttribute(key);
}
- //TODO Dzmitry Sakovich
- //dialog.setStyleForPreview();
+ if (!updateDataFromStyleAttributes) {
+ notifyListeners();
+ }
}
});
} else {
-// new Label(this, SWT.NONE).setLayoutData(new GridData(GridData.END, GridData.CENTER, false, false));
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);
}
- //TODO Dzmitry Sakovich
- //dialog.setStyleForPreview();
+ if (!updateDataFromStyleAttributes) {
+ notifyListeners();
+ }
}
});
}
@@ -403,7 +378,6 @@
*/
private void createText(final String name, final String value) {
Button btn = null;
-
final Text text;
// create "button" in case of FONT_FAMILY style property
@@ -428,7 +402,6 @@
btn.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
FontFamilyDialog dialog = new FontFamilyDialog(getShell(), text.getText());
-
if (dialog.open() == Window.OK) {
text.setText(dialog.getFontFamily());
}
@@ -444,8 +417,9 @@
} else {
styleAttributes.removeAttribute(key);
}
- //TODO Dzmitry Sakovich
- //dialog.setStyleForPreview();
+ if (!updateDataFromStyleAttributes) {
+ notifyListeners();
+ }
}
});
} else {
@@ -473,50 +447,38 @@
public void modifyText(ModifyEvent event) {
String tmpCombo = text.getText().trim();
- if (tmpCombo == null) {
- return;
+ if (tmpCombo != null && !tmpCombo.equals(Constants.EMPTY)) {
+ String tmpExt = extCombo.getText();
+ if (tmpExt != null) {
+ styleAttributes.addAttribute(key, tmpCombo + tmpExt);
+ }
}
- if (tmpCombo.equals(Constants.EMPTY)) {
- return;
+ if (!updateDataFromStyleAttributes) {
+ notifyListeners();
}
- String tmpExt = extCombo.getText();
- if (tmpExt != null) {
- styleAttributes.addAttribute(key, tmpCombo + tmpExt);
- //TODO Dzmitry Sakovich
- //dialog.setStyleForPreview();
- }
}
});
-
text.addModifyListener(new ModifyListener() {
String key = name;
public void modifyText(ModifyEvent e) {
String tmp = text.getText().trim();
-
- if (tmp != null) {
- if (!tmp.equals(Constants.EMPTY)) {
- String extTmp = extCombo.getText().trim();
-
- if (extTmp != null) {
- styleAttributes.addAttribute(key, tmp + extTmp);
- } else {
- styleAttributes.addAttribute(key, tmp);
- }
- } else {
- styleAttributes.removeAttribute(key);
- }
+ if (tmp != null && !tmp.equals(Constants.EMPTY)) {
+ String extTmp = extCombo.getText().trim();
+ if (extTmp != null) {
+ styleAttributes.addAttribute(key, tmp + extTmp);
+ } else {
+ styleAttributes.addAttribute(key, tmp);
+ }
} else {
styleAttributes.removeAttribute(key);
}
-
- //TODO Dzmitry Sakovich
- //dialog.setStyleForPreview();
+ if (!updateDataFromStyleAttributes) {
+ notifyListeners();
+ }
}
});
} else {
-// new Label(this, SWT.NONE).setLayoutData(new GridData(GridData.END, GridData.CENTER, false, false));
-
text.addModifyListener(new ModifyListener() {
String key = name;
@@ -526,8 +488,9 @@
} else {
styleAttributes.removeAttribute(key);
}
- //TODO Dzmitry Sakovich
- //dialog.setStyleForPreview();
+ if (!updateDataFromStyleAttributes) {
+ notifyListeners();
+ }
}
});
}
@@ -581,4 +544,41 @@
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);
+ }
+ }
}
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-11-21 10:35:47 UTC (rev 11944)
+++ trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/tabs/TabTextControl.java 2008-11-21 13:53:11 UTC (rev 11945)
@@ -42,6 +42,8 @@
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.StyleAttributes;
import org.jboss.tools.jst.jsp.outline.cssdialog.parsers.ColorParser;
@@ -65,8 +67,8 @@
private ArrayList<String> list;
private StyleAttributes styleAttributes;
- //TODO Dzmitry Sakovich
- //private Browser browser = null;
+ private ArrayList<ManualChangeStyleListener> listeners = new ArrayList<ManualChangeStyleListener>();
+ private boolean updateDataFromStyleAttributes = false;
/**
* Constructor for creating controls
@@ -78,8 +80,6 @@
super(composite, SWT.NONE);
this.styleAttributes = styleAttributes;
- //TODO Dzmitry Sakovich
- //this.browser = dialog;
final GridLayout gridLayout = new GridLayout();
gridLayout.numColumns = numColumns;
setLayout(gridLayout);
@@ -93,19 +93,17 @@
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) {
String tmp = fontFamilyText.getText();
- if (tmp != null) {
- if (tmp.trim().length() > 0) {
- styleAttributes.addAttribute(CSSConstants.FONT_FAMILY, tmp);
- } else {
- styleAttributes.removeAttribute(CSSConstants.FONT_FAMILY);
- }
+ if (tmp != null && tmp.trim().length() > 0) {
+ styleAttributes.addAttribute(CSSConstants.FONT_FAMILY, tmp);
+ } else {
+ styleAttributes.removeAttribute(CSSConstants.FONT_FAMILY);
}
- //TODO Dzmitry Sakovich
- //cssDialog.setStyleForPreview();
+ if (!updateDataFromStyleAttributes) {
+ notifyListeners();
+ }
}
});
@@ -125,7 +123,6 @@
button.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
FontFamilyDialog dialog = new FontFamilyDialog(getShell(), fontFamilyText.getText());
-
if (dialog.open() == Window.OK) {
fontFamilyText.setText(dialog.getFontFamily());
}
@@ -141,19 +138,17 @@
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) {
String tmp = colorCombo.getText();
- if (tmp != null) {
- if (tmp.trim().length() > 0) {
- styleAttributes.addAttribute(CSSConstants.COLOR, tmp);
- } else {
- styleAttributes.removeAttribute(CSSConstants.COLOR);
- }
+ if (tmp != null && tmp.trim().length() > 0) {
+ styleAttributes.addAttribute(CSSConstants.COLOR, tmp);
+ } else {
+ styleAttributes.removeAttribute(CSSConstants.COLOR);
}
- //TODO Dzmitry Sakovich
- //cssDialog.setStyleForPreview();
+ if (!updateDataFromStyleAttributes) {
+ notifyListeners();
+ }
}
});
Set<Entry<String, String>> set = ColorParser.getInstance().getMap().entrySet();
@@ -184,7 +179,6 @@
dlg.setText(JstUIMessages.COLOR_DIALOG_TITLE);
RGB rgb = dlg.open();
-
if (rgb != null) {
String colorStr = Util.createColorString(rgb);
colorCombo.setText(colorStr);
@@ -207,22 +201,18 @@
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) {
String fontSize = fontSizeCombo.getText().trim();
- if (fontSize == null) {
- return;
+ if (fontSize != null && !fontSize.equals(Constants.EMPTY)) {
+ String tmp = extFontSizeCombo.getText();
+ if (tmp != null) {
+ styleAttributes.addAttribute(CSSConstants.FONT_SIZE, fontSize + tmp);
+ }
}
- if (fontSize.equals(Constants.EMPTY)) {
- return;
- }
- String tmp = extFontSizeCombo.getText();
- if (tmp != null) {
- styleAttributes.addAttribute(CSSConstants.FONT_SIZE, fontSize + tmp);
- //TODO Dzmitry Sakovich
- //cssDialog.setStyleForPreview();
- }
+ if (!updateDataFromStyleAttributes) {
+ notifyListeners();
+ }
}
});
for (int i = 0; i < Constants.extSizes.length; i++) {
@@ -232,43 +222,34 @@
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);
-
- //TODO Dzmitry Sakovich
- //cssDialog.setStyleForPreview();
+ if (!updateDataFromStyleAttributes) {
+ notifyListeners();
+ }
return;
}
}
extFontSizeCombo.setEnabled(true);
-
String tmp = fontSizeCombo.getText();
-
- if (tmp != null) {
- if (tmp.trim().length() > 0) {
- String extFont = extFontSizeCombo.getText().trim();
-
- if (extFont != null) {
- styleAttributes.addAttribute(CSSConstants.FONT_SIZE, tmp + extFont);
- } else {
- styleAttributes.addAttribute(CSSConstants.FONT_SIZE, tmp);
- }
- } else {
- styleAttributes.removeAttribute(CSSConstants.FONT_SIZE);
- }
+ if (tmp != null && tmp.trim().length() > 0) {
+ String extFont = extFontSizeCombo.getText().trim();
+ if (extFont != null) {
+ styleAttributes.addAttribute(CSSConstants.FONT_SIZE, tmp + extFont);
+ } else {
+ styleAttributes.addAttribute(CSSConstants.FONT_SIZE, tmp);
+ }
} else {
styleAttributes.removeAttribute(CSSConstants.FONT_SIZE);
}
-
- //TODO Dzmitry Sakovich
- //cssDialog.setStyleForPreview();
+ if (!updateDataFromStyleAttributes) {
+ notifyListeners();
+ }
}
});
list = comboMap.get(CSSConstants.FONT_SIZE);
@@ -287,19 +268,17 @@
gridData.horizontalSpan = 2;
fontStyleCombo = new Combo(this, SWT.BORDER);
fontStyleCombo.setLayoutData(gridData);
-
fontStyleCombo.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent event) {
String tmp = fontStyleCombo.getText();
- if (tmp != null) {
- if (tmp.trim().length() > 0) {
- styleAttributes.addAttribute(CSSConstants.FONT_STYLE, tmp);
- } else {
- styleAttributes.removeAttribute(CSSConstants.FONT_STYLE);
- }
+ if (tmp != null && tmp.trim().length() > 0) {
+ styleAttributes.addAttribute(CSSConstants.FONT_STYLE, tmp);
+ } else {
+ styleAttributes.removeAttribute(CSSConstants.FONT_STYLE);
}
- //TODO Dzmitry Sakovich
- //cssDialog.setStyleForPreview();
+ if (!updateDataFromStyleAttributes) {
+ notifyListeners();
+ }
}
});
list = comboMap.get(CSSConstants.FONT_STYLE);
@@ -318,19 +297,17 @@
gridData.horizontalSpan = 2;
fontWeigthCombo = new Combo(this, SWT.BORDER);
fontWeigthCombo.setLayoutData(gridData);
-
fontWeigthCombo.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent event) {
String tmp = fontWeigthCombo.getText();
- if (tmp != null) {
- if (tmp.trim().length() > 0) {
- styleAttributes.addAttribute(CSSConstants.FONT_WEIGHT, tmp);
- } else {
- styleAttributes.removeAttribute(CSSConstants.FONT_WEIGHT);
- }
+ if (tmp != null && tmp.trim().length() > 0) {
+ styleAttributes.addAttribute(CSSConstants.FONT_WEIGHT, tmp);
+ } else {
+ styleAttributes.removeAttribute(CSSConstants.FONT_WEIGHT);
}
- //TODO Dzmitry Sakovich
- //cssDialog.setStyleForPreview();
+ if (!updateDataFromStyleAttributes) {
+ notifyListeners();
+ }
}
});
list = comboMap.get(CSSConstants.FONT_WEIGHT);
@@ -349,19 +326,17 @@
gridData.horizontalSpan = 2;
textDecorationCombo = new Combo(this, SWT.BORDER);
textDecorationCombo.setLayoutData(gridData);
-
textDecorationCombo.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent event) {
String tmp = textDecorationCombo.getText();
- if (tmp != null) {
- if (tmp.trim().length() > 0) {
- styleAttributes.addAttribute(CSSConstants.TEXT_DECORATION, tmp);
- } else {
- styleAttributes.removeAttribute(CSSConstants.TEXT_DECORATION);
- }
+ if (tmp != null && tmp.trim().length() > 0) {
+ styleAttributes.addAttribute(CSSConstants.TEXT_DECORATION, tmp);
+ } else {
+ styleAttributes.removeAttribute(CSSConstants.TEXT_DECORATION);
}
- //TODO Dzmitry Sakovich
- //cssDialog.setStyleForPreview();
+ if (!updateDataFromStyleAttributes) {
+ notifyListeners();
+ }
}
});
list = comboMap.get(CSSConstants.TEXT_DECORATION);
@@ -380,19 +355,17 @@
gridData.horizontalSpan = 2;
textAlignCombo = new Combo(this, SWT.BORDER);
textAlignCombo.setLayoutData(gridData);
-
textAlignCombo.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent event) {
String tmp = textAlignCombo.getText();
- if (tmp != null) {
- if (tmp.trim().length() > 0) {
- styleAttributes.addAttribute(CSSConstants.TEXT_ALIGN, tmp);
- } else {
- styleAttributes.removeAttribute(CSSConstants.TEXT_ALIGN);
- }
+ if (tmp != null && tmp.trim().length() > 0) {
+ styleAttributes.addAttribute(CSSConstants.TEXT_ALIGN, tmp);
+ } else {
+ styleAttributes.removeAttribute(CSSConstants.TEXT_ALIGN);
}
- //TODO Dzmitry Sakovich
- //cssDialog.setStyleForPreview();
+ if (!updateDataFromStyleAttributes) {
+ notifyListeners();
+ }
}
});
list = comboMap.get(CSSConstants.TEXT_ALIGN);
@@ -418,26 +391,26 @@
}
/**
- * Method for get data in controls (if param equal true ), or set data (if
- * param equal false).
+ * Method for get data in controls (if parameter equal true ), or set data (if parameter equal false).
*
* @param param
*/
public void updateData(boolean param) {
+ updateDataFromStyleAttributes = true;
String tmp;
-
+ // set FONT_FAMILY attribute
if ((tmp = styleAttributes.getAttribute(CSSConstants.FONT_FAMILY)) != null) {
fontFamilyText.setText(tmp);
} else {
fontFamilyText.setText(Constants.EMPTY);
}
-
+ // set COLOR attribute
if ((tmp = styleAttributes.getAttribute(CSSConstants.COLOR)) != null) {
colorCombo.setText(tmp);
} else {
colorCombo.setText(Constants.EMPTY);
}
-
+ // set FONT_SIZE and EXTENSION_FONT_SIZE attributes
if ((tmp = styleAttributes.getAttribute(CSSConstants.FONT_SIZE)) != null) {
String[] str = Util.convertExtString(tmp);
fontSizeCombo.setText(str[0]);
@@ -452,29 +425,67 @@
fontSizeCombo.setText(Constants.EMPTY);
extFontSizeCombo.select(0);
}
-
+ // set TEXT_DECORATION attribute
if ((tmp = styleAttributes.getAttribute(CSSConstants.TEXT_DECORATION)) != null) {
textDecorationCombo.setText(tmp);
} else {
textDecorationCombo.setText(Constants.EMPTY);
}
-
+ // set FONT_STYLE attribute
if ((tmp = styleAttributes.getAttribute(CSSConstants.FONT_STYLE)) != null) {
fontStyleCombo.setText(tmp);
} else {
fontStyleCombo.setText(Constants.EMPTY);
}
-
+ // set FONT_WEIGHT attribute
if ((tmp = styleAttributes.getAttribute(CSSConstants.FONT_WEIGHT)) != null) {
fontWeigthCombo.setText(tmp);
} else {
fontWeigthCombo.setText(Constants.EMPTY);
}
-
+ // set TEXT_ALIGN attribute
if ((tmp = styleAttributes.getAttribute(CSSConstants.TEXT_ALIGN)) != null) {
textAlignCombo.setText(tmp);
} else {
textAlignCombo.setText(Constants.EMPTY);
}
+ updateDataFromStyleAttributes = false;
}
+
+ /**
+ * 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);
+ }
+ }
}
Modified: trunk/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/wizards/css/NewCSSClassWizard.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/wizards/css/NewCSSClassWizard.java 2008-11-21 10:35:47 UTC (rev 11944)
+++ trunk/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/wizards/css/NewCSSClassWizard.java 2008-11-21 13:53:11 UTC (rev 11945)
@@ -10,34 +10,51 @@
******************************************************************************/
package org.jboss.tools.jst.web.ui.wizards.css;
+import org.eclipse.core.runtime.IStatus;
import org.eclipse.jface.dialogs.IDialogPage;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.wizard.Wizard;
import org.eclipse.jface.wizard.WizardPage;
-
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
-
import org.eclipse.ui.INewWizard;
import org.eclipse.ui.IWorkbench;
-
+import org.eclipse.ui.IWorkbenchWizard;
import org.jboss.tools.jst.jsp.outline.cssdialog.CSSClassDialog;
+import org.jboss.tools.jst.jsp.outline.cssdialog.events.MessageDialogEvent;
+import org.jboss.tools.jst.jsp.outline.cssdialog.events.MessageDialogListener;
-
+/**
+ * New CSS class wizard.
+ */
public class NewCSSClassWizard extends Wizard implements INewWizard {
- private NewCSSClassWizardPage page;
+ private static final String WIZARD_WINDOW_TITLE = "New CSS Class";
+
+ // workbench selection when the wizard was started
+ protected IStructuredSelection selection;
+ // the workbench instance
+ protected IWorkbench workbench;
+
+ // wizard contains only one page
+ private NewCSSClassWizardPage page;
+
/**
* Constructor for SampleNewWizard.
*/
public NewCSSClassWizard() {
super();
+ setWindowTitle(WIZARD_WINDOW_TITLE);
}
- /** {@link org.eclipse.ui.IWorkbenchWizard#init(IWorkbench, IStructuredSelection)} */
- public void init(IWorkbench workbench, IStructuredSelection selection) {
- }
+ /**
+ * @see IWorkbenchWizard#init(IWorkbench, IStructuredSelection)
+ */
+ public void init(IWorkbench workbench, IStructuredSelection selection) {
+ this.workbench = workbench;
+ this.selection = selection;
+ }
/**
* Adding the page to the wizard.
@@ -57,15 +74,36 @@
return true;
}
+ /**
+ * @see org.eclipse.jface.wizard.IWizard#canFinish()
+ */
+ @Override
+ public boolean canFinish() {
+ return page.showFinish;
+ }
+
+ /**
+ * @see org.eclipse.jface.wizard.IWizard#performCancel()
+ */
+ @Override
+ public boolean performCancel() {
+ page.cancel();
+ return true;
+ }
+
+ /**
+ * Class representing the first page of the wizard.
+ */
private class NewCSSClassWizardPage extends WizardPage {
// TODO: take out to the property manager file
- final static String WIZARD_WINDOW_TITLE = "New CSS Class";
final static String WIZARD_TITLE = "CSS Class";
final static String WIZARD_DESCRIPTION = "Create New CSS Class.";
private CSSClassDialog dialog;
+ boolean showFinish = false;
+
/**
* Constructor for SampleNewWizardPage.
*
@@ -73,7 +111,6 @@
*/
public NewCSSClassWizardPage() {
super("newCSSClassWizard");
- setWindowTitle(WIZARD_WINDOW_TITLE);
setTitle(WIZARD_TITLE);
setDescription(WIZARD_DESCRIPTION);
}
@@ -86,13 +123,69 @@
GridLayout layout = new GridLayout();
container.setLayout(layout);
- dialog = new CSSClassDialog(getShell(), true);
+ // Initialize CSS dialog that is integrated to CSS wizard.
+ // Also it can be used separately without integration to wizard component.
+ dialog = new CSSClassDialog(getShell(), selection, true);
+ dialog.addMessageDialogListener(new MessageDialogListener() {
+ @Override
+ public void throwMessage(MessageDialogEvent event) {
+ if (event != null) {
+ IStatus status = event.getOperationStatus();
+ if (status != null) {
+ applyToStatusLine(status);
+ }
+ getWizard().getContainer().updateButtons();
+ }
+ }
+ });
dialog.createDialogComposite(container);
setControl(container);
}
+ /**
+ * Save page model.
+ */
public void saveChanges() {
dialog.saveChanges();
}
+
+ /**
+ * Handle cancel operation correctly.
+ */
+ public void cancel() {
+ dialog.closeDialog();
+ }
+
+ /**
+ * Applies the status to the status line of a dialog page.
+ */
+ private void applyToStatusLine(IStatus status) {
+ String message= status.getMessage();
+ if (message.length() == 0) {
+ message = null;
+ }
+ switch (status.getSeverity()) {
+ case IStatus.OK:
+ setErrorMessage(null);
+ setMessage(message);
+ showFinish = true;
+ break;
+ case IStatus.WARNING:
+ setErrorMessage(null);
+ showFinish = true;
+ setMessage(message, WizardPage.WARNING);
+ break;
+ case IStatus.INFO:
+ setErrorMessage(null);
+ showFinish = true;
+ setMessage(message, WizardPage.INFORMATION);
+ break;
+ default:
+ setErrorMessage(message);
+ setMessage(null);
+ showFinish = false;
+ break;
+ }
+ }
}
}
17 years, 5 months
JBoss Tools SVN: r11944 - in trunk/esb/docs/esb_ref_guide/en: images/esb_project and 1 other directories.
by jbosstools-commits@lists.jboss.org
Author: dennyxu
Date: 2008-11-21 05:35:47 -0500 (Fri, 21 Nov 2008)
New Revision: 11944
Added:
trunk/esb/docs/esb_ref_guide/en/images/esb_project/
trunk/esb/docs/esb_ref_guide/en/images/esb_project/01_create_esb_project.png
trunk/esb/docs/esb_ref_guide/en/images/esb_project/02_create_esb_project.png
trunk/esb/docs/esb_ref_guide/en/images/esb_project/03_create_esb_project.png
trunk/esb/docs/esb_ref_guide/en/images/esb_project/04_create_esb_project.png
trunk/esb/docs/esb_ref_guide/en/images/esb_project/05_esb_project_example.png
trunk/esb/docs/esb_ref_guide/en/images/esb_project/06_esb_project_example.png
trunk/esb/docs/esb_ref_guide/en/images/esb_project/07_esb_project_example.png
trunk/esb/docs/esb_ref_guide/en/images/esb_project/08_esb_project_deploy.png
trunk/esb/docs/esb_ref_guide/en/images/esb_project/09_esb_project_deploy.png
trunk/esb/docs/esb_ref_guide/en/images/esb_project/10_esb_runtime.png
trunk/esb/docs/esb_ref_guide/en/images/esb_project/11_esb_runtime_new.png
trunk/esb/docs/esb_ref_guide/en/images/esb_project/12_esb_container_page.png
Modified:
trunk/esb/docs/esb_ref_guide/en/modules/esb_support.xml
Log:
JBIDE-2891: add documents for ESB project wizard and deployment....
Added: trunk/esb/docs/esb_ref_guide/en/images/esb_project/01_create_esb_project.png
===================================================================
(Binary files differ)
Property changes on: trunk/esb/docs/esb_ref_guide/en/images/esb_project/01_create_esb_project.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/esb/docs/esb_ref_guide/en/images/esb_project/02_create_esb_project.png
===================================================================
(Binary files differ)
Property changes on: trunk/esb/docs/esb_ref_guide/en/images/esb_project/02_create_esb_project.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/esb/docs/esb_ref_guide/en/images/esb_project/03_create_esb_project.png
===================================================================
(Binary files differ)
Property changes on: trunk/esb/docs/esb_ref_guide/en/images/esb_project/03_create_esb_project.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/esb/docs/esb_ref_guide/en/images/esb_project/04_create_esb_project.png
===================================================================
(Binary files differ)
Property changes on: trunk/esb/docs/esb_ref_guide/en/images/esb_project/04_create_esb_project.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/esb/docs/esb_ref_guide/en/images/esb_project/05_esb_project_example.png
===================================================================
(Binary files differ)
Property changes on: trunk/esb/docs/esb_ref_guide/en/images/esb_project/05_esb_project_example.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/esb/docs/esb_ref_guide/en/images/esb_project/06_esb_project_example.png
===================================================================
(Binary files differ)
Property changes on: trunk/esb/docs/esb_ref_guide/en/images/esb_project/06_esb_project_example.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/esb/docs/esb_ref_guide/en/images/esb_project/07_esb_project_example.png
===================================================================
(Binary files differ)
Property changes on: trunk/esb/docs/esb_ref_guide/en/images/esb_project/07_esb_project_example.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/esb/docs/esb_ref_guide/en/images/esb_project/08_esb_project_deploy.png
===================================================================
(Binary files differ)
Property changes on: trunk/esb/docs/esb_ref_guide/en/images/esb_project/08_esb_project_deploy.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/esb/docs/esb_ref_guide/en/images/esb_project/09_esb_project_deploy.png
===================================================================
(Binary files differ)
Property changes on: trunk/esb/docs/esb_ref_guide/en/images/esb_project/09_esb_project_deploy.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/esb/docs/esb_ref_guide/en/images/esb_project/10_esb_runtime.png
===================================================================
(Binary files differ)
Property changes on: trunk/esb/docs/esb_ref_guide/en/images/esb_project/10_esb_runtime.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/esb/docs/esb_ref_guide/en/images/esb_project/11_esb_runtime_new.png
===================================================================
(Binary files differ)
Property changes on: trunk/esb/docs/esb_ref_guide/en/images/esb_project/11_esb_runtime_new.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/esb/docs/esb_ref_guide/en/images/esb_project/12_esb_container_page.png
===================================================================
(Binary files differ)
Property changes on: trunk/esb/docs/esb_ref_guide/en/images/esb_project/12_esb_container_page.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Modified: trunk/esb/docs/esb_ref_guide/en/modules/esb_support.xml
===================================================================
--- trunk/esb/docs/esb_ref_guide/en/modules/esb_support.xml 2008-11-21 09:11:19 UTC (rev 11943)
+++ trunk/esb/docs/esb_ref_guide/en/modules/esb_support.xml 2008-11-21 10:35:47 UTC (rev 11944)
@@ -30,6 +30,84 @@
>InstallingJBossTools</ulink> section.</para>
</section>
+ <section>
+ <title>Creating a ESB Project</title>
+ <para>In this chapter we suggest a step-by-step walk-through of creating a new
+ ESB project. Let's try to create a new JBoss ESB project.</para>
+
+ <para>We will show you how to use the ESB Project Creation wizard for creating a new ESB project and setting basic ESB classpath.</para>
+
+ <para>Select <emphasis>
+ <property>File >New > Project...</property>
+ </emphasis> in the main menu bar or context menu for selected project and
+ then <emphasis>
+ <property>ESB > ESB Project</property>
+ </emphasis> in the New dialog:</para>
+
+ <figure>
+ <title>New Dialog</title>
+ <mediaobject>
+ <imageobject>
+ <imagedata fileref="images/esb_project/01_create_esb_project.png"/>
+ </imageobject>
+ </mediaobject>
+ </figure>
+
+ <para> Clicking <emphasis>
+ <property>Next</property>
+ </emphasis> brings us to the first wizard page where it's necessary to
+ specify the project name, ESB version and target JBoss Runtime. We set, for example, <emphasis>
+ <property>helloworld</property>
+ </emphasis> as the name and accept default ESB version.</para>
+ <figure>
+ <title>Project Name, Target JBoss Runtime and ESB Version</title>
+ <mediaobject>
+ <imageobject>
+ <imagedata fileref="images/esb_project/02_create_esb_project.png"/>
+ </imageobject>
+ </mediaobject>
+ </figure>
+
+ <para> Clicking <emphasis>
+ <property>Next</property>
+ </emphasis> brings us to the ESB facet installation page where we can
+ specify source folder name, ESB content folder name, ESB content folder is the folder that contains the most of
+ artifacts that an ESB archive needs, we also can configure ESB libraries to the project by selecting a ESB runtime,
+ there are two ways to set ESB runtime: </para>
+ <para>1. Use <emphasis>
+ <property>Server Supplied ESB Runtime</property>
+ </emphasis>
+
+ </para>
+ <para> 2. Select an ESB runtime from JBoss ESB runtime list predefined in preference
+ </para>
+ <para>If choose the first option, we have to make sure that the project has Target JBoss Runtime set and the runtime has a ESB runtime installed.
+ </para>
+ <figure>
+ <title>JBoss ESB facet installation</title>
+ <mediaobject>
+ <imageobject>
+ <imagedata fileref="images/esb_project/03_create_esb_project.png"/>
+ </imageobject>
+ </mediaobject>
+ </figure>
+ <para>Clicking <emphasis>
+ <property>Finish</property>
+ </emphasis>, an ESB project with default <emphasis><property>jboss-esb.xml</property></emphasis>
+ will be created. </para>
+
+ <figure>
+ <title>The generated ESB project structure</title>
+ <mediaobject>
+ <imageobject>
+ <imagedata fileref="images/esb_project/04_create_esb_project.png"/>
+ </imageobject>
+ </mediaobject>
+ </figure>
+
+ </section>
+
+
<section>
<title>Creating a ESB File</title>
<para>In this chapter we suggest a step-by-step walk-through of creating your own
17 years, 5 months