Author: dgolovin
Date: 2008-10-08 02:45:58 -0400 (Wed, 08 Oct 2008)
New Revision: 10722
Modified:
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/editor/EditorPartWrapper.java
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/util/EclipseResourceUtil.java
trunk/common/plugins/org.jboss.tools.common.text.ext/src/org/jboss/tools/common/text/ext/hyperlink/CSSClassHyperlink.java
trunk/common/plugins/org.jboss.tools.common.text.ext/src/org/jboss/tools/common/text/ext/hyperlink/xpl/AbstractBaseHyperlink.java
trunk/common/plugins/org.jboss.tools.common.text.ext/src/org/jboss/tools/common/text/ext/hyperlink/xpl/BaseHyperlinkDetector.java
trunk/common/plugins/org.jboss.tools.common.text.ext/src/org/jboss/tools/common/text/ext/util/CSSTextScanner.java
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/jspeditor/JSPMultiPageEditor.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/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/TabPropertySheetMouseAdapter.java
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/parsers/ColorParser.java
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/tabs/TabQuickEditControl.java
trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsBeanNameHyperlink.java
trunk/tests/tests/org.jboss.tools.test/src/org/jboss/tools/test/util/ProjectImportTestSetup.java
trunk/tests/tests/org.jboss.tools.test/src/org/jboss/tools/test/util/WorkbenchUtils.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-2858
JUnit tests have been added
Modified:
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/util/EclipseResourceUtil.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/util/EclipseResourceUtil.java 2008-10-08
05:39:34 UTC (rev 10721)
+++
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/util/EclipseResourceUtil.java 2008-10-08
06:45:58 UTC (rev 10722)
@@ -770,34 +770,7 @@
* @location Absolute path on disk
*/
public static IFile getFile(String location) {
- location = new java.io.File(location).getAbsolutePath().replace('\\',
'/');
- IProject[] projects = ModelPlugin.getWorkspace().getRoot().getProjects();
- for (int i = 0; projects != null && i < projects.length; i++) {
- if (!projects[i].isOpen()) continue;
- String l = projects[i].getLocation().toFile().getAbsolutePath().replace('\\',
'/');
- if (!l.endsWith("/")) l += "/";
- if (location.startsWith(l)) {
- String relative = location.substring(l.length());
- return projects[i].getFile(relative);
- }
- IResource[] ms = null;
- try {
- ms = projects[i].members(true);
- } catch (CoreException e) {
- //ignore - we do not care if project can give its members here.
- }
- if(ms != null) for (int j = 0; j < ms.length; j++) {
- if(!ms[j].isLinked() || !(ms[j] instanceof IContainer)) continue;
- IContainer c = (IContainer)ms[j];
- l = c.getLocation().toFile().getAbsolutePath().replace('\\', '/');
- if (!l.endsWith("/")) l += "/";
- if (location.startsWith(l)) {
- String relative = location.substring(l.length());
- return c.getFile(new Path(relative));
- }
- }
- }
- return null;
+ return ResourcesPlugin.getWorkspace().getRoot().getFileForLocation(new
Path(location).makeAbsolute());
}
public static IResource getFolder(String location) {
Modified:
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/editor/EditorPartWrapper.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/editor/EditorPartWrapper.java 2008-10-08
05:39:34 UTC (rev 10721)
+++
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/editor/EditorPartWrapper.java 2008-10-08
06:45:58 UTC (rev 10722)
@@ -48,6 +48,9 @@
import org.jboss.tools.common.text.ext.IEditorWrapper;
public class EditorPartWrapper extends EditorPart implements IReusableEditor,
IEditorWrapper {
+
+ public static final String EDITOR_ID =
"org.jboss.tools.common.model.ui.editor.EditorPartWrapper";
+
IEditorPart editor;
String entity = null;
Modified:
trunk/common/plugins/org.jboss.tools.common.text.ext/src/org/jboss/tools/common/text/ext/hyperlink/CSSClassHyperlink.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.text.ext/src/org/jboss/tools/common/text/ext/hyperlink/CSSClassHyperlink.java 2008-10-08
05:39:34 UTC (rev 10721)
+++
trunk/common/plugins/org.jboss.tools.common.text.ext/src/org/jboss/tools/common/text/ext/hyperlink/CSSClassHyperlink.java 2008-10-08
06:45:58 UTC (rev 10722)
@@ -104,33 +104,6 @@
}
}
- //is never used
- IFile getFileToOpen(String fileName, String fileExt) {
- IFile documentFile = getFile();
-
- try {
- IProject project = documentFile.getProject();
-
- String name = fileName.replace('.','/')+ (fileExt != null ?
"." + fileExt : "");
-
- if(project == null || !project.isOpen()) return null;
- if(!project.hasNature(JavaCore.NATURE_ID)) return null;
- IJavaProject javaProject = JavaCore.create(project);
- IClasspathEntry[] es = javaProject.getResolvedClasspath(true);
-
- for (int i = 0; i < es.length; i++) {
- if(es[i].getEntryKind() != IClasspathEntry.CPE_SOURCE) continue;
- IFile file =
(IFile)project.getFile(es[i].getPath().lastSegment()+"/"+name);
- if(file != null && file.exists()) return file;
- }
- return null;
- } catch (CoreException x) {
- //ignore
- return null;
- }
-
- }
-
IRegion fLastRegion = null;
/**
Modified:
trunk/common/plugins/org.jboss.tools.common.text.ext/src/org/jboss/tools/common/text/ext/hyperlink/xpl/AbstractBaseHyperlink.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.text.ext/src/org/jboss/tools/common/text/ext/hyperlink/xpl/AbstractBaseHyperlink.java 2008-10-08
05:39:34 UTC (rev 10721)
+++
trunk/common/plugins/org.jboss.tools.common.text.ext/src/org/jboss/tools/common/text/ext/hyperlink/xpl/AbstractBaseHyperlink.java 2008-10-08
06:45:58 UTC (rev 10722)
@@ -54,18 +54,14 @@
super();
}
- private ITextViewer fTextViewer;
+ private IDocument fDocument;
private int fOffset;
- public void setTextViewer(ITextViewer textViewer) {
- fTextViewer = textViewer;
+ public void setDocument(IDocument document) {
+ fDocument = document;
}
- public ITextViewer getTextViewer() {
- return fTextViewer;
- }
-
public void setOffset(int offset) {
fOffset = offset;
}
@@ -291,7 +287,7 @@
* @return IDocument
*/
public IDocument getDocument() {
- return (fTextViewer == null ? null : fTextViewer.getDocument());
+ return fDocument;
}
/*
Modified:
trunk/common/plugins/org.jboss.tools.common.text.ext/src/org/jboss/tools/common/text/ext/hyperlink/xpl/BaseHyperlinkDetector.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.text.ext/src/org/jboss/tools/common/text/ext/hyperlink/xpl/BaseHyperlinkDetector.java 2008-10-08
05:39:34 UTC (rev 10721)
+++
trunk/common/plugins/org.jboss.tools.common.text.ext/src/org/jboss/tools/common/text/ext/hyperlink/xpl/BaseHyperlinkDetector.java 2008-10-08
06:45:58 UTC (rev 10722)
@@ -72,7 +72,7 @@
IHyperlink hyperlink = defs[i].createHyperlink();
if(!hyperlinks.contains(hyperlink)) {
if (hyperlink instanceof AbstractHyperlink) {
- ((AbstractHyperlink)hyperlink).setTextViewer(textViewer);
+ ((AbstractHyperlink)hyperlink).setDocument(textViewer.getDocument());
((AbstractHyperlink)hyperlink).setOffset(region.getOffset());
}
hyperlinks.add(hyperlink);
Modified:
trunk/common/plugins/org.jboss.tools.common.text.ext/src/org/jboss/tools/common/text/ext/util/CSSTextScanner.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.text.ext/src/org/jboss/tools/common/text/ext/util/CSSTextScanner.java 2008-10-08
05:39:34 UTC (rev 10721)
+++
trunk/common/plugins/org.jboss.tools.common.text.ext/src/org/jboss/tools/common/text/ext/util/CSSTextScanner.java 2008-10-08
06:45:58 UTC (rev 10722)
@@ -116,11 +116,6 @@
state = STATE_NAME;
return (readsCount > 0 ? getToken(CSS_CLASS_NAME_SEPARATOR) : nextNameToken());
}
- if (WS_DETECTOR.isWhitespace((char)ch)) {
- unread();
- state = STATE_NAME_SEPARATOR;
- return (readsCount > 0 ? getToken(CSS_CLASS_NAME_SEPARATOR) :
nextNameSeparatorToken());
- }
if (ch == '{') {
unread();
state = STATE_BODY;
@@ -128,13 +123,19 @@
}
if (ch == '/') {
ch = read();
- if (ch == ICharacterScanner.EOF) break;
+ if (ch == ICharacterScanner.EOF) {
+ break;
+ }
if (ch == '*') {
// Comment openning
unread(); // Unread '*'-char
unread(); // Unread '/'-char
setState(STATE_COMMENT);
- return (readsCount > 0 ? getToken(CSS_CLASS_NAME_SEPARATOR) :
nextCommentToken());
+ if (readsCount > 0) {
+ return getToken(CSS_CLASS_NAME_SEPARATOR);
+ } else {
+ return nextCommentToken();
+ }
}
// Broken file ??? Emulate END of text
clearText();
@@ -162,7 +163,9 @@
}
if (ch == '/') {
ch = read();
- if (ch == ICharacterScanner.EOF) break;
+ if (ch == ICharacterScanner.EOF) {
+ break;
+ }
if (ch == '*') {
// Comment openning
unread(); // Unread '*'-char
Modified:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/jspeditor/JSPMultiPageEditor.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/jspeditor/JSPMultiPageEditor.java 2008-10-08
05:39:34 UTC (rev 10721)
+++
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/jspeditor/JSPMultiPageEditor.java 2008-10-08
06:45:58 UTC (rev 10722)
@@ -88,6 +88,8 @@
IReusableEditor, ITextEditorExtension, ITextEditorExtension2,
ITextEditorExtension3, INavigationLocationProvider, IMultiPageEditor {
+ public static final String EDITOR_ID =
"org.jboss.tools.jst.jsp.jspeditor.JSPTextEditor";
+
private static final String VISUALSOURCE_TAB_LABEL =
"JSPMultiPageEditor.TabLabel.VisualSource"; //$NON-NLS-1$
private static final String SOURCE_TAB_LABEL =
"JSPMultiPageEditor.TabLabel.Source"; //$NON-NLS-1$
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-10-08
05:39:34 UTC (rev 10721)
+++
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/CSSClassDialog.java 2008-10-08
06:45:58 UTC (rev 10722)
@@ -17,6 +17,7 @@
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.jface.resource.ImageDescriptor;
@@ -118,10 +119,8 @@
IResource res = null;
if (allProject) {
- IWorkspace workspace = Util.getCurrentWorkspace();
- if(workspace!=null) {
+ IWorkspace workspace = ResourcesPlugin.getWorkspace();
res = workspace.getRoot().findMember(text.getText());
- }
} else {
IProject project = Util.getCurrentProject();
if (project!=null)
@@ -187,7 +186,7 @@
button.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
- IAdaptable project = Util.getCurrentWorkspace();
+ IAdaptable project = ResourcesPlugin.getWorkspace();
if (!allProject) {
project = Util.getCurrentProject();
}
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-10-08
05:39:34 UTC (rev 10721)
+++
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/common/Constants.java 2008-10-08
06:45:58 UTC (rev 10722)
@@ -10,6 +10,11 @@
******************************************************************************/
package org.jboss.tools.jst.jsp.outline.cssdialog.common;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Set;
+
import org.eclipse.swt.graphics.RGB;
/**
@@ -24,11 +29,11 @@
public static final String extSizes[] = new String[] { "", "em",
"ex",
"px", "in", "cm", "mm", "pt",
"pc" };
- public static final String elemFolder[] = new String[] {
+ public static final Set elemFolder = Collections.unmodifiableSet(new
HashSet(Arrays.asList(new String[] {
"background-image", "list-style-image", "cursor",
"cue-after",
- "cue-before" };
+ "cue-before" })));
- public static final String extElem[] = new String[] {
+ public static final Set extElem = Collections.unmodifiableSet(new
HashSet(Arrays.asList(new String[] {
"border-bottom-width", "border-left-width",
"borer-right-width",
"border-top-width", "border-width", "bottom",
"font-size",
"height", "left", "letter-spacing",
"line-height", "margin",
@@ -37,7 +42,7 @@
"min-height", "min-width", "outline-width",
"padding",
"padding-bottom", "padding-left", "padding-right",
"padding-top",
"right", "size", "text-indent", "top",
"vertical-align", "width",
- "word-spacing" };
+ "word-spacing" })));
public static final String NONE = "none";
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-10-08
05:39:34 UTC (rev 10721)
+++
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/common/Util.java 2008-10-08
06:45:58 UTC (rev 10722)
@@ -17,7 +17,6 @@
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IWorkspace;
import org.eclipse.swt.graphics.RGB;
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IEditorPart;
@@ -34,340 +33,276 @@
*/
public class Util {
- private static String RGB = "rgb"; //$NON-NLS-1$
+ private static String RGB = "rgb"; //$NON-NLS-1$
- private static String NONE = "none"; //$NON-NLS-1$
+ private static String NONE = "none"; //$NON-NLS-1$
- private static String THIN = "thin"; //$NON-NLS-1$
+ private static String THIN = "thin"; //$NON-NLS-1$
- private static String COMMA = ","; //$NON-NLS-1$
+ private static String COMMA = ","; //$NON-NLS-1$
- private static int START_INDEX_RED = 1;
- private static int END_INDEX_RED = 3;
- private static int START_INDEX_GRENN = 3;
- private static int END_INDEX_GREEN = 5;
- private static int START_INDEX_BLUE = 5;
- private static int END_INDEX_BLUE = 7;
+ private static int START_INDEX_RED = 1;
+ private static int END_INDEX_RED = 3;
+ private static int START_INDEX_GRENN = 3;
+ private static int END_INDEX_GREEN = 5;
+ private static int START_INDEX_BLUE = 5;
+ private static int END_INDEX_BLUE = 7;
- private static int MAX_VALUE_RGB = 255;
- private static int MIN_VALUE_RGB = 0;
+ private static int MAX_VALUE_RGB = 255;
+ private static int MIN_VALUE_RGB = 0;
- private static int COUNT_COLORS = 3;
+ private static int COUNT_COLORS = 3;
- private static int RADIX = 16;
+ private static int RADIX = 16;
- private static int COLOR_LENGTH = 7;
+ private static int COLOR_LENGTH = 7;
- private static int START_COLOR_INDEX = 0;
+ private static int START_COLOR_INDEX = 0;
- private static char OPEN_BRACKET = '{';
- private static char CLOSE_BRACKET = '}';
+ private static char OPEN_BRACKET = '{';
+ private static char CLOSE_BRACKET = '}';
- private static char SHARP = '#';
- private static String SHARP_STRING = "#"; //$NON-NLS-1$
+ private static char SHARP = '#';
+ private static String SHARP_STRING = "#"; //$NON-NLS-1$
- private static String ZERO_STR = "0"; //$NON-NLS-1$
- private static int NORMAL_MIN_VALUE = 10;
+ private static String ZERO_STR = "0"; //$NON-NLS-1$
+ private static int NORMAL_MIN_VALUE = 10;
- /**
- * Method for checking contain or not css attribute folder
- *
- * @param name
- * Name css attribute
- * @return true - contain, or else - dont contain
- */
- public static boolean containFolder(String name) {
+ /**
+ * Method for checking contain or not css attribute folder
+ *
+ * @param name
+ * Name css attribute
+ * @return true - contain, or else - dont contain
+ */
+ public static boolean containFolder(String name) {
+ return Constants.elemFolder.contains(name);
+ }
- for (int i = 0; i < Constants.elemFolder.length; i++)
- if (Constants.elemFolder[i].equals(name))
- return true;
- return false;
- }
+ /**
+ * Method for search string into css attributes
+ *
+ * @param name
+ * Name
+ * @param elementMap
+ * Map of css attributes
+ * @return true - find, or else - dont find
+ */
+ public static boolean searchInElement(String name,
+ HashMap<String, ArrayList<String>> elementMap) {
- /**
- * Method for search css attribute in block elements (Aural, Boxes,....)
- *
- * @param name
- * Name css attribute
- * @param set
- * Set of block elemnts
- * @return true - find, or else - dont find
- */
- public static boolean searchOnBlock(String name, Set<String> set) {
+ Set<String> set = elementMap.keySet();
- for (String str1 : set)
- if (str1.equals(name))
- return true;
+ for (String str : set) {
+ ArrayList<String> list = elementMap.get(str);
+ if(list.contains(name)) {
+ return true;
+ }
+ }
- return false;
- }
+ return false;
+ }
- /**
- * Method for search css attribute in combo elements (text-decoration,
- * font-weight,....)
- *
- * @param name
- * Name css attribute
- * @param set
- * Set of combo elemnts
- * @return true - find, or else - dont find
- */
- public static boolean searchInCombo(String name, Set<String> set) {
+ /**
+ * Method for get RGB from string
+ *
+ * @param color
+ * Color string
+ * @return RGB color, or null, if color invalid
+ */
+ public static RGB getColor(String color) {
- for (String str1 : set)
- if (str1.equals(name))
- return true;
+ if (color.equals(Constants.EMPTY_STRING) || color.equals(NONE)) {
+ return null;
+ }
- return false;
- }
+ if (color.charAt(START_COLOR_INDEX) == SHARP
+ && color.length() == COLOR_LENGTH) {
- /**
- * Method for search string into css attributes
- *
- * @param name
- * Name
- * @param elementMap
- * Map of css attributes
- * @return true - find, or else - dont find
- */
- public static boolean searchInElement(String name,
- HashMap<String, ArrayList<String>> elementMap) {
+ String strR = color.substring(START_INDEX_RED, END_INDEX_RED);
+ String strG = color.substring(START_INDEX_GRENN, END_INDEX_GREEN);
+ String strB = color.substring(START_INDEX_BLUE, END_INDEX_BLUE);
- Set<String> set = elementMap.keySet();
+ try {
+ Integer.parseInt(strR, RADIX);
+ Integer.parseInt(strG, RADIX);
+ Integer.parseInt(strB, RADIX);
+ } catch (NumberFormatException e) {
+ return null;
+ }
+ return convertColorHEX(color);
+ } else if (color.toLowerCase().indexOf(RGB) != Constants.DONT_CONTAIN) {
- for (String str : set) {
+ int start = color.indexOf(OPEN_BRACKET);
+ int end = color.indexOf(CLOSE_BRACKET);
+ String str = color.substring(start + 1, end);
- ArrayList<String> list = elementMap.get(str);
- for (String str1 : list)
- if (str1.equals(name))
- return true;
- }
+ StringTokenizer st = new StringTokenizer(str, COMMA);
- return false;
- }
+ int j = 0;
+ while (st.hasMoreTokens()) {
+ try {
+ int i = Integer.parseInt(st.nextToken().trim());
+ if (i < MIN_VALUE_RGB || i > MAX_VALUE_RGB) {
+ return null;
+ }
+ } catch (NumberFormatException e) {
+ return null;
+ }
+ j++;
+ }
+ if (j == COUNT_COLORS) {
+ return convertColorRGB(color);
+ }
+ } else {
+ HashMap<String, String> colorMap = ColorParser.getInstance()
+ .getMap();
- /**
- * Method for get RGB from string
- *
- * @param color
- * Color string
- * @return RGB color, or null, if color invalid
- */
- public static RGB getColor(String color) {
+ for (String key : colorMap.keySet()) {
+ if (colorMap.get(key).equalsIgnoreCase(color)) {
+ return convertColorHEX(key);
+ }
+ }
+ }
- if (color.equals(Constants.EMPTY_STRING) || color.equals(NONE))
- return null;
-
- if (color.charAt(START_COLOR_INDEX) == SHARP
- && color.length() == COLOR_LENGTH) {
-
- String strR = color.substring(START_INDEX_RED, END_INDEX_RED);
- String strG = color.substring(START_INDEX_GRENN, END_INDEX_GREEN);
- String strB = color.substring(START_INDEX_BLUE, END_INDEX_BLUE);
-
- try {
- Integer.parseInt(strR, RADIX);
- Integer.parseInt(strG, RADIX);
- Integer.parseInt(strB, RADIX);
- } catch (RuntimeException e) {
return null;
- }
- return convertColorHEX(color);
- } else if (color.toLowerCase().indexOf(RGB) != Constants.DONT_CONTAIN) {
+ }
- int start = color.indexOf(OPEN_BRACKET);
- int end = color.indexOf(CLOSE_BRACKET);
- String str = color.substring(start + 1, end);
+ /**
+ * Method for convert string(123px) into two string (123 and px)
+ *
+ * @param str
+ * String for convert
+ * @return Array two strings, or null, if str uncorrect
+ */
+ public static String[] convertExtString(String str) {
- StringTokenizer st = new StringTokenizer(str, COMMA);
+ if (str.equalsIgnoreCase(THIN))
+ return new String[] { THIN, Constants.EMPTY_STRING };
- int j = 0;
- while (st.hasMoreTokens()) {
- try {
- int i = Integer.parseInt(st.nextToken().trim());
- if (i < MIN_VALUE_RGB || i > MAX_VALUE_RGB)
+ if (str == null)
return null;
- } catch (NumberFormatException e) {
- return null;
- }
- j++;
- }
+ if (str.trim().equals(Constants.EMPTY_STRING))
+ return new String[] { Constants.EMPTY_STRING,
+ Constants.EMPTY_STRING };
- if (j == COUNT_COLORS)
- return convertColorRGB(color);
- } else {
- HashMap<String, String> colorMap = ColorParser.getInstance()
- .getMap();
+ String newStr = str.toLowerCase().trim();
- for (String key : colorMap.keySet())
- if (colorMap.get(key).equalsIgnoreCase(color))
- return convertColorHEX(key);
- }
+ int index = -1;
+ for (int i = 1; i < Constants.extSizes.length; i++) {
- return null;
- }
+ index = newStr.indexOf(Constants.extSizes[i]);
+ if (index != -1)
+ break;
+ }
- /**
- * Method for convert string(123px) into two string (123 and px)
- *
- * @param str
- * String for convert
- * @return Array two strings, or null, if str uncorrect
- */
- public static String[] convertExtString(String str) {
+ if (index == -1)
+ return new String[] { newStr, Constants.EMPTY_STRING };
- if (str.equalsIgnoreCase(THIN))
- return new String[] { THIN, Constants.EMPTY_STRING };
+ String number = newStr.substring(0, index);
+ String ext = newStr.substring(index, index + 2);
- if (str == null)
- return null;
+ return new String[] { number, ext };
+ }
- if (str.trim().equals(Constants.EMPTY_STRING))
- return new String[] { Constants.EMPTY_STRING,
- Constants.EMPTY_STRING };
-
- String newStr = str.toLowerCase().trim();
-
- int index = -1;
- for (int i = 1; i < Constants.extSizes.length; i++) {
-
- index = newStr.indexOf(Constants.extSizes[i]);
- if (index != -1)
- break;
+ /**
+ * Method for search css attribute into extElements
+ *
+ * @param name
+ * Name of css attribute
+ * @return true - find, or else - dont find
+ */
+ public static boolean searchInExtElement(String name) {
+ return Constants.extElem.contains(name);
}
- if (index == -1)
- return new String[] { newStr, Constants.EMPTY_STRING };
+ /**
+ * Method for getting RGB color from string color
+ *
+ * @param color
+ * String color
+ * @return RGB color
+ */
+ public static RGB convertColorRGB(String color) {
- String number = newStr.substring(0, index);
- String ext = newStr.substring(index, index + 2);
+ String newStr = color.trim().toLowerCase();
- return new String[] { number, ext };
- }
+ int rgb[] = new int[COUNT_COLORS];
- /**
- * Method for search css attribute into extElements
- *
- * @param name
- * Name of css attribute
- * @return true - find, or else - dont find
- */
- public static boolean searchInExtElement(String name) {
+ int start = newStr.indexOf(OPEN_BRACKET);
+ int end = newStr.indexOf(CLOSE_BRACKET);
+ String str = newStr.substring(start + 1, end);
- for (int i = 0; i < Constants.extElem.length; i++)
- if (Constants.extElem[i].equals(name))
- return true;
- return false;
- }
+ StringTokenizer st = new StringTokenizer(str, COMMA);
+ int i = 0;
+ while (st.hasMoreTokens())
+ rgb[i++] = Integer.parseInt(st.nextToken().trim());
+ return new RGB(rgb[0], rgb[1], rgb[2]);
+ }
- /**
- * Method for getting RGB color from string color
- *
- * @param color
- * String color
- * @return RGB color
- */
- public static RGB convertColorRGB(String color) {
+ /**
+ * Method for getting RGB color from hex string
+ *
+ * @param color
+ * String color
+ * @return RGB color
+ */
+ public static RGB convertColorHEX(String color) {
- String newStr = color.trim().toLowerCase();
+ String newStr = color.trim().toLowerCase();
- int rgb[] = new int[COUNT_COLORS];
+ String strR = newStr.substring(START_INDEX_RED, END_INDEX_RED);
+ String strG = newStr.substring(START_INDEX_GRENN, END_INDEX_GREEN);
+ String strB = newStr.substring(START_INDEX_BLUE, END_INDEX_BLUE);
- int start = newStr.indexOf(OPEN_BRACKET);
- int end = newStr.indexOf(CLOSE_BRACKET);
- String str = newStr.substring(start + 1, end);
+ int red = Integer.parseInt(strR, RADIX);
+ int green = Integer.parseInt(strG, RADIX);
+ int blue = Integer.parseInt(strB, RADIX);
- StringTokenizer st = new StringTokenizer(str, COMMA);
- int i = 0;
- while (st.hasMoreTokens())
- rgb[i++] = Integer.parseInt(st.nextToken().trim());
- return new RGB(rgb[0], rgb[1], rgb[2]);
- }
+ return new RGB(red, green, blue);
+ }
- /**
- * Method for getting RGB color from hex string
- *
- * @param color
- * String color
- * @return RGB color
- */
- public static RGB convertColorHEX(String color) {
-
- String newStr = color.trim().toLowerCase();
-
- String strR = newStr.substring(START_INDEX_RED, END_INDEX_RED);
- String strG = newStr.substring(START_INDEX_GRENN, END_INDEX_GREEN);
- String strB = newStr.substring(START_INDEX_BLUE, END_INDEX_BLUE);
-
- int red = Integer.parseInt(strR, RADIX);
- int green = Integer.parseInt(strG, RADIX);
- int blue = Integer.parseInt(strB, RADIX);
-
- return new RGB(red, green, blue);
- }
-
- /**
- * Method for convert RGB to String
- *
- * @param rgb
- * RGB color
- * @return String color
- */
- public static String createColorString(RGB rgb) {
- String colorStr = SHARP_STRING
- + (rgb.red < NORMAL_MIN_VALUE ? ZERO_STR
- : Constants.EMPTY_STRING)
- + Integer.toHexString(rgb.red)
- + (rgb.green < NORMAL_MIN_VALUE ? ZERO_STR
- : Constants.EMPTY_STRING)
- + Integer.toHexString(rgb.green)
- + Constants.EMPTY_STRING
- + (rgb.blue < NORMAL_MIN_VALUE ? ZERO_STR
- : Constants.EMPTY_STRING)
- + Integer.toHexString(rgb.blue);
- colorStr = colorStr.toUpperCase();
- if (ColorParser.getInstance().getMap().get(colorStr) != null)
- return ColorParser.getInstance().getMap().get(colorStr);
- return colorStr;
- }
-
- /**
- * Get current project
- *
- * @return
- */
- public static IProject getCurrentProject() {
- IEditorPart editor = JspEditorPlugin.getDefault().getWorkbench()
- .getActiveWorkbenchWindow().getActivePage().getActiveEditor();
- IEditorInput input = editor.getEditorInput();
- IFile file = null;
- if (input instanceof IFileEditorInput) {
- file = ((IFileEditorInput) input).getFile();
+ /**
+ * Method for convert RGB to String
+ *
+ * @param rgb
+ * RGB color
+ * @return String color
+ */
+ public static String createColorString(RGB rgb) {
+ String colorStr = SHARP_STRING
+ + (rgb.red < NORMAL_MIN_VALUE ? ZERO_STR
+ : Constants.EMPTY_STRING)
+ + Integer.toHexString(rgb.red)
+ + (rgb.green < NORMAL_MIN_VALUE ? ZERO_STR
+ : Constants.EMPTY_STRING)
+ + Integer.toHexString(rgb.green)
+ + Constants.EMPTY_STRING
+ + (rgb.blue < NORMAL_MIN_VALUE ? ZERO_STR
+ : Constants.EMPTY_STRING)
+ + Integer.toHexString(rgb.blue);
+ colorStr = colorStr.toUpperCase();
+ if (ColorParser.getInstance().getMap().get(colorStr) != null)
+ return ColorParser.getInstance().getMap().get(colorStr);
+ return colorStr;
}
- if (file == null)
- return null;
- IProject project = file.getProject();
- return project;
- }
-
- /**
- * Get current workspace
- *
- * @return
- */
- public static IWorkspace getCurrentWorkspace() {
- IEditorPart editor = JspEditorPlugin.getDefault().getWorkbench()
- .getActiveWorkbenchWindow().getActivePage().getActiveEditor();
- IEditorInput input = editor.getEditorInput();
- IFile file = null;
- if (input instanceof IFileEditorInput) {
- file = ((IFileEditorInput) input).getFile();
+ /**
+ * Get current project for opened editor
+ *
+ * @return
+ */
+ 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();
+ }
+ return project;
}
- if (file == null)
- return null;
- IWorkspace workspace = file.getWorkspace();
- return workspace;
- }
+
}
\ No newline at end of file
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-10-08
05:39:34 UTC (rev 10721)
+++
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/events/TabPropertySheetMouseAdapter.java 2008-10-08
06:45:58 UTC (rev 10722)
@@ -103,29 +103,29 @@
*/
public void mouseDown(MouseEvent event) {
- for (int i = 0; i < tree.getColumnCount(); i++)
- tree.getColumn(i).pack();
-
- Control old = editor.getEditor();
- if (old != null)
- old.dispose();
-
- Point pt = new Point(event.x, event.y);
-
- final TreeItem item = tree.getItem(pt);
-
- if (item != null) {
-
- if (Util.searchOnBlock(item.getText(Constants.FIRST_COLUMN).trim(),
- elementsMap.keySet()))
- return;
-
- if (Util.searchInCombo(item.getText(Constants.FIRST_COLUMN).trim(),
- comboMap.keySet()))
- createCombo(item, Constants.SECOND_COLUMN);
- else
- createText(item, Constants.SECOND_COLUMN);
- }
+ for (int i = 0; i < tree.getColumnCount(); i++)
+ tree.getColumn(i).pack();
+
+ Control old = editor.getEditor();
+ if (old != null)
+ old.dispose();
+
+ Point pt = new Point(event.x, event.y);
+
+ final TreeItem item = tree.getItem(pt);
+
+ if (item != null) {
+
+ if (elementsMap.keySet().contains(item.getText(Constants.FIRST_COLUMN).trim())) {
+ return;
+ }
+
+ if (comboMap.keySet().contains(item.getText(Constants.FIRST_COLUMN).trim())) {
+ createCombo(item, Constants.SECOND_COLUMN);
+ } else {
+ createText(item, Constants.SECOND_COLUMN);
+ }
+ }
}
/**
Modified:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/parsers/ColorParser.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/parsers/ColorParser.java 2008-10-08
05:39:34 UTC (rev 10721)
+++
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/parsers/ColorParser.java 2008-10-08
06:45:58 UTC (rev 10722)
@@ -50,12 +50,8 @@
private static final String FILE_NAME = "cssdialog/colors.xml";
//$NON-NLS-1$
- public static synchronized ColorParser getInstance() {
-
- if(colorParser==null) {
- colorParser = new ColorParser();
- }
- return colorParser;
+ public static ColorParser getInstance() {
+ return ColorParserHolder.INSTANCE;
}
/**
* Constructor for Color parser
@@ -107,4 +103,8 @@
}
return map;
}
+
+ private static class ColorParserHolder {
+ private static final ColorParser INSTANCE = new ColorParser();
+ }
}
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-10-08
05:39:34 UTC (rev 10721)
+++
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/tabs/TabQuickEditControl.java 2008-10-08
06:45:58 UTC (rev 10722)
@@ -113,10 +113,11 @@
label.setText(format(key));
label.setLayoutData(new GridData(GridData.END, GridData.CENTER,
false, false));
- if (Util.searchInCombo(key, comboMap.keySet()))
- createCombo(this, key, styleAttributes.getAttribute(key));
- else
- createText(this, key, styleAttributes.getAttribute(key));
+ if (comboMap.keySet().contains(key)) {
+ createCombo(this, key, styleAttributes.getAttribute(key));
+ } else {
+ createText(this, key, styleAttributes.getAttribute(key));
+ }
}
}
@@ -145,10 +146,11 @@
label.setText(format(key));
label.setLayoutData(new GridData(GridData.END, GridData.CENTER,
false, false));
- if (Util.searchInCombo(key, comboMap.keySet()))
- createCombo(this, key, styleAttributes.getAttribute(key));
- else
- createText(this, key, styleAttributes.getAttribute(key));
+ if (comboMap.keySet().contains(key)) {
+ createCombo(this, key, styleAttributes.getAttribute(key));
+ } else {
+ createText(this, key, styleAttributes.getAttribute(key));
+ }
}
this.layout();
}
Modified:
trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsBeanNameHyperlink.java
===================================================================
---
trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsBeanNameHyperlink.java 2008-10-08
05:39:34 UTC (rev 10721)
+++
trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsBeanNameHyperlink.java 2008-10-08
06:45:58 UTC (rev 10722)
@@ -69,7 +69,7 @@
return;
}
StrutsFormBeanHyperlink openOn = new StrutsFormBeanHyperlink();
- openOn.setTextViewer(getTextViewer());
+ openOn.setDocument(getDocument());
openOn.setOffset(getOffset());
openOn.doHyperlink(region);
}
Modified:
trunk/tests/tests/org.jboss.tools.test/src/org/jboss/tools/test/util/ProjectImportTestSetup.java
===================================================================
---
trunk/tests/tests/org.jboss.tools.test/src/org/jboss/tools/test/util/ProjectImportTestSetup.java 2008-10-08
05:39:34 UTC (rev 10721)
+++
trunk/tests/tests/org.jboss.tools.test/src/org/jboss/tools/test/util/ProjectImportTestSetup.java 2008-10-08
06:45:58 UTC (rev 10722)
@@ -19,7 +19,6 @@
import org.eclipse.core.resources.IncrementalProjectBuilder;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
-import org.eclipse.ui.ide.ResourceUtil;
import org.jboss.tools.test.util.xpl.EditorTestHelper;
/**
Modified:
trunk/tests/tests/org.jboss.tools.test/src/org/jboss/tools/test/util/WorkbenchUtils.java
===================================================================
---
trunk/tests/tests/org.jboss.tools.test/src/org/jboss/tools/test/util/WorkbenchUtils.java 2008-10-08
05:39:34 UTC (rev 10721)
+++
trunk/tests/tests/org.jboss.tools.test/src/org/jboss/tools/test/util/WorkbenchUtils.java 2008-10-08
06:45:58 UTC (rev 10722)
@@ -13,17 +13,23 @@
import junit.framework.TestCase;
+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.core.runtime.CoreException;
import org.eclipse.jface.preference.PreferenceDialog;
import org.eclipse.jface.preference.PreferenceManager;
import org.eclipse.jface.wizard.IWizard;
import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.IWorkbenchWizard;
+import org.eclipse.ui.PartInitException;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.dialogs.PreferencesUtil;
+import org.eclipse.ui.part.FileEditorInput;
import org.eclipse.ui.wizards.IWizardDescriptor;
/**
@@ -81,4 +87,14 @@
return PreferencesUtil.createPropertyDialogOn(WorkbenchUtils
.getActiveShell(), project, pageId, new String[] {pageId}, null);
}
+
+ public static IEditorPart openEditor(IFile inputFile, String editorId) {
+ IEditorPart part = null;
+ try {
+ part = getWorkbenchActivePage().openEditor(new FileEditorInput(inputFile), editorId);
+ } catch (PartInitException e) {
+ e.printStackTrace();
+ }
+ return part;
+ }
}
\ No newline at end of file