Author: scabanovich
Date: 2007-09-13 09:51:44 -0400 (Thu, 13 Sep 2007)
New Revision: 3607
Modified:
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/editor/ObjectMultiPageEditor.java
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/editor/XMLEditorLauncher.java
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/editor/form/SampleErrorForm.java
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/action/SaveModelActionDelegate.java
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/action/XModelObjectAction.java
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/action/file/ModelResourceActionDelegate.java
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/action/file/RemoveModelNatureActionDelegate.java
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/attribute/adapter/XChildrenTableStructuredAdapter.java
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/attribute/editor/TableStructuredFieldEditor.java
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/dialog/SelectEclipseFileWizard.java
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/dnd/ControlDragDrop.java
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/objecteditor/PropertiesWizard.java
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/outline/OutlineContentProvider.java
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/outline/XModelObjectContentProvider.java
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/problem/ResourceProblemManager.java
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/reporting/ReportProblemWizard.java
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/resources/ResourceLayoutManager.java
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/select/SelectObjectWizard.java
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/select/XModelObjectSelectionProvider.java
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/texteditors/PropertiesTextEditorComponent.java
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/texteditors/TextEditorComponent.java
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/texteditors/XMLTextEditorComponent.java
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/texteditors/preferences/ReplaceTabsAdapter.java
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/texteditors/preferences/TabWidthAdapter.java
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/texteditors/xmleditor/XMLTextEditor.java
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/views/palette/PaletteAdapter.java
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/views/palette/PaletteInsertHelper.java
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/views/palette/editor/PaletteDialog.java
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/views/palette/model/PaletteModel.java
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/wizard/newfile/NewXHTMLFileWizard.java
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/propertieseditor/bundlemodel/BundleModel.java
Log:
JBIDE-893
Modified:
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/editor/ObjectMultiPageEditor.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/editor/ObjectMultiPageEditor.java 2007-09-13
13:46:53 UTC (rev 3606)
+++
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/editor/ObjectMultiPageEditor.java 2007-09-13
13:51:44 UTC (rev 3607)
@@ -129,7 +129,11 @@
private void updateFile() {
IFile file = getFile();
- if(file != null) try { file.refreshLocal(0, null); } catch (Exception e) {}
+ if(file != null) try {
+ file.refreshLocal(0, null);
+ } catch (CoreException e) {
+ //ignore
+ }
}
private IFile getFile() {
@@ -161,21 +165,26 @@
try {
String q = p.getPersistentProperty(qn);
selectedPageIndex = (q == null) ? 0 : Integer.parseInt(q);
- } catch (Exception e) {
+ } catch (NumberFormatException e) {
//ignore
selectedPageIndex = 0;
+ } catch (CoreException e) {
+ //ignore
+ selectedPageIndex = 0;
}
}
private void saveSelectedTab() {
IFile file = getFile();
- try {
if(file == null) {
saveSelectedTabForStorage();
} else {
- file.setPersistentProperty(persistentTabQualifiedName, "" +
selectedPageIndex);
+ try {
+ if(file.isAccessible()) file.setPersistentProperty(persistentTabQualifiedName,
"" + selectedPageIndex);
+ } catch (CoreException e) {
+ ModelUIPlugin.getPluginLog().logError(e);
+ }
}
- } catch (Exception e) {}
}
private void saveSelectedTabForStorage() {
@@ -185,7 +194,7 @@
if(p == null || !p.isOpen()) return;
try {
p.setPersistentProperty(qn, "" + selectedPageIndex);
- } catch (Exception e) {
+ } catch (CoreException e) {
//ignore
}
}
@@ -223,7 +232,9 @@
try {
setActivePage(selectedPageIndex);
updateSelectionProvider();
- } catch (Exception e) {}
+ } catch (Exception e) {
+ ModelUIPlugin.getPluginLog().logError(e);
+ }
new ResourceChangeListener(this, getContainer());
}
@@ -236,7 +247,9 @@
selectedPageIndex = i;
try {
switchToPage(i);
- } catch (Exception e) {}
+ } catch (Exception e) {
+ ModelUIPlugin.getPluginLog().logError(e);
+ }
}
}
@@ -545,7 +558,11 @@
Display.getDefault().syncExec(
new Runnable() {
public void run() {
- try { Thread.sleep(200); } catch (Exception e) {}
+ try {
+ Thread.sleep(200);
+ } catch (InterruptedException e) {
+ //ignore
+ }
textEditor.save();
}
}
@@ -886,6 +903,7 @@
new ProgressMonitorDialog(shell).run(false, true, op);
success = true;
} catch (InterruptedException x) {
+ //ignore
} catch (InvocationTargetException x) {
Throwable targetException= x.getTargetException();
String title = "Save As";
@@ -913,7 +931,11 @@
XModelObject o = null;
for (int i = 0; i < 5 && o == null; i++) {
o = EclipseResourceUtil.getObjectByResource(file);
- if(o == null) try { Thread.sleep(200); } catch (Exception e) {}
+ if(o == null) try {
+ Thread.sleep(200);
+ } catch (InterruptedException e) {
+ //ignore
+ }
}
if(o == null) o = EclipseResourceUtil.createObjectForResource(file);
if(o != null) {
Modified:
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/editor/XMLEditorLauncher.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/editor/XMLEditorLauncher.java 2007-09-13
13:46:53 UTC (rev 3606)
+++
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/editor/XMLEditorLauncher.java 2007-09-13
13:51:44 UTC (rev 3607)
@@ -63,7 +63,11 @@
int time = 100;
while(workbenchPage.findEditor(input) != null) {
if(time > 1000) return;
- try { Thread.sleep(time); } catch (Exception e) {}
+ try {
+ Thread.sleep(time);
+ } catch (InterruptedException e) {
+ //ignore
+ }
time *= 2;
}
try {
Modified:
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/editor/form/SampleErrorForm.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/editor/form/SampleErrorForm.java 2007-09-13
13:46:53 UTC (rev 3606)
+++
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/editor/form/SampleErrorForm.java 2007-09-13
13:51:44 UTC (rev 3607)
@@ -14,6 +14,7 @@
import java.util.StringTokenizer;
import org.jboss.tools.common.editor.ErrorSelectionListener;
import org.eclipse.swt.SWT;
+import org.eclipse.swt.SWTException;
import org.eclipse.swt.custom.StyleRange;
import org.eclipse.swt.custom.StyledText;
import org.eclipse.swt.events.MouseAdapter;
@@ -28,6 +29,7 @@
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Layout;
+import org.jboss.tools.common.model.ui.ModelUIPlugin;
import org.jboss.tools.common.model.ui.forms.ExpandableForm;
import org.jboss.tools.common.model.ui.widgets.IWidgetSettings;
@@ -221,18 +223,24 @@
public StyleRange2(int start, int length, Color fg, Color bg, String location) {
super(start, length, fg, bg);
int i = location.indexOf(":");
- try {
- line = Integer.parseInt(location.substring(0, i));
- } catch (Exception e) {}
- try {
- position = Integer.parseInt(location.substring(i + 1));
- } catch (Exception e) {}
+ line = getInt(location.substring(0, i), 0);
+ position = getInt(location.substring(i + 1), 0);
}
public void execute() {
if(listener != null) listener.errorSelected(line, position);
}
}
+ int getInt(String s, int def) {
+ if(s == null || s.length() == 0) return def;
+ try {
+ return Integer.parseInt(s);
+ } catch (NumberFormatException e) {
+ ModelUIPlugin.getPluginLog().logError(e);
+ }
+ return def;
+ }
+
class ML extends MouseAdapter implements MouseMoveListener {
Cursor hand = new Cursor(null, SWT.CURSOR_HAND);
Cursor arrow = new Cursor(null, SWT.CURSOR_ARROW);
@@ -256,8 +264,10 @@
int offset = 0;
try {
offset = styledText.getOffsetAtLocation(new Point(e.x, e.y));
- } catch (Exception exc) {
+ } catch (SWTException exc) {
return null;
+ } catch (IllegalArgumentException e2) {
+ return null;
}
return getRange(offset);
}
@@ -315,11 +325,6 @@
result[ERROR_TYPE] = s.substring(0, i);
result[ERROR_LOCATION] = q;
result[ERROR_MESSAGE] = s.substring(k + 1);
-// int qi = q.indexOf(':');
-// if(qi > 0) {
-// try { line = Integer.parseInt(q.substring(0, qi)); } catch (Exception e) {}
-// try { position = Integer.parseInt(q.substring(qi + 1)); } catch (Exception e) {}
-// }
} else {
result[ERROR_TYPE] = "ERROR";
result[ERROR_LOCATION] = "0:0";
Modified:
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/action/SaveModelActionDelegate.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/action/SaveModelActionDelegate.java 2007-09-13
13:46:53 UTC (rev 3606)
+++
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/action/SaveModelActionDelegate.java 2007-09-13
13:51:44 UTC (rev 3607)
@@ -17,6 +17,7 @@
import org.jboss.tools.common.meta.action.impl.handlers.SaveAllHandler;
import org.jboss.tools.common.model.*;
import org.jboss.tools.common.model.impl.RootImpl;
+import org.jboss.tools.common.model.ui.ModelUIPlugin;
public class SaveModelActionDelegate extends AbstractModelActionDelegate {
ModifyUpdate update = null;
@@ -36,7 +37,11 @@
XModel model = (object != null) ? object.getModel() : null;
update.setData(action, model);
synchronized (monitor) {
- try { monitor.notifyAll(); } catch (Exception e) {}
+ try {
+ monitor.notifyAll();
+ } catch (IllegalMonitorStateException e) {
+ //ignore
+ }
}
}
@@ -48,7 +53,11 @@
if(update != null) {
update.stopped = true;
synchronized (monitor) {
- try { monitor.notifyAll(); } catch (Exception e) {}
+ try {
+ monitor.notifyAll();
+ } catch (IllegalMonitorStateException e) {
+ //ignore
+ }
}
update = null;
}
@@ -92,12 +101,18 @@
public void run() {
while(!stopped) {
synchronized (monitor) {
- try { monitor.wait(); } catch (Exception e) {}
+ try {
+ monitor.wait();
+ } catch (InterruptedException e) {
+ //ignore
+ }
if(stopped) return;
if(action != null) try {
boolean enabled = model != null && model.getRoot().isModified();
if(action.isEnabled() != enabled) action.setEnabled(enabled);
- } catch (Exception e) {}
+ } catch (Exception e) {
+ ModelUIPlugin.getPluginLog().logError(e);
+ }
}
}
}
Modified:
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/action/XModelObjectAction.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/action/XModelObjectAction.java 2007-09-13
13:46:53 UTC (rev 3606)
+++
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/action/XModelObjectAction.java 2007-09-13
13:51:44 UTC (rev 3607)
@@ -96,9 +96,10 @@
w.execute();
}
} catch (ActionDeclinedException de) {
+ //ignore
} catch(Exception e) {
ModelUIPlugin.getPluginLog().logError(e);
- }
+ }
}
protected Properties prepareProperties() {
Modified:
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/action/file/ModelResourceActionDelegate.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/action/file/ModelResourceActionDelegate.java 2007-09-13
13:46:53 UTC (rev 3606)
+++
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/action/file/ModelResourceActionDelegate.java 2007-09-13
13:51:44 UTC (rev 3607)
@@ -145,7 +145,9 @@
if(isSupportingImplementation(IFile.class)) {
try {
resource = ((IClassFile)object).getCorrespondingResource();
- } catch (Exception e) {}
+ } catch (Exception e) {
+ //ignore
+ }
} else if(isWindowAction && isSupportingImplementation(IJavaProject.class)) {
object = ((IClassFile)object).getJavaProject();
}
Modified:
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/action/file/RemoveModelNatureActionDelegate.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/action/file/RemoveModelNatureActionDelegate.java 2007-09-13
13:46:53 UTC (rev 3606)
+++
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/action/file/RemoveModelNatureActionDelegate.java 2007-09-13
13:51:44 UTC (rev 3607)
@@ -12,6 +12,8 @@
import java.util.*;
import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
+import org.jboss.tools.common.model.ui.ModelUIPlugin;
public class RemoveModelNatureActionDelegate extends ProjectRootActionDelegate {
protected String getActionPath() {
@@ -25,10 +27,12 @@
protected boolean hasModelNature(IProject project) {
String nature = getModelNatureName();
- if(nature == null) return super.hasModelNature(project);
+ if(nature == null) return super.hasModelNature(project);
+ if(project == null || !project.isAccessible()) return false;
try {
if(project.hasNature(nature)) return true;
- } catch (Exception e) {
+ } catch (CoreException e) {
+ ModelUIPlugin.getPluginLog().logError(e);
}
return false;
}
Modified:
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/attribute/adapter/XChildrenTableStructuredAdapter.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/attribute/adapter/XChildrenTableStructuredAdapter.java 2007-09-13
13:46:53 UTC (rev 3606)
+++
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/attribute/adapter/XChildrenTableStructuredAdapter.java 2007-09-13
13:51:44 UTC (rev 3607)
@@ -38,6 +38,7 @@
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.jface.viewers.TableLayout;
import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.swt.SWTException;
import org.eclipse.swt.events.ControlAdapter;
import org.eclipse.swt.events.ControlEvent;
import org.eclipse.swt.graphics.Color;
@@ -141,10 +142,8 @@
int dw = (w - cw) * getWidthHint(i) / hs;
try {
c.setWidth(c.getWidth() + dw);
-
-
-
- } catch (Exception exc) {
+ } catch (SWTException exc) {
+ //ignore
}
}
resizeLock = false;
Modified:
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/attribute/editor/TableStructuredFieldEditor.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/attribute/editor/TableStructuredFieldEditor.java 2007-09-13
13:46:53 UTC (rev 3606)
+++
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/attribute/editor/TableStructuredFieldEditor.java 2007-09-13
13:51:44 UTC (rev 3607)
@@ -336,17 +336,20 @@
// IStructureChangeListener
public void structureChanged(StructuredChangedEvent event) {
- if (this.tableViewer!=null) {
- try {
- int i = tableViewer.getTable().getSelectionIndex();
- if(i < 0) i = 0;
- tableViewer.refresh();
- int c = tableViewer.getTable().getItemCount();
- while(i >= c) --i;
- if(i >= 0) {
- tableViewer.setSelection(new
StructuredSelection(tableViewer.getTable().getItem(i).getData()));
- }
- } catch (Exception e) {}
+ if(tableViewer == null) return;
+ Table table = tableViewer.getTable();
+ if(table == null || table.isDisposed()) return;
+ int i = table.getSelectionIndex();
+ if(i < 0) i = 0;
+ try {
+ tableViewer.refresh();
+ int c = tableViewer.getTable().getItemCount();
+ while(i >= c) --i;
+ if(i >= 0) {
+ tableViewer.setSelection(new
StructuredSelection(tableViewer.getTable().getItem(i).getData()));
+ }
+ } catch (Exception e) {
+ ModelUIPlugin.getPluginLog().logError(e);
}
}
Modified:
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/dialog/SelectEclipseFileWizard.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/dialog/SelectEclipseFileWizard.java 2007-09-13
13:46:53 UTC (rev 3606)
+++
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/dialog/SelectEclipseFileWizard.java 2007-09-13
13:51:44 UTC (rev 3607)
@@ -14,6 +14,7 @@
import java.util.List;
import org.eclipse.core.resources.*;
import org.eclipse.core.runtime.*;
+import org.jboss.tools.common.model.ui.ModelUIPlugin;
import org.jboss.tools.common.model.ui.wizards.one.ServiceDialogImpl;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.jface.viewers.ViewerFilter;
@@ -178,6 +179,7 @@
}
private boolean collect(IContainer container, Set<IResource> set) {
+ if(container == null || !container.isAccessible()) return false;
boolean added = false;
try {
IResource[] resources = container.members();
@@ -197,6 +199,7 @@
}
}
} catch (CoreException e) {
+ ModelUIPlugin.getPluginLog().logError(e);
}
return added;
}
Modified:
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/dnd/ControlDragDrop.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/dnd/ControlDragDrop.java 2007-09-13
13:46:53 UTC (rev 3606)
+++
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/dnd/ControlDragDrop.java 2007-09-13
13:51:44 UTC (rev 3607)
@@ -133,7 +133,11 @@
public void run() {
while(status == 1) {
- try { Thread.sleep(200); } catch (Exception e) {}
+ try {
+ Thread.sleep(200);
+ } catch (InterruptedException e) {
+ ignore();
+ }
long t = System.currentTimeMillis();
if(item != null && t > item_time) {
expandPending = true;
Modified:
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/objecteditor/PropertiesWizard.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/objecteditor/PropertiesWizard.java 2007-09-13
13:46:53 UTC (rev 3606)
+++
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/objecteditor/PropertiesWizard.java 2007-09-13
13:51:44 UTC (rev 3607)
@@ -77,8 +77,10 @@
public void stopEditing() {
try {
- objectEditor.stopEditing();
- } catch (Exception e) {}
+ if(objectEditor != null) objectEditor.stopEditing();
+ } catch (Exception e) {
+ ModelUIPlugin.getPluginLog().logError(e);
+ }
}
public void dispose() {
Modified:
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/outline/OutlineContentProvider.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/outline/OutlineContentProvider.java 2007-09-13
13:46:53 UTC (rev 3606)
+++
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/outline/OutlineContentProvider.java 2007-09-13
13:51:44 UTC (rev 3607)
@@ -37,21 +37,6 @@
return es2;
}
-/*
- private void createFilteredTree() {
- XModel model = cache.getObject().getModel();
- if(EclipseResourceUtil.isProjectFragment(model)) return;
- String classname =
model.getMetaData().getMapping("FilteredTrees").getValue("FileSystems");
- try {
- tree = (XFilteredTree)getClass().getClassLoader().loadClass(classname).newInstance();
- tree.setModel(model);
- if(tree.getRoot() == null) tree = null;
- isProjectEnabled = (tree != null);
- } catch(Exception ex) {
- }
- }
-*/
-
public Object[] getChildren(Object parentElement) {
Object result[] = null;
if(cache.getObject() == parentElement || tree == null)
Modified:
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/outline/XModelObjectContentProvider.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/outline/XModelObjectContentProvider.java 2007-09-13
13:46:53 UTC (rev 3606)
+++
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/outline/XModelObjectContentProvider.java 2007-09-13
13:51:44 UTC (rev 3607)
@@ -16,8 +16,8 @@
import org.eclipse.jface.viewers.TreeViewer;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.ui.model.WorkbenchContentProvider;
-import org.jboss.tools.common.model.XFilteredTreeConstraint;
import org.jboss.tools.common.model.*;
+import org.jboss.tools.common.model.ui.ModelUIPlugin;
import org.jboss.tools.common.model.util.*;
public class XModelObjectContentProvider extends WorkbenchContentProvider {
@@ -34,6 +34,7 @@
((TreeViewer)viewer).expandToLevel(2);
if(cache != null) viewer.setSelection(new StructuredSelection(cache.getObject()));
} catch (Exception e) {
+ ModelUIPlugin.getPluginLog().logError(e);
}
}
}
@@ -100,19 +101,19 @@
}
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+ super.inputChanged(viewer, oldInput, newInput);
+ this.viewer = viewer;
+ if(viewer instanceof TreeViewer) {
+ ((TreeViewer)viewer).setAutoExpandLevel(2);
+ }
+ if(viewer == null || viewer.getControl() == null || viewer.getControl().isDisposed())
return;
try {
- super.inputChanged(viewer, oldInput, newInput);
- this.viewer = viewer;
- if(viewer instanceof TreeViewer) {
- ((TreeViewer)viewer).setAutoExpandLevel(2);
- }
- if(viewer.getControl() == null || viewer.getControl().isDisposed()) return;
viewer.refresh();
if(viewer.getSelection() == null || viewer.getSelection().isEmpty()) {
if(cache != null) viewer.setSelection(new StructuredSelection(cache.getObject()));
}
} catch (Exception t) {
- //ignore
+ ModelUIPlugin.getPluginLog().logError(t);
}
}
Modified:
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/problem/ResourceProblemManager.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/problem/ResourceProblemManager.java 2007-09-13
13:46:53 UTC (rev 3606)
+++
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/problem/ResourceProblemManager.java 2007-09-13
13:51:44 UTC (rev 3607)
@@ -101,7 +101,11 @@
int line = marker.getAttribute(IMarker.LINE_NUMBER, -1);
int position = marker.getAttribute(IMarker.CHAR_START, -1);
String type = IMarker.PROBLEM;
- try { type = marker.getType(); } catch (Exception e) {}
+ try {
+ if(marker.exists()) type = marker.getType();
+ } catch (CoreException e) {
+ ModelUIPlugin.getPluginLog().logError(e);
+ }
Problem p = new Problem(message, position, line, -1);
p.setType(type);
p.setLocation(location);
Modified:
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/reporting/ReportProblemWizard.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/reporting/ReportProblemWizard.java 2007-09-13
13:46:53 UTC (rev 3606)
+++
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/reporting/ReportProblemWizard.java 2007-09-13
13:51:44 UTC (rev 3607)
@@ -13,7 +13,6 @@
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.io.File;
-import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.IOException;
@@ -227,10 +226,12 @@
*/
private byte[] getEclipseLogContent() {
StringBuffer sb = new StringBuffer();
+ String location = Platform.getLogFileLocation().toOSString();
+ File f = new File(location);
+ if(!f.isFile()) return sb.toString().getBytes();
try {
- InputStreamReader in = new FileReader(Platform.getLogFileLocation()
- .toOSString());
+ InputStreamReader in = new FileReader(location);
char[] tempBuffer = new char[512];
int len = 0;
@@ -238,8 +239,8 @@
sb.append(tempBuffer);
}
- } catch (FileNotFoundException e) {
} catch (IOException e) {
+ ModelUIPlugin.getPluginLog().logError(e);
}
return sb.toString().getBytes();
Modified:
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/resources/ResourceLayoutManager.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/resources/ResourceLayoutManager.java 2007-09-13
13:46:53 UTC (rev 3606)
+++
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/resources/ResourceLayoutManager.java 2007-09-13
13:51:44 UTC (rev 3607)
@@ -94,7 +94,7 @@
private Document getLayoutDocument(IResource resource) {
Document document = null;
- if (resource==null) {
+ if (resource == null) {
ModelUIPlugin.getPluginLog().logError(ModelUIMessages.getString(ERROR_RESOURCE_NULL));
return null;
}
@@ -102,9 +102,13 @@
String fullResourceLocation = getFullLocation(resource).toString();
String layoutLocation = null;
try {
- layoutLocation = resource.getPersistentProperty(new
QualifiedName("",LAYOUT_PROPERTY));
- } catch (CoreException e) {}
- if (layoutLocation==null) layoutLocation = createNewLayoutLocation(resource);
+ if(resource.isAccessible()) {
+ layoutLocation = resource.getPersistentProperty(new
QualifiedName("",LAYOUT_PROPERTY));
+ }
+ } catch (CoreException e) {
+ ModelUIPlugin.getPluginLog().logError(e);
+ }
+ if (layoutLocation == null) layoutLocation = createNewLayoutLocation(resource);
//String fullLayoutLocation =
getFullLocation(resource).addFileExtension(LAYOUT_EXT).toString();
// try get from hashMap
@@ -160,9 +164,13 @@
getFullLocation(resource).toString();
String layoutLocation = null;
try {
- layoutLocation = resource.getPersistentProperty(new
QualifiedName("",LAYOUT_PROPERTY));
- } catch (CoreException e) {}
- if (layoutLocation==null) layoutLocation = createNewLayoutLocation(resource);
+ if(resource != null && resource.isAccessible()) {
+ layoutLocation = resource.getPersistentProperty(new
QualifiedName("",LAYOUT_PROPERTY));
+ }
+ } catch (CoreException e) {
+ ModelUIPlugin.getPluginLog().logError(e);
+ }
+ if (layoutLocation == null) layoutLocation = createNewLayoutLocation(resource);
if(!new File(layoutLocation).isFile()) return null;
//String fullLayoutLocation =
getFullLocation(resource).addFileExtension(LAYOUT_EXT).toString();
Document document = null;
@@ -204,8 +212,12 @@
public void store(IResource resource) {
String layoutLocation = null;
try {
- layoutLocation = resource.getPersistentProperty(new
QualifiedName("",LAYOUT_PROPERTY));
- } catch (CoreException e) {}
+ if(resource != null && resource.isAccessible()) {
+ layoutLocation = resource.getPersistentProperty(new
QualifiedName("",LAYOUT_PROPERTY));
+ }
+ } catch (CoreException e) {
+ ModelUIPlugin.getPluginLog().logError(e);
+ }
if (layoutLocation==null) {
layoutLocation = createNewLayoutLocation(resource);
}
@@ -260,8 +272,12 @@
String layoutLocation = getPluginMetadataPath().toString();
String result = layoutLocation+"/"+fileName+"."+LAYOUT_EXT;
try {
- resource.setPersistentProperty(new QualifiedName("", LAYOUT_PROPERTY),
result);
- } catch (CoreException e) {}
+ if(resource != null && resource.isAccessible()) {
+ resource.setPersistentProperty(new QualifiedName("", LAYOUT_PROPERTY),
result);
+ }
+ } catch (CoreException e) {
+ ModelUIPlugin.getPluginLog().logError(e);
+ }
return result;
}
@@ -272,4 +288,5 @@
return INSTANCE;
}
}
+
}
Modified:
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/select/SelectObjectWizard.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/select/SelectObjectWizard.java 2007-09-13
13:46:53 UTC (rev 3606)
+++
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/select/SelectObjectWizard.java 2007-09-13
13:51:44 UTC (rev 3607)
@@ -102,7 +102,11 @@
if(getSelection(navigatorpart) == o
// Actually, this is next to never show WebProjectsView.
&& where == FindObjectHelper.IN_NAVIGATOR_ONLY) {
- try { page.showView(views[i]); } catch (Exception e) {}
+ try {
+ page.showView(views[i]);
+ } catch (PartInitException e) {
+ //ignore
+ }
}
}
return of;
Modified:
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/select/XModelObjectSelectionProvider.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/select/XModelObjectSelectionProvider.java 2007-09-13
13:46:53 UTC (rev 3606)
+++
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/select/XModelObjectSelectionProvider.java 2007-09-13
13:51:44 UTC (rev 3607)
@@ -16,6 +16,7 @@
import org.eclipse.jdt.core.ICompilationUnit;
import org.eclipse.jface.viewers.*;
import org.jboss.tools.common.model.*;
+import org.jboss.tools.common.model.ui.ModelUIPlugin;
public class XModelObjectSelectionProvider implements ISelectionProvider,
ISelectionChangedListener {
private List<ISelectionChangedListener> listeners;
@@ -55,7 +56,9 @@
if(this.host != null) {
try {
host.removeSelectionChangedListener(this);
- } catch (Exception e) {}
+ } catch (Exception e) {
+ ModelUIPlugin.getPluginLog().logError(e);
+ }
}
this.host = host;
if(host != null)
Modified:
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/texteditors/PropertiesTextEditorComponent.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/texteditors/PropertiesTextEditorComponent.java 2007-09-13
13:46:53 UTC (rev 3606)
+++
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/texteditors/PropertiesTextEditorComponent.java 2007-09-13
13:51:44 UTC (rev 3607)
@@ -18,9 +18,12 @@
import org.jboss.tools.common.propertieseditor.text.*;
import org.jboss.tools.common.model.ui.ModelUIPlugin;
import
org.jboss.tools.common.model.ui.texteditors.propertyeditor.PropertiesTextEditorStub;
+import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.DocumentEvent;
+import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.ITextListener;
import org.eclipse.jface.text.TextEvent;
+import org.eclipse.jface.text.source.ISourceViewer;
import org.eclipse.swt.events.FocusListener;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
@@ -88,9 +91,13 @@
public String getText() {
String text = null;
+ if(getSourceViewer() == null) return null;
+ if(getSourceViewer().getDocument() == null) return null;
try {
text = getSourceViewer().getDocument().get();
- } catch (Exception ex) {}
+ } catch (Exception ex) {
+ ModelUIPlugin.getPluginLog().logError(ex);
+ }
return (text == null) ? "" : text;
}
@@ -136,10 +143,16 @@
}
public void setCursor(int line, int position) {
+ ISourceViewer sv = getSourceViewer();
+ if(sv == null) return;
+ IDocument d = sv.getDocument();
+ if(d == null) return;
try {
- int i = getSourceViewer().getDocument().getLineOffset(line - 1) + position -1;
- getSourceViewer().setSelectedRange(i, 0);
- } catch (Exception e) {}
+ int i = d.getLineOffset(line - 1) + position - 1;
+ sv.setSelectedRange(i, 0);
+ } catch (BadLocationException e) {
+ ModelUIPlugin.getPluginLog().logError(e);
+ }
}
public void doSaveAs() {}
@@ -185,7 +198,11 @@
Display.getDefault().syncExec(
new Runnable() {
public void run() {
- try { Thread.sleep(200); } catch (Exception e) {}
+ try {
+ Thread.sleep(200);
+ } catch (InterruptedException e) {
+ //ignore
+ }
support.save();
}
}
Modified:
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/texteditors/TextEditorComponent.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/texteditors/TextEditorComponent.java 2007-09-13
13:46:53 UTC (rev 3606)
+++
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/texteditors/TextEditorComponent.java 2007-09-13
13:51:44 UTC (rev 3607)
@@ -167,7 +167,9 @@
String text = null;
try {
if (document != null) text = document.get();
- } catch (Exception ex) {}
+ } catch (Exception ex) {
+ ModelUIPlugin.getPluginLog().logError(ex);
+ }
return (text == null) ? "" : text;
}
@@ -193,7 +195,9 @@
try {
int i = document.getLineOffset(line - 1) + position -1;
preview.setSelectedRange(i, 0);
- } catch (Exception e) {}
+ } catch (Exception e) {
+ //ignore
+ }
}
//AbstractTextEditor
Modified:
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/texteditors/XMLTextEditorComponent.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/texteditors/XMLTextEditorComponent.java 2007-09-13
13:46:53 UTC (rev 3606)
+++
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/texteditors/XMLTextEditorComponent.java 2007-09-13
13:51:44 UTC (rev 3607)
@@ -23,8 +23,10 @@
import org.jboss.tools.common.editor.ObjectTextEditor;
import org.jboss.tools.common.model.ui.ModelUIPlugin;
import org.jboss.tools.common.model.ui.texteditors.xmleditor.XMLTextEditor;
+import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.ITextSelection;
import org.eclipse.jface.text.TextEvent;
+import org.eclipse.jface.text.source.ISourceViewer;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.swt.events.FocusListener;
//import org.eclipse.swt.graphics.Point;
@@ -94,9 +96,15 @@
public String getText() {
String text = null;
+ ISourceViewer sv = getSourceViewer();
+ if(sv == null) return "";
+ IDocument d = sv.getDocument();
+ if(d == null) return "";
try {
- text = getSourceViewer().getDocument().get();
- } catch (Exception ex) {}
+ text = d.get();
+ } catch (Exception ex) {
+ ModelUIPlugin.getPluginLog().logError(ex);
+ }
return (text == null) ? "" : text;
}
@@ -150,11 +158,15 @@
}
public void setCursor(int line, int position) {
+ ISourceViewer sv = getSourceViewer();
+ if(sv == null) return;
try {
- int i = getSourceViewer().getDocument().getLineOffset(line - 1) + position -1;
- getSourceViewer().setSelectedRange(i, 0);
- getSourceViewer().revealRange(i, 0);
- } catch (Exception e) {}
+ int i = sv.getDocument().getLineOffset(line - 1) + position -1;
+ sv.setSelectedRange(i, 0);
+ sv.revealRange(i, 0);
+ } catch (Exception e) {
+ ModelUIPlugin.getPluginLog().logError(e);
+ }
}
public void doSaveAs() {
@@ -179,6 +191,7 @@
if(old.isModified()) try {
new DiscardFileHandler().executeHandler(old, new Properties());
} catch (Exception e) {
+ //ignore
// ModelUIPlugin.log(e);
}
}
@@ -229,7 +242,11 @@
Display.getDefault().syncExec(
new Runnable() {
public void run() {
- try { Thread.sleep(200); } catch (Exception e) {}
+ try {
+ Thread.sleep(200);
+ } catch (InterruptedException e) {
+ //ignore
+ }
support.save(true);
}
}
@@ -265,7 +282,9 @@
try {
operation.run(getProgressMonitor());
} catch (InterruptedException x) {
+ //ignore
} catch (InvocationTargetException x) {
+ //ignore
}
} else {
@@ -273,6 +292,7 @@
try {
doSetInput(input);
} catch (CoreException x) {
+ //ignore
}
}
}
@@ -319,7 +339,11 @@
int bp = searcher.getStartPosition();
int ep = searcher.getEndPosition();
if(ep >= bp && bp >= 0) {
- try { selectAndReveal(bp, ep - bp); } catch (Exception e) {}
+ try {
+ selectAndReveal(bp, ep - bp);
+ } catch (Exception e) {
+ ModelUIPlugin.getPluginLog().logError(e);
+ }
}
}
@@ -350,19 +374,6 @@
boolean isUpdating = false;
private void updateAnnotationModel() {
- /*
- if(isUpdating) return;
- isUpdating = true;
- Display.getDefault().asyncExec(new Runnable() {
- public void run() {
- try { Thread.sleep(200); } catch (Exception e) {}
- isUpdating = false;
- if(getSourceViewer() == null) return;
- getSourceViewer().getAnnotationModel().disconnect(getSourceViewer().getDocument());
- getSourceViewer().getAnnotationModel().connect(getSourceViewer().getDocument());
- }
- });
- */
}
public void gotoMarker(IMarker marker) {
Modified:
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/texteditors/preferences/ReplaceTabsAdapter.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/texteditors/preferences/ReplaceTabsAdapter.java 2007-09-13
13:46:53 UTC (rev 3606)
+++
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/texteditors/preferences/ReplaceTabsAdapter.java 2007-09-13
13:51:44 UTC (rev 3607)
@@ -12,6 +12,7 @@
import org.jboss.tools.common.meta.constraint.*;
import org.jboss.tools.common.model.XModelObject;
+import org.jboss.tools.common.model.ui.ModelUIPlugin;
import org.jboss.tools.common.text.xml.ui.xpl.BasePreferenceConstants;
public class ReplaceTabsAdapter extends XAdapter {
@@ -30,7 +31,9 @@
if(EditorsPreferencesPage.store == null) return;
try {
EditorsPreferencesPage.store.setValue(PROPERTY, "true".equals(value));
- } catch (Exception e) {}
+ } catch (Exception e) {
+ ModelUIPlugin.getPluginLog().logError(e);
+ }
}
}
Modified:
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/texteditors/preferences/TabWidthAdapter.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/texteditors/preferences/TabWidthAdapter.java 2007-09-13
13:46:53 UTC (rev 3606)
+++
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/texteditors/preferences/TabWidthAdapter.java 2007-09-13
13:51:44 UTC (rev 3607)
@@ -12,6 +12,7 @@
import org.jboss.tools.common.meta.constraint.*;
import org.jboss.tools.common.model.XModelObject;
+import org.jboss.tools.common.model.ui.ModelUIPlugin;
import org.jboss.tools.common.text.xml.ui.xpl.BasePreferenceConstants;
public class TabWidthAdapter extends XAdapter {
@@ -30,9 +31,13 @@
if(!o.isActive()) return;
if(EditorsPreferencesPage.store == null) return;
int i = 4;
- try {
- i = Integer.parseInt(value);
- } catch (Exception e) {}
+ if(value != null && value.length() > 0) {
+ try {
+ i = Integer.parseInt(value);
+ } catch (NumberFormatException e) {
+ ModelUIPlugin.getPluginLog().logError(e);
+ }
+ }
EditorsPreferencesPage.store.setValue(PROPERTY, i);
}
Modified:
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/texteditors/xmleditor/XMLTextEditor.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/texteditors/xmleditor/XMLTextEditor.java 2007-09-13
13:46:53 UTC (rev 3606)
+++
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/texteditors/xmleditor/XMLTextEditor.java 2007-09-13
13:51:44 UTC (rev 3607)
@@ -286,7 +286,11 @@
Display.getDefault().syncExec(
new Runnable() {
public void run() {
- try { Thread.sleep(200); } catch (Exception e) {}
+ try {
+ Thread.sleep(200);
+ } catch (InterruptedException e) {
+ //ignore
+ }
save();
}
}
@@ -617,28 +621,26 @@
}
private int getPosition(int x, int y) {
- try {
- ISourceViewer v = getSourceViewer();
- StyledText t = v.getTextWidget();
- Point pp = t.toControl(x, y);
- x = pp.x;
- y = pp.y;
- int lineIndex = (t.getTopPixel() + y) / t.getLineHeight();
- if (lineIndex >= t.getLineCount()) {
- return t.getCharCount();
- } else {
- int c = 0;
- try {
- c = t.getOffsetAtLocation(new Point(x, y));
- if(c < 0) c = 0;
- } catch (Exception ex) {
- c = t.getOffsetAtLine(lineIndex + 1) -
- (t.getLineDelimiter() == null ? 0 :
t.getLineDelimiter().length());
- }
- return c;
+ ISourceViewer v = getSourceViewer();
+ if(v == null) return 0;
+ StyledText t = v.getTextWidget();
+ if(t == null || t.isDisposed()) return 0;
+ Point pp = t.toControl(x, y);
+ x = pp.x;
+ y = pp.y;
+ int lineIndex = (t.getTopPixel() + y) / t.getLineHeight();
+ if (lineIndex >= t.getLineCount()) {
+ return t.getCharCount();
+ } else {
+ int c = 0;
+ try {
+ c = t.getOffsetAtLocation(new Point(x, y));
+ if(c < 0) c = 0;
+ } catch (Exception ex) {
+ c = t.getOffsetAtLine(lineIndex + 1) -
+ (t.getLineDelimiter() == null ? 0 : t.getLineDelimiter().length());
}
- } catch (Exception e) {
- return 0;
+ return c;
}
}
Modified:
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/views/palette/PaletteAdapter.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/views/palette/PaletteAdapter.java 2007-09-13
13:46:53 UTC (rev 3606)
+++
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/views/palette/PaletteAdapter.java 2007-09-13
13:51:44 UTC (rev 3607)
@@ -14,6 +14,7 @@
import java.util.Properties;
import org.eclipse.core.resources.IFile;
+import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.QualifiedName;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.ScrolledComposite;
@@ -77,7 +78,9 @@
try {
selectedTab =
ModelUIPlugin.getWorkspace().getRoot().getPersistentProperty(persistentTabQualifiedName);
- } catch (Exception e) {}
+ } catch (CoreException e) {
+ ModelUIPlugin.getPluginLog().logError(e);
+ }
pane = new ScrolledComposite(composite, SWT.V_SCROLL);
pane.setExpandHorizontal(true);
@@ -260,7 +263,9 @@
if (selectedTab != null) {
ModelUIPlugin.getWorkspace().getRoot().setPersistentProperty(persistentTabQualifiedName,
selectedTab);
}
- } catch (Exception e) {}
+ } catch (CoreException e) {
+ ModelUIPlugin.getPluginLog().logError(e);
+ }
}
public void setPaletteContents(PaletteContents contents) {
@@ -399,6 +404,8 @@
DnDUtil.paste(o, new Properties());
model.getXModel().saveOptions();
} catch (ActionDeclinedException de) {
+ //ignore - this exception is thrown to inform that user
+ //selected cancel option in dialog.
} catch (Exception e) {
message(e);
}
Modified:
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/views/palette/PaletteInsertHelper.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/views/palette/PaletteInsertHelper.java 2007-09-13
13:46:53 UTC (rev 3606)
+++
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/views/palette/PaletteInsertHelper.java 2007-09-13
13:51:44 UTC (rev 3607)
@@ -76,7 +76,7 @@
p.put(PROPOPERTY_SELECTION_PROVIDER, selProvider);
insertIntoEditorInternal(doc, p);
} catch (Exception x) {
- //ignore
+ ModelUIPlugin.getPluginLog().logError(x);
}
}
@@ -240,10 +240,11 @@
boolean appendFirstDelimiter = true;
try {
- if (d.getLineOffset(d.getLineOfOffset(offset)) == offset)
+ if (d != null && d.getLength() > offset && offset >= 0
+ && d.getLineOffset(d.getLineOfOffset(offset)) == offset)
appendFirstDelimiter = false; // At start of a line
- } catch (Exception ex) {
- //ignore
+ } catch (BadLocationException ex) {
+ ModelUIPlugin.getPluginLog().logError(ex);
}
if (body == null || body.length() == 0) appendFirstDelimiter = false;
@@ -259,7 +260,7 @@
if (lineOffset + lineLength - offset - length == 0)
appendLastDelimiter = false;
} catch (Exception ex) {
-
+ ModelUIPlugin.getPluginLog().logError(ex);
}
final StringBuffer buffer= new StringBuffer();
@@ -404,6 +405,7 @@
if (document.getNumberOfLines() > 1)
return document.getLineDelimiter(0);
} catch (BadLocationException e) {
+ ModelUIPlugin.getPluginLog().logError(e);
}
return System.getProperty("line.separator"); //$NON-NLS-1$
@@ -411,6 +413,7 @@
private static String getIndentOfFirstLine(IDocument d, int offset) {
String indent = "";
+ if(d == null) return indent;
try {
int line = d.getLineOfOffset(offset);
while (line >= 0) {
@@ -420,18 +423,21 @@
}
line--;
}
- } catch (Exception ex) {
+ } catch (BadLocationException ex) {
+ ModelUIPlugin.getPluginLog().logError(ex);
}
return indent;
}
private static String getIndentOfLineOfOffset(IDocument d, int offset) {
String indent = "";
+ if(d == null) return indent;
try {
int line = d.getLineOfOffset(offset);
String lineText = d.get(d.getLineOffset(line), d.getLineLength(line));
return getIndentOfLine(lineText, getLineDelimiter(d));
} catch (Exception ex) {
+ ModelUIPlugin.getPluginLog().logError(ex);
}
return indent;
}
@@ -496,9 +502,11 @@
if(defaultPrefix == null || defaultPrefix.length() == 0) return;
IDocument doc = null;
try {
- doc = editor.getDocumentProvider().getDocument(editor.getEditorInput());
+ if(editor != null && editor.getDocumentProvider() != null) {
+ doc = editor.getDocumentProvider().getDocument(editor.getEditorInput());
+ }
} catch (Exception x) {
- //ignore
+ ModelUIPlugin.getPluginLog().logError(x);
}
applyPrefix(text, doc, tagname, uri, defaultPrefix);
}
Modified:
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/views/palette/editor/PaletteDialog.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/views/palette/editor/PaletteDialog.java 2007-09-13
13:46:53 UTC (rev 3606)
+++
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/views/palette/editor/PaletteDialog.java 2007-09-13
13:51:44 UTC (rev 3607)
@@ -137,9 +137,7 @@
protected void buttonPressed(int buttonId) {
if(buttonId == IDialogConstants.HELP_ID) {
- try {
- HelpUtil.helpEclipse(PreferenceModelUtilities.getPreferenceModel(),
"PaletteEditor");
- } catch (Exception e) {}
+ HelpUtil.helpEclipse(PreferenceModelUtilities.getPreferenceModel(),
"PaletteEditor");
} else {
super.buttonPressed(buttonId);
}
Modified:
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/views/palette/model/PaletteModel.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/views/palette/model/PaletteModel.java 2007-09-13
13:46:53 UTC (rev 3606)
+++
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/views/palette/model/PaletteModel.java 2007-09-13
13:51:44 UTC (rev 3607)
@@ -108,6 +108,7 @@
URL url = new URL(BASE_URL, imagePath + fileName);
return ImageDescriptor.createFromURL(url);
} catch (MalformedURLException e) {
+ ModelUIPlugin.getPluginLog().logError(e);
}
return ImageDescriptor.getMissingImageDescriptor();
}
Modified:
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/wizard/newfile/NewXHTMLFileWizard.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/wizard/newfile/NewXHTMLFileWizard.java 2007-09-13
13:46:53 UTC (rev 3606)
+++
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/wizard/newfile/NewXHTMLFileWizard.java 2007-09-13
13:51:44 UTC (rev 3607)
@@ -12,6 +12,7 @@
import org.jboss.tools.common.meta.action.impl.SpecialWizardSupport;
import org.jboss.tools.common.model.files.handlers.CreateFileSupport;
+import org.jboss.tools.common.model.ui.ModelUIPlugin;
import org.jboss.tools.common.model.util.ModelFeatureFactory;
public class NewXHTMLFileWizard extends NewFileWizardEx {
@@ -25,7 +26,9 @@
CreateFileSupport support = null;
try {
support =
(CreateFileSupport)ModelFeatureFactory.getInstance().createFeatureInstance("org.jboss.tools.jst.web.model.handlers.CreateJSPFileSupport");
- } catch (Exception e) {}
+ } catch (ClassCastException e) {
+ ModelUIPlugin.getPluginLog().logError(e);
+ }
if(support == null) {
support = new CreateFileSupport();
}
Modified:
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/propertieseditor/bundlemodel/BundleModel.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/propertieseditor/bundlemodel/BundleModel.java 2007-09-13
13:46:53 UTC (rev 3606)
+++
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/propertieseditor/bundlemodel/BundleModel.java 2007-09-13
13:51:44 UTC (rev 3607)
@@ -174,7 +174,13 @@
}
ByteArrayInputStream is = new ByteArrayInputStream(sb.toString().getBytes());
p.clear();
- try { p.load(is); } catch (Exception e) {}
+ try {
+ p.load(is);
+ } catch (IllegalArgumentException e1) {
+ //ignore
+ } catch (IOException e) {
+ ModelUIPlugin.getPluginLog().logError(e);
+ }
Enumeration ee = p.keys();
if(ee.hasMoreElements()) {
String key = ee.nextElement().toString();