JBoss Tools SVN: r10953 - trunk/common/tests/org.jboss.tools.common.test/src/org/jboss/tools/common/test/util.
by jbosstools-commits@lists.jboss.org
Author: dgolovin
Date: 2008-10-18 11:23:45 -0400 (Sat, 18 Oct 2008)
New Revision: 10953
Modified:
trunk/common/tests/org.jboss.tools.common.test/src/org/jboss/tools/common/test/util/TestProjectProvider.java
Log:
fix for JUnit Tests errors
Modified: trunk/common/tests/org.jboss.tools.common.test/src/org/jboss/tools/common/test/util/TestProjectProvider.java
===================================================================
--- trunk/common/tests/org.jboss.tools.common.test/src/org/jboss/tools/common/test/util/TestProjectProvider.java 2008-10-18 13:45:37 UTC (rev 10952)
+++ trunk/common/tests/org.jboss.tools.common.test/src/org/jboss/tools/common/test/util/TestProjectProvider.java 2008-10-18 15:23:45 UTC (rev 10953)
@@ -79,6 +79,7 @@
try {
oldAutoBuilding = ResourcesUtils.setBuildAutomatically(false);
JobUtils.waitForIdle();
+ project.close(null);
project.delete(true, null);
JobUtils.waitForIdle();
} finally {
16 years, 2 months
JBoss Tools SVN: r10952 - branches/jbosstools-3.0.0.Beta1/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/src/org/hibernate/eclipse/jdt/ui/test.
by jbosstools-commits@lists.jboss.org
Author: snjeza
Date: 2008-10-18 09:45:37 -0400 (Sat, 18 Oct 2008)
New Revision: 10952
Modified:
branches/jbosstools-3.0.0.Beta1/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/src/org/hibernate/eclipse/jdt/ui/test/HibernateErrorsTest2.java
Log:
Checking the hibernate tests.
Modified: branches/jbosstools-3.0.0.Beta1/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/src/org/hibernate/eclipse/jdt/ui/test/HibernateErrorsTest2.java
===================================================================
--- branches/jbosstools-3.0.0.Beta1/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/src/org/hibernate/eclipse/jdt/ui/test/HibernateErrorsTest2.java 2008-10-18 13:15:43 UTC (rev 10951)
+++ branches/jbosstools-3.0.0.Beta1/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/src/org/hibernate/eclipse/jdt/ui/test/HibernateErrorsTest2.java 2008-10-18 13:45:37 UTC (rev 10952)
@@ -7,9 +7,12 @@
import org.eclipse.core.internal.resources.ResourceException;
import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IWorkspaceRunnable;
import org.eclipse.core.resources.IncrementalProjectBuilder;
+import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Path;
@@ -45,6 +48,8 @@
private ConsoleConfiguration ccfg;
+ private boolean deleted;
+
public HibernateErrorsTest2(String name) {
super(name);
}
@@ -152,18 +157,23 @@
// super.tearDown();
- IProject proj = getProject().getIProject();
+ final IProject proj = getProject().getIProject();
String projRoot = proj.getLocation().toFile().getAbsolutePath();
File file = new File(projRoot);
- boolean deleted = true;
+ deleted = false;
int nTrys = 0;
- while (!deleted && nTrys++ < 5)
- try {
- proj.delete(true, true, null);
- deleted = true;
- } catch (ResourceException re) {
- waitForJobs();
- Thread.sleep(100);
+ while (!deleted && nTrys++ < 5) {
+ ResourcesPlugin.getWorkspace().run(new IWorkspaceRunnable() {
+ public void run(IProgressMonitor monitor) throws CoreException {
+ try {
+ proj.delete(true, true, null);
+ deleted = true;
+ } catch (ResourceException re) {
+ //waitForJobs();
+ delay(1000);
+ }
+ }
+ }, new NullProgressMonitor());
}
waitForJobs();
delete(file);
16 years, 2 months
JBoss Tools SVN: r10951 - trunk/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/src/org/hibernate/eclipse/jdt/ui/test.
by jbosstools-commits@lists.jboss.org
Author: snjeza
Date: 2008-10-18 09:15:43 -0400 (Sat, 18 Oct 2008)
New Revision: 10951
Modified:
trunk/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/src/org/hibernate/eclipse/jdt/ui/test/HibernateErrorsTest2.java
Log:
Checking the hibernate tests.
Modified: trunk/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/src/org/hibernate/eclipse/jdt/ui/test/HibernateErrorsTest2.java
===================================================================
--- trunk/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/src/org/hibernate/eclipse/jdt/ui/test/HibernateErrorsTest2.java 2008-10-18 01:27:10 UTC (rev 10950)
+++ trunk/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/src/org/hibernate/eclipse/jdt/ui/test/HibernateErrorsTest2.java 2008-10-18 13:15:43 UTC (rev 10951)
@@ -7,9 +7,12 @@
import org.eclipse.core.internal.resources.ResourceException;
import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IWorkspaceRunnable;
import org.eclipse.core.resources.IncrementalProjectBuilder;
+import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Path;
@@ -45,6 +48,8 @@
private ConsoleConfiguration ccfg;
+ private boolean deleted;
+
public HibernateErrorsTest2(String name) {
super(name);
}
@@ -152,18 +157,23 @@
// super.tearDown();
- IProject proj = getProject().getIProject();
+ final IProject proj = getProject().getIProject();
String projRoot = proj.getLocation().toFile().getAbsolutePath();
File file = new File(projRoot);
- boolean deleted = true;
+ deleted = false;
int nTrys = 0;
- while (!deleted && nTrys++ < 5)
- try {
- proj.delete(true, true, null);
- deleted = true;
- } catch (ResourceException re) {
- waitForJobs();
- Thread.sleep(100);
+ while (!deleted && nTrys++ < 5) {
+ ResourcesPlugin.getWorkspace().run(new IWorkspaceRunnable() {
+ public void run(IProgressMonitor monitor) throws CoreException {
+ try {
+ proj.delete(true, true, null);
+ deleted = true;
+ } catch (ResourceException re) {
+ //waitForJobs();
+ delay(1000);
+ }
+ }
+ }, new NullProgressMonitor());
}
waitForJobs();
delete(file);
@@ -203,8 +213,12 @@
buffer.append(file.getAbsolutePath());
buffer.append(" file. ");
if (file.exists() && file.isDirectory()) {
+ String[] files = file.list();
buffer.append("List=");
- buffer.append(file.list());
+ buffer.append(files);
+ buffer.append("-");
+ for (int i = 0; i < files.length; i++)
+ buffer.append(files[i]);
}
return buffer.toString();
}
16 years, 2 months
JBoss Tools SVN: r10950 - in trunk/as/plugins: org.jboss.ide.eclipse.as.ui and 2 other directories.
by jbosstools-commits@lists.jboss.org
Author: rob.stryker(a)jboss.com
Date: 2008-10-17 21:27:10 -0400 (Fri, 17 Oct 2008)
New Revision: 10950
Added:
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/eclipse/wst/server/ui/internal/view/servers/provisional/extensions/XPathActionProvider.java
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/eclipse/wst/server/ui/internal/view/servers/provisional/extensions/XPathChangeValueAction.java
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/eclipse/wst/server/ui/internal/view/servers/provisional/extensions/XPathDecorator.java
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/eclipse/wst/server/ui/internal/view/servers/provisional/extensions/XPathTreeContentProvider.java
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/eclipse/wst/server/ui/internal/view/servers/provisional/extensions/XPathTreeLabelProvider.java
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/IPreferenceKeys.java
Removed:
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/eclipse/wst/server/ui/internal/view/servers/provisional/extensions/XPathProvider.java
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/extensions/descriptors/XPathModel.java
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/JBossServerUIPlugin.java
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/plugin.xml
Log:
More additions for the beta server's view including an in-line editor inside the view. Also automatically enabling the decorators for the beta view.
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/extensions/descriptors/XPathModel.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/extensions/descriptors/XPathModel.java 2008-10-17 22:48:29 UTC (rev 10949)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/extensions/descriptors/XPathModel.java 2008-10-18 01:27:10 UTC (rev 10950)
@@ -42,6 +42,7 @@
import org.eclipse.wst.server.core.IServerLifecycleListener;
import org.eclipse.wst.server.core.ServerCore;
import org.jboss.ide.eclipse.as.core.JBossServerCorePlugin;
+import org.jboss.ide.eclipse.as.core.extensions.descriptors.XPathFileResult.XPathResultNode;
import org.jboss.ide.eclipse.as.core.server.internal.LocalJBossServerRuntime;
import org.jboss.ide.eclipse.as.core.server.internal.ServerAttributeHelper;
@@ -304,4 +305,39 @@
serverToCategories.put(server.getId(), retVal);
}
+
+
+ /*
+ * Static utility methods
+ */
+
+
+ public static XPathResultNode getResultNode(Object data) {
+ // if we are the node to change, change me
+ if( data instanceof XPathResultNode ) {
+ return (XPathResultNode)data;
+ }
+
+ // if we're a node which represents a file, but only have one matched node, thats the node.
+ if( data instanceof XPathFileResult && ((XPathFileResult)data).getChildren().length == 1 ) {
+ return (XPathResultNode) (((XPathFileResult)data).getChildren()[0]);
+ }
+
+ // if we're a top level tree item (JNDI), with one file child and one mbean grandchild, the grandchild is the node
+ if( data instanceof XPathQuery && ((XPathQuery)data).getResults().length == 1 ) {
+ XPathFileResult item = ((XPathFileResult) ((XPathQuery)data).getResults()[0]);
+ if( item.getChildren().length == 1 )
+ return (XPathResultNode)item.getChildren()[0];
+ }
+ return null;
+ }
+
+ public static XPathResultNode[] getResultNodes(XPathQuery query) {
+ ArrayList<XPathResultNode> l = new ArrayList<XPathResultNode>();
+ XPathFileResult[] files = query.getResults();
+ for( int i = 0; i < files.length; i++ ) {
+ l.addAll(Arrays.asList(files[i].getChildren()));
+ }
+ return l.toArray(new XPathResultNode[l.size()]);
+ }
}
Copied: trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/eclipse/wst/server/ui/internal/view/servers/provisional/extensions/XPathActionProvider.java (from rev 10904, trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/eclipse/wst/server/ui/internal/view/servers/provisional/extensions/XPathProvider.java)
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/eclipse/wst/server/ui/internal/view/servers/provisional/extensions/XPathActionProvider.java (rev 0)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/eclipse/wst/server/ui/internal/view/servers/provisional/extensions/XPathActionProvider.java 2008-10-18 01:27:10 UTC (rev 10950)
@@ -0,0 +1,271 @@
+package org.eclipse.wst.server.ui.internal.view.servers.provisional.extensions;
+
+import org.eclipse.core.filesystem.EFS;
+import org.eclipse.core.filesystem.IFileStore;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.action.IMenuManager;
+import org.eclipse.jface.action.Separator;
+import org.eclipse.jface.viewers.ISelectionProvider;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.StructuredViewer;
+import org.eclipse.jface.window.Window;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.MessageBox;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.ide.IDE;
+import org.eclipse.ui.navigator.CommonActionProvider;
+import org.eclipse.ui.navigator.CommonViewer;
+import org.eclipse.ui.navigator.ICommonActionExtensionSite;
+import org.eclipse.ui.navigator.ICommonViewerSite;
+import org.eclipse.ui.navigator.ICommonViewerWorkbenchSite;
+import org.eclipse.wst.server.core.IServer;
+import org.eclipse.wst.server.ui.internal.view.servers.provisional.extensions.XPathTreeContentProvider.ServerWrapper;
+import org.jboss.ide.eclipse.as.core.extensions.descriptors.XPathCategory;
+import org.jboss.ide.eclipse.as.core.extensions.descriptors.XPathFileResult;
+import org.jboss.ide.eclipse.as.core.extensions.descriptors.XPathModel;
+import org.jboss.ide.eclipse.as.core.extensions.descriptors.XPathQuery;
+import org.jboss.ide.eclipse.as.core.extensions.descriptors.XPathFileResult.XPathResultNode;
+import org.jboss.ide.eclipse.as.ui.JBossServerUIPlugin;
+import org.jboss.ide.eclipse.as.ui.Messages;
+import org.jboss.ide.eclipse.as.ui.dialogs.XPathDialogs;
+import org.jboss.ide.eclipse.as.ui.dialogs.XPathDialogs.XPathCategoryDialog;
+import org.jboss.ide.eclipse.as.ui.dialogs.XPathDialogs.XPathDialog;
+
+public class XPathActionProvider extends CommonActionProvider {
+
+ private ICommonActionExtensionSite actionSite;
+ public Action newXPathCategoryAction, deleteXPathCategoryAction,
+ newXPathAction, editXPathAction, deleteXPathAction, editFileAction;
+ private XPathChangeValueAction xpathChangeValueAction;
+ private Object selectedNode;
+
+ public void init(ICommonActionExtensionSite aSite) {
+ super.init(aSite);
+ this.actionSite = aSite;
+ ICommonViewerSite site = aSite.getViewSite();
+ if( site instanceof ICommonViewerWorkbenchSite ) {
+ StructuredViewer v = aSite.getStructuredViewer();
+ if( v instanceof CommonViewer ) {
+ CommonViewer cv = (CommonViewer)v;
+ ICommonViewerWorkbenchSite wsSite = (ICommonViewerWorkbenchSite)site;
+ createActions(cv, wsSite.getSelectionProvider());
+ }
+ }
+ }
+
+ public void createActions(CommonViewer tableViewer, ISelectionProvider provider) {
+ Shell shell = tableViewer.getTree().getShell();
+ newXPathCategoryAction = new Action() {
+ public void run() {
+ XPathCategoryDialog d = new XPathCategoryDialog(Display
+ .getCurrent().getActiveShell(), getServer());
+ if (d.open() == Window.OK) {
+ XPathModel.getDefault().addCategory(getServer(),
+ d.getText());
+ XPathModel.getDefault().save(getServer());
+ refreshViewer();
+ }
+ }
+ };
+ newXPathCategoryAction.setText("New Category");
+
+ deleteXPathCategoryAction = new Action() {
+ public void run() {
+ int style = SWT.APPLICATION_MODAL | SWT.YES | SWT.NO;
+ MessageBox messageBox = new MessageBox(Display.getCurrent()
+ .getActiveShell(), style);
+ messageBox
+ .setText(Messages.DescriptorXPathRemoveCategory + "?");
+ messageBox
+ .setMessage(Messages.DescriptorXPathRemoveCategoryDesc);
+ if (messageBox.open() == SWT.YES) {
+ XPathModel.getDefault().removeCategory(getServer(),
+ ((XPathCategory) selectedNode).getName());
+ XPathModel.getDefault().save(getServer());
+ refreshViewer();
+ }
+ }
+ };
+ deleteXPathCategoryAction
+ .setText(Messages.DescriptorXPathRemoveCategory);
+
+ newXPathAction = new Action() {
+ public void run() {
+ XPathCategory category = (XPathCategory) selectedNode;
+ if (category != null) {
+ String categoryName = category.getName();
+ XPathDialog d = new XPathDialog(Display.getCurrent()
+ .getActiveShell(), getServer(), categoryName);
+ if (d.open() == Window.OK) {
+ XPathCategory[] categoryList = XPathModel.getDefault()
+ .getCategories(getServer());
+ XPathCategory categoryItem = null;
+ for (int i = 0; i < categoryList.length; i++) {
+ if (categoryList[i].getName().equals(
+ category.getName()))
+ categoryItem = categoryList[i];
+ }
+ if (categoryItem != null) {
+ XPathQuery query = new XPathQuery(d.getName(),
+ XPathDialogs.getConfigFolder(getServer()),
+ null, d.getXpath(), d.getAttribute());
+ categoryItem.addQuery(query);
+ XPathModel.getDefault().save(getServer());
+ refreshViewer();
+ }
+ }
+ }
+ }
+ };
+ newXPathAction.setText(Messages.DescriptorXPathNewXPath);
+
+ editXPathAction = new Action() {
+ public void run() {
+ Object o = selectedNode;
+ if (o != null && o instanceof XPathQuery) {
+ XPathQuery original = (XPathQuery) o;
+ XPathCategory category = original.getCategory();
+
+ XPathDialog d = new XPathDialog(Display.getCurrent()
+ .getActiveShell(), getServer(), category.getName(),
+ original.getName());
+ d.setAttribute(original.getAttribute());
+ d.setXpath(original.getXpathPattern());
+
+ if (d.open() == Window.OK) {
+ original.setAttribute(d.getAttribute());
+ original.setXpathPattern(d.getXpath());
+ original.setName(d.getName());
+ category.save();
+ refreshViewer();
+ }
+ }
+ }
+ };
+ editXPathAction.setText(Messages.DescriptorXPathEditXPath);
+
+ deleteXPathAction = new Action() {
+ public void run() {
+ Object o = selectedNode;
+ if (o instanceof XPathQuery) {
+ XPathCategory cat = ((XPathQuery) o).getCategory();
+ cat.removeQuery((XPathQuery) o);
+ cat.save();
+ refreshViewer();
+ }
+ }
+ };
+ deleteXPathAction.setText(Messages.DescriptorXPathDeleteXPath);
+
+ editFileAction = new Action() {
+ public void run() {
+ try {
+ Object o = selectedNode;
+ Path p = null;
+ if (o instanceof XPathQuery
+ && ((XPathQuery) o).getResults().length == 1) {
+ o = (XPathFileResult) ((XPathQuery) o).getResults()[0];
+ }
+ if (o instanceof XPathFileResult) {
+ p = new Path(((XPathFileResult) o).getFileLocation());
+ } else if (o instanceof XPathResultNode) {
+ p = new Path(((XPathResultNode) o).getFileLocation());
+ }
+ if (p != null) {
+
+ IFileStore fileStore = EFS.getLocalFileSystem()
+ .getStore(p.removeLastSegments(1));
+ fileStore = fileStore.getChild(p.lastSegment());
+ IWorkbench wb = PlatformUI.getWorkbench();
+ IWorkbenchWindow win = wb.getActiveWorkbenchWindow();
+ IWorkbenchPage page = win.getActivePage();
+
+ if (!fileStore.fetchInfo().isDirectory()
+ && fileStore.fetchInfo().exists()) {
+ try {
+ IDE.openEditorOnFileStore(page, fileStore);
+ } catch (PartInitException e) {
+ }
+ }
+ }
+ } catch (Exception exc) {
+ JBossServerUIPlugin.log("Error running edit file action",
+ exc);
+ }
+ }
+ };
+ editFileAction.setText("Edit File");
+
+ xpathChangeValueAction = new XPathChangeValueAction(shell, tableViewer, provider);
+ }
+
+ public void fillContextMenu(IMenuManager menu) {
+ ICommonViewerSite site = actionSite.getViewSite();
+ IStructuredSelection selection = null;
+ if (site instanceof ICommonViewerWorkbenchSite) {
+ ICommonViewerWorkbenchSite wsSite = (ICommonViewerWorkbenchSite) site;
+ selection = (IStructuredSelection) wsSite.getSelectionProvider()
+ .getSelection();
+ Object first = selection.getFirstElement();
+ if (first == null)
+ return;
+
+ if (first instanceof ServerWrapper) {
+ menu.add(newXPathCategoryAction);
+ menu.add(new Separator());
+ return;
+ }
+
+ if (first instanceof XPathCategory) {
+ menu.add(newXPathAction);
+ menu.add(deleteXPathCategoryAction);
+ menu.add(new Separator());
+ return;
+ }
+
+ if (first instanceof XPathQuery) {
+ selectedNode = first;
+ menu.add(newXPathAction);
+ menu.add(editXPathAction);
+ menu.add(deleteXPathAction);
+ }
+
+ if( xpathChangeValueAction.shouldRun())
+ menu.add(xpathChangeValueAction);
+
+ if ((first instanceof XPathResultNode || first instanceof XPathFileResult)
+ || (first instanceof XPathQuery && ((XPathQuery) first)
+ .getResults().length == 1)) {
+ menu.add(editFileAction);
+ }
+ }
+ }
+
+ protected void refreshViewer() {
+ actionSite.getStructuredViewer().refresh();
+ }
+
+ protected IServer getServer() {
+ Object o = selectedNode;
+ if (o instanceof ServerWrapper)
+ return ((ServerWrapper) o).server;
+ if (o instanceof XPathCategory)
+ return ((XPathCategory) o).getServer();
+ if (o instanceof XPathQuery)
+ return ((XPathQuery) o).getCategory().getServer();
+ if (o instanceof XPathFileResult)
+ return ((XPathFileResult) o).getQuery().getCategory().getServer();
+ if (o instanceof XPathResultNode)
+ return ((XPathResultNode) o).getFile().getQuery().getCategory()
+ .getServer();
+ return null;
+ }
+
+}
\ No newline at end of file
Property changes on: trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/eclipse/wst/server/ui/internal/view/servers/provisional/extensions/XPathActionProvider.java
___________________________________________________________________
Name: svn:mergeinfo
+
Added: trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/eclipse/wst/server/ui/internal/view/servers/provisional/extensions/XPathChangeValueAction.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/eclipse/wst/server/ui/internal/view/servers/provisional/extensions/XPathChangeValueAction.java (rev 0)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/eclipse/wst/server/ui/internal/view/servers/provisional/extensions/XPathChangeValueAction.java 2008-10-18 01:27:10 UTC (rev 10950)
@@ -0,0 +1,364 @@
+/*******************************************************************************
+ * Copyright (c) 2007 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.server.ui.internal.view.servers.provisional.extensions;
+
+import org.eclipse.jface.viewers.ISelectionProvider;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.TreeEditor;
+import org.eclipse.swt.events.FocusAdapter;
+import org.eclipse.swt.events.FocusEvent;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.graphics.Rectangle;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Listener;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.swt.widgets.Tree;
+import org.eclipse.swt.widgets.TreeItem;
+import org.eclipse.ui.actions.SelectionProviderAction;
+import org.eclipse.ui.actions.TextActionHandler;
+import org.jboss.ide.eclipse.as.core.extensions.descriptors.XPathModel;
+import org.jboss.ide.eclipse.as.core.extensions.descriptors.XPathQuery;
+import org.jboss.ide.eclipse.as.core.extensions.descriptors.XPathFileResult.XPathResultNode;
+/**
+ * Action to rename a server.
+ */
+public class XPathChangeValueAction extends SelectionProviderAction {
+ protected CustomTreeEditor treeEditor;
+ protected Tree tree;
+ protected TreeViewer viewer;
+ protected Text textEditor;
+ protected Composite textEditorParent;
+ private TextActionHandler textActionHandler;
+ protected Shell shell;
+ protected int width = -1;
+ protected Rectangle newParentBounds;
+
+ protected boolean saving = false;
+
+ public XPathChangeValueAction(Shell shell, TreeViewer viewer, ISelectionProvider selectionProvider) {
+ super(selectionProvider, "Change Value");
+ this.shell = shell;
+ this.viewer = viewer;
+ this.tree = viewer.getTree();
+ this.treeEditor = new CustomTreeEditor(tree);
+ }
+
+ public boolean shouldRun() {
+ if( getStructuredSelection().toArray().length > 1)
+ return false;
+
+ Object o = getStructuredSelection().getFirstElement();
+ if( XPathDecorator.getDecoration(o) != null )
+ return true;
+ return false;
+ }
+
+ public void run() {
+ queryNewValueInline(getStructuredSelection().getFirstElement());
+ }
+
+ /**
+ * On Mac the text widget already provides a border when it has focus, so
+ * there is no need to draw another one. The value of returned by this
+ * method is usd to control the inset we apply to the text field bound's in
+ * order to get space for drawing a border. A value of 1 means a one-pixel
+ * wide border around the text field. A negative value supresses the border.
+ * However, in M9 the system property
+ * "org.eclipse.swt.internal.carbon.noFocusRing" has been introduced as a
+ * temporary workaround for bug #28842. The existence of the property turns
+ * the native focus ring off if the widget is contained in a main window
+ * (not dialog). The check for the property should be removed after a final
+ * fix for #28842 has been provided.
+ */
+ private static int getCellEditorInset(Control c) {
+ // special case for MacOS X
+ if ("carbon".equals(SWT.getPlatform())) { //$NON-NLS-1$
+ if (System
+ .getProperty("org.eclipse.swt.internal.carbon.noFocusRing") == null || c.getShell().getParent() != null) { //$NON-NLS-1$
+ return -2; // native border
+ }
+ }
+ return 1; // one pixel wide black border
+ }
+
+ /**
+ * Get the Tree being edited.
+ *
+ * @returnTree
+ */
+ private Tree getTree() {
+ return tree;
+ }
+
+ private Composite createParent() {
+ Tree tree2 = getTree();
+ Composite result = new Composite(tree2, SWT.NONE);
+ TreeItem[] selectedItems = tree2.getSelection();
+ treeEditor.horizontalAlignment = SWT.LEFT;
+ treeEditor.grabHorizontal = true;
+ treeEditor.setEditor(result, selectedItems[0]);
+ return result;
+ }
+
+ /**
+ * Return the new name to be given to the target resource or
+ * <code>null<code>
+ * if the query was canceled. Rename the currently selected server using the table editor.
+ * Continue the action when the user is done.
+ *
+ * @param server the server to rename
+ */
+ private void queryNewValueInline(final Object node) {
+
+ // Make sure text editor is created only once. Simply reset text
+ // editor when action is executed more than once. Fixes bug 22269
+ if (textEditorParent == null) {
+ createTextEditor(node);
+ }
+ textEditor.setText(XPathModel.getResultNode(node).getText());
+ // Open text editor with initial size
+ Point textSize = textEditor.computeSize(SWT.DEFAULT, SWT.DEFAULT);
+ textSize.x += textSize.y; // Add extra space for new characters
+ Point parentSize = textEditorParent.getSize();
+ int inset = getCellEditorInset(textEditorParent);
+ textEditor.setBounds(2, inset, Math.min(textSize.x, parentSize.x - 4),
+ parentSize.y - 2 * inset);
+ textEditor.setText(new XPathTreeLabelProvider().getText(node));
+ width = textEditor.getSize().x - 10;
+ textEditor.setText(XPathModel.getResultNode(node).getText());
+ treeEditor.layout();
+ textEditorParent.setVisible(true);
+ textEditor.setVisible(true);
+ textEditorParent.redraw();
+ textEditor.selectAll();
+ textEditor.setFocus();
+ }
+
+ /**
+ * Create the text editor widget.
+ *
+ * @param server the server to rename
+ */
+ private void createTextEditor(final Object node) {
+ // Create text editor parent. This draws a nice bounding rect
+ textEditorParent = createParent();
+ textEditorParent.setVisible(false);
+ final int inset = getCellEditorInset(textEditorParent);
+ if (inset > 0) {
+ textEditorParent.addListener(SWT.Paint, new Listener() {
+ public void handleEvent(Event e) {
+ Point textSize = textEditor.getSize();
+ Point parentSize = textEditorParent.getSize();
+ e.gc.drawRectangle(0, 0, Math.min(textSize.x + 4,
+ parentSize.x - 1), parentSize.y - 1);
+ }
+ });
+ }
+ // Create inner text editor
+ textEditor = new Text(textEditorParent, SWT.NONE);
+ textEditor.setFont(tree.getFont());
+ textEditorParent.setBackground(textEditor.getBackground());
+ textEditor.addListener(SWT.Modify, new Listener() {
+ public void handleEvent(Event e) {
+ Point textSize = textEditor.computeSize(SWT.DEFAULT,
+ SWT.DEFAULT);
+ textSize.x += textSize.y; // Add extra space for new
+ // characters.
+ Point parentSize = textEditorParent.getSize();
+
+ textEditor.setBounds(2, inset, Math.min(textSize.x,
+ parentSize.x - 4), parentSize.y - 2 * inset);
+ textEditorParent.redraw();
+ }
+ });
+ textEditor.addListener(SWT.Traverse, new Listener() {
+ public void handleEvent(Event event) {
+
+ // Workaround for Bug 20214 due to extra
+ // traverse events
+ switch (event.detail) {
+ case SWT.TRAVERSE_ESCAPE:
+ // Do nothing in this case
+ disposeTextWidget();
+ event.doit = true;
+ event.detail = SWT.TRAVERSE_NONE;
+ break;
+ case SWT.TRAVERSE_RETURN:
+ saveChangesAndDispose(node);
+ event.doit = true;
+ event.detail = SWT.TRAVERSE_NONE;
+ break;
+ }
+ }
+ });
+ textEditor.addFocusListener(new FocusAdapter() {
+ public void focusLost(FocusEvent fe) {
+ saveChangesAndDispose(node);
+ }
+ });
+
+ if (textActionHandler != null) {
+ textActionHandler.addText(textEditor);
+ }
+ textEditor.setVisible(false);
+ }
+
+ /**
+ * Close the text widget and reset the editorText field.
+ */
+ protected void disposeTextWidget() {
+ width = -1;
+ if (textActionHandler != null)
+ textActionHandler.removeText(textEditor);
+
+ if (textEditorParent != null) {
+ textEditorParent.dispose();
+ textEditorParent = null;
+ textEditor = null;
+ treeEditor.setEditor(null, null);
+ }
+ }
+
+ /**
+ * Save the changes and dispose of the text widget.
+ *
+ * @param server the server to rename
+ */
+ protected void saveChangesAndDispose(Object node) {
+ if (saving == true)
+ return;
+ saving = true;
+
+ // Cache the resource to avoid selection loss since a selection of
+ // another item can trigger this method
+ final String newVal = textEditor.getText();
+ XPathResultNode itemToChange = XPathModel.getResultNode(node);
+ // if its unchanged do nothing
+ if( !itemToChange.getText().equals(newVal)) {
+ // set the text and add the document to the list of dirty ones
+ itemToChange.setText(newVal);
+ if( itemToChange.getDocument() != null ) {
+ itemToChange.saveDescriptor();
+ }
+ }
+
+ // Run this in an async to make sure that the operation that triggered
+ // this action is completed. Otherwise this leads to problems when the
+ // icon of the item being renamed is clicked (i.e., which causes the
+ // rename text widget to lose focus and trigger this method)
+ getTree().getShell().getDisplay().asyncExec(new Runnable() {
+ public void run() {
+ try {
+ // Dispose the text widget regardless
+ disposeTextWidget();
+ // Ensure the Navigator tree has focus, which it may not if
+ // the text widget previously had focus
+ if (tree != null && !tree.isDisposed()) {
+ tree.setFocus();
+ viewer.refresh(getStructuredSelection().getFirstElement());
+ }
+ } finally {
+ saving = false;
+ }
+ }
+ });
+ }
+
+
+ protected class CustomTreeEditor extends TreeEditor {
+ public CustomTreeEditor(Tree tree) {
+ super(tree);
+ }
+
+ public void setItem (TreeItem item) {
+ super.setItem(item);
+ }
+
+ private boolean hadFocus = false;
+ public void layout () {
+ if (tree == null || tree.isDisposed()) return;
+ if (getItem() == null || getItem().isDisposed()) return;
+ int columnCount = tree.getColumnCount();
+ if (columnCount == 0 && getColumn() != 0) return;
+ if (columnCount > 0 && (getColumn() < 0 || getColumn() >= columnCount)) return;
+
+ if (getEditor() == null || getEditor().isDisposed()) return;
+ if (getEditor().getVisible ()) {
+ hadFocus = getEditor().isFocusControl();
+ } // this doesn't work because
+ // resizing the column takes the focus away
+ // before we get here
+ getEditor().setBounds (customComputeBounds (superComputeBounds()));
+ if (hadFocus) {
+ if (getEditor() == null || getEditor().isDisposed()) return;
+ getEditor().setFocus ();
+ }
+ }
+
+ Rectangle customComputeBounds (Rectangle rect) {
+ Rectangle r = new Rectangle(rect.x + (width == -1 ? 0 : width), rect.y, rect.width, rect.height);
+ return r;
+ }
+
+ Rectangle superComputeBounds() {
+ if (getItem() == null || getColumn() == -1 || getItem().isDisposed() ) return new Rectangle(0, 0, 0, 0);
+ Rectangle cell = getItem().getBounds(getColumn());
+ Rectangle rect = getItem().getImageBounds(getColumn());
+ cell.x = rect.x + rect.width;
+ cell.width -= rect.width;
+ Rectangle area = tree.getClientArea();
+ if (cell.x < area.x + area.width) {
+ if (cell.x + cell.width > area.x + area.width) {
+ cell.width = area.x + area.width - cell.x;
+ }
+ }
+ Rectangle editorRect = new Rectangle(cell.x, cell.y, minimumWidth, minimumHeight);
+
+ if (grabHorizontal) {
+ if (tree.getColumnCount() == 0) {
+ // Bounds of tree item only include the text area - stretch out to include
+ // entire client area
+ cell.width = area.x + area.width - cell.x;
+ }
+ editorRect.width = Math.max(cell.width, minimumWidth);
+ }
+
+ if (grabVertical) {
+ editorRect.height = Math.max(cell.height, minimumHeight);
+ }
+
+ if (horizontalAlignment == SWT.RIGHT) {
+ editorRect.x += cell.width - editorRect.width;
+ } else if (horizontalAlignment == SWT.LEFT) {
+ // do nothing - cell.x is the right answer
+ } else { // default is CENTER
+ editorRect.x += (cell.width - editorRect.width)/2;
+ }
+ // don't let the editor overlap with the +/- of the tree
+ editorRect.x = Math.max(cell.x, editorRect.x);
+
+ if (verticalAlignment == SWT.BOTTOM) {
+ editorRect.y += cell.height - editorRect.height;
+ } else if (verticalAlignment == SWT.TOP) {
+ // do nothing - cell.y is the right answer
+ } else { // default is CENTER
+ editorRect.y += (cell.height - editorRect.height)/2;
+ }
+ return editorRect;
+ }
+
+ }
+
+}
\ No newline at end of file
Added: trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/eclipse/wst/server/ui/internal/view/servers/provisional/extensions/XPathDecorator.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/eclipse/wst/server/ui/internal/view/servers/provisional/extensions/XPathDecorator.java (rev 0)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/eclipse/wst/server/ui/internal/view/servers/provisional/extensions/XPathDecorator.java 2008-10-18 01:27:10 UTC (rev 10950)
@@ -0,0 +1,38 @@
+package org.eclipse.wst.server.ui.internal.view.servers.provisional.extensions;
+
+import org.eclipse.jface.viewers.IDecoration;
+import org.eclipse.jface.viewers.ILightweightLabelDecorator;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.jboss.ide.eclipse.as.core.extensions.descriptors.XPathFileResult;
+import org.jboss.ide.eclipse.as.core.extensions.descriptors.XPathModel;
+import org.jboss.ide.eclipse.as.core.extensions.descriptors.XPathQuery;
+import org.jboss.ide.eclipse.as.core.extensions.descriptors.XPathFileResult.XPathResultNode;
+
+public class XPathDecorator extends LabelProvider implements ILightweightLabelDecorator {
+ public void decorate(Object element, IDecoration decoration) {
+ String decoration2 = getDecoration(element);
+ if( decoration2 != null ) {
+ decoration.addSuffix(decoration2);
+ }
+ }
+
+ public static String getDecoration(Object element) {
+ if( element instanceof XPathQuery) {
+ XPathResultNode[] nodes = XPathModel.getResultNodes((XPathQuery)element);
+ if(nodes.length == 1 ) {
+ return " " + nodes[0].getText();
+ }
+ }
+
+ if( element instanceof XPathFileResult ) {
+ XPathResultNode[] nodes = ((XPathFileResult)element).getChildren();
+ if( nodes.length == 1 )
+ return " " + nodes[0].getText();
+ }
+
+ if( element instanceof XPathResultNode ) {
+ return ((XPathResultNode)element).getText();
+ }
+ return null;
+ }
+}
\ No newline at end of file
Deleted: trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/eclipse/wst/server/ui/internal/view/servers/provisional/extensions/XPathProvider.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/eclipse/wst/server/ui/internal/view/servers/provisional/extensions/XPathProvider.java 2008-10-17 22:48:29 UTC (rev 10949)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/eclipse/wst/server/ui/internal/view/servers/provisional/extensions/XPathProvider.java 2008-10-18 01:27:10 UTC (rev 10950)
@@ -1,457 +0,0 @@
-package org.eclipse.wst.server.ui.internal.view.servers.provisional.extensions;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-
-import org.eclipse.core.filesystem.EFS;
-import org.eclipse.core.filesystem.IFileStore;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.core.runtime.jobs.Job;
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.action.IMenuManager;
-import org.eclipse.jface.action.Separator;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.jface.viewers.IDecoration;
-import org.eclipse.jface.viewers.ILightweightLabelDecorator;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.ITreeContentProvider;
-import org.eclipse.jface.viewers.LabelProvider;
-import org.eclipse.jface.viewers.StructuredViewer;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.jface.window.Window;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.MessageBox;
-import org.eclipse.ui.ISharedImages;
-import org.eclipse.ui.IWorkbench;
-import org.eclipse.ui.IWorkbenchPage;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.PartInitException;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.ide.IDE;
-import org.eclipse.ui.navigator.CommonActionProvider;
-import org.eclipse.ui.navigator.ICommonActionExtensionSite;
-import org.eclipse.ui.navigator.ICommonViewerSite;
-import org.eclipse.ui.navigator.ICommonViewerWorkbenchSite;
-import org.eclipse.wst.server.core.IServer;
-import org.eclipse.wst.server.ui.internal.view.servers.provisional.extensions.XPathProvider.XPathTreeContentProvider.ServerWrapper;
-import org.jboss.ide.eclipse.as.core.extensions.descriptors.XPathCategory;
-import org.jboss.ide.eclipse.as.core.extensions.descriptors.XPathFileResult;
-import org.jboss.ide.eclipse.as.core.extensions.descriptors.XPathModel;
-import org.jboss.ide.eclipse.as.core.extensions.descriptors.XPathQuery;
-import org.jboss.ide.eclipse.as.core.extensions.descriptors.XPathFileResult.XPathResultNode;
-import org.jboss.ide.eclipse.as.ui.JBossServerUIPlugin;
-import org.jboss.ide.eclipse.as.ui.Messages;
-import org.jboss.ide.eclipse.as.ui.dialogs.XPathDialogs;
-import org.jboss.ide.eclipse.as.ui.dialogs.XPathDialogs.XPathCategoryDialog;
-import org.jboss.ide.eclipse.as.ui.dialogs.XPathDialogs.XPathDialog;
-
-public class XPathProvider {
- public static class XPathTreeContentProvider implements
- ITreeContentProvider {
-
- public static class DelayProxy {}
- public static final DelayProxy LOADING = new DelayProxy();
-
- private Viewer viewer;
- private ArrayList<XPathCategory> loading = new ArrayList<XPathCategory>();
-
- public class ServerWrapper {
- public IServer server;
-
- public ServerWrapper(IServer server) {
- this.server = server;
- }
- public int hashCode() {
- return server.getId().hashCode();
- }
- public boolean equals(Object other) {
- return other instanceof ServerWrapper &&
- ((ServerWrapper)other).server.getId().equals(server.getId());
- }
- }
-
- public Object[] getChildren(Object parentElement) {
- if (parentElement == null)
- return new Object[] {};
- if (parentElement instanceof IServer) {
- return new Object[] { new ServerWrapper((IServer) parentElement) };
- }
-
- if (parentElement instanceof ServerWrapper) {
- return XPathModel.getDefault().getCategories(
- ((ServerWrapper) parentElement).server);
- }
-
- if( parentElement instanceof XPathCategory) {
- if( ((XPathCategory)parentElement).isLoaded())
- return ((XPathCategory)parentElement).getQueries();
-
- if( !loading.contains((XPathCategory)parentElement))
- launchLoad((XPathCategory)parentElement);
-
- return new Object[] { LOADING };
- }
-
- // we're the named element (JNDI)
- if( parentElement instanceof XPathQuery) {
- if( XPathProvider.getResultNodes((XPathQuery)parentElement).length == 1 ) {
- return new Object[0];
- } else {
- return ((XPathQuery)parentElement).getResults();
- }
- }
-
- // we're a file node (blah.xml)
- if( parentElement instanceof XPathFileResult ) {
- if( ((XPathFileResult)parentElement).getChildren().length == 1 )
- return new Object[0];
- return ((XPathFileResult)parentElement).getChildren();
- }
-
- if( parentElement instanceof XPathResultNode ) {
- return new Object[0];
- }
-
-
- return new Object[0];
- }
-
-
- protected void launchLoad(final XPathCategory cat) {
- new Job("Loading XPaths") {
- protected IStatus run(IProgressMonitor monitor) {
- loading.add(cat);
- XPathQuery[] queries = cat.getQueries();
- XPathFileResult[] results;
- for( int i = 0; i < queries.length; i++ ) {
- results = queries[i].getResults();
- for( int j = 0; j < results.length; j++ ) {
- results[j].getChildren();
- }
- }
- Display.getDefault().asyncExec(new Runnable() {
- public void run() {
- loading.remove(cat);
- ((StructuredViewer)viewer).refresh(cat.getServer());
- }
- });
- return Status.OK_STATUS;
- }
- }.schedule(200);
- }
-
- public Object getParent(Object element) {
- return null;
- }
-
- public boolean hasChildren(Object element) {
- return getChildren(element).length > 0 ? true : false;
- }
-
- public Object[] getElements(Object inputElement) {
- return new Object[0];
- }
-
- public void dispose() {
- }
-
- public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
- this.viewer = viewer;
- }
- }
-
- public static class XPathTreeLabelProvider extends LabelProvider {
- private Image rootImage;
- public XPathTreeLabelProvider() {
- super();
- ImageDescriptor des = ImageDescriptor.createFromURL(JBossServerUIPlugin.getDefault().getBundle().getEntry("icons/XMLFile.gif"));
- rootImage = des.createImage();
- }
-
- public Image getImage(Object element) {
- if( element instanceof ServerWrapper )
- return rootImage;
-
- if (element instanceof XPathCategory)
- return PlatformUI.getWorkbench().getSharedImages().getImage(
- ISharedImages.IMG_OBJ_FOLDER);
-
- return null;
- }
-
- public String getText(Object element) {
- if( element instanceof ServerWrapper )
- return "XML Configuration";
- if( element == XPathTreeContentProvider.LOADING )
- return "Loading...";
-
- if (element instanceof XPathCategory)
- return ((XPathCategory) element).getName();
-
- if( element instanceof XPathQuery )
- return ((XPathQuery)element).getName();
-
- if( element instanceof XPathFileResult )
- return ((XPathFileResult)element).getFileLocation();
-
- return "";
- }
-
- public XPathResultNode[] getResultNodes(XPathQuery query) {
- ArrayList<XPathResultNode> l = new ArrayList<XPathResultNode>();
- XPathFileResult[] files = query.getResults();
- for( int i = 0; i < files.length; i++ ) {
- l.addAll(Arrays.asList(files[i].getChildren()));
- }
- return l.toArray(new XPathResultNode[l.size()]);
- }
- }
-
- public static class XMLActionProvider extends CommonActionProvider {
-
- private ICommonActionExtensionSite actionSite;
- public Action newXPathCategoryAction, deleteXPathCategoryAction,
- newXPathAction, editXPathAction, deleteXPathAction,
- editFileAction;
- private Object selectedNode;
-
- public void init(ICommonActionExtensionSite aSite) {
- super.init(aSite);
- this.actionSite = aSite;
- createActions();
- }
-
- public void createActions() {
- newXPathCategoryAction = new Action() {
- public void run() {
- XPathCategoryDialog d = new XPathCategoryDialog(Display
- .getCurrent().getActiveShell(), getServer());
- if (d.open() == Window.OK) {
- XPathModel.getDefault()
- .addCategory(getServer(), d.getText());
- XPathModel.getDefault().save(getServer());
- refreshViewer();
- }
- }
- };
- newXPathCategoryAction.setText("New Category");
-
- deleteXPathCategoryAction = new Action() {
- public void run() {
- int style = SWT.APPLICATION_MODAL | SWT.YES | SWT.NO;
- MessageBox messageBox = new MessageBox(Display.getCurrent()
- .getActiveShell(), style);
- messageBox.setText(Messages.DescriptorXPathRemoveCategory
- + "?");
- messageBox
- .setMessage(Messages.DescriptorXPathRemoveCategoryDesc);
- if (messageBox.open() == SWT.YES) {
- XPathModel.getDefault().removeCategory(getServer(),
- ((XPathCategory)selectedNode).getName());
- XPathModel.getDefault().save(getServer());
- refreshViewer();
- }
- }
- };
- deleteXPathCategoryAction
- .setText(Messages.DescriptorXPathRemoveCategory);
-
- newXPathAction = new Action() {
- public void run() {
- XPathCategory category = (XPathCategory)selectedNode;
- if (category != null) {
- String categoryName = category.getName();
- XPathDialog d = new XPathDialog(Display.getCurrent()
- .getActiveShell(), getServer(), categoryName);
- if (d.open() == Window.OK) {
- XPathCategory[] categoryList = XPathModel
- .getDefault().getCategories(getServer());
- XPathCategory categoryItem = null;
- for (int i = 0; i < categoryList.length; i++) {
- if (categoryList[i].getName().equals(
- category.getName()))
- categoryItem = categoryList[i];
- }
- if (categoryItem != null) {
- XPathQuery query = new XPathQuery(d.getName(),
- XPathDialogs.getConfigFolder(getServer()),
- null, d.getXpath(), d.getAttribute());
- categoryItem.addQuery(query);
- XPathModel.getDefault().save(getServer());
- refreshViewer();
- }
- }
- }
- }
- };
- newXPathAction.setText(Messages.DescriptorXPathNewXPath);
-
- editXPathAction = new Action() {
- public void run() {
- Object o = selectedNode;
- if (o != null && o instanceof XPathQuery) {
- XPathQuery original = (XPathQuery) o;
- XPathCategory category = original.getCategory();
-
- XPathDialog d = new XPathDialog(Display.getCurrent()
- .getActiveShell(), getServer(), category.getName(),
- original.getName());
- d.setAttribute(original.getAttribute());
- d.setXpath(original.getXpathPattern());
-
- if (d.open() == Window.OK) {
- original.setAttribute(d.getAttribute());
- original.setXpathPattern(d.getXpath());
- original.setName(d.getName());
- category.save();
- refreshViewer();
- }
- }
- }
- };
- editXPathAction.setText(Messages.DescriptorXPathEditXPath);
-
- deleteXPathAction = new Action() {
- public void run() {
- Object o = selectedNode;
- if (o instanceof XPathQuery) {
- XPathCategory cat = ((XPathQuery) o).getCategory();
- cat.removeQuery((XPathQuery) o);
- cat.save();
- refreshViewer();
- }
- }
- };
- deleteXPathAction.setText(Messages.DescriptorXPathDeleteXPath);
-
- editFileAction = new Action() {
- public void run() {
- try {
- Object o = selectedNode;
- Path p = null;
- if (o instanceof XPathQuery
- && ((XPathQuery) o).getResults().length == 1) {
- o = (XPathFileResult) ((XPathQuery) o).getResults()[0];
- }
- if (o instanceof XPathFileResult) {
- p = new Path(((XPathFileResult) o)
- .getFileLocation());
- } else if (o instanceof XPathResultNode) {
- p = new Path(((XPathResultNode) o)
- .getFileLocation());
- }
- if (p != null) {
-
- IFileStore fileStore = EFS.getLocalFileSystem()
- .getStore(p.removeLastSegments(1));
- fileStore = fileStore.getChild(p.lastSegment());
- IWorkbench wb = PlatformUI.getWorkbench();
- IWorkbenchWindow win = wb
- .getActiveWorkbenchWindow();
- IWorkbenchPage page = win.getActivePage();
-
- if (!fileStore.fetchInfo().isDirectory()
- && fileStore.fetchInfo().exists()) {
- try {
- IDE.openEditorOnFileStore(page, fileStore);
- } catch (PartInitException e) {
- }
- }
- }
- } catch (Exception exc) {
- JBossServerUIPlugin.log(
- "Error running edit file action", exc);
- }
- }
- };
- editFileAction.setText("Edit File");
- }
-
- public void fillContextMenu(IMenuManager menu) {
- ICommonViewerSite site = actionSite.getViewSite();
- IStructuredSelection selection = null;
- if (site instanceof ICommonViewerWorkbenchSite) {
- ICommonViewerWorkbenchSite wsSite = (ICommonViewerWorkbenchSite) site;
- selection = (IStructuredSelection) wsSite
- .getSelectionProvider().getSelection();
- Object first = selection.getFirstElement();
- if( first == null )
- return;
-
- if (first instanceof ServerWrapper) {
- menu.add(newXPathCategoryAction);
- menu.add(new Separator());
- return;
- }
-
- if (first instanceof XPathCategory) {
-
- menu.add(newXPathAction);
- menu.add(deleteXPathCategoryAction);
- menu.add(new Separator());
- return;
- }
-
- if( first instanceof XPathQuery) {
- selectedNode = first;
- menu.add(newXPathAction);
- menu.add(editXPathAction);
- menu.add(deleteXPathAction);
- }
- if( (first instanceof XPathResultNode || first instanceof XPathFileResult ) ||
- (first instanceof XPathQuery && ((XPathQuery)first).getResults().length == 1)) {
- menu.add(editFileAction);
- }
- }
- }
-
- protected void refreshViewer() {
- actionSite.getStructuredViewer().refresh();
- }
-
- protected IServer getServer() {
- Object o = selectedNode;
- if( o instanceof ServerWrapper) return ((ServerWrapper)o).server;
- if( o instanceof XPathCategory) return ((XPathCategory)o).getServer();
- if( o instanceof XPathQuery) return ((XPathQuery)o).getCategory().getServer();
- if( o instanceof XPathFileResult) return ((XPathFileResult)o).getQuery().getCategory().getServer();
- if( o instanceof XPathResultNode) return ((XPathResultNode)o).getFile().getQuery().getCategory().getServer();
- return null;
- }
- }
-
-
- public static class XMLDecorator extends LabelProvider implements ILightweightLabelDecorator {
- public void decorate(Object element, IDecoration decoration) {
- if( element instanceof XPathQuery) {
- XPathResultNode[] nodes = getResultNodes((XPathQuery)element);
- if(nodes.length == 1 ) {
- decoration.addSuffix(" " + nodes[0].getText());
- }
- return;
- }
-
- // we're a file node (blah.xml)
- if( element instanceof XPathFileResult ) {
- XPathResultNode[] nodes = ((XPathFileResult)element).getChildren();
- if( nodes.length == 1 )
- decoration.addSuffix(" " + nodes[0].getText());
- }
- }
- }
-
- public static XPathResultNode[] getResultNodes(XPathQuery query) {
- ArrayList<XPathResultNode> l = new ArrayList<XPathResultNode>();
- XPathFileResult[] files = query.getResults();
- for( int i = 0; i < files.length; i++ ) {
- l.addAll(Arrays.asList(files[i].getChildren()));
- }
- return l.toArray(new XPathResultNode[l.size()]);
- }
-
-}
Added: trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/eclipse/wst/server/ui/internal/view/servers/provisional/extensions/XPathTreeContentProvider.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/eclipse/wst/server/ui/internal/view/servers/provisional/extensions/XPathTreeContentProvider.java (rev 0)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/eclipse/wst/server/ui/internal/view/servers/provisional/extensions/XPathTreeContentProvider.java 2008-10-18 01:27:10 UTC (rev 10950)
@@ -0,0 +1,135 @@
+package org.eclipse.wst.server.ui.internal.view.servers.provisional.extensions;
+
+import java.util.ArrayList;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.jface.viewers.StructuredViewer;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.wst.server.core.IServer;
+import org.jboss.ide.eclipse.as.core.extensions.descriptors.XPathCategory;
+import org.jboss.ide.eclipse.as.core.extensions.descriptors.XPathFileResult;
+import org.jboss.ide.eclipse.as.core.extensions.descriptors.XPathModel;
+import org.jboss.ide.eclipse.as.core.extensions.descriptors.XPathQuery;
+import org.jboss.ide.eclipse.as.core.extensions.descriptors.XPathFileResult.XPathResultNode;
+
+public class XPathTreeContentProvider implements ITreeContentProvider {
+
+ public static class DelayProxy {
+ }
+
+ public static final DelayProxy LOADING = new DelayProxy();
+
+ private Viewer viewer;
+ private ArrayList<XPathCategory> loading = new ArrayList<XPathCategory>();
+
+ public class ServerWrapper {
+ public IServer server;
+
+ public ServerWrapper(IServer server) {
+ this.server = server;
+ }
+
+ public int hashCode() {
+ return server.getId().hashCode();
+ }
+
+ public boolean equals(Object other) {
+ return other instanceof ServerWrapper
+ && ((ServerWrapper) other).server.getId().equals(
+ server.getId());
+ }
+ }
+
+ public Object[] getChildren(Object parentElement) {
+ if (parentElement == null)
+ return new Object[] {};
+ if (parentElement instanceof IServer) {
+ return new Object[] { new ServerWrapper((IServer) parentElement) };
+ }
+
+ if (parentElement instanceof ServerWrapper) {
+ return XPathModel.getDefault().getCategories(
+ ((ServerWrapper) parentElement).server);
+ }
+
+ if (parentElement instanceof XPathCategory) {
+ if (((XPathCategory) parentElement).isLoaded())
+ return ((XPathCategory) parentElement).getQueries();
+
+ if (!loading.contains((XPathCategory) parentElement))
+ launchLoad((XPathCategory) parentElement);
+
+ return new Object[] { LOADING };
+ }
+
+ // we're the named element (JNDI)
+ if (parentElement instanceof XPathQuery) {
+ if (XPathModel.getResultNodes((XPathQuery) parentElement).length == 1) {
+ return new Object[0];
+ } else {
+ return ((XPathQuery) parentElement).getResults();
+ }
+ }
+
+ // we're a file node (blah.xml)
+ if (parentElement instanceof XPathFileResult) {
+ if (((XPathFileResult) parentElement).getChildren().length == 1)
+ return new Object[0];
+ return ((XPathFileResult) parentElement).getChildren();
+ }
+
+ if (parentElement instanceof XPathResultNode) {
+ return new Object[0];
+ }
+
+ return new Object[0];
+ }
+
+ protected void launchLoad(final XPathCategory cat) {
+ new Job("Loading XPaths") {
+ protected IStatus run(IProgressMonitor monitor) {
+ loading.add(cat);
+ XPathQuery[] queries = cat.getQueries();
+ XPathFileResult[] results;
+ for (int i = 0; i < queries.length; i++) {
+ results = queries[i].getResults();
+ for (int j = 0; j < results.length; j++) {
+ results[j].getChildren();
+ }
+ }
+ Display.getDefault().asyncExec(new Runnable() {
+ public void run() {
+ loading.remove(cat);
+ ((StructuredViewer) viewer).refresh(cat.getServer());
+ }
+ });
+ return Status.OK_STATUS;
+ }
+ }.schedule(200);
+ }
+
+
+ public Object getParent(Object element) {
+ return null;
+ }
+
+ public boolean hasChildren(Object element) {
+ return getChildren(element).length > 0 ? true : false;
+ }
+
+ public Object[] getElements(Object inputElement) {
+ return new Object[0];
+ }
+
+ public void dispose() {
+ }
+
+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+ this.viewer = viewer;
+ }
+}
\ No newline at end of file
Added: trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/eclipse/wst/server/ui/internal/view/servers/provisional/extensions/XPathTreeLabelProvider.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/eclipse/wst/server/ui/internal/view/servers/provisional/extensions/XPathTreeLabelProvider.java (rev 0)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/eclipse/wst/server/ui/internal/view/servers/provisional/extensions/XPathTreeLabelProvider.java 2008-10-18 01:27:10 UTC (rev 10950)
@@ -0,0 +1,63 @@
+package org.eclipse.wst.server.ui.internal.view.servers.provisional.extensions;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.ui.ISharedImages;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.wst.server.ui.internal.view.servers.provisional.extensions.XPathTreeContentProvider.ServerWrapper;
+import org.jboss.ide.eclipse.as.core.extensions.descriptors.XPathCategory;
+import org.jboss.ide.eclipse.as.core.extensions.descriptors.XPathFileResult;
+import org.jboss.ide.eclipse.as.core.extensions.descriptors.XPathQuery;
+import org.jboss.ide.eclipse.as.core.extensions.descriptors.XPathFileResult.XPathResultNode;
+import org.jboss.ide.eclipse.as.ui.JBossServerUIPlugin;
+
+public class XPathTreeLabelProvider extends LabelProvider {
+ private Image rootImage;
+ public XPathTreeLabelProvider() {
+ super();
+ ImageDescriptor des = ImageDescriptor.createFromURL(JBossServerUIPlugin.getDefault().getBundle().getEntry("icons/XMLFile.gif"));
+ rootImage = des.createImage();
+ }
+
+ public Image getImage(Object element) {
+ if( element instanceof ServerWrapper )
+ return rootImage;
+
+ if (element instanceof XPathCategory)
+ return PlatformUI.getWorkbench().getSharedImages().getImage(
+ ISharedImages.IMG_OBJ_FOLDER);
+
+ return null;
+ }
+
+ public String getText(Object element) {
+ if( element instanceof ServerWrapper )
+ return "XML Configuration";
+ if( element == XPathTreeContentProvider.LOADING )
+ return "Loading...";
+
+ if (element instanceof XPathCategory)
+ return ((XPathCategory) element).getName();
+
+ if( element instanceof XPathQuery )
+ return ((XPathQuery)element).getName();
+
+ if( element instanceof XPathFileResult )
+ return ((XPathFileResult)element).getFileLocation();
+
+ return "";
+ }
+
+ public XPathResultNode[] getResultNodes(XPathQuery query) {
+ ArrayList<XPathResultNode> l = new ArrayList<XPathResultNode>();
+ XPathFileResult[] files = query.getResults();
+ for( int i = 0; i < files.length; i++ ) {
+ l.addAll(Arrays.asList(files[i].getChildren()));
+ }
+ return l.toArray(new XPathResultNode[l.size()]);
+ }
+}
Added: trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/IPreferenceKeys.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/IPreferenceKeys.java (rev 0)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/IPreferenceKeys.java 2008-10-18 01:27:10 UTC (rev 10950)
@@ -0,0 +1,6 @@
+package org.jboss.ide.eclipse.as.ui;
+
+
+public interface IPreferenceKeys {
+ public static final String ENABLED_DECORATORS = "org.jboss.ide.eclipse.as.ui.preferences.enabledDecorators";
+}
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/JBossServerUIPlugin.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/JBossServerUIPlugin.java 2008-10-17 22:48:29 UTC (rev 10949)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/JBossServerUIPlugin.java 2008-10-18 01:27:10 UTC (rev 10950)
@@ -25,8 +25,12 @@
import java.util.ResourceBundle;
import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Preferences;
import org.eclipse.core.runtime.Status;
+import org.eclipse.ui.IDecoratorManager;
import org.eclipse.ui.IStartup;
+import org.eclipse.ui.internal.WorkbenchPlugin;
+import org.eclipse.ui.internal.decorators.DecoratorDefinition;
import org.eclipse.ui.plugin.AbstractUIPlugin;
import org.jboss.ide.eclipse.as.core.JBossServerCorePlugin;
import org.osgi.framework.BundleContext;
@@ -59,6 +63,15 @@
*/
public void start(BundleContext context) throws Exception {
super.start(context);
+ Preferences prefs = getPluginPreferences();
+
+ if( !prefs.getBoolean(IPreferenceKeys.ENABLED_DECORATORS)) {
+ IDecoratorManager manager = WorkbenchPlugin.getDefault().getDecoratorManager();
+ manager.setEnabled("org.eclipse.wst.server.ui.navigatorDecorator", true);
+ manager.setEnabled("org.jboss.ide.eclipse.as.ui.extensions.xml.decorator", true);
+ prefs.setValue(IPreferenceKeys.ENABLED_DECORATORS, true);
+ savePluginPreferences();
+ }
}
/**
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.ui/plugin.xml
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.ui/plugin.xml 2008-10-17 22:48:29 UTC (rev 10949)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.ui/plugin.xml 2008-10-18 01:27:10 UTC (rev 10950)
@@ -437,10 +437,10 @@
</navigatorContent>
<navigatorContent
activeByDefault="true"
- contentProvider="org.eclipse.wst.server.ui.internal.view.servers.provisional.extensions.XPathProvider$XPathTreeContentProvider"
+ contentProvider="org.eclipse.wst.server.ui.internal.view.servers.provisional.extensions.XPathTreeContentProvider"
icon="icons/XMLFile.gif"
id="org.jboss.ide.eclipse.as.ui.extensions.xml"
- labelProvider="org.eclipse.wst.server.ui.internal.view.servers.provisional.extensions.XPathProvider$XPathTreeLabelProvider"
+ labelProvider="org.eclipse.wst.server.ui.internal.view.servers.provisional.extensions.XPathTreeLabelProvider"
name="XML Configuration"
priority="normal">
<triggerPoints>
@@ -470,7 +470,7 @@
</instanceof></or>
</possibleChildren>
<actionProvider
- class="org.eclipse.wst.server.ui.internal.view.servers.provisional.extensions.XPathProvider$XMLActionProvider"
+ class="org.eclipse.wst.server.ui.internal.view.servers.provisional.extensions.XPathActionProvider"
id="org.jboss.ide.eclipse.as.ui.extensions.eventLog.actions"
priority="highest">
</actionProvider>
@@ -498,7 +498,7 @@
<!-- Decorator for xpaths / xml-->
<extension point="org.eclipse.ui.decorators">
<decorator
- class="org.eclipse.wst.server.ui.internal.view.servers.provisional.extensions.XPathProvider$XMLDecorator"
+ class="org.eclipse.wst.server.ui.internal.view.servers.provisional.extensions.XPathDecorator"
id="org.jboss.ide.eclipse.as.ui.extensions.xml.decorator"
label="JBoss Server XML Configuration Decorator"
lightweight="true"
16 years, 2 months
JBoss Tools SVN: r10949 - branches/jbosstools-3.0.0.Beta1.
by jbosstools-commits@lists.jboss.org
Author: dgolovin
Date: 2008-10-17 18:48:29 -0400 (Fri, 17 Oct 2008)
New Revision: 10949
Added:
branches/jbosstools-3.0.0.Beta1/archives/
branches/jbosstools-3.0.0.Beta1/as/
branches/jbosstools-3.0.0.Beta1/birt/
branches/jbosstools-3.0.0.Beta1/common/
branches/jbosstools-3.0.0.Beta1/documentation/
branches/jbosstools-3.0.0.Beta1/drools/
branches/jbosstools-3.0.0.Beta1/esb/
branches/jbosstools-3.0.0.Beta1/examples/
branches/jbosstools-3.0.0.Beta1/flow/
branches/jbosstools-3.0.0.Beta1/freemarker/
branches/jbosstools-3.0.0.Beta1/hibernatetools/
branches/jbosstools-3.0.0.Beta1/jbpm/
branches/jbosstools-3.0.0.Beta1/jsf/
branches/jbosstools-3.0.0.Beta1/jst/
branches/jbosstools-3.0.0.Beta1/labs/
branches/jbosstools-3.0.0.Beta1/portlet/
branches/jbosstools-3.0.0.Beta1/seam/
branches/jbosstools-3.0.0.Beta1/smooks/
branches/jbosstools-3.0.0.Beta1/struts/
branches/jbosstools-3.0.0.Beta1/tests/
branches/jbosstools-3.0.0.Beta1/tptp/
branches/jbosstools-3.0.0.Beta1/vpe/
branches/jbosstools-3.0.0.Beta1/ws/
Log:
jbosstools-3.0.0.Beta1 branch created
Copied: branches/jbosstools-3.0.0.Beta1/archives (from rev 10948, trunk/archives)
Copied: branches/jbosstools-3.0.0.Beta1/as (from rev 10948, trunk/as)
Copied: branches/jbosstools-3.0.0.Beta1/birt (from rev 10948, trunk/birt)
Copied: branches/jbosstools-3.0.0.Beta1/common (from rev 10948, trunk/common)
Copied: branches/jbosstools-3.0.0.Beta1/documentation (from rev 10948, trunk/documentation)
Copied: branches/jbosstools-3.0.0.Beta1/drools (from rev 10948, trunk/drools)
Copied: branches/jbosstools-3.0.0.Beta1/esb (from rev 10948, trunk/esb)
Copied: branches/jbosstools-3.0.0.Beta1/examples (from rev 10948, trunk/examples)
Copied: branches/jbosstools-3.0.0.Beta1/flow (from rev 10948, trunk/flow)
Copied: branches/jbosstools-3.0.0.Beta1/freemarker (from rev 10948, trunk/freemarker)
Copied: branches/jbosstools-3.0.0.Beta1/hibernatetools (from rev 10948, trunk/hibernatetools)
Copied: branches/jbosstools-3.0.0.Beta1/jbpm (from rev 10948, trunk/jbpm)
Copied: branches/jbosstools-3.0.0.Beta1/jsf (from rev 10948, trunk/jsf)
Copied: branches/jbosstools-3.0.0.Beta1/jst (from rev 10948, trunk/jst)
Copied: branches/jbosstools-3.0.0.Beta1/labs (from rev 10948, trunk/labs)
Copied: branches/jbosstools-3.0.0.Beta1/portlet (from rev 10948, trunk/portlet)
Copied: branches/jbosstools-3.0.0.Beta1/seam (from rev 10948, trunk/seam)
Copied: branches/jbosstools-3.0.0.Beta1/smooks (from rev 10948, trunk/smooks)
Copied: branches/jbosstools-3.0.0.Beta1/struts (from rev 10948, trunk/struts)
Copied: branches/jbosstools-3.0.0.Beta1/tests (from rev 10948, trunk/tests)
Copied: branches/jbosstools-3.0.0.Beta1/tptp (from rev 10948, trunk/tptp)
Copied: branches/jbosstools-3.0.0.Beta1/vpe (from rev 10948, trunk/vpe)
Copied: branches/jbosstools-3.0.0.Beta1/ws (from rev 10948, trunk/ws)
16 years, 2 months
JBoss Tools SVN: r10948 - branches.
by jbosstools-commits@lists.jboss.org
Author: dgolovin
Date: 2008-10-17 18:47:12 -0400 (Fri, 17 Oct 2008)
New Revision: 10948
Added:
branches/jbosstools-3.0.0.Beta1/
Log:
16 years, 2 months
JBoss Tools SVN: r10947 - trunk/seam/tests/org.jboss.tools.seam.core.test/src/org/jboss/tools/seam/core/test.
by jbosstools-commits@lists.jboss.org
Author: dgolovin
Date: 2008-10-17 18:44:32 -0400 (Fri, 17 Oct 2008)
New Revision: 10947
Modified:
trunk/seam/tests/org.jboss.tools.seam.core.test/src/org/jboss/tools/seam/core/test/ScannerTest.java
Log:
error for project deletion in tearDown() method fixed
Modified: trunk/seam/tests/org.jboss.tools.seam.core.test/src/org/jboss/tools/seam/core/test/ScannerTest.java
===================================================================
--- trunk/seam/tests/org.jboss.tools.seam.core.test/src/org/jboss/tools/seam/core/test/ScannerTest.java 2008-10-17 22:40:46 UTC (rev 10946)
+++ trunk/seam/tests/org.jboss.tools.seam.core.test/src/org/jboss/tools/seam/core/test/ScannerTest.java 2008-10-17 22:44:32 UTC (rev 10947)
@@ -21,6 +21,7 @@
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IncrementalProjectBuilder;
import org.eclipse.core.runtime.NullProgressMonitor;
+import org.jboss.tools.common.test.util.TestProjectProvider;
import org.jboss.tools.seam.core.BeanType;
import org.jboss.tools.seam.core.BijectedAttributeType;
import org.jboss.tools.seam.core.IBijectedAttribute;
@@ -53,6 +54,7 @@
public class ScannerTest extends TestCase {
IProject project = null;
+ TestProjectProvider provider = null;
boolean makeCopy = true;
public ScannerTest() {
@@ -61,8 +63,9 @@
protected void setUp() throws Exception {
boolean save = ResourcesUtils.setBuildAutomatically(false);
- project = ResourcesUtils.importProject(
- "org.jboss.tools.seam.core.test","/projects/TestScanner" , new NullProgressMonitor());
+ provider = new TestProjectProvider("org.jboss.tools.seam.core.test",
+ null,"TestScanner" ,true);
+ project = provider.getProject();
project.refreshLocal(IResource.DEPTH_INFINITE, new NullProgressMonitor());
this.project.build(IncrementalProjectBuilder.FULL_BUILD, null);
//EditorTestHelper.joinBackgroundActivities();
@@ -509,8 +512,6 @@
@Override
protected void tearDown() throws Exception {
- boolean save = ResourcesUtils.setBuildAutomatically(false);
- project.delete(true,true, null);
- ResourcesUtils.setBuildAutomatically(save);
+ provider.dispose();
}
}
16 years, 2 months
JBoss Tools SVN: r10946 - trunk/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/src/org/hibernate/eclipse/jdt/ui/test.
by jbosstools-commits@lists.jboss.org
Author: snjeza
Date: 2008-10-17 18:40:46 -0400 (Fri, 17 Oct 2008)
New Revision: 10946
Modified:
trunk/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/src/org/hibernate/eclipse/jdt/ui/test/HQLQueryValidatorTest.java
trunk/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/src/org/hibernate/eclipse/jdt/ui/test/HibernateErrorsTest.java
trunk/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/src/org/hibernate/eclipse/jdt/ui/test/HibernateErrorsTest2.java
Log:
Checking the hibernate tests.
Modified: trunk/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/src/org/hibernate/eclipse/jdt/ui/test/HQLQueryValidatorTest.java
===================================================================
--- trunk/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/src/org/hibernate/eclipse/jdt/ui/test/HQLQueryValidatorTest.java 2008-10-17 20:14:28 UTC (rev 10945)
+++ trunk/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/src/org/hibernate/eclipse/jdt/ui/test/HQLQueryValidatorTest.java 2008-10-17 22:40:46 UTC (rev 10946)
@@ -127,6 +127,7 @@
protected void tearDown() throws Exception {
ccfg.reset();
super.tearDown();
+ waitForJobs();
}
public void testHQLDetector() throws JavaModelException {
Modified: trunk/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/src/org/hibernate/eclipse/jdt/ui/test/HibernateErrorsTest.java
===================================================================
--- trunk/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/src/org/hibernate/eclipse/jdt/ui/test/HibernateErrorsTest.java 2008-10-17 20:14:28 UTC (rev 10945)
+++ trunk/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/src/org/hibernate/eclipse/jdt/ui/test/HibernateErrorsTest.java 2008-10-17 22:40:46 UTC (rev 10946)
@@ -173,9 +173,9 @@
private void deleteFile(File file) {
try {
if (!file.delete())
- throw new RuntimeException("Cannot remove the " + file.getAbsolutePath() + " file. (" + Platform.getOS() + ")");
+ throw new RuntimeException("Cannot remove the " + file.getAbsolutePath() + " file.");
} catch (Throwable e) {
- throw new RuntimeException("Cannot remove the " + file.getAbsolutePath() + " file. (" + Platform.getOS() + ")",e);
+ throw new RuntimeException("Cannot remove the " + file.getAbsolutePath() + " file.",e);
}
}
Modified: trunk/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/src/org/hibernate/eclipse/jdt/ui/test/HibernateErrorsTest2.java
===================================================================
--- trunk/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/src/org/hibernate/eclipse/jdt/ui/test/HibernateErrorsTest2.java 2008-10-17 20:14:28 UTC (rev 10945)
+++ trunk/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/src/org/hibernate/eclipse/jdt/ui/test/HibernateErrorsTest2.java 2008-10-17 22:40:46 UTC (rev 10946)
@@ -5,10 +5,12 @@
import java.io.File;
import java.io.IOException;
+import org.eclipse.core.internal.resources.ResourceException;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IncrementalProjectBuilder;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Platform;
@@ -153,8 +155,16 @@
IProject proj = getProject().getIProject();
String projRoot = proj.getLocation().toFile().getAbsolutePath();
File file = new File(projRoot);
-
- getProject().getIProject().delete(false, true, null);
+ boolean deleted = true;
+ int nTrys = 0;
+ while (!deleted && nTrys++ < 5)
+ try {
+ proj.delete(true, true, null);
+ deleted = true;
+ } catch (ResourceException re) {
+ waitForJobs();
+ Thread.sleep(100);
+ }
waitForJobs();
delete(file);
}
@@ -179,12 +189,25 @@
private void deleteFile(File file) {
try {
- if (!file.delete())
- throw new RuntimeException("Cannot remove the " + file.getAbsolutePath() + " file. (" + Platform.getOS() + ")");
+ if (!file.delete()) {
+ throw new RuntimeException(getMessage(file));
+ }
} catch (Throwable e) {
- throw new RuntimeException("Cannot remove the " + file.getAbsolutePath() + " file. (" + Platform.getOS() + ")",e);
+ throw new RuntimeException(getMessage(file),e);
}
}
+
+ private String getMessage(File file) {
+ StringBuffer buffer = new StringBuffer();
+ buffer.append("Cannot remove the ");
+ buffer.append(file.getAbsolutePath());
+ buffer.append(" file. ");
+ if (file.exists() && file.isDirectory()) {
+ buffer.append("List=");
+ buffer.append(file.list());
+ }
+ return buffer.toString();
+ }
protected SimpleTestProject getProject() {
return this.project;
16 years, 2 months
JBoss Tools SVN: r10945 - trunk/jsf/features/org.jboss.tools.richfaces.feature.
by jbosstools-commits@lists.jboss.org
Author: dgolovin
Date: 2008-10-17 16:14:28 -0400 (Fri, 17 Oct 2008)
New Revision: 10945
Modified:
trunk/jsf/features/org.jboss.tools.richfaces.feature/feature.xml
Log:
new plugin included in build: jsf.text.ext.reachfaces
Modified: trunk/jsf/features/org.jboss.tools.richfaces.feature/feature.xml
===================================================================
--- trunk/jsf/features/org.jboss.tools.richfaces.feature/feature.xml 2008-10-17 20:13:31 UTC (rev 10944)
+++ trunk/jsf/features/org.jboss.tools.richfaces.feature/feature.xml 2008-10-17 20:14:28 UTC (rev 10945)
@@ -307,6 +307,12 @@
version="0.0.0"/>
<plugin
+ id="org.jboss.tools.jsf.text.ext.richfaces"
+ download-size="0"
+ install-size="0"
+ version="0.0.0"/>
+
+ <plugin
id="org.jboss.tools.jsf.ui"
download-size="0"
install-size="0"
16 years, 2 months
JBoss Tools SVN: r10944 - in trunk/seam: tests/org.jboss.tools.seam.ui.test/src/org/jboss/tools/seam/ui/test/wizard and 1 other directory.
by jbosstools-commits@lists.jboss.org
Author: dgolovin
Date: 2008-10-17 16:13:31 -0400 (Fri, 17 Oct 2008)
New Revision: 10944
Modified:
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/OpenSeamComponentDialog.java
trunk/seam/tests/org.jboss.tools.seam.ui.test/src/org/jboss/tools/seam/ui/test/wizard/AbstractSeamNewOperationTest.java
trunk/seam/tests/org.jboss.tools.seam.ui.test/src/org/jboss/tools/seam/ui/test/wizard/OpenSeamComponentDialogTest.java
trunk/seam/tests/org.jboss.tools.seam.ui.test/src/org/jboss/tools/seam/ui/test/wizard/SeamProjectNewWizardTest.java
Log:
Example how coverage report should be used to achieve maximum coverage for JUnitTests
Modified: trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/OpenSeamComponentDialog.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/OpenSeamComponentDialog.java 2008-10-17 18:09:05 UTC (rev 10943)
+++ trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/OpenSeamComponentDialog.java 2008-10-17 20:13:31 UTC (rev 10944)
@@ -15,8 +15,10 @@
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
+import java.util.Collections;
import java.util.Comparator;
import java.util.Iterator;
+import java.util.List;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.ResourcesPlugin;
@@ -24,6 +26,7 @@
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.jface.dialogs.DialogSettings;
import org.eclipse.jface.dialogs.IDialogSettings;
@@ -50,6 +53,7 @@
*
*/
public class OpenSeamComponentDialog extends FilteredItemsSelectionDialog {
+
private static final String FILE_NAME = "OpenSeamComponentHistory.xml"; //$NON-NLS-1$
private static final String ROOT_NODE = "historyRootNode"; //$NON-NLS-1$
private static final String INFO_NODE = "infoNode"; //$NON-NLS-1$
@@ -73,14 +77,21 @@
getSelectionHistory().load(memento);
}
- public void beginTest() {
- create();
+ public void startSearch() {
applyFilter();
}
- public void endTest() {
+ @Override
+ public void okPressed() {
+ // TODO Auto-generated method stub
+ super.okPressed();
+ }
+
+ public void stopSearchAndShowResults() {
refresh();
- setResult(getSelectedItems().toList());
+ List list = getSelectedItems().toList();
+ Collections.sort(list,getItemsComparator());
+ setResult(list);
}
protected Control createExtendedContentArea(Composite parent) {
@@ -198,7 +209,7 @@
}
protected IStatus validateItem(Object item) {
- return new SeamComponentStatus();
+ return new Status(getSelectedItems().size() >= 0?IStatus.OK:IStatus.ERROR,SeamGuiPlugin.PLUGIN_ID,null);
}
public class SeamComponentComparator implements
@@ -239,48 +250,6 @@
}
}
- public class SeamComponentStatus implements IStatus {
- public IStatus[] getChildren() {
- return null;
- }
-
- public int getCode() {
- return 0;
- }
-
- public Throwable getException() {
- return null;
- }
-
- public String getMessage() {
- return ""; //$NON-NLS-1$
- }
-
- public String getPlugin() {
- return ""; //$NON-NLS-1$
- }
-
- public int getSeverity() {
- return 0;
- }
-
- public boolean isMultiStatus() {
- return false;
- }
-
- public boolean isOK() {
- if (getSelectedItems().size() < 0)
- return false;
-
- return true;
- }
-
- public boolean matches(int severityMask) {
- return false;
- }
-
- }
-
public class SeamComponentSelectionHistory extends SelectionHistory {
public SeamComponentSelectionHistory() {
@@ -368,18 +337,10 @@
return componentName;
}
- public void setComponentName(String componentName) {
- this.componentName = componentName;
- }
-
public String getProjectName() {
return projectName;
}
- public void setProjectName(String projectName) {
- this.projectName = projectName;
- }
-
public ISeamComponent getComponent() {
if (component == null) {
IProject project = ResourcesPlugin.getWorkspace().getRoot()
@@ -398,10 +359,6 @@
return component;
}
- public void setComponent(ISeamComponent component) {
- this.component = component;
- }
-
}
public static void validateHistory(ISeamProject seamProject) {
Modified: trunk/seam/tests/org.jboss.tools.seam.ui.test/src/org/jboss/tools/seam/ui/test/wizard/AbstractSeamNewOperationTest.java
===================================================================
--- trunk/seam/tests/org.jboss.tools.seam.ui.test/src/org/jboss/tools/seam/ui/test/wizard/AbstractSeamNewOperationTest.java 2008-10-17 18:09:05 UTC (rev 10943)
+++ trunk/seam/tests/org.jboss.tools.seam.ui.test/src/org/jboss/tools/seam/ui/test/wizard/AbstractSeamNewOperationTest.java 2008-10-17 20:13:31 UTC (rev 10944)
@@ -84,13 +84,12 @@
}
protected void setUp() throws Exception {
- super.setUp();
- try {
+
JobUtils.waitForIdle();
- } catch (Exception e) {
- JUnitUtils.fail(e.getMessage(), e);
- }
- JobUtils.delay(3000);
+
+
+
+
}
abstract protected IProject getProject();
Modified: trunk/seam/tests/org.jboss.tools.seam.ui.test/src/org/jboss/tools/seam/ui/test/wizard/OpenSeamComponentDialogTest.java
===================================================================
--- trunk/seam/tests/org.jboss.tools.seam.ui.test/src/org/jboss/tools/seam/ui/test/wizard/OpenSeamComponentDialogTest.java 2008-10-17 18:09:05 UTC (rev 10943)
+++ trunk/seam/tests/org.jboss.tools.seam.ui.test/src/org/jboss/tools/seam/ui/test/wizard/OpenSeamComponentDialogTest.java 2008-10-17 20:13:31 UTC (rev 10944)
@@ -43,10 +43,8 @@
"projects/TestComponentView",
"TestComponentView");
project = setup.importProject();
- this.project.refreshLocal(IResource.DEPTH_INFINITE, null);
}
this.project = project.getProject();
- this.project.build(IncrementalProjectBuilder.FULL_BUILD, null);
JobUtils.waitForIdle();
}
@@ -69,45 +67,44 @@
}
public void testOpenSeamComponentDialogSearch() {
-
find("m", "mockSecureEntity", true);
find("o", "org.jboss.seam.captcha.captcha", false);
find("p", "org.jboss.seam.core.pageContext", false);
-
}
-
//JBIDE-1879
public void testFindShortHand() {
find("o*jbpm", "org.jboss.seam.core.jbpm", true);
find("jbpm", "org.jboss.seam.core.jbpm", false);
-
-
}
private void find(String pattern, String componentName, boolean wait){
OpenSeamComponentDialog dialog = new OpenSeamComponentDialog(
PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell());
+ dialog.setBlockOnOpen(false);
dialog.setInitialPattern(pattern);
- dialog.beginTest();
- if(wait){
- try {
- JobUtils.waitForIdle();
- }catch(Exception ex){
- ex.printStackTrace();
+ dialog.open();
+ try {
+ dialog.startSearch();
+ if(wait){
+ JobUtils.waitForIdle();
+ JobUtils.delay(2000);
}
- }
- dialog.endTest();
- Object[] objects = dialog.getResult();
+ dialog.stopSearchAndShowResults();
+ Object[] objects = dialog.getResult();
+
+ assertNotNull("Search dialog returned null when searching for " + pattern, objects);
+
+ assertTrue("Component "+componentName+" not found", objects.length != 0);
- assertNotNull("Search dialog returned null when searching for " + pattern, objects);
+ SeamComponentWrapper wrapper = (SeamComponentWrapper)objects[0];
+ assertNotNull(wrapper.getComponent());
- assertTrue("Component "+componentName+" not found", objects.length != 0);
-
- SeamComponentWrapper wrapper = (SeamComponentWrapper)objects[0];
-
- assertEquals("Component "+componentName+" not found with " + pattern, wrapper.getComponentName(), componentName);
+ assertEquals("Component "+componentName+" not found with " + pattern, componentName, wrapper.getComponentName());
+ } finally {
+ dialog.okPressed();
+ }
}
}
Modified: trunk/seam/tests/org.jboss.tools.seam.ui.test/src/org/jboss/tools/seam/ui/test/wizard/SeamProjectNewWizardTest.java
===================================================================
--- trunk/seam/tests/org.jboss.tools.seam.ui.test/src/org/jboss/tools/seam/ui/test/wizard/SeamProjectNewWizardTest.java 2008-10-17 18:09:05 UTC (rev 10943)
+++ trunk/seam/tests/org.jboss.tools.seam.ui.test/src/org/jboss/tools/seam/ui/test/wizard/SeamProjectNewWizardTest.java 2008-10-17 20:13:31 UTC (rev 10944)
@@ -26,6 +26,7 @@
import org.eclipse.ui.PlatformUI;
import org.eclipse.wst.common.componentcore.datamodel.properties.IFacetDataModelProperties;
import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
+import org.eclipse.wst.common.frameworks.internal.operations.IProjectCreationPropertiesNew;
import org.eclipse.wst.server.core.IServerWorkingCopy;
import org.eclipse.wst.web.ui.internal.wizards.NewProjectDataModelFacetWizard;
import org.jboss.tools.common.util.WorkbenchUtils;
@@ -70,6 +71,7 @@
wizard);
dialog.create();
startSeamPrjWzPg = wizard.getStartingPage();
+ wizard.getDataModel().setStringProperty("IProjectCreationPropertiesNew.PROJECT_NAME","testName");
assertNotNull("Cannot create seam start wizard page", startSeamPrjWzPg);
}
16 years, 2 months