Author: dgolovin
Date: 2008-07-24 12:09:09 -0400 (Thu, 24 Jul 2008)
New Revision: 9272
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.ui/src/org/jboss/tools/jsf/ui/editor/FacesConfigEditor.java
trunk/jsf/plugins/org.jboss.tools.jsf.ui/src/org/jboss/tools/jsf/ui/editor/JSFEditor.java
trunk/jsf/plugins/org.jboss.tools.jsf.ui/src/org/jboss/tools/jsf/ui/editor/model/commands/JSFCompoundCommand.java
trunk/jsf/plugins/org.jboss.tools.jsf.ui/src/org/jboss/tools/jsf/ui/editor/model/impl/JSFModel.java
trunk/jsf/plugins/org.jboss.tools.jsf.ui/src/org/jboss/tools/jsf/ui/editor/model/impl/Segment.java
trunk/jsf/plugins/org.jboss.tools.jsf.ui/src/org/jboss/tools/jsf/ui/perspective/JSFPerspectiveFactory.java
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.ajax4jsf/src/org/jboss/tools/jsf/vpe/ajax4jsf/Activator.java
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/RichFacesTemplatesActivator.java
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesCalendarTemplate.java
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesDataGridTemplate.java
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesDataOrderedListTemplate.java
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesDataTableTemplate.java
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesInsertTemplate.java
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesScrollableDataTableTemplate.java
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.seam/src/org/jboss/tools/jsf/vpe/seam/template/SeamFormattedTextTemplate.java
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/model/helpers/JSFPageUpdateManager.java
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/model/pv/JSFPromptingProvider.java
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/project/capabilities/AddJSFCapabilitiesSupport.java
Log:
Cleanup VPE code:
1. Unnecessary catch(Exception ex) blocks were removed;
2. Catch(Exception ex) blocks were converted to catch particular exception(s) where it was
possible
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/model/helpers/JSFPageUpdateManager.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/model/helpers/JSFPageUpdateManager.java 2008-07-24
15:52:20 UTC (rev 9271)
+++
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/model/helpers/JSFPageUpdateManager.java 2008-07-24
16:09:09 UTC (rev 9272)
@@ -147,11 +147,7 @@
}
if(stopped) break;
if(!isLocked()) {
- try {
- updateAll();
- } catch (Exception t) {
- JSFModelPlugin.log("Error while running page update", t);
- }
+ updateAll();
}
}
}
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/model/pv/JSFPromptingProvider.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/model/pv/JSFPromptingProvider.java 2008-07-24
15:52:20 UTC (rev 9271)
+++
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/model/pv/JSFPromptingProvider.java 2008-07-24
16:09:09 UTC (rev 9272)
@@ -44,7 +44,7 @@
public List<Object> getList(XModel model, String id, String prefix, Properties
properties) {
try {
return getListInternal(model, id, prefix, properties);
- } catch (Exception e) {
+ } catch (CoreException e) {
if(properties != null) {
String message = e.getMessage();
if(message==null) {
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/project/capabilities/AddJSFCapabilitiesSupport.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/project/capabilities/AddJSFCapabilitiesSupport.java 2008-07-24
15:52:20 UTC (rev 9271)
+++
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/project/capabilities/AddJSFCapabilitiesSupport.java 2008-07-24
16:09:09 UTC (rev 9272)
@@ -12,6 +12,7 @@
import java.lang.reflect.InvocationTargetException;
+import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.jface.operation.*;
import org.jboss.tools.common.meta.action.impl.*;
@@ -98,10 +99,10 @@
}
monitor.worked(getTaskCount(items[i], 0));
}
- } catch (Exception e) {
+ } catch (CoreException e) {
exception = e;
monitor.setCanceled(true);
- } finally {
+ }finally {
monitor.done();
added = (String[])context.changeList.toArray(new String[0]);
cancelled = monitor.isCanceled();
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.ui/src/org/jboss/tools/jsf/ui/editor/FacesConfigEditor.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf.ui/src/org/jboss/tools/jsf/ui/editor/FacesConfigEditor.java 2008-07-24
15:52:20 UTC (rev 9271)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.ui/src/org/jboss/tools/jsf/ui/editor/FacesConfigEditor.java 2008-07-24
16:09:09 UTC (rev 9272)
@@ -17,6 +17,7 @@
import org.eclipse.gef.ui.actions.ActionRegistry;
import org.eclipse.jface.viewers.ISelectionProvider;
import org.eclipse.swt.widgets.Composite;
+import org.eclipse.ui.PartInitException;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.views.contentoutline.IContentOutlinePage;
@@ -79,7 +80,7 @@
selectionProvider.setHost(guiEditor.getSelectionProvider());
guiEditor.addErrorSelectionListener(createErrorSelectionListener());
selectionProvider.addHost("guiEditor", guiEditor.getSelectionProvider());
- } catch(Exception ex) {
+ } catch(PartInitException ex) {
JsfUiPlugin.getPluginLog().logError(ex);
}
}
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.ui/src/org/jboss/tools/jsf/ui/editor/JSFEditor.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf.ui/src/org/jboss/tools/jsf/ui/editor/JSFEditor.java 2008-07-24
15:52:20 UTC (rev 9271)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.ui/src/org/jboss/tools/jsf/ui/editor/JSFEditor.java 2008-07-24
16:09:09 UTC (rev 9272)
@@ -81,6 +81,7 @@
import org.eclipse.jface.viewers.SelectionChangedEvent;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.swt.SWT;
+import org.eclipse.swt.SWTException;
import org.eclipse.swt.events.KeyEvent;
import org.eclipse.swt.events.MouseEvent;
import org.eclipse.swt.graphics.GC;
@@ -599,7 +600,7 @@
Exception ex = null;
try {
printer.getDPI();
- } catch (Exception ee) {
+ } catch (SWTException ee) {
ex = ee;
printer.dispose();
d = null;
@@ -607,10 +608,8 @@
"org.jboss.tools.jsf.ui", 0, WizardKeys
.getString("PRN_ERROR"), ee);
ProblemReportingHelper.reportProblem(status);
- }
- if (ex == null) {
- d
- .setPages(new Pages(viewer, new PageFormat(printer,
+
+ d.setPages(new Pages(viewer, new PageFormat(printer,
this.getWorkbenchPart().getSite().getShell()
.getDisplay())));
String result = d.open();
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.ui/src/org/jboss/tools/jsf/ui/editor/model/commands/JSFCompoundCommand.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf.ui/src/org/jboss/tools/jsf/ui/editor/model/commands/JSFCompoundCommand.java 2008-07-24
15:52:20 UTC (rev 9271)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.ui/src/org/jboss/tools/jsf/ui/editor/model/commands/JSFCompoundCommand.java 2008-07-24
16:09:09 UTC (rev 9272)
@@ -34,16 +34,10 @@
XModelObject[] objects = (XModelObject[])elements.toArray(new XModelObject[]{});
XModelObject object= objects[0];
if(elements.size() == 1) objects = null;
- try{
- XAction action = DnDUtil.getEnabledAction(object, objects, actionName);
- if(action != null) return true;
- else return false;
- }catch(Exception ex){
- JsfUiPlugin.getPluginLog().logError(ex);
- return false;
- }
-
- }else return false;
+ XAction action = DnDUtil.getEnabledAction(object, objects, actionName);
+ if(action != null) return true;
+ }
+ return false;
}
public boolean canUndo() {
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.ui/src/org/jboss/tools/jsf/ui/editor/model/impl/JSFModel.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf.ui/src/org/jboss/tools/jsf/ui/editor/model/impl/JSFModel.java 2008-07-24
15:52:20 UTC (rev 9271)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.ui/src/org/jboss/tools/jsf/ui/editor/model/impl/JSFModel.java 2008-07-24
16:09:09 UTC (rev 9272)
@@ -309,25 +309,21 @@
}
public void nodeChanged(XModelTreeEvent event) {
- try {
- fireProcessChanged(false);
- if (map == null || event == null)
- return;
- IJSFElement element = (JSFElement) map.get(event.getInfo());
- if (element != null
- && !event.getModelObject().getPath()
- .equals(event.getInfo())) {
- updateCash((String) event.getInfo());
- }
- String path = event.getModelObject().getPath();
- element = (path == null) ? null : (IJSFElement) map.get(path);
- if (element == null) {
- return;
- }
- element.nodeChanged(event);
- } catch (Exception exc) {
- JsfUiPlugin.getPluginLog().logError("Error in processing model event",
exc);
+ fireProcessChanged(false);
+ if (map == null || event == null)
+ return;
+ IJSFElement element = (JSFElement) map.get(event.getInfo());
+ if (element != null
+ && !event.getModelObject().getPath()
+ .equals(event.getInfo())) {
+ updateCash((String) event.getInfo());
}
+ String path = event.getModelObject().getPath();
+ element = (path == null) ? null : (IJSFElement) map.get(path);
+ if (element == null) {
+ return;
+ }
+ element.nodeChanged(event);
}
public void structureChanged(XModelTreeEvent event) {
@@ -341,16 +337,12 @@
if (element == null) {
return;
}
- try {
- if (event.kind() == XModelTreeEvent.STRUCTURE_CHANGED) {
- element.structureChanged(event);
- } else if (event.kind() == XModelTreeEvent.CHILD_ADDED) {
- element.nodeAdded(event);
- } else if (event.kind() == XModelTreeEvent.CHILD_REMOVED) {
- element.nodeRemoved(event);
- }
- } catch (Exception exc) {
- JsfUiPlugin.getPluginLog().logError("Error in processing model event",
exc);
+ if (event.kind() == XModelTreeEvent.STRUCTURE_CHANGED) {
+ element.structureChanged(event);
+ } else if (event.kind() == XModelTreeEvent.CHILD_ADDED) {
+ element.nodeAdded(event);
+ } else if (event.kind() == XModelTreeEvent.CHILD_REMOVED) {
+ element.nodeRemoved(event);
}
}
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.ui/src/org/jboss/tools/jsf/ui/editor/model/impl/Segment.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf.ui/src/org/jboss/tools/jsf/ui/editor/model/impl/Segment.java 2008-07-24
15:52:20 UTC (rev 9271)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.ui/src/org/jboss/tools/jsf/ui/editor/model/impl/Segment.java 2008-07-24
16:09:09 UTC (rev 9272)
@@ -34,7 +34,7 @@
}
} catch(PropertyVetoException exception) {
length = 0;
- } catch(Exception exception) {
+ } catch(NumberFormatException exception) {
length = 0;
JsfUiPlugin.getPluginLog().logError(exception);
}
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.ui/src/org/jboss/tools/jsf/ui/perspective/JSFPerspectiveFactory.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf.ui/src/org/jboss/tools/jsf/ui/perspective/JSFPerspectiveFactory.java 2008-07-24
15:52:20 UTC (rev 9271)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.ui/src/org/jboss/tools/jsf/ui/perspective/JSFPerspectiveFactory.java 2008-07-24
16:09:09 UTC (rev 9272)
@@ -24,7 +24,6 @@
public JSFPerspectiveFactory() {}
public void createInitialLayout(IPageLayout layout) {
- try {
String editorArea = layout.getEditorArea();
IFolderLayout leftTop = layout.createFolder("leftTop", IPageLayout.LEFT,
0.24f, editorArea);
leftTop.addView(JavaUI.ID_PACKAGES);
@@ -36,10 +35,6 @@
bottom.addView(IPageLayout.ID_PROBLEM_VIEW);
bottom.addView(IPageLayout.ID_TASK_LIST);
IFolderLayout rightTop = layout.createFolder("rightTop", IPageLayout.RIGHT,
0.84f, editorArea);
- rightTop.addView(PaletteViewPart.VIEW_ID);
- } catch (Exception ex) {
- JsfUiPlugin.getPluginLog().logError(ex);
- }
+ rightTop.addView(PaletteViewPart.VIEW_ID);
}
-
}
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.ajax4jsf/src/org/jboss/tools/jsf/vpe/ajax4jsf/Activator.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.ajax4jsf/src/org/jboss/tools/jsf/vpe/ajax4jsf/Activator.java 2008-07-24
15:52:20 UTC (rev 9271)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.ajax4jsf/src/org/jboss/tools/jsf/vpe/ajax4jsf/Activator.java 2008-07-24
16:09:09 UTC (rev 9272)
@@ -10,6 +10,7 @@
******************************************************************************/
package org.jboss.tools.jsf.vpe.ajax4jsf;
+import java.io.IOException;
import java.net.URL;
import org.eclipse.core.runtime.FileLocator;
@@ -65,7 +66,7 @@
URL url = null;
try {
url = bundle == null ? null :
FileLocator.resolve(bundle.getEntry("/resources"));
- } catch (Exception e) {
+ } catch (IOException e) {
url = bundle.getEntry("/resources");
}
return (url == null) ? null : url.getPath();
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/RichFacesTemplatesActivator.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/RichFacesTemplatesActivator.java 2008-07-24
15:52:20 UTC (rev 9271)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/RichFacesTemplatesActivator.java 2008-07-24
16:09:09 UTC (rev 9272)
@@ -10,6 +10,7 @@
******************************************************************************/
package org.jboss.tools.jsf.vpe.richfaces;
+import java.io.IOException;
import java.net.URL;
import org.eclipse.core.runtime.FileLocator;
@@ -68,7 +69,7 @@
URL url = null;
try {
url = bundle == null ? null :
FileLocator.resolve(bundle.getEntry("/resources"));
- } catch (Exception e) {
+ } catch (IOException e) {
url = bundle.getEntry("/resources");
}
return (url == null) ? null : url.getPath();
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesCalendarTemplate.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesCalendarTemplate.java 2008-07-24
15:52:20 UTC (rev 9271)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesCalendarTemplate.java 2008-07-24
16:09:09 UTC (rev 9272)
@@ -558,22 +558,18 @@
array = HEADER_CONTENT_ON_POPUP;
}
- SimpleDateFormat sdf = new SimpleDateFormat();
+ SimpleDateFormat sdf = new SimpleDateFormat(DEFAULT_DATE_PATTERN);
Date date = getCalendarWithLocale().getTime();
- String dateStr = "";
+
if (attrPresents(datePattern)) {
try {
sdf.applyPattern(datePattern);
- dateStr = sdf.format(date);
- } catch (Exception e) {
- sdf.applyPattern(DEFAULT_DATE_PATTERN);
- dateStr = sdf.format(date);
+ } catch (IllegalArgumentException e) {
+ // DEFAULT_DATE_PATTERN is used in this case
}
- } else {
- sdf.applyPattern(DEFAULT_DATE_PATTERN);
- dateStr = sdf.format(date);
}
- array[2] = dateStr;
+
+ array[2] = sdf.format(date);
nsIDOMElement table = visualDocument
.createElement(HtmlComponentUtil.HTML_TAG_TABLE);
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesDataGridTemplate.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesDataGridTemplate.java 2008-07-24
15:52:20 UTC (rev 9271)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesDataGridTemplate.java 2008-07-24
16:09:09 UTC (rev 9272)
@@ -146,34 +146,24 @@
protected int getColumnsCount(Element sourceElement) {
int count = 0;
// check for exact value in component
- Integer span = null;
try {
- span = Integer.valueOf(sourceElement.getAttribute("columns"));
- } catch (Exception e) {
- // Ignore bad attribute
+ int span = Integer.parseInt(sourceElement.getAttribute("columns"));
+ count = span > 0 ? span : 0;
+ } catch (NumberFormatException e) {
+ // Ignore wrong formatted attribute
}
- if (null != span && span.intValue() >0) {
- count = span.intValue();
- }
return count;
}
protected int getElementsCount(Element sourceElement, int columnCount) {
int elements = 0;
// check for exact value in component
- Integer span = null;
try {
- span = Integer.valueOf(sourceElement.getAttribute("elements"));
- } catch (Exception e) {
- // Ignore bad attribute
- }
- if (null != span && span.intValue()>0) {
- elements = span.intValue();
- } else {
- // default rows = 3;
+ int span = Integer.parseInt(sourceElement.getAttribute("elements"));
+ elements = span>0 ? span : columnCount * defaultRows;
+ } catch (NumberFormatException e) {
elements = columnCount * defaultRows;
}
-
return elements;
}
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesDataOrderedListTemplate.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesDataOrderedListTemplate.java 2008-07-24
15:52:20 UTC (rev 9271)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesDataOrderedListTemplate.java 2008-07-24
16:09:09 UTC (rev 9272)
@@ -44,14 +44,14 @@
VpeCreationData creatorInfo = new VpeCreationData(orderedList);
- int rows = -1;
+ int rows = 3;
try {
- rows = Integer.valueOf(sourceElement.getAttribute(HtmlComponentUtil.HTML_ROW_ATTR));
- } catch (Exception x) {
- rows = -1;
+ rows = Integer.parseInt(sourceElement.getAttribute(HtmlComponentUtil.HTML_ROW_ATTR));
+ } catch (NumberFormatException x) {
+ rows = 3;
}
- for (int i = 0; i < (rows == -1 ? 3 : rows); i++) {
+ for (int i = 0; i < rows; i++) {
nsIDOMElement listItem = visualDocument.createElement("li");
listItem.setAttribute("class", "dr-list-item rich-list-item");
orderedList.appendChild(listItem);
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesDataTableTemplate.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesDataTableTemplate.java 2008-07-24
15:52:20 UTC (rev 9271)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesDataTableTemplate.java 2008-07-24
16:09:09 UTC (rev 9272)
@@ -291,16 +291,9 @@
protected int getColumnsCount(Element sourceElement, ArrayList<Element> columns)
{
int count = 0;
// check for exact value in component
- Integer span = null;
try {
- span = Integer.valueOf(sourceElement.getAttribute("columns"));
- } catch (Exception e) {
- // Ignore bad attribute
- }
- if (null != span && span.intValue() != Integer.MIN_VALUE) {
- count = span.intValue();
- } else {
- // calculate max html columns count for all columns/rows children.
+ count = Integer.parseInt(sourceElement.getAttribute("columns"));
+ } catch (NumberFormatException e) {
count = calculateRowColumns(sourceElement, columns);
}
return count;
@@ -316,59 +309,33 @@
for (Element column : columns) {
if (ComponentUtil.isRendered(column)) {
if (column.getNodeName().endsWith(":columnGroup")) {
- // Store max calculated value of previsous rows.
- if (currentLength > count) {
- count = currentLength;
- }
+ // Store max calculated value of previous rows.
+ count = Math.max(currentLength,count);
// Calculate number of columns in row.
currentLength = calculateRowColumns(sourceElement, getColumns(column));
// Store max calculated value
- if (currentLength > count) {
- count = currentLength;
- }
+ count = Math.max(currentLength,count);
currentLength = 0;
} else if (column.getNodeName().equals(sourceElement.getPrefix() +
":column")) {
- String breakBeforeStr = column.getAttribute("breakBefore");
- boolean breakBefore = false;
- if(breakBeforeStr!=null) {
- try {
- breakBefore = Boolean.getBoolean(breakBeforeStr);
- } catch (Exception e) {
- // Ignore bad attribute
- }
- }
- // For new row, save length of previsous.
- if (breakBefore) {
- if (currentLength > count) {
- count = currentLength;
- }
+ // For new row, save length of previous.
+ if (Boolean.getBoolean(column.getAttribute("breakBefore"))) {
+ count = Math.max(currentLength,count);
currentLength = 0;
}
String colspanStr = column.getAttribute("colspan");
Integer colspan = null;
try {
- colspan = Integer.valueOf(colspanStr);
+ currentLength += Integer.parseInt(colspanStr);
} catch (NumberFormatException e) {
- // Ignore
- }
- // Append colspan of this column
- if (null != colspan
- && colspan.intValue() != Integer.MIN_VALUE) {
- currentLength += colspan.intValue();
- } else {
currentLength++;
}
} else if (column.getNodeName().endsWith(":column")) {
// UIColumn always have colspan == 1.
currentLength++;
}
-
}
}
- if (currentLength > count) {
- count = currentLength;
- }
- return count;
+ return Math.max(currentLength,count);
}
@Override
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesInsertTemplate.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesInsertTemplate.java 2008-07-24
15:52:20 UTC (rev 9271)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesInsertTemplate.java 2008-07-24
16:09:09 UTC (rev 9272)
@@ -21,6 +21,7 @@
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
import org.eclipse.core.resources.IFile;
import org.jboss.tools.jsf.vpe.richfaces.HtmlComponentUtil;
@@ -36,6 +37,7 @@
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.Text;
+import org.xml.sax.SAXException;
import com.uwyn.jhighlight.renderer.Renderer;
import com.uwyn.jhighlight.renderer.XhtmlRendererFactory;
@@ -113,7 +115,7 @@
while ((buf = br.readLine()) != null)
finalStr += buf + "\n"; //$NON-NLS-1$
- } catch (Exception e) {
+ } catch (IOException e) {
div.setAttribute(HtmlComponentUtil.HTML_STYLE_ATTR, ERROR_MESSAGE_STYLE);
nsIDOMText text = visualDocument.createTextNode(RESOURCE_READING_ERROR_MESSAGE);
div.appendChild(text);
@@ -208,8 +210,12 @@
builder = fact.newDocumentBuilder();
doc = builder.parse(new StringBufferInputStream(transformString));
node = doc.getElementsByTagName("code").item(0); //$NON-NLS-1$
- } catch (Exception e) {
+ } catch (IOException e) {
return node;
+ } catch (SAXException e) {
+ return node;
+ } catch (ParserConfigurationException e) {
+ return node;
}
return node;
}
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesScrollableDataTableTemplate.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesScrollableDataTableTemplate.java 2008-07-24
15:52:20 UTC (rev 9271)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesScrollableDataTableTemplate.java 2008-07-24
16:09:09 UTC (rev 9272)
@@ -495,18 +495,12 @@
ArrayList<Element> columns) {
int count = 0;
// check for exact value in component
- Integer span = null;
try {
- span = Integer.valueOf(sourceElement.getAttribute("columns"));
- } catch (Exception e) {
- // Ignore bad attribute
+ int span = Integer.parseInt(sourceElement.getAttribute("columns"));
+ count = count > 0 ? span : calculateRowColumns(sourceElement, columns);
+ } catch (NumberFormatException e) {
+ count = count = calculateRowColumns(sourceElement, columns);
}
- if (null != span && span.intValue() != Integer.MIN_VALUE) {
- count = span.intValue();
- } else {
- // calculate max html columns count for all columns/rows children.
- count = calculateRowColumns(sourceElement, columns);
- }
return count;
}
@@ -536,16 +530,8 @@
} else if (column.getNodeName().equals(
sourceElement.getPrefix() + ":column")) {
String breakBeforeStr = column.getAttribute("breakBefore");
- boolean breakBefore = false;
- if (breakBeforeStr != null) {
- try {
- breakBefore = Boolean.getBoolean(breakBeforeStr);
- } catch (Exception e) {
- // Ignore bad attribute
- }
- }
// For new row, save length of previsous.
- if (breakBefore) {
+ if (Boolean.getBoolean(breakBeforeStr)) {
if (currentLength > count) {
count = currentLength;
}
@@ -553,17 +539,10 @@
}
String colspanStr = column
.getAttribute(HtmlComponentUtil.HTML_TABLE_COLSPAN);
- Integer colspan = null;
try {
- colspan = Integer.valueOf(colspanStr);
- } catch (Exception e) {
- // Ignore
- }
- // Append colspan of this column
- if (null != colspan
- && colspan.intValue() != Integer.MIN_VALUE) {
- currentLength += colspan.intValue();
- } else {
+ int colspan = Integer.parseInt(colspanStr);
+ currentLength += colspan > 0 ? colspan : 1;
+ } catch (NumberFormatException e) {
currentLength++;
}
} else if (column.getNodeName().endsWith(":column")) {
@@ -614,7 +593,13 @@
// .queryInterface(nsIDOMElement.NS_IDOMELEMENT_IID);
// if (name.equalsIgnoreCase(HtmlComponentUtil.HTML_WIDTH_ATTR)) {
// String style = visualElement
- // .getAttribute(HtmlComponentUtil.HTML_STYLE_ATTR);
+ // .getAttribute(HtmlComponentUtil.HTML_S // Append colspan of this column
+ if (null != colspan
+ && colspan.intValue() != Integer.MIN_VALUE) {
+ currentLength += colspan.intValue();
+ } else {
+
+ }TYLE_ATTR);
// visualElement.removeAttribute(HtmlComponentUtil.HTML_STYLE_ATTR);
// style += "; " + HtmlComponentUtil.HTML_WIDTH_ATTR + " : "
// + DEFAULT_WIDTH + ";";
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.seam/src/org/jboss/tools/jsf/vpe/seam/template/SeamFormattedTextTemplate.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.seam/src/org/jboss/tools/jsf/vpe/seam/template/SeamFormattedTextTemplate.java 2008-07-24
15:52:20 UTC (rev 9271)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.seam/src/org/jboss/tools/jsf/vpe/seam/template/SeamFormattedTextTemplate.java 2008-07-24
16:09:09 UTC (rev 9272)
@@ -74,18 +74,15 @@
} catch (TokenStreamException e) {
SeamTemplatesActivator.getPluginLog().logError(e);
}
- nsIDOMParser parserDom = null;
- try {
- parserDom = (nsIDOMParser)getComponentManager().
+
+ nsIDOMParser parserDom = parserDom = (nsIDOMParser)getComponentManager().
createInstanceByContractID(CID_DOMPARSER, null,
nsIDOMParser.NS_IDOMPARSER_IID);
- } catch (Exception e) {
- SeamTemplatesActivator.getPluginLog().logError(e);
- }
+
String strDoc = "<HTML><BODY>" + parser.toString() +
"</BODY></HTML>";
- nsIDOMDocument domDoc = null != parserDom ? parserDom.parseFromString(strDoc,
"application/xhtml+xml") : null;
+ nsIDOMDocument domDoc = parserDom.parseFromString(strDoc,
"application/xhtml+xml");
nsIDOMNode patronItem = null, nodeTmp = null;
nsIDOMNodeList list = null;
- if (null != domDoc && null != domDoc.getDocumentElement()) {
+ if ( null != domDoc.getDocumentElement()) {
list = domDoc.getDocumentElement().getChildNodes();
long i = 0;
for (; i < list.getLength(); i++) {