JBoss Tools SVN: r26166 - in trunk: jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/i18n/handlers and 3 other directories.
by jbosstools-commits@lists.jboss.org
Author: yradtsevich
Date: 2010-11-01 12:26:23 -0400 (Mon, 01 Nov 2010)
New Revision: 26166
Added:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/i18n/handlers/I18nHandler.java
Removed:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/i18n/handlers/I18Handler.java
Modified:
trunk/jst/plugins/org.jboss.tools.jst.jsp/plugin.xml
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/selection/bar/handlers/SelectionBarHandler.java
trunk/jst/tests/org.jboss.tools.jst.jsp.test/src/org/jboss/tools/jst/jsp/test/ca/SelectionBarTest.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/handlers/PageDesignOptionsHandler.java
Log:
https://jira.jboss.org/browse/JBIDE-7462: Replace overriding of isEnabled() by setEnabled(Object) for VPE command handlers.
Modified: trunk/jst/plugins/org.jboss.tools.jst.jsp/plugin.xml
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.jsp/plugin.xml 2010-11-01 16:22:37 UTC (rev 26165)
+++ trunk/jst/plugins/org.jboss.tools.jst.jsp/plugin.xml 2010-11-01 16:26:23 UTC (rev 26166)
@@ -528,7 +528,7 @@
commandId="org.jboss.tools.jst.jsp.commands.showSelectionBar">
</handler>
<handler
- class="org.jboss.tools.jst.jsp.i18n.handlers.I18Handler"
+ class="org.jboss.tools.jst.jsp.i18n.handlers.I18nHandler"
commandId="org.jboss.tools.jst.jsp.commands.i18">
</handler>
</extension>
Deleted: trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/i18n/handlers/I18Handler.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/i18n/handlers/I18Handler.java 2010-11-01 16:22:37 UTC (rev 26165)
+++ trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/i18n/handlers/I18Handler.java 2010-11-01 16:26:23 UTC (rev 26166)
@@ -1,128 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007-2010 Exadel, Inc. and Red Hat, Inc.
- * Distributed under license by Red Hat, Inc. All rights reserved.
- * This program is made available under the terms of the
- * Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
-
-package org.jboss.tools.jst.jsp.i18n.handlers;
-
-import java.util.Map;
-
-import org.eclipse.core.commands.AbstractHandler;
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.core.commands.HandlerEvent;
-import org.eclipse.jface.text.TextSelection;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.commands.IElementUpdater;
-import org.eclipse.ui.handlers.HandlerUtil;
-import org.eclipse.ui.menus.UIElement;
-import org.eclipse.ui.texteditor.ITextEditor;
-import org.jboss.tools.jst.jsp.i18n.ExternalizeStringsDialog;
-import org.jboss.tools.jst.jsp.i18n.ExternalizeStringsUtils;
-import org.jboss.tools.jst.jsp.i18n.ExternalizeStringsWizard;
-import org.w3c.dom.Attr;
-
-/**
- * Externalization command handler
- * @author mareshkau
- *
- */
-public class I18Handler extends AbstractHandler implements IElementUpdater{
-
- /* (non-Javadoc)
- * @see org.eclipse.core.commands.AbstractHandler#isEnabled()
- */
- @Override
- public boolean isEnabled() {
- IEditorPart activeEditor= PlatformUI
- .getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
- if(activeEditor instanceof ITextEditor){
- ITextEditor txtEditor = (ITextEditor) activeEditor;
- ISelection selection = txtEditor.getSelectionProvider().getSelection();
- return getExternalizeStringsCommandEnabled(selection);
- }
- return false;
- }
- /**
- *
- */
-// public I18Handler() {
-// setBaseEnabled(true);
-// }
- /**
- * Calculates the state of ext command
- * @param selection
- * @return
- */
- private static boolean getExternalizeStringsCommandEnabled(ISelection selection) {
- boolean enabled=false;
- String stringToUpdate = ""; //$NON-NLS-1$
- if (ExternalizeStringsUtils.isSelectionCorrect(selection)) {
- String text = ""; //$NON-NLS-1$
- TextSelection textSelection = null;
- IStructuredSelection structuredSelection = (IStructuredSelection) selection;
- textSelection = (TextSelection) selection;
- text = textSelection.getText();
- Object selectedElement = structuredSelection.getFirstElement();
- /*
- * When selected text is empty parse selected element and find a
- * string to replace..
- */
- if ((text.trim().length() == 0)) {
- if (selectedElement instanceof org.w3c.dom.Text) {
- /*
- * ..it could be a plain text
- */
- org.w3c.dom.Text textNode = (org.w3c.dom.Text) selectedElement;
- if (textNode.getNodeValue().trim().length() > 0) {
- stringToUpdate = textNode.getNodeValue();
- }
- } else if (selectedElement instanceof Attr) {
- /*
- * ..or an attribute's value
- */
- Attr attrNode = (Attr) selectedElement;
- if (attrNode.getNodeValue().trim().length() > 0) {
- stringToUpdate = attrNode.getNodeValue();
- }
- }
- } else {
- stringToUpdate = text;
- }
- }
- if ((stringToUpdate.length() > 0)) {
- enabled=true;
- }
- return enabled;
- }
-
- /**
- * the command has been executed, so extract extract the needed information
- * from the application context.
- */
- public Object execute(ExecutionEvent event) throws ExecutionException {
- IEditorPart activeEditor = HandlerUtil.getActiveEditorChecked(event);
-
- if(activeEditor instanceof ITextEditor){
- ExternalizeStringsDialog dlg = new ExternalizeStringsDialog(
- PlatformUI.getWorkbench().getDisplay().getActiveShell(),
- new ExternalizeStringsWizard((ITextEditor)activeEditor,
- null));
- dlg.open();
- }
- return null;
- }
-
- public void updateElement(UIElement element, Map parameters) {
- fireHandlerChanged(new HandlerEvent(this, true, false));
- }
-}
Copied: trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/i18n/handlers/I18nHandler.java (from rev 26152, trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/i18n/handlers/I18Handler.java)
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/i18n/handlers/I18nHandler.java (rev 0)
+++ trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/i18n/handlers/I18nHandler.java 2010-11-01 16:26:23 UTC (rev 26166)
@@ -0,0 +1,129 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2010 Exadel, Inc. and Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+
+package org.jboss.tools.jst.jsp.i18n.handlers;
+
+import java.util.Map;
+
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.commands.HandlerEvent;
+import org.eclipse.jface.text.TextSelection;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.commands.IElementUpdater;
+import org.eclipse.ui.handlers.HandlerUtil;
+import org.eclipse.ui.menus.UIElement;
+import org.eclipse.ui.texteditor.ITextEditor;
+import org.jboss.tools.jst.jsp.i18n.ExternalizeStringsDialog;
+import org.jboss.tools.jst.jsp.i18n.ExternalizeStringsUtils;
+import org.jboss.tools.jst.jsp.i18n.ExternalizeStringsWizard;
+import org.w3c.dom.Attr;
+
+/**
+ * Internationalization command handler
+ * @author mareshkau
+ *
+ */
+public class I18nHandler extends AbstractHandler implements IElementUpdater {
+
+ @Override
+ public void setEnabled(Object evaluationContext) {
+ IEditorPart activeEditor= PlatformUI
+ .getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
+ boolean enabled;
+ if(activeEditor instanceof ITextEditor){
+ ITextEditor txtEditor = (ITextEditor) activeEditor;
+ ISelection selection = txtEditor.getSelectionProvider().getSelection();
+ enabled = getExternalizeStringsCommandEnabled(selection);
+ } else {
+ enabled = false;
+ }
+
+ if (isEnabled() != enabled) {
+ setBaseEnabled(enabled);
+ }
+ }
+
+// public I18nHandler() {
+// setBaseEnabled(true);
+// }
+ /**
+ * Calculates the state of ext command
+ * @param selection
+ * @return
+ */
+ private static boolean getExternalizeStringsCommandEnabled(ISelection selection) {
+ boolean enabled=false;
+ String stringToUpdate = ""; //$NON-NLS-1$
+ if (ExternalizeStringsUtils.isSelectionCorrect(selection)) {
+ String text = ""; //$NON-NLS-1$
+ TextSelection textSelection = null;
+ IStructuredSelection structuredSelection = (IStructuredSelection) selection;
+ textSelection = (TextSelection) selection;
+ text = textSelection.getText();
+ Object selectedElement = structuredSelection.getFirstElement();
+ /*
+ * When selected text is empty parse selected element and find a
+ * string to replace..
+ */
+ if ((text.trim().length() == 0)) {
+ if (selectedElement instanceof org.w3c.dom.Text) {
+ /*
+ * ..it could be a plain text
+ */
+ org.w3c.dom.Text textNode = (org.w3c.dom.Text) selectedElement;
+ if (textNode.getNodeValue().trim().length() > 0) {
+ stringToUpdate = textNode.getNodeValue();
+ }
+ } else if (selectedElement instanceof Attr) {
+ /*
+ * ..or an attribute's value
+ */
+ Attr attrNode = (Attr) selectedElement;
+ if (attrNode.getNodeValue().trim().length() > 0) {
+ stringToUpdate = attrNode.getNodeValue();
+ }
+ }
+ } else {
+ stringToUpdate = text;
+ }
+ }
+ if ((stringToUpdate.length() > 0)) {
+ enabled=true;
+ }
+ return enabled;
+ }
+
+ /**
+ * the command has been executed, so extract extract the needed information
+ * from the application context.
+ */
+ public Object execute(ExecutionEvent event) throws ExecutionException {
+ IEditorPart activeEditor = HandlerUtil.getActiveEditorChecked(event);
+
+ if(activeEditor instanceof ITextEditor){
+ ExternalizeStringsDialog dlg = new ExternalizeStringsDialog(
+ PlatformUI.getWorkbench().getDisplay().getActiveShell(),
+ new ExternalizeStringsWizard((ITextEditor)activeEditor,
+ null));
+ dlg.open();
+ }
+ return null;
+ }
+
+ public void updateElement(UIElement element, Map parameters) {
+ fireHandlerChanged(new HandlerEvent(this, true, false));
+ }
+}
Modified: trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/selection/bar/handlers/SelectionBarHandler.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/selection/bar/handlers/SelectionBarHandler.java 2010-11-01 16:22:37 UTC (rev 26165)
+++ trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/selection/bar/handlers/SelectionBarHandler.java 2010-11-01 16:26:23 UTC (rev 26166)
@@ -50,7 +50,9 @@
}
}
- setBaseEnabled(enabled);
+ if (enabled != isEnabled()) {
+ setBaseEnabled(enabled);
+ }
}
/**
Modified: trunk/jst/tests/org.jboss.tools.jst.jsp.test/src/org/jboss/tools/jst/jsp/test/ca/SelectionBarTest.java
===================================================================
--- trunk/jst/tests/org.jboss.tools.jst.jsp.test/src/org/jboss/tools/jst/jsp/test/ca/SelectionBarTest.java 2010-11-01 16:22:37 UTC (rev 26165)
+++ trunk/jst/tests/org.jboss.tools.jst.jsp.test/src/org/jboss/tools/jst/jsp/test/ca/SelectionBarTest.java 2010-11-01 16:26:23 UTC (rev 26166)
@@ -56,18 +56,15 @@
public void testSelectionBarCommandState() throws Throwable{
assertEquals("check command enabled command status",false,toggleSelBarCommand.isEnabled()); //$NON-NLS-1$
IEditorPart editorPart = WorkbenchUtils.openEditor(project.getName()+"/WebContent/pages/selectionBar.xhtml"); //$NON-NLS-1$
- if(editorPart instanceof JSPMultiPageEditor){
- JSPMultiPageEditor multiPageEditor = (JSPMultiPageEditor) editorPart;
- multiPageEditor.pageChange(0);
- assertEquals("check command enabled command status",true,toggleSelBarCommand.isEnabled()&&(Boolean)toggleSelBarState.getValue()); //$NON-NLS-1$
- multiPageEditor.pageChange(multiPageEditor.getPreviewIndex());
- assertEquals("check command enabled command status",false,toggleSelBarCommand.isEnabled()&&(Boolean)toggleSelBarState.getValue()); //$NON-NLS-1$
- multiPageEditor.pageChange(0);
- assertEquals("check command enabled command status",true,toggleSelBarCommand.isEnabled()&&(Boolean)toggleSelBarState.getValue()); //$NON-NLS-1$
- TestUtil.closeAllEditors();
- assertEquals("check command enabled command status",false,toggleSelBarCommand.isEnabled()&&(Boolean)toggleSelBarState.getValue()); //$NON-NLS-1$
- } else{
- fail("Should be opened JSPMultiPage Editor"); //$NON-NLS-1$
- }
+
+ assertTrue("Should be opened JSPMultiPage Editor", //$NON-NLS-1$
+ editorPart instanceof JSPMultiPageEditor);
+ JSPMultiPageEditor multiPageEditor = (JSPMultiPageEditor) editorPart;
+ multiPageEditor.pageChange(0);
+ assertEquals("check command enabled command status",true,toggleSelBarCommand.isEnabled()&&(Boolean)toggleSelBarState.getValue()); //$NON-NLS-1$
+ multiPageEditor.pageChange(multiPageEditor.getPreviewIndex());
+ assertEquals("check command enabled command status",false,toggleSelBarCommand.isEnabled()&&(Boolean)toggleSelBarState.getValue()); //$NON-NLS-1$
+ multiPageEditor.pageChange(0);
+ assertEquals("check command enabled command status",true,toggleSelBarCommand.isEnabled()&&(Boolean)toggleSelBarState.getValue()); //$NON-NLS-1$
}
}
Modified: trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/handlers/PageDesignOptionsHandler.java
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/handlers/PageDesignOptionsHandler.java 2010-11-01 16:22:37 UTC (rev 26165)
+++ trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/handlers/PageDesignOptionsHandler.java 2010-11-01 16:26:23 UTC (rev 26166)
@@ -67,7 +67,7 @@
}
@Override
- public boolean isEnabled() {
+ public void setEnabled(Object evaluationContext) {
IEditorPart activeEditor = PlatformUI.getWorkbench()
.getActiveWorkbenchWindow().getActivePage().getActiveEditor();
IEditorInput input = activeEditor.getEditorInput();
@@ -81,6 +81,10 @@
file = FileUtil.getFile(input, path.lastSegment());
}
}
- return ((file != null) && (file.exists()));
+
+ boolean enabled = file != null && file.exists();
+ if (isEnabled() != enabled) {
+ setBaseEnabled(enabled);
+ }
}
}
13 years, 5 months
JBoss Tools SVN: r26165 - in trunk/jsf: tests/org.jboss.tools.jsf.vpe.richfaces.test/resources/richFacesTest/WebContent/pages/components and 1 other directories.
by jbosstools-commits@lists.jboss.org
Author: mareshkau
Date: 2010-11-01 12:22:37 -0400 (Mon, 01 Nov 2010)
New Revision: 26165
Added:
trunk/jsf/tests/org.jboss.tools.jsf.vpe.richfaces.test/resources/richFacesTest/WebContent/pages/components/clientValidator.xhtml
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/templates/vpe-templates-richfaces.xml
trunk/jsf/tests/org.jboss.tools.jsf.vpe.richfaces.test/src/org/jboss/tools/jsf/vpe/richfaces/test/RichFacesComponentContentTest.java
Log:
https://jira.jboss.org/browse/JBIDE-7452
Modified: trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/templates/vpe-templates-richfaces.xml
===================================================================
--- trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/templates/vpe-templates-richfaces.xml 2010-11-01 14:40:15 UTC (rev 26164)
+++ trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/templates/vpe-templates-richfaces.xml 2010-11-01 16:22:37 UTC (rev 26165)
@@ -735,6 +735,10 @@
<vpe:template children="yes" modify="no"/>
</vpe:tag>
+ <vpe:tag name="rich:clientValidator" case-sensitive="yes">
+ <vpe:template children="no" modify="no"/>
+ </vpe:tag>
+
<vpe:tag name="rich:hotKey" case-sensitive="yes">
<vpe:template children="yes" modify="no"/>
</vpe:tag>
Added: trunk/jsf/tests/org.jboss.tools.jsf.vpe.richfaces.test/resources/richFacesTest/WebContent/pages/components/clientValidator.xhtml
===================================================================
--- trunk/jsf/tests/org.jboss.tools.jsf.vpe.richfaces.test/resources/richFacesTest/WebContent/pages/components/clientValidator.xhtml (rev 0)
+++ trunk/jsf/tests/org.jboss.tools.jsf.vpe.richfaces.test/resources/richFacesTest/WebContent/pages/components/clientValidator.xhtml 2010-11-01 16:22:37 UTC (rev 26165)
@@ -0,0 +1,9 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:h="http://java.sun.com/jsf/html"
+ xmlns:f="http://java.sun.com/jsf/core"
+ xmlns:rich="http://richfaces.org/rich">
+<h:form>
+<rich:clientValidator id="clientValidator" [event="onsubmit"]/>
+</h:form>
+</html>
Modified: trunk/jsf/tests/org.jboss.tools.jsf.vpe.richfaces.test/src/org/jboss/tools/jsf/vpe/richfaces/test/RichFacesComponentContentTest.java
===================================================================
--- trunk/jsf/tests/org.jboss.tools.jsf.vpe.richfaces.test/src/org/jboss/tools/jsf/vpe/richfaces/test/RichFacesComponentContentTest.java 2010-11-01 14:40:15 UTC (rev 26164)
+++ trunk/jsf/tests/org.jboss.tools.jsf.vpe.richfaces.test/src/org/jboss/tools/jsf/vpe/richfaces/test/RichFacesComponentContentTest.java 2010-11-01 16:22:37 UTC (rev 26165)
@@ -135,6 +135,10 @@
public void testDragListener() throws Throwable {
performInvisibleTagTest("components/dragListener.xhtml", "dragListener"); //$NON-NLS-1$ //$NON-NLS-2$
}
+
+ public void testClientValidator() throws Throwable {
+ performInvisibleTagTest("components/clientValidator.xhtml", "clientValidator"); //$NON-NLS-1$ //$NON-NLS-2$
+ }
public void testDropListener() throws Throwable {
performInvisibleTagTest("components/dropListener.xhtml", "dropListener"); //$NON-NLS-1$ //$NON-NLS-2$
13 years, 5 months
JBoss Tools SVN: r26164 - in trunk/jsf: plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/util and 3 other directories.
by jbosstools-commits@lists.jboss.org
Author: dvinnichek
Date: 2010-11-01 10:40:15 -0400 (Mon, 01 Nov 2010)
New Revision: 26164
Added:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesAutocompleteTemplate.java
trunk/jsf/tests/org.jboss.tools.jsf.vpe.richfaces.test/resources/richFacesTest/WebContent/pages/components/autocomplete.xhtml
trunk/jsf/tests/org.jboss.tools.jsf.vpe.richfaces.test/resources/richFacesTest/WebContent/pages/components/autocomplete.xhtml.xml
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/util/RichFaces.java
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/templates/vpe-templates-richfaces.xml
trunk/jsf/tests/org.jboss.tools.jsf.vpe.richfaces.test/src/org/jboss/tools/jsf/vpe/richfaces/test/RichFacesComponentContentTest.java
Log:
added template for <rich:autocomplete> element (https://jira.jboss.org/browse/JBIDE-7448)
Added: trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesAutocompleteTemplate.java
===================================================================
--- trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesAutocompleteTemplate.java (rev 0)
+++ trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesAutocompleteTemplate.java 2010-11-01 14:40:15 UTC (rev 26164)
@@ -0,0 +1,72 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2009 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+
+package org.jboss.tools.jsf.vpe.richfaces.template;
+
+import org.jboss.tools.jsf.vpe.richfaces.template.util.RichFaces;
+import org.jboss.tools.vpe.editor.context.VpePageContext;
+import org.jboss.tools.vpe.editor.template.VpeCreationData;
+import org.jboss.tools.vpe.editor.util.Constants;
+import org.jboss.tools.vpe.editor.util.HTML;
+import org.mozilla.interfaces.nsIDOMDocument;
+import org.mozilla.interfaces.nsIDOMElement;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+
+/**
+ * Template for the <rich:autocomplete> component.
+ *
+ * @author dvinnichek
+ */
+public class RichFacesAutocompleteTemplate extends
+ AbstractEditableRichFacesTemplate {
+
+ private boolean disabled;
+ private boolean showButton;
+
+ @Override
+ public VpeCreationData create(VpePageContext pageContext, Node sourceNode,
+ nsIDOMDocument visualDocument) {
+
+ readAttributes(pageContext, sourceNode);
+
+ nsIDOMElement wrapper = visualDocument.createElement(HTML.TAG_SPAN);
+ nsIDOMElement element = showButton ? visualDocument
+ .createElement(HTML.TAG_SELECT) : visualDocument
+ .createElement(HTML.TAG_INPUT);
+ if (disabled) {
+ element.setAttribute(RichFaces.ATTR_DISABLED,
+ RichFaces.ATTR_DISABLED);
+ }
+ wrapper.appendChild(element);
+ VpeCreationData creationData = new VpeCreationData(wrapper);
+
+ return creationData;
+ }
+
+ /**
+ * Read attributes from the source element.
+ *
+ * @param sourceNode
+ * the source node
+ */
+ private void readAttributes(VpePageContext pageContext, Node sourceNode) {
+
+ Element sourceElement = (Element) sourceNode;
+
+ // disabled
+ disabled = Constants.TRUE.equalsIgnoreCase(sourceElement
+ .getAttribute(RichFaces.ATTR_DISABLED));
+ // showButton
+ showButton = Constants.TRUE.equalsIgnoreCase(sourceElement
+ .getAttribute(RichFaces.ATTR_SHOW_BUTTON));
+ }
+}
Property changes on: trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesAutocompleteTemplate.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Id Revision Date
Name: svn:eol-style
+ native
Modified: trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/util/RichFaces.java
===================================================================
--- trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/util/RichFaces.java 2010-11-01 14:34:45 UTC (rev 26163)
+++ trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/util/RichFaces.java 2010-11-01 14:40:15 UTC (rev 26164)
@@ -60,7 +60,8 @@
public static final String ATTR_ROWS = "rows"; //$NON-NLS-1$
public static final String ATTR_ROW_CLASSES = "rowClasses"; //$NON-NLS-1$
public static final String ATTR_SELECT_ITEM_LABEL = "itemLabel"; //$NON-NLS-1$
- public static final String ATTR_SELECT_ITEM_VALUE = "itemValue"; //$NON-NLS-1$
+ public static final String ATTR_SELECT_ITEM_VALUE = "itemValue"; //$NON-NLS-1$showButton
+ public static final String ATTR_SHOW_BUTTON = "showButton"; //$NON-NLS-1$
public static final String ATTR_SHOW_BUTTON_LABELS = "showButtonLabels"; //$NON-NLS-1$
public static final String ATTR_SORT_BY = "sortBy"; //$NON-NLS-1$
public static final String ATTR_SORT_ICON = "sortIcon"; //$NON-NLS-1$
Modified: trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/templates/vpe-templates-richfaces.xml
===================================================================
--- trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/templates/vpe-templates-richfaces.xml 2010-11-01 14:34:45 UTC (rev 26163)
+++ trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/templates/vpe-templates-richfaces.xml 2010-11-01 14:40:15 UTC (rev 26164)
@@ -781,4 +781,15 @@
</vpe:template>
</vpe:tag>
+ <!-- Since RichFaces 4.0 -->
+ <vpe:tag name="rich:autocomplete" case-sensitive="yes">
+ <vpe:template children="yes" modify="no"
+ class="org.jboss.tools.jsf.vpe.richfaces.template.RichFacesAutocompleteTemplate">
+ <vpe:dnd>
+ <vpe:drag start-enable="yes" />
+ <vpe:drop container="no" />
+ </vpe:dnd>
+ </vpe:template>
+ </vpe:tag>
+
</vpe:templates>
Added: trunk/jsf/tests/org.jboss.tools.jsf.vpe.richfaces.test/resources/richFacesTest/WebContent/pages/components/autocomplete.xhtml
===================================================================
(Binary files differ)
Property changes on: trunk/jsf/tests/org.jboss.tools.jsf.vpe.richfaces.test/resources/richFacesTest/WebContent/pages/components/autocomplete.xhtml
___________________________________________________________________
Name: svn:mime-type
+ application/xhtml+xml
Added: trunk/jsf/tests/org.jboss.tools.jsf.vpe.richfaces.test/resources/richFacesTest/WebContent/pages/components/autocomplete.xhtml.xml
===================================================================
--- trunk/jsf/tests/org.jboss.tools.jsf.vpe.richfaces.test/resources/richFacesTest/WebContent/pages/components/autocomplete.xhtml.xml (rev 0)
+++ trunk/jsf/tests/org.jboss.tools.jsf.vpe.richfaces.test/resources/richFacesTest/WebContent/pages/components/autocomplete.xhtml.xml 2010-11-01 14:40:15 UTC (rev 26164)
@@ -0,0 +1,17 @@
+<tests>
+ <test id="autocomplete1">
+ <SPAN>
+ <INPUT />
+ </SPAN>
+ </test>
+ <test id="autocomplete2">
+ <SPAN>
+ <INPUT DISABLED="disabled" />
+ </SPAN>
+ </test>
+ <test id="autocomplete3">
+ <SPAN>
+ <SELECT />
+ </SPAN>
+ </test>
+</tests>
\ No newline at end of file
Property changes on: trunk/jsf/tests/org.jboss.tools.jsf.vpe.richfaces.test/resources/richFacesTest/WebContent/pages/components/autocomplete.xhtml.xml
___________________________________________________________________
Name: svn:mime-type
+ text/xml
Name: svn:eol-style
+ native
Modified: trunk/jsf/tests/org.jboss.tools.jsf.vpe.richfaces.test/src/org/jboss/tools/jsf/vpe/richfaces/test/RichFacesComponentContentTest.java
===================================================================
--- trunk/jsf/tests/org.jboss.tools.jsf.vpe.richfaces.test/src/org/jboss/tools/jsf/vpe/richfaces/test/RichFacesComponentContentTest.java 2010-11-01 14:34:45 UTC (rev 26163)
+++ trunk/jsf/tests/org.jboss.tools.jsf.vpe.richfaces.test/src/org/jboss/tools/jsf/vpe/richfaces/test/RichFacesComponentContentTest.java 2010-11-01 14:40:15 UTC (rev 26164)
@@ -368,6 +368,10 @@
performContentTest("components/colorPicker.xhtml");//$NON-NLS-1$
}
+ public void testAutocomplete() throws Throwable {
+ performContentTest("components/autocomplete.xhtml");//$NON-NLS-1$
+ }
+
@Override
protected String getTestProjectName() {
return RichFacesAllTests.IMPORT_PROJECT_NAME;
13 years, 5 months
JBoss Tools SVN: r26163 - trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/marker.
by jbosstools-commits@lists.jboss.org
Author: dazarov
Date: 2010-11-01 10:34:45 -0400 (Mon, 01 Nov 2010)
New Revision: 26163
Modified:
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/marker/AddSetterMarkerResolution.java
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/marker/SeamProblemMarkerResolutionGenerator.java
Log:
https://jira.jboss.org/browse/JBIDE-6872
Modified: trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/marker/AddSetterMarkerResolution.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/marker/AddSetterMarkerResolution.java 2010-11-01 14:17:36 UTC (rev 26162)
+++ trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/marker/AddSetterMarkerResolution.java 2010-11-01 14:34:45 UTC (rev 26163)
@@ -11,20 +11,24 @@
package org.jboss.tools.seam.ui.marker;
import java.text.MessageFormat;
+import java.util.Hashtable;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IMarker;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.jdt.core.Flags;
+import org.eclipse.jdt.core.IBuffer;
import org.eclipse.jdt.core.ICompilationUnit;
import org.eclipse.jdt.core.IField;
import org.eclipse.jdt.core.IMethod;
import org.eclipse.jdt.core.IType;
+import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jdt.internal.corext.codemanipulation.GetterSetterUtil;
import org.eclipse.swt.graphics.Image;
import org.eclipse.ui.IMarkerResolution2;
import org.jboss.tools.common.EclipseUtil;
+import org.jboss.tools.common.java.generation.JavaPropertyGenerator;
import org.jboss.tools.seam.core.ISeamJavaComponentDeclaration;
import org.jboss.tools.seam.core.ISeamProperty;
import org.jboss.tools.seam.ui.SeamGuiPlugin;
@@ -55,8 +59,19 @@
ICompilationUnit original = EclipseUtil.getCompilationUnit(file);
ICompilationUnit compilationUnit = original.getWorkingCopy(new NullProgressMonitor());
- String lineDelim= compilationUnit.findRecommendedLineSeparator();
+ String lineDelim= JavaPropertyGenerator.getLineDelimiterUsed(compilationUnit);
+ Hashtable<String, String> options = JavaCore.getOptions();
+
+ int tabSize = new Integer(options.get("org.eclipse.jdt.core.formatter.tabulation.size"));
+
+ StringBuffer tabBuf = new StringBuffer();
+
+ for(int i = 0;i<tabSize;i++)
+ tabBuf.append(" ");
+
+ String tab = tabBuf.toString();
+
IType type = compilationUnit.findPrimaryType();
IField field = type.getField(property.getName());
@@ -69,17 +84,42 @@
StringBuffer buf= new StringBuffer();
- buf.append("private "+propertyType+" "+property.getName()+";"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ buf.append(tab+"private "+propertyType+" "+property.getName()+";"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
buf.append(lineDelim);
field = type.createField(buf.toString(), null, false, new NullProgressMonitor());
+ if(field != null){
+ IBuffer buffer = compilationUnit.getBuffer();
+
+ buffer.replace(field.getSourceRange().getOffset(), field.getSourceRange().getLength(), buf.toString());
+ synchronized(compilationUnit) {
+ compilationUnit.reconcile(ICompilationUnit.NO_AST, true, null, null);
+ }
+ }
}
- String setterName = GetterSetterUtil.getSetterName(field, null);
IMethod oldMethod = GetterSetterUtil.getSetter(field);
if(oldMethod == null || !oldMethod.exists()){
+ String setterName = GetterSetterUtil.getSetterName(field, null);
+ //JavaPropertyGenerator.createSetter(compilationUnit, type, "public", field.getTypeSignature(), setterName, lineDelim);
+
String stub = GetterSetterUtil.getSetterStub(field, setterName, true, Flags.AccPublic);
- type.createMethod(stub, null, false, new NullProgressMonitor());
+ IMethod newMethod = type.createMethod(stub, null, false, new NullProgressMonitor());
+ if(newMethod != null){
+ IBuffer buffer = compilationUnit.getBuffer();
+ // format
+ StringBuffer buf= new StringBuffer();
+
+ buf.append(lineDelim);
+ buf.append(tab+"public void "+setterName+"("+propertyType+" "+property.getName()+"){"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ buf.append(lineDelim);
+ buf.append(tab+tab+"this."+property.getName()+" = "+property.getName()+";");
+ buf.append(lineDelim);
+ buf.append(tab+"}");
+ buf.append(lineDelim);
+
+ buffer.replace(newMethod.getSourceRange().getOffset(), newMethod.getSourceRange().getLength(), buf.toString());
+ }
}
compilationUnit.commitWorkingCopy(false, new NullProgressMonitor());
Modified: trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/marker/SeamProblemMarkerResolutionGenerator.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/marker/SeamProblemMarkerResolutionGenerator.java 2010-11-01 14:17:36 UTC (rev 26162)
+++ trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/marker/SeamProblemMarkerResolutionGenerator.java 2010-11-01 14:34:45 UTC (rev 26163)
@@ -217,7 +217,7 @@
if(project == null)
return null;
- ISeamProject seamProject = SeamCorePlugin.getSeamProject(project, false);
+ ISeamProject seamProject = SeamCorePlugin.getSeamProject(project, true);
if(seamProject == null)
return null;
13 years, 5 months
JBoss Tools SVN: r26162 - in trunk/as: tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test and 2 other directories.
by jbosstools-commits@lists.jboss.org
Author: rob.stryker(a)jboss.com
Date: 2010-11-01 10:17:36 -0400 (Mon, 01 Nov 2010)
New Revision: 26162
Added:
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/util/IOUtil.java
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.ssh/src/org/jboss/ide/eclipse/as/ssh/server/ISSHDeploymentConstants.java
trunk/as/plugins/org.jboss.ide.eclipse.as.ssh/src/org/jboss/ide/eclipse/as/ssh/server/SSHPublishUtil.java
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/ASTest.java
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/publishing/v2/JSTDeployBinaryChildModuleTest.java
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/publishing/v2/JSTDeploymentTester.java
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/publishing/v2/JSTZippedDeploymentTester.java
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/publishing/v2/SingleFileDeploymentTester.java
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/util/ServerRuntimeUtils.java
Log:
JBIDE-7471 - zipped folder publishing order tests and slight changes to accomodate
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.ssh/src/org/jboss/ide/eclipse/as/ssh/server/ISSHDeploymentConstants.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.ssh/src/org/jboss/ide/eclipse/as/ssh/server/ISSHDeploymentConstants.java 2010-11-01 14:08:51 UTC (rev 26161)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.ssh/src/org/jboss/ide/eclipse/as/ssh/server/ISSHDeploymentConstants.java 2010-11-01 14:17:36 UTC (rev 26162)
@@ -10,10 +10,13 @@
******************************************************************************/
package org.jboss.ide.eclipse.as.ssh.server;
+import org.jboss.ide.eclipse.as.core.server.IDeployableServer;
+
public interface ISSHDeploymentConstants {
public static final String HOSTS_FILE = "org.jboss.ide.eclipse.as.ssh.server.hostsFile"; //$NON-NLS-1$
public static final String DEPLOY_DIRECTORY = "org.jboss.ide.eclipse.as.ssh.server.deployDirectory"; //$NON-NLS-1$
public static final String USERNAME = "org.jboss.ide.eclipse.as.ssh.server.username"; //$NON-NLS-1$
public static final String PASSWORD = "org.jboss.ide.eclipse.as.ssh.server.password"; //$NON-NLS-1$
- public static final String ZIP_DEPLOYMENTS_PREF = "org.jboss.ide.eclipse.as.ssh.server.zipDeploymentsPreference"; //$NON-NLS-1$
+ public static final String SSH_ZIP_DEPLOYMENTS_PREF_LEGACY = "org.jboss.ide.eclipse.as.ssh.server.zipDeploymentsPreference"; //$NON-NLS-1$
+ public static final String ZIP_DEPLOYMENTS_PREF = IDeployableServer.ZIP_DEPLOYMENTS_PREF;
}
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.ssh/src/org/jboss/ide/eclipse/as/ssh/server/SSHPublishUtil.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.ssh/src/org/jboss/ide/eclipse/as/ssh/server/SSHPublishUtil.java 2010-11-01 14:08:51 UTC (rev 26161)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.ssh/src/org/jboss/ide/eclipse/as/ssh/server/SSHPublishUtil.java 2010-11-01 14:17:36 UTC (rev 26162)
@@ -18,7 +18,8 @@
public class SSHPublishUtil {
public static boolean getZipsSSHDeployments(IServer server) {
- return ((Server)server).getAttribute(ISSHDeploymentConstants.ZIP_DEPLOYMENTS_PREF, false);
+ boolean defaultVal = ((Server)server).getAttribute(ISSHDeploymentConstants.SSH_ZIP_DEPLOYMENTS_PREF_LEGACY, false);
+ return ((Server)server).getAttribute(ISSHDeploymentConstants.ZIP_DEPLOYMENTS_PREF, defaultVal);
}
public static String getDeployDir(IServer server) {
return ((Server)server).getAttribute(ISSHDeploymentConstants.DEPLOY_DIRECTORY, "/home");
Modified: trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/ASTest.java
===================================================================
--- trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/ASTest.java 2010-11-01 14:08:51 UTC (rev 26161)
+++ trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/ASTest.java 2010-11-01 14:17:36 UTC (rev 26162)
@@ -21,7 +21,11 @@
*/
package org.jboss.ide.eclipse.as.test;
+import java.io.File;
+
+import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Plugin;
+import org.jboss.ide.eclipse.as.core.util.FileUtil;
import org.jboss.ide.eclipse.as.core.util.IJBossToolingConstants;
import org.osgi.framework.BundleContext;
@@ -81,4 +85,17 @@
public static final String JBOSS_AS_52_HOME = System.getProperty("jbosstools.test.jboss.home.5.2", "C:\\apps\\jboss\\jboss-5.2.0.GA\\");
public static final String JBOSS_AS_HOME = System.getProperty("jbosstools.test.jboss.home", JBOSS_AS_42_HOME);
+
+ public static void clearStateLocation() {
+ IPath state = ASTest.getDefault().getStateLocation();
+ if( state.toFile().exists()) {
+ File[] children = state.toFile().listFiles();
+ for( int i = 0; i < children.length; i++ ) {
+ FileUtil.safeDelete(children[i]);
+ }
+ }
+ }
+
+
+
}
Modified: trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/publishing/v2/JSTDeployBinaryChildModuleTest.java
===================================================================
--- trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/publishing/v2/JSTDeployBinaryChildModuleTest.java 2010-11-01 14:08:51 UTC (rev 26161)
+++ trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/publishing/v2/JSTDeployBinaryChildModuleTest.java 2010-11-01 14:17:36 UTC (rev 26162)
@@ -14,6 +14,7 @@
import org.eclipse.wst.server.core.IModule;
import org.eclipse.wst.server.core.ServerUtil;
import org.jboss.ide.eclipse.as.test.publishing.AbstractDeploymentTest;
+import org.jboss.ide.eclipse.as.test.util.ServerRuntimeUtils;
import org.jboss.ide.eclipse.as.test.util.wtp.JavaEEFacetConstants;
import org.jboss.ide.eclipse.as.test.util.wtp.OperationTestCase;
import org.jboss.ide.eclipse.as.test.util.wtp.ProjectCreationUtil;
@@ -37,9 +38,9 @@
IModule mod = ServerUtil.getModule(project);
IModule[] module = new IModule[] { mod };
verifyJSTPublisher(module);
- addModule(mod);
- publish();
- IPath deployRoot = new Path(getDeployRoot(server));
+ server = ServerRuntimeUtils.addModule(server, mod);
+ ServerRuntimeUtils.publish(server);
+ IPath deployRoot = new Path(ServerRuntimeUtils.getDeployRoot(server));
IPath rootFolder = deployRoot.append(MODULE_NAME + ".war");
assertTrue(rootFolder.toFile().exists());
IPath webinf_lib_testjar = rootFolder.append("WEB-INF").append("lib").append("test.jar");
Modified: trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/publishing/v2/JSTDeploymentTester.java
===================================================================
--- trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/publishing/v2/JSTDeploymentTester.java 2010-11-01 14:08:51 UTC (rev 26161)
+++ trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/publishing/v2/JSTDeploymentTester.java 2010-11-01 14:17:36 UTC (rev 26162)
@@ -1,11 +1,7 @@
package org.jboss.ide.eclipse.as.test.publishing.v2;
-import java.io.BufferedInputStream;
-import java.io.ByteArrayInputStream;
import java.io.File;
-import java.io.FileInputStream;
import java.io.IOException;
-import java.io.InputStream;
import junit.framework.TestCase;
@@ -14,34 +10,21 @@
import org.eclipse.core.resources.ResourcesPlugin;
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.wst.common.frameworks.datamodel.IDataModel;
import org.eclipse.wst.server.core.IModule;
-import org.eclipse.wst.server.core.IRuntime;
-import org.eclipse.wst.server.core.IRuntimeType;
-import org.eclipse.wst.server.core.IRuntimeWorkingCopy;
import org.eclipse.wst.server.core.IServer;
-import org.eclipse.wst.server.core.IServerType;
-import org.eclipse.wst.server.core.IServerWorkingCopy;
-import org.eclipse.wst.server.core.ServerCore;
import org.eclipse.wst.server.core.ServerUtil;
-import org.eclipse.wst.server.core.internal.ServerWorkingCopy;
import org.jboss.ide.eclipse.as.core.ExtensionManager;
import org.jboss.ide.eclipse.as.core.publishers.JstPublisher;
-import org.jboss.ide.eclipse.as.core.server.IDeployableServer;
import org.jboss.ide.eclipse.as.core.server.IJBossServerPublisher;
-import org.jboss.ide.eclipse.as.core.server.internal.DeployableServer;
-import org.jboss.ide.eclipse.as.core.util.FileUtil;
-import org.jboss.ide.eclipse.as.core.util.ServerConverter;
import org.jboss.ide.eclipse.as.test.ASTest;
+import org.jboss.ide.eclipse.as.test.util.IOUtil;
import org.jboss.ide.eclipse.as.test.util.ServerRuntimeUtils;
import org.jboss.ide.eclipse.as.test.util.wtp.JavaEEFacetConstants;
import org.jboss.ide.eclipse.as.test.util.wtp.OperationTestCase;
import org.jboss.ide.eclipse.as.test.util.wtp.ProjectCreationUtil;
import org.jboss.ide.eclipse.as.test.util.wtp.ProjectUtility;
-import org.jboss.tools.test.util.JobUtils;
public class JSTDeploymentTester extends TestCase {
@@ -53,14 +36,14 @@
final IPath CONTENT_TEXT_FILE = new Path(CONTENT_DIR).append(TEXT_FILE);
public void setUp() throws Exception {
project = createProject();
- server = createServer();
+ server = ServerRuntimeUtils.createMockDeployOnlyServer();
}
public void tearDown() throws Exception {
ServerRuntimeUtils.deleteAllServers();
ServerRuntimeUtils.deleteAllRuntimes();
ProjectUtility.deleteAllProjects();
- clearStateLocation();
+ ASTest.clearStateLocation();
}
protected IProject createProject() throws Exception {
@@ -70,110 +53,19 @@
assertTrue(p.exists());
return p;
}
-
- protected IServer createServer() throws CoreException {
- IPath state = ASTest.getDefault().getStateLocation();
- IPath deploy = state.append("testDeployments").append("deploy");
- IPath tmpDeploy = state.append("testDeployments").append("tmpDeploy");
- return createServer(deploy.toOSString(), tmpDeploy.toOSString());
- }
-
- protected void clearStateLocation() {
- IPath state = ASTest.getDefault().getStateLocation();
- if( state.toFile().exists()) {
- File[] children = state.toFile().listFiles();
- for( int i = 0; i < children.length; i++ ) {
- FileUtil.safeDelete(children[i]);
- }
- }
- }
-
- protected String getDeployRoot(IServer server) {
- IDeployableServer ds = ServerConverter.getDeployableServer(server);
- return ds.getDeployFolder();
- }
-
- protected IServer createServer(String deployLocation, String tempDeployLocation) throws CoreException {
- IRuntimeType rt = ServerCore.findRuntimeType("org.jboss.ide.eclipse.as.runtime.stripped");
- IRuntimeWorkingCopy wc = rt.createRuntime("testRuntime", null);
- IRuntime runtime = wc.save(true, null);
- IServerType st = ServerCore.findServerType("org.jboss.ide.eclipse.as.systemCopyServer");
- ServerWorkingCopy swc = (ServerWorkingCopy) st.createServer("testServer", null, null);
- swc.setServerConfiguration(null);
- swc.setName("testServer");
- swc.setRuntime(runtime);
- swc.setAttribute(DeployableServer.DEPLOY_DIRECTORY, deployLocation);
- swc.setAttribute(DeployableServer.TEMP_DEPLOY_DIRECTORY, tempDeployLocation);
- IServer server = swc.save(true, null);
- return server;
- }
-
- protected IStatus publish() throws CoreException {
- return server.publish(IServer.PUBLISH_INCREMENTAL, new NullProgressMonitor());
- }
-
- protected void addModule(IModule module) throws CoreException {
- IServerWorkingCopy copy = server.createWorkingCopy();
- copy.modifyModules(new IModule[]{module}, new IModule[0], new NullProgressMonitor());
- server = copy.save(false, new NullProgressMonitor());
- }
-
- protected void removeModule(IModule module) throws CoreException {
- IServerWorkingCopy copy = server.createWorkingCopy();
- copy.modifyModules(new IModule[]{}, new IModule[] {module}, new NullProgressMonitor());
- server = copy.save(false, new NullProgressMonitor());
- }
-
+
protected void verifyJSTPublisher(IModule[] module) {
IJBossServerPublisher publisher = ExtensionManager
.getDefault().getPublisher(server, module, "local");
assertTrue(publisher instanceof JstPublisher);
}
-
- public int countFiles(File root) {
- int count = 0;
- if( !root.isDirectory() )
- return 1;
- File[] children = root.listFiles();
- for( int i = 0; i < children.length; i++ )
- count += countFiles(children[i]);
- return count;
- }
-
- public int countAllResources(File root) {
- int count = 0;
- if( !root.isDirectory() )
- return 1;
- File[] children = root.listFiles();
- for( int i = 0; i < children.length; i++ )
- count += countFiles(children[i]);
- return 1 + count;
- }
-
-
- protected void setContents(IFile file, int val) throws IOException , CoreException{
- setContents(file, "" + val);
- }
-
- protected void setContents(IFile file, String val) throws IOException , CoreException{
- if( !file.exists())
- file.create(new ByteArrayInputStream((val).getBytes()), false, null);
- else
- file.setContents(new ByteArrayInputStream((val).getBytes()), false, false, new NullProgressMonitor());
- try {
- Thread.sleep(2000);
- } catch( InterruptedException ie) {}
- JobUtils.waitForIdle();
- }
-
protected void assertContents(IFile file, int val) throws IOException, CoreException {
assertContents(file, "" + val);
}
protected void assertContents(IFile file, String val) throws IOException, CoreException {
- String contents = getContents(file);
- assertEquals(val, contents);
+ assertEquals(val, IOUtil.getContents(file));
}
protected void assertContents(File file, int val) throws IOException, CoreException {
@@ -181,68 +73,40 @@
}
protected void assertContents(File file, String val) throws IOException, CoreException {
- String contents = getContents(file);
- assertEquals(val, contents);
+ assertEquals(val, IOUtil.getContents(file));
}
- protected String getContents(IFile file) throws IOException, CoreException {
- BufferedInputStream bis = new BufferedInputStream(file.getContents());
- int l = (int)file.getLocation().toFile().length();
- byte[] bs = new byte[l];
- l = bis.read(bs, 0, l);
- bis.close();
- return new String(bs);
- }
-
- public static byte[] getBytesFromFile(File file) throws IOException {
- InputStream is = new FileInputStream(file);
- byte[] bytes = new byte[(int)file.length()];
- int offset = 0;
- int numRead = 0;
- while (offset < bytes.length
- && (numRead=is.read(bytes, offset, bytes.length-offset)) >= 0) {
- offset += numRead;
- }
- is.close();
- return bytes;
- }
-
- static public String getContents(File aFile) throws IOException {
- return new String(getBytesFromFile(aFile));
- }
-
-
public void testMain() throws CoreException, IOException {
IModule mod = ServerUtil.getModule(project);
IModule[] module = new IModule[] { mod };
verifyJSTPublisher(module);
- addModule(mod);
- publish();
- IPath deployRoot = new Path(getDeployRoot(server));
+ server = ServerRuntimeUtils.addModule(server,mod);
+ ServerRuntimeUtils.publish(server);
+ IPath deployRoot = new Path(ServerRuntimeUtils.getDeployRoot(server));
IPath rootFolder = deployRoot.append(MODULE_NAME + ".ear");
assertTrue(rootFolder.toFile().exists());
- assertTrue(countFiles(rootFolder.toFile()) == 0);
- assertTrue(countAllResources(rootFolder.toFile()) == 1);
+ assertTrue(IOUtil.countFiles(rootFolder.toFile()) == 0);
+ assertTrue(IOUtil.countAllResources(rootFolder.toFile()) == 1);
IFile textFile = project.getFile(CONTENT_TEXT_FILE);
- setContents(textFile, 0);
- assertEquals(countFiles(rootFolder.toFile()), 0);
- assertTrue(countAllResources(rootFolder.toFile()) == 1);
- publish();
- assertEquals(countFiles(rootFolder.toFile()), 1);
- assertTrue(countAllResources(rootFolder.toFile()) == 2);
+ IOUtil.setContents(textFile, 0);
+ assertEquals(IOUtil.countFiles(rootFolder.toFile()), 0);
+ assertTrue(IOUtil.countAllResources(rootFolder.toFile()) == 1);
+ ServerRuntimeUtils.publish(server);
+ assertEquals(IOUtil.countFiles(rootFolder.toFile()), 1);
+ assertTrue(IOUtil.countAllResources(rootFolder.toFile()) == 2);
assertContents(rootFolder.append(TEXT_FILE).toFile(), 0);
- setContents(textFile, 1);
- publish();
+ IOUtil.setContents(textFile, 1);
+ ServerRuntimeUtils.publish(server);
assertContents(rootFolder.append(TEXT_FILE).toFile(), 1);
textFile.delete(true, null);
- assertEquals(countFiles(rootFolder.toFile()), 1);
- assertTrue(countAllResources(rootFolder.toFile()) == 2);
- publish();
- assertEquals(countFiles(rootFolder.toFile()), 0);
- assertTrue(countAllResources(rootFolder.toFile()) == 1);
- removeModule(mod);
+ assertEquals(IOUtil.countFiles(rootFolder.toFile()), 1);
+ assertTrue(IOUtil.countAllResources(rootFolder.toFile()) == 2);
+ ServerRuntimeUtils.publish(server);
+ assertEquals(IOUtil.countFiles(rootFolder.toFile()), 0);
+ assertTrue(IOUtil.countAllResources(rootFolder.toFile()) == 1);
+ server = ServerRuntimeUtils.removeModule(server, mod);
assertTrue(rootFolder.toFile().exists());
- publish();
+ ServerRuntimeUtils.publish(server);
assertFalse(rootFolder.toFile().exists());
}
}
Modified: trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/publishing/v2/JSTZippedDeploymentTester.java
===================================================================
--- trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/publishing/v2/JSTZippedDeploymentTester.java 2010-11-01 14:08:51 UTC (rev 26161)
+++ trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/publishing/v2/JSTZippedDeploymentTester.java 2010-11-01 14:17:36 UTC (rev 26162)
@@ -2,12 +2,10 @@
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
-import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
-import java.io.InputStream;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;
@@ -42,12 +40,12 @@
import org.jboss.ide.eclipse.as.core.util.ServerConverter;
import org.jboss.ide.eclipse.as.test.ASTest;
import org.jboss.ide.eclipse.as.test.publishing.AbstractDeploymentTest;
+import org.jboss.ide.eclipse.as.test.util.IOUtil;
import org.jboss.ide.eclipse.as.test.util.ServerRuntimeUtils;
import org.jboss.ide.eclipse.as.test.util.wtp.JavaEEFacetConstants;
import org.jboss.ide.eclipse.as.test.util.wtp.OperationTestCase;
import org.jboss.ide.eclipse.as.test.util.wtp.ProjectCreationUtil;
import org.jboss.ide.eclipse.as.test.util.wtp.ProjectUtility;
-import org.jboss.tools.test.util.JobUtils;
public class JSTZippedDeploymentTester extends TestCase {
@@ -59,7 +57,7 @@
final IPath CONTENT_TEXT_FILE = new Path(CONTENT_DIR).append(TEXT_FILE);
public void setUp() throws Exception {
project = createProject();
- server = createServer();
+ server = ServerRuntimeUtils.createMockDeployOnlyServer();
IServerWorkingCopy wc = server.createWorkingCopy();
ServerAttributeHelper helper = new ServerAttributeHelper(server, wc);
helper.setAttribute(IDeployableServer.ZIP_DEPLOYMENTS_PREF, true);
@@ -70,7 +68,7 @@
ServerRuntimeUtils.deleteAllServers();
ServerRuntimeUtils.deleteAllRuntimes();
ProjectUtility.deleteAllProjects();
- clearStateLocation();
+ ASTest.clearStateLocation();
}
protected IProject createProject() throws Exception {
@@ -86,111 +84,23 @@
p.refreshLocal(IResource.DEPTH_INFINITE, new NullProgressMonitor());
return p;
}
-
- protected IServer createServer() throws CoreException {
- IPath state = ASTest.getDefault().getStateLocation();
- IPath deploy = state.append("testDeployments").append("deploy");
- IPath tmpDeploy = state.append("testDeployments").append("tmpDeploy");
- return createServer(deploy.toOSString(), tmpDeploy.toOSString());
- }
-
- protected void clearStateLocation() {
- IPath state = ASTest.getDefault().getStateLocation();
- if( state.toFile().exists()) {
- File[] children = state.toFile().listFiles();
- for( int i = 0; i < children.length; i++ ) {
- FileUtil.safeDelete(children[i]);
- }
- }
- }
-
- protected String getDeployRoot(IServer server) {
- IDeployableServer ds = ServerConverter.getDeployableServer(server);
- return ds.getDeployFolder();
- }
-
- protected IServer createServer(String deployLocation, String tempDeployLocation) throws CoreException {
- IRuntimeType rt = ServerCore.findRuntimeType("org.jboss.ide.eclipse.as.runtime.stripped");
- IRuntimeWorkingCopy wc = rt.createRuntime("testRuntime", null);
- wc.setLocation(ASTest.getDefault().getStateLocation());
- IRuntime runtime = wc.save(true, null);
- IServerType st = ServerCore.findServerType("org.jboss.ide.eclipse.as.systemCopyServer");
- ServerWorkingCopy swc = (ServerWorkingCopy) st.createServer("testServer", null, null);
- swc.setServerConfiguration(null);
- swc.setName("testServer");
- swc.setRuntime(runtime);
- swc.setAttribute(DeployableServer.DEPLOY_DIRECTORY, deployLocation);
- swc.setAttribute(DeployableServer.TEMP_DEPLOY_DIRECTORY, tempDeployLocation);
- IServer server = swc.save(true, null);
- return server;
- }
-
- protected IStatus publish() throws CoreException {
- return server.publish(IServer.PUBLISH_INCREMENTAL, new NullProgressMonitor());
- }
-
- protected void addModule(IModule module) throws CoreException {
- IServerWorkingCopy copy = server.createWorkingCopy();
- copy.modifyModules(new IModule[]{module}, new IModule[0], new NullProgressMonitor());
- server = copy.save(false, new NullProgressMonitor());
- }
-
- protected void removeModule(IModule module) throws CoreException {
- IServerWorkingCopy copy = server.createWorkingCopy();
- copy.modifyModules(new IModule[]{}, new IModule[] {module}, new NullProgressMonitor());
- server = copy.save(false, new NullProgressMonitor());
- }
-
+
protected void verifyJSTZippedPublisher(IModule[] module) {
IJBossServerPublisher publisher = ExtensionManager
.getDefault().getPublisher(server, module, "local");
assertTrue(publisher.getClass().getName().contains("WTPZippedPublisher"));
}
- public int countFiles(File root) {
- int count = 0;
- if( !root.isDirectory() )
- return 1;
- File[] children = root.listFiles();
- for( int i = 0; i < children.length; i++ )
- count += countFiles(children[i]);
- return count;
- }
-
- public int countAllResources(File root) {
- int count = 0;
- if( !root.isDirectory() )
- return 1;
- File[] children = root.listFiles();
- for( int i = 0; i < children.length; i++ )
- count += countFiles(children[i]);
- return 1 + count;
- }
-
-
-
protected void setContents(IFile file, int val) throws IOException , CoreException{
- setContents(file, "" + val);
+ IOUtil.setContents(file, "" + val);
}
-
- protected void setContents(IFile file, String val) throws IOException , CoreException{
- if( !file.exists())
- file.create(new ByteArrayInputStream((val).getBytes()), false, null);
- else
- file.setContents(new ByteArrayInputStream((val).getBytes()), false, false, new NullProgressMonitor());
- try {
- Thread.sleep(2000);
- } catch( InterruptedException ie) {}
- JobUtils.waitForIdle();
- }
-
+
protected void assertContents(IFile file, int val) throws IOException, CoreException {
assertContents(file, "" + val);
}
protected void assertContents(IFile file, String val) throws IOException, CoreException {
- String contents = getContents(file);
- assertEquals(val, contents);
+ assertEquals(val, IOUtil.getContents(file));
}
protected void assertContents(File file, int val) throws IOException, CoreException {
@@ -198,37 +108,9 @@
}
protected void assertContents(File file, String val) throws IOException, CoreException {
- String contents = getContents(file);
- assertEquals(val, contents);
+ assertEquals(val, IOUtil.getContents(file));
}
-
- protected String getContents(IFile file) throws IOException, CoreException {
- BufferedInputStream bis = new BufferedInputStream(file.getContents());
- int l = (int)file.getLocation().toFile().length();
- byte[] bs = new byte[l];
- l = bis.read(bs, 0, l);
- bis.close();
- return new String(bs);
- }
- public static byte[] getBytesFromFile(File file) throws IOException {
- InputStream is = new FileInputStream(file);
- byte[] bytes = new byte[(int)file.length()];
- int offset = 0;
- int numRead = 0;
- while (offset < bytes.length
- && (numRead=is.read(bytes, offset, bytes.length-offset)) >= 0) {
- offset += numRead;
- }
- is.close();
- return bytes;
- }
-
- static public String getContents(File aFile) throws IOException {
- return new String(getBytesFromFile(aFile));
- }
-
-
public void testMain() throws CoreException, IOException {
IModule[] mods = ServerUtil.getModules(project);
IModule mod = null;
@@ -240,55 +122,24 @@
assertNotNull(mod);
IModule[] module = new IModule[] { mod };
verifyJSTZippedPublisher(module);
- addModule(mod);
- publish();
+ server = ServerRuntimeUtils.addModule(server, mod);
+ ServerRuntimeUtils.publish(server);
IPath projLoc = project.getLocation();
System.out.println(projLoc);
- IPath deployRoot = new Path(getDeployRoot(server));
+ IPath deployRoot = new Path(ServerRuntimeUtils.getDeployRoot(server));
IPath zipped = deployRoot.append(MODULE_NAME + ".ear");
assertTrue(zipped.toFile().exists());
assertTrue(zipped.toFile().isFile());
IPath unzip1 = ASTest.getDefault().getStateLocation().append("unzip1");
IPath unzip2 = ASTest.getDefault().getStateLocation().append("unzip2");
- unzipFile(zipped,unzip1);
+ IOUtil.unzipFile(zipped,unzip1);
assertTrue(unzip1.toFile().list().length == 1);
- unzipFile(unzip1.append("mvel2.jar"), unzip2);
+ IOUtil.unzipFile(unzip1.append("mvel2.jar"), unzip2);
assertTrue(unzip2.toFile().list().length > 1);
System.out.println("end");
- removeModule(mod);
- publish();
+ server = ServerRuntimeUtils.removeModule(server, mod);
+ ServerRuntimeUtils.publish(server);
assertFalse(zipped.toFile().exists());
}
-
-
- public static void unzipFile(IPath zipped, IPath toLoc) {
- toLoc.toFile().mkdirs();
- final int BUFFER = 2048;
- try {
- BufferedOutputStream dest = null;
- FileInputStream fis = new
- FileInputStream(zipped.toFile());
- ZipInputStream zis = new ZipInputStream(new BufferedInputStream(fis));
- ZipEntry entry;
- while((entry = zis.getNextEntry()) != null) {
- int count;
- byte data[] = new byte[BUFFER];
- // write the files to the disk
- toLoc.append(entry.getName()).toFile().getParentFile().mkdirs();
- if( !toLoc.append(entry.getName()).toFile().exists()) {
- FileOutputStream fos = new FileOutputStream(toLoc.append(entry.getName()).toOSString());
- dest = new BufferedOutputStream(fos, BUFFER);
- while ((count = zis.read(data, 0, BUFFER)) != -1) {
- dest.write(data, 0, count);
- }
- dest.flush();
- dest.close();
- }
- }
- zis.close();
- } catch(Exception e) {
- e.printStackTrace();
- }
- }
}
Modified: trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/publishing/v2/SingleFileDeploymentTester.java
===================================================================
--- trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/publishing/v2/SingleFileDeploymentTester.java 2010-11-01 14:08:51 UTC (rev 26161)
+++ trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/publishing/v2/SingleFileDeploymentTester.java 2010-11-01 14:17:36 UTC (rev 26162)
@@ -1,61 +1,174 @@
package org.jboss.ide.eclipse.as.test.publishing.v2;
+import java.io.File;
import java.io.IOException;
import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IFolder;
+import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Path;
import org.eclipse.wst.server.core.IModule;
import org.jboss.ide.eclipse.as.core.ExtensionManager;
import org.jboss.ide.eclipse.as.core.modules.SingleDeployableFactory;
import org.jboss.ide.eclipse.as.core.publishers.SingleFilePublisher;
import org.jboss.ide.eclipse.as.core.server.IJBossServerPublisher;
+import org.jboss.ide.eclipse.as.test.ASTest;
+import org.jboss.ide.eclipse.as.test.util.IOUtil;
+import org.jboss.ide.eclipse.as.test.util.ServerRuntimeUtils;
public class SingleFileDeploymentTester extends JSTDeploymentTester {
- public void testMain() throws CoreException, IOException {
- IFile file = createXMLFile();
+ public void testSingleFile() throws CoreException, IOException {
+ final String filename = "test.xml";
+ IResource file = createFile(filename, "<test>done</test>");
IModule[] mods = SingleDeployableFactory.getFactory().getModules();
assertEquals(mods.length, 0);
SingleDeployableFactory.makeDeployable(file);
mods = SingleDeployableFactory.getFactory().getModules();
assertEquals(mods.length, 1);
- verifyPublisher(mods[0]);
- addModule(mods[0]);
- IPath deployRoot = new Path(getDeployRoot(server));
+ verifyPublisher(mods[0], SingleFilePublisher.class);
+ server = ServerRuntimeUtils.addModule(server, mods[0]);
+ IPath deployRoot = new Path(ServerRuntimeUtils.getDeployRoot(server));
deployRoot.toFile().mkdirs();
- assertEquals(countFiles(deployRoot.toFile()), 0);
- assertEquals(countAllResources(deployRoot.toFile()), 1);
- publish();
- assertEquals(countFiles(deployRoot.toFile()), 1);
- assertEquals(countAllResources(deployRoot.toFile()), 2);
+ assertEquals(IOUtil.countFiles(deployRoot.toFile()), 0);
+ assertEquals(IOUtil.countAllResources(deployRoot.toFile()), 1);
+ ServerRuntimeUtils.publish(server);
+ assertEquals(IOUtil.countFiles(deployRoot.toFile()), 1);
+ assertEquals(IOUtil.countAllResources(deployRoot.toFile()), 2);
assertContents(deployRoot.append("test.xml").toFile(),
"<test>done</test>");
- setContents(file, "<test>done2</test>");
+ IOUtil.setContents(project.getFile(filename), "<test>done2</test>");
assertContents(deployRoot.append("test.xml").toFile(),
"<test>done</test>");
- publish();
+ ServerRuntimeUtils.publish(server);
assertContents(deployRoot.append("test.xml").toFile(),
"<test>done2</test>");
- removeModule(mods[0]);
+ server = ServerRuntimeUtils.removeModule(server, mods[0]);
assertContents(deployRoot.append("test.xml").toFile(),
"<test>done2</test>");
- assertEquals(countAllResources(deployRoot.toFile()), 2);
- publish();
+ assertEquals(IOUtil.countAllResources(deployRoot.toFile()), 2);
+ ServerRuntimeUtils.publish(server);
assertFalse(deployRoot.append("test.xml").toFile().exists());
- assertEquals(countAllResources(deployRoot.toFile()), 1);
+ assertEquals(IOUtil.countAllResources(deployRoot.toFile()), 1);
}
- protected void verifyPublisher(IModule module) {
+ protected void verifyPublisher(IModule module, Class c) {
IModule[] mod = new IModule[] { module };
IJBossServerPublisher publisher = ExtensionManager
.getDefault().getPublisher(server, mod, "local");
- assertTrue(publisher instanceof SingleFilePublisher);
+ assertTrue(publisher.getClass().equals(c));
}
- protected IFile createXMLFile() throws CoreException, IOException {
- IFile xmlFile = project.getFile("test.xml");
- setContents(xmlFile, "<test>done</test>");
- return xmlFile;
+ protected IFile createFile(String filename, String contents) throws CoreException, IOException {
+ IFile resource = project.getFile(filename);
+ IOUtil.setContents(resource, contents);
+ return resource;
}
+
+ public void testSingleFolder() throws CoreException, IOException {
+ final String folderName = "test";
+ IFolder folder = project.getFolder(folderName);
+ folder.create(true, true, new NullProgressMonitor());
+ IOUtil.setContents(folder.getFile("1.txt"), "1");
+ IOUtil.setContents(folder.getFile("2.txt"), "2");
+ IOUtil.setContents(folder.getFile("3.txt"), "3");
+ IModule[] mods = SingleDeployableFactory.getFactory().getModules();
+ assertEquals(mods.length, 0);
+ SingleDeployableFactory.makeDeployable(folder);
+ mods = SingleDeployableFactory.getFactory().getModules();
+ assertEquals(mods.length, 1);
+ verifyPublisher(mods[0], SingleFilePublisher.class);
+ server = ServerRuntimeUtils.addModule(server, mods[0]);
+ IPath deployRoot = new Path(ServerRuntimeUtils.getDeployRoot(server));
+ deployRoot.toFile().mkdirs();
+ assertEquals(IOUtil.countFiles(deployRoot.toFile()), 0);
+ assertEquals(IOUtil.countAllResources(deployRoot.toFile()), 1);
+ ServerRuntimeUtils.publish(server);
+ assertEquals(IOUtil.countFiles(deployRoot.toFile()), 3);
+ assertEquals(IOUtil.countAllResources(deployRoot.toFile()), 4);
+ File folder2 = deployRoot.toFile().listFiles()[0];
+ assertTrue(folder2.getName().equals(folderName));
+ File[] folderChildren = folder2.listFiles();
+ assertTrue(folderChildren.length == 3);
+ File three = new File(folder2, "3.txt");
+ assertEquals(IOUtil.getContents(three), "3");
+ IOUtil.setContents(folder.getFile("3.txt"), "3a");
+ ServerRuntimeUtils.publish(server);
+ assertEquals(IOUtil.countFiles(deployRoot.toFile()), 3);
+ assertEquals(IOUtil.countAllResources(deployRoot.toFile()), 4);
+ folder2 = deployRoot.toFile().listFiles()[0];
+ assertTrue(folder2.getName().equals(folderName));
+ folderChildren = folder2.listFiles();
+ assertTrue(folderChildren.length == 3);
+ three = new File(folder2, "3.txt");
+ assertEquals(IOUtil.getContents(three), "3a");
+ }
+
+ public void testSingleFileZipped() throws CoreException, IOException {
+ server = ServerRuntimeUtils.setZipped(server, true);
+ try {
+ testSingleFile();
+ } finally {
+ server = ServerRuntimeUtils.setZipped(server, false);
+ }
+ }
+
+ public void testSingleFolderZipped() throws CoreException, IOException {
+ server = ServerRuntimeUtils.setZipped(server, true);
+ try {
+ singleFolderZippedInternal2();
+ } finally {
+ server = ServerRuntimeUtils.setZipped(server, false);
+ }
+ }
+
+ public void singleFolderZippedInternal2() throws CoreException, IOException {
+ // create proj and files
+ final String folderName = "test";
+ IFolder folder = project.getFolder(folderName);
+ folder.create(true, true, new NullProgressMonitor());
+ IOUtil.setContents(folder.getFile("1.txt"), "1");
+ IOUtil.setContents(folder.getFile("2.txt"), "2");
+ IOUtil.setContents(folder.getFile("3.txt"), "3");
+ IModule[] mods = SingleDeployableFactory.getFactory().getModules();
+ assertEquals(mods.length, 0);
+
+ // make deployable, do checks
+ SingleDeployableFactory.makeDeployable(folder);
+ mods = SingleDeployableFactory.getFactory().getModules();
+ assertEquals(mods.length, 1);
+ server = ServerRuntimeUtils.addModule(server, mods[0]);
+ IPath deployRoot = new Path(ServerRuntimeUtils.getDeployRoot(server));
+ deployRoot.toFile().mkdirs();
+ assertEquals(IOUtil.countFiles(deployRoot.toFile()), 0);
+ assertEquals(IOUtil.countAllResources(deployRoot.toFile()), 1);
+
+ // publish and verify deployment
+ ServerRuntimeUtils.publish(server);
+ assertEquals(IOUtil.countFiles(deployRoot.toFile()), 1);
+ assertEquals(IOUtil.countAllResources(deployRoot.toFile()), 2);
+
+ // unzip, verify 3.txt
+ IPath unzip1 = ASTest.getDefault().getStateLocation().append("unzip1");
+ IOUtil.unzipFile(deployRoot.append(folderName),unzip1);
+ assertEquals(IOUtil.countFiles(unzip1.toFile()), 3);
+ String deploy3txt1 = IOUtil.getContents(unzip1.append("3.txt").toFile());
+ assertEquals("3", deploy3txt1);
+
+ // make workspace change, repeat
+ IOUtil.setContents(folder.getFile("3.txt"), "3a");
+ ServerRuntimeUtils.publish(server);
+ assertEquals(IOUtil.countFiles(deployRoot.toFile()), 1);
+ assertEquals(IOUtil.countAllResources(deployRoot.toFile()), 2);
+
+ // verify new changes
+ IPath unzip2 = ASTest.getDefault().getStateLocation().append("unzip2");
+ IOUtil.unzipFile(deployRoot.append(folderName),unzip2);
+ assertEquals(IOUtil.countFiles(unzip2.toFile()), 3);
+ String deploy3txt2 = IOUtil.getContents(unzip2.append("3.txt").toFile());
+ assertEquals("3a", deploy3txt2);
+
+ }
}
Added: trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/util/IOUtil.java
===================================================================
--- trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/util/IOUtil.java (rev 0)
+++ trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/util/IOUtil.java 2010-11-01 14:17:36 UTC (rev 26162)
@@ -0,0 +1,107 @@
+package org.jboss.ide.eclipse.as.test.util;
+
+import java.io.BufferedInputStream;
+import java.io.BufferedOutputStream;
+import java.io.ByteArrayInputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipInputStream;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.jboss.tools.test.util.JobUtils;
+
+public class IOUtil {
+ public static String getContents(IFile file) throws IOException, CoreException {
+ return getContents(file.getLocation().toFile());
+ }
+
+ public static String getContents(File aFile) throws IOException {
+ return new String(getBytesFromFile(aFile));
+ }
+
+ public static byte[] getBytesFromFile(File file) throws IOException {
+ InputStream is = new FileInputStream(file);
+ byte[] bytes = new byte[(int)file.length()];
+ int offset = 0;
+ int numRead = 0;
+ while (offset < bytes.length
+ && (numRead=is.read(bytes, offset, bytes.length-offset)) >= 0) {
+ offset += numRead;
+ }
+ is.close();
+ return bytes;
+ }
+
+ public static void setContents(IFile file, int val) throws IOException , CoreException{
+ setContents(file, "" + val);
+ }
+
+ public static void setContents(IFile file, String val) throws IOException , CoreException{
+ if( !file.exists())
+ file.create(new ByteArrayInputStream((val).getBytes()), false, null);
+ else
+ file.setContents(new ByteArrayInputStream((val).getBytes()), false, false, new NullProgressMonitor());
+ try {
+ Thread.sleep(2000);
+ } catch( InterruptedException ie) {}
+ JobUtils.waitForIdle();
+ }
+
+ public static int countFiles(File root) {
+ int count = 0;
+ if( !root.isDirectory() )
+ return 1;
+ File[] children = root.listFiles();
+ for( int i = 0; i < children.length; i++ )
+ count += countFiles(children[i]);
+ return count;
+ }
+
+ public static int countAllResources(File root) {
+ int count = 0;
+ if( !root.isDirectory() )
+ return 1;
+ File[] children = root.listFiles();
+ for( int i = 0; i < children.length; i++ )
+ count += countFiles(children[i]);
+ return 1 + count;
+ }
+
+ public static void unzipFile(IPath zipped, IPath toLoc) {
+ toLoc.toFile().mkdirs();
+ final int BUFFER = 2048;
+ try {
+ BufferedOutputStream dest = null;
+ FileInputStream fis = new
+ FileInputStream(zipped.toFile());
+ ZipInputStream zis = new ZipInputStream(new BufferedInputStream(fis));
+ ZipEntry entry;
+ while((entry = zis.getNextEntry()) != null) {
+ int count;
+ byte data[] = new byte[BUFFER];
+ // write the files to the disk
+ toLoc.append(entry.getName()).toFile().getParentFile().mkdirs();
+ if( !toLoc.append(entry.getName()).toFile().exists()) {
+ FileOutputStream fos = new FileOutputStream(toLoc.append(entry.getName()).toOSString());
+ dest = new BufferedOutputStream(fos, BUFFER);
+ while ((count = zis.read(data, 0, BUFFER)) != -1) {
+ dest.write(data, 0, count);
+ }
+ dest.flush();
+ dest.close();
+ }
+ }
+ zis.close();
+ } catch(Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+}
Modified: trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/util/ServerRuntimeUtils.java
===================================================================
--- trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/util/ServerRuntimeUtils.java 2010-11-01 14:08:51 UTC (rev 26161)
+++ trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/util/ServerRuntimeUtils.java 2010-11-01 14:17:36 UTC (rev 26162)
@@ -17,6 +17,7 @@
import org.eclipse.core.runtime.Status;
import org.eclipse.jdt.launching.IVMInstall;
import org.eclipse.jdt.launching.JavaRuntime;
+import org.eclipse.wst.server.core.IModule;
import org.eclipse.wst.server.core.IRuntime;
import org.eclipse.wst.server.core.IRuntimeType;
import org.eclipse.wst.server.core.IRuntimeWorkingCopy;
@@ -26,9 +27,14 @@
import org.eclipse.wst.server.core.ServerCore;
import org.eclipse.wst.server.core.ServerUtil;
import org.eclipse.wst.server.core.internal.RuntimeWorkingCopy;
+import org.eclipse.wst.server.core.internal.ServerWorkingCopy;
+import org.jboss.ide.eclipse.as.core.server.IDeployableServer;
import org.jboss.ide.eclipse.as.core.server.IJBossServerRuntime;
+import org.jboss.ide.eclipse.as.core.server.internal.DeployableServer;
+import org.jboss.ide.eclipse.as.core.server.internal.ServerAttributeHelper;
import org.jboss.ide.eclipse.as.core.util.FileUtil;
import org.jboss.ide.eclipse.as.core.util.IJBossToolingConstants;
+import org.jboss.ide.eclipse.as.core.util.ServerConverter;
import org.jboss.ide.eclipse.as.test.ASTest;
import org.jboss.ide.eclipse.as.test.publishing.AbstractDeploymentTest;
import org.osgi.framework.Bundle;
@@ -70,8 +76,35 @@
serverRuntimeMap.put(IJBossToolingConstants.SERVER_AS_60, IJBossToolingConstants.AS_60);
serverRuntimeMap.put(IJBossToolingConstants.SERVER_EAP_43, IJBossToolingConstants.EAP_43);
serverRuntimeMap.put(IJBossToolingConstants.SERVER_EAP_50, IJBossToolingConstants.EAP_50);
-}
+ }
+ public static IServer createMockDeployOnlyServer() throws CoreException {
+ IPath state = ASTest.getDefault().getStateLocation();
+ IPath deploy = state.append("testDeployments").append("deploy");
+ IPath tmpDeploy = state.append("testDeployments").append("tmpDeploy");
+ return ServerRuntimeUtils.createMockDeployOnlyServer(deploy.toOSString(),
+ tmpDeploy.toOSString());
+ }
+ public static IServer createMockDeployOnlyServer(String deployLocation, String tempDeployLocation) throws CoreException {
+ return createMockDeployOnlyServer(deployLocation, tempDeployLocation, "testRuntime", "testServer");
+ }
+ public static IServer createMockDeployOnlyServer(String deployLocation, String tempDeployLocation,
+ String rtName, String serverName) throws CoreException {
+ IRuntimeType rt = ServerCore.findRuntimeType("org.jboss.ide.eclipse.as.runtime.stripped");
+ IRuntimeWorkingCopy wc = rt.createRuntime(rtName, null);
+ IRuntime runtime = wc.save(true, null);
+ IServerType st = ServerCore.findServerType("org.jboss.ide.eclipse.as.systemCopyServer");
+ ServerWorkingCopy swc = (ServerWorkingCopy) st.createServer(serverName, null, null);
+ swc.setServerConfiguration(null);
+ swc.setName(serverName);
+ swc.setRuntime(runtime);
+ swc.setAttribute(DeployableServer.DEPLOY_DIRECTORY, deployLocation);
+ swc.setAttribute(DeployableServer.TEMP_DEPLOY_DIRECTORY, tempDeployLocation);
+ IServer server = swc.save(true, null);
+ return server;
+ }
+
+
public static IServer createMockServerWithRuntime(String serverType, String name, String config) {
try {
IPath serverDir = createMockServerDirectory(name, twiddleMap.get(serverType), config);
@@ -176,4 +209,38 @@
String location = url.getFile();
return new File(location);
}
+
+ public static String getDeployRoot(IServer server) {
+ IDeployableServer ds = ServerConverter.getDeployableServer(server);
+ return ds.getDeployFolder();
+ }
+
+ public static IServer setServerAttribute(IServer server, String attribute, boolean value) {
+ ServerAttributeHelper helper =
+ new ServerAttributeHelper(server, server.createWorkingCopy());
+ helper.setAttribute(attribute, value);
+ return helper.save();
+ }
+
+ public static IServer addModule(IServer server, IModule module) throws CoreException {
+ IServerWorkingCopy copy = server.createWorkingCopy();
+ copy.modifyModules(new IModule[]{module}, new IModule[0], new NullProgressMonitor());
+ return copy.save(false, new NullProgressMonitor());
+ }
+
+ public static IServer removeModule(IServer server, IModule module) throws CoreException {
+ IServerWorkingCopy copy = server.createWorkingCopy();
+ copy.modifyModules(new IModule[]{}, new IModule[] {module}, new NullProgressMonitor());
+ return copy.save(false, new NullProgressMonitor());
+ }
+
+ public static IStatus publish(IServer server) throws CoreException {
+ return server.publish(IServer.PUBLISH_INCREMENTAL, new NullProgressMonitor());
+ }
+
+ public static IServer setZipped(IServer server, boolean val) {
+ return ServerRuntimeUtils.setServerAttribute(server, IDeployableServer.ZIP_DEPLOYMENTS_PREF, val);
+ }
+
+
}
13 years, 5 months
JBoss Tools SVN: r26161 - trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/views.
by jbosstools-commits@lists.jboss.org
Author: dgeraskov
Date: 2010-11-01 10:08:51 -0400 (Mon, 01 Nov 2010)
New Revision: 26161
Removed:
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/views/TextDialogCellEditor.java
Modified:
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/views/QueryParametersPage.java
Log:
Reverted wrong commit
Modified: trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/views/QueryParametersPage.java
===================================================================
--- trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/views/QueryParametersPage.java 2010-11-01 13:55:48 UTC (rev 26160)
+++ trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/views/QueryParametersPage.java 2010-11-01 14:08:51 UTC (rev 26161)
@@ -48,7 +48,6 @@
import org.eclipse.jface.viewers.TableViewer;
import org.eclipse.jface.viewers.TextCellEditor;
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.layout.GridData;
@@ -63,7 +62,6 @@
import org.eclipse.ui.part.Page;
import org.hibernate.console.ConsoleQueryParameter;
import org.hibernate.console.ImageConstants;
-import org.hibernate.console.ParametersListDialog;
import org.hibernate.console.QueryInputModel;
import org.hibernate.eclipse.console.HibernateConsoleMessages;
import org.hibernate.eclipse.console.QueryEditor;
@@ -124,6 +122,8 @@
toggleActive.setChecked(model.ignoreParameters());
tableViewer.getTable().setEnabled(!model.ignoreParameters());
tableViewer.setInput(model);
+
+
}
private void createStatusLabel() {
@@ -224,27 +224,11 @@
}
}
if ( VALUE_PROPERTY.equals( property ) ) {
- String[] inputStrings;
- if (value instanceof String[]){
- inputStrings = (String[])value;
- } else {
- inputStrings = new String[]{(String) value};
- }
- Object[] values = new Object[inputStrings.length];
- for (int i = 0; i < inputStrings.length; i++) {
- values[i] = cqp.convertStringToValue(inputStrings[i]);
- }
- if (values.length > 1){
- cqp.setValue(values);
- } else if (values.length == 1){
- cqp.setValue(values[0]);
- } else {
- cqp.setValue(null);
- }
+ cqp.setValueFromString((String) value);
}
if ( NULL_PROPERTY.equals( property ) ) {
if(cqp.isNull()) {
- cqp.setValue(cqp.convertStringToValue( "" )); // best attempt to "unnull" //$NON-NLS-1$
+ cqp.setValueFromString( "" ); // best attempt to "unnull" //$NON-NLS-1$
} else {
cqp.setNull();
}
@@ -269,11 +253,7 @@
}
}
if ( VALUE_PROPERTY.equals( property ) ) {
- return cqp.getStringValues();
- /*if (cqp.isArrayValue()){
- return cqp.convertValueToString(((Object[])cqp.getValue())[0]);
- }
- return cqp.convertValueToString(cqp.getValue());*/
+ return cqp.getValueAsString();
}
if ( NULL_PROPERTY.equals( property )) {
return Boolean.valueOf(cqp.isNull());
@@ -314,21 +294,7 @@
CellEditor[] editors = new CellEditor[columnProperties.length];
editors[0] = new TextCellEditor( queryParametersTable );
editors[1] = new ComboBoxCellEditor( queryParametersTable, valueTypes );
- editors[2] = new TextDialogCellEditor(queryParametersTable) {
-
- @Override
- protected Object openDialogBox(Control cellEditorWindow) {
- Object firstElement = ((IStructuredSelection)tableViewer.getSelection()).getFirstElement();
- if(firstElement instanceof ConsoleQueryParameter) {
- ParametersListDialog pld = new ParametersListDialog(null, (ConsoleQueryParameter) firstElement);
- if (pld.open()==Window.OK){
- return pld.getValue();//String[]
- }
- }
- return getValue();//could be String or String[]
- }
- };
-
+ editors[2] = new TextCellEditor( queryParametersTable );
editors[3] = new CheckboxCellEditor( queryParametersTable );
tableViewer.setCellEditors( editors );
@@ -357,7 +323,7 @@
case 1:
return cqp.getType().getName();
case 2:
- return cqp.getStringValues()[0];
+ return cqp.getValueAsString();
case 3:
return null; //cqp.isNull()?"X":"";
default:
Deleted: trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/views/TextDialogCellEditor.java
===================================================================
--- trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/views/TextDialogCellEditor.java 2010-11-01 13:55:48 UTC (rev 26160)
+++ trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/views/TextDialogCellEditor.java 2010-11-01 14:08:51 UTC (rev 26161)
@@ -1,243 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010 Red Hat, Inc.
- * Distributed under license by Red Hat, Inc. All rights reserved.
- * This program is made available under the terms of the
- * Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributor:
- * Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
-package org.hibernate.eclipse.console.views;
-
-import java.text.MessageFormat;
-
-import org.eclipse.jface.viewers.TextCellEditor;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.FocusEvent;
-import org.eclipse.swt.events.FocusListener;
-import org.eclipse.swt.events.KeyAdapter;
-import org.eclipse.swt.events.KeyEvent;
-import org.eclipse.swt.events.ModifyEvent;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.Font;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.graphics.Rectangle;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Layout;
-import org.eclipse.swt.widgets.Text;
-
-/**
- * @author Dmitry Geraskov
- *
- */
-public abstract class TextDialogCellEditor extends TextCellEditor {
-
- private Text text;
-
- /**
- * The button.
- */
- private Button button;
-
- /**
- * The editor control.
- */
- private Composite editor;
-
- private String[] strValues = null;
-
- private FocusListener buttonFocusListener;
-
- protected TextDialogCellEditor(Composite parent) {
- super(parent);
- }
-
- @Override
- protected Control createControl(Composite parent) {
- Font font = parent.getFont();
- Color bg = parent.getBackground();
-
- editor = new Composite(parent, getStyle());
- editor.setFont(font);
- editor.setBackground(bg);
- editor.setLayout(new DialogCellLayout());
-
- text = (Text) super.createControl(editor);
- updateContents(strValues);
-
- button = createButton(editor);
- button.setFont(font);
-
- button.addKeyListener(new KeyAdapter() {
- /* (non-Javadoc)
- * @see org.eclipse.swt.events.KeyListener#keyReleased(org.eclipse.swt.events.KeyEvent)
- */
- public void keyReleased(KeyEvent e) {
- if (e.character == '\u001b') { // Escape
- fireCancelEditor();
- }
- }
- });
-
- button.addFocusListener(getButtonFocusListener());
-
- button.addSelectionListener(new SelectionAdapter() {
- /* (non-Javadoc)
- * @see org.eclipse.swt.events.SelectionListener#widgetSelected(org.eclipse.swt.events.SelectionEvent)
- */
- public void widgetSelected(SelectionEvent event) {
- // Remove the button's focus listener since it's guaranteed
- // to lose focus when the dialog opens
- button.removeFocusListener(getButtonFocusListener());
-
- Object newValue = openDialogBox(editor);
-
- // Re-add the listener once the dialog closes
- button.addFocusListener(getButtonFocusListener());
-
- if (newValue != null) {
- boolean newValidState = isCorrect(newValue);
- if (newValidState) {
- markDirty();
- doSetValue(newValue);
- } else {
- // try to insert the current value into the error message.
- setErrorMessage(MessageFormat.format(getErrorMessage(),
- new Object[] { newValue.toString() }));
- }
- fireApplyEditorValue();
- }
- }
-
-
- });
-
- setValueValid(true);
-
- return editor;
- }
-
- @Override
- protected void focusLost() {
- if (isActivated()) {
- if (button != null && !button.isDisposed() && !button.isFocusControl()) {
- if (text != null && !text.isDisposed() && !text.isFocusControl()){
- fireApplyEditorValue();
- deactivate();
- }
- }
- }
- }
-
- protected abstract Object openDialogBox(Control cellEditorWindow);
-
- private FocusListener getButtonFocusListener() {
- if (buttonFocusListener == null) {
- buttonFocusListener = new FocusListener() {
-
- /* (non-Javadoc)
- * @see org.eclipse.swt.events.FocusListener#focusGained(org.eclipse.swt.events.FocusEvent)
- */
- public void focusGained(FocusEvent e) {
-
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.swt.events.FocusListener#focusLost(org.eclipse.swt.events.FocusEvent)
- */
- public void focusLost(FocusEvent e) {
- TextDialogCellEditor.this.focusLost();
- }
- };
- }
-
- return buttonFocusListener;
- }
-
- protected Button createButton(Composite parent) {
- Button result = new Button(parent, SWT.DOWN);
- result.setText("..."); //$NON-NLS-1$
- return result;
- }
-
- public void deactivate() {
- if (button != null && !button.isDisposed()) {
- button.removeFocusListener(getButtonFocusListener());
- }
-
- super.deactivate();
- }
-
- @Override
- protected void editOccured(ModifyEvent e) {
- String text = this.text.getText();
- if (strValues == null || strValues.length == 0){
- strValues = new String[]{text};
- } else {
- strValues[0] = text;
- }
- super.editOccured(e);
- }
-
- protected Object doGetValue() {
- return strValues;
- }
-
- protected void doSetValue(Object value) {
- if (value == null) {
- value = "";
- this.strValues = new String[]{""};
- } else if (value.getClass().isArray()){
- this.strValues = (String[])value;
- value = this.strValues[0];
- }
- super.doSetValue(value);
- }
-
- protected void updateContents(String[] value) {
- if (text == null) {
- return;
- }
-
- String strVal = "";//$NON-NLS-1$
- if (value != null && value.length > 0) {
- strVal = value[0];
- }
- text.setText(strVal);
- }
-
- private class DialogCellLayout extends Layout {
- public void layout(Composite editor, boolean force) {
- Rectangle bounds = editor.getClientArea();
- Point size = button.computeSize(SWT.DEFAULT, SWT.DEFAULT, force);
- if (text != null) {
- text.setBounds(0, 0, bounds.width - size.x, bounds.height);
- }
- button.setBounds(bounds.width - size.x, 0, size.x, bounds.height);
- }
-
- public Point computeSize(Composite editor, int wHint, int hHint,
- boolean force) {
- if (wHint != SWT.DEFAULT && hHint != SWT.DEFAULT) {
- return new Point(wHint, hHint);
- }
- Point contentsSize = text.computeSize(SWT.DEFAULT, SWT.DEFAULT,
- force);
- Point buttonSize = button.computeSize(SWT.DEFAULT, SWT.DEFAULT,
- force);
- // Just return the button width to ensure the button is not clipped
- // if the label is long.
- // The label will just use whatever extra width there is
- Point result = new Point(buttonSize.x, Math.max(contentsSize.y,
- buttonSize.y));
- return result;
- }
- }
-
-
-}
\ No newline at end of file
13 years, 5 months
JBoss Tools SVN: r26160 - trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/filesystems/impl.
by jbosstools-commits@lists.jboss.org
Author: scabanovich
Date: 2010-11-01 09:55:48 -0400 (Mon, 01 Nov 2010)
New Revision: 26160
Modified:
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/filesystems/impl/JarAccess.java
Log:
JBIDE-7399
https://jira.jboss.org/browse/JBIDE-7399
Modified: trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/filesystems/impl/JarAccess.java
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/filesystems/impl/JarAccess.java 2010-11-01 13:28:32 UTC (rev 26159)
+++ trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/filesystems/impl/JarAccess.java 2010-11-01 13:55:48 UTC (rev 26160)
@@ -131,6 +131,7 @@
private ZipFile getZipFile() throws IOException {
synchronized (this) {
lockJar();
+ if(!new File(templocation).isFile()) return null;
if(jar != null) return jar;
return jar = new ZipFile(templocation);
}
@@ -200,6 +201,11 @@
try {
jar = getZipFile();
} catch (IOException e) {
+ String error = "JarAccess: cannot load zip file for location " + templocation; //$NON-NLS-1$
+ errors.add(error);
+ ModelPlugin.getDefault().logError(error);
+ }
+ if(jar == null) {
unlockJar();
return ""; //$NON-NLS-1$
}
13 years, 5 months
JBoss Tools SVN: r26159 - in trunk/hibernatetools/plugins/org.hibernate.eclipse/lib: hibernate and 1 other directory.
by jbosstools-commits@lists.jboss.org
Author: dgeraskov
Date: 2010-11-01 09:28:32 -0400 (Mon, 01 Nov 2010)
New Revision: 26159
Removed:
trunk/hibernatetools/plugins/org.hibernate.eclipse/lib/annotations/ejb3-persistence.jar
trunk/hibernatetools/plugins/org.hibernate.eclipse/lib/annotations/hibernate-annotations.jar
trunk/hibernatetools/plugins/org.hibernate.eclipse/lib/annotations/hibernate-commons-annotations.jar
trunk/hibernatetools/plugins/org.hibernate.eclipse/lib/annotations/hibernate-entitymanager.jar
trunk/hibernatetools/plugins/org.hibernate.eclipse/lib/hibernate/hibernate-jmx.jar
Log:
JBIDE-7241
move hibernate plugins to hibernte-tools3.4.0.Beta2
Deleted: trunk/hibernatetools/plugins/org.hibernate.eclipse/lib/annotations/ejb3-persistence.jar
===================================================================
(Binary files differ)
Deleted: trunk/hibernatetools/plugins/org.hibernate.eclipse/lib/annotations/hibernate-annotations.jar
===================================================================
(Binary files differ)
Deleted: trunk/hibernatetools/plugins/org.hibernate.eclipse/lib/annotations/hibernate-commons-annotations.jar
===================================================================
(Binary files differ)
Deleted: trunk/hibernatetools/plugins/org.hibernate.eclipse/lib/annotations/hibernate-entitymanager.jar
===================================================================
(Binary files differ)
Deleted: trunk/hibernatetools/plugins/org.hibernate.eclipse/lib/hibernate/hibernate-jmx.jar
===================================================================
(Binary files differ)
13 years, 5 months
JBoss Tools SVN: r26158 - in trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe: handlers and 1 other directory.
by jbosstools-commits@lists.jboss.org
Author: mareshkau
Date: 2010-11-01 09:21:18 -0400 (Mon, 01 Nov 2010)
New Revision: 26158
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeEditorPart.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/handlers/RotateEditorsHandler.java
Log:
https://jira.jboss.org/browse/JBIDE-7383
Modified: trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeEditorPart.java
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeEditorPart.java 2010-11-01 13:00:20 UTC (rev 26157)
+++ trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeEditorPart.java 2010-11-01 13:21:18 UTC (rev 26158)
@@ -318,7 +318,9 @@
* Restore the state after switching from Preview, for example.
*/
// selectionBar.setVisible(selectionBar.getAlwaysVisibleOption());
- setVerticalToolbarVisible(true);
+ //added by Maksim Areshkau, here we remove Visual Page Editor Toolbar
+// setVerticalToolbarVisible(true);
+ setVerticalToolbarVisible(false);
/*
* Fixes https://jira.jboss.org/jira/browse/JBIDE-3140
* author Denis Maliarevich.
Modified: trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/handlers/RotateEditorsHandler.java
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/handlers/RotateEditorsHandler.java 2010-11-01 13:00:20 UTC (rev 26157)
+++ trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/handlers/RotateEditorsHandler.java 2010-11-01 13:21:18 UTC (rev 26158)
@@ -151,6 +151,9 @@
JSPMultiPageEditor jspEditor = (JSPMultiPageEditor) activeEditor;
VpeController vpeController = (VpeController) jspEditor
.getVisualEditor().getController();
+ //if called in initialization time, vpe controller is null
+ //added by Maksim Areshkau
+ if(vpeController!=null)
vpeController.getPageContext().getEditPart()
.fillContainer(true, orientation);
}
13 years, 5 months
JBoss Tools SVN: r26157 - in trunk/hibernatetools: plugins/org.hibernate.eclipse/META-INF and 7 other directories.
by jbosstools-commits@lists.jboss.org
Author: dgeraskov
Date: 2010-11-01 09:00:20 -0400 (Mon, 01 Nov 2010)
New Revision: 26157
Added:
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/views/TextDialogCellEditor.java
trunk/hibernatetools/plugins/org.hibernate.eclipse/lib/annotations/hibernate-jpa-2.0-api-1.0.0.Final.jar
Modified:
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/views/QueryParametersPage.java
trunk/hibernatetools/plugins/org.hibernate.eclipse/.classpath
trunk/hibernatetools/plugins/org.hibernate.eclipse/META-INF/MANIFEST.MF
trunk/hibernatetools/plugins/org.hibernate.eclipse/build.properties
trunk/hibernatetools/plugins/org.hibernate.eclipse/hibernate-build.xml
trunk/hibernatetools/plugins/org.hibernate.eclipse/lib/hibernate/hibernate3.jar
trunk/hibernatetools/plugins/org.hibernate.eclipse/lib/tools/hibernate-tools.jar
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/mappingproject/OpenSourceFileTest.java
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/project/ConfigurableTestProject.java
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/project/TestProject.java
trunk/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/src/org/hibernate/eclipse/jdt/ui/test/HQLQueryValidatorTest.java
Log:
JBIDE-7241
move hibernate plugins to hibernte-tools3.4.0.Beta2
Modified: trunk/hibernatetools/plugins/org.hibernate.eclipse/.classpath
===================================================================
--- trunk/hibernatetools/plugins/org.hibernate.eclipse/.classpath 2010-11-01 12:39:23 UTC (rev 26156)
+++ trunk/hibernatetools/plugins/org.hibernate.eclipse/.classpath 2010-11-01 13:00:20 UTC (rev 26157)
@@ -6,6 +6,10 @@
<classpathentry exported="true" kind="lib" path="lib/hibernate/asm.jar"/>
<classpathentry exported="true" kind="lib" path="lib/hibernate/asm-attrs.jar"/>
<classpathentry exported="true" kind="lib" path="lib/hibernate/dom4j-1.6.1.jar"/>
+ <classpathentry exported="true" kind="lib" path="lib/hibernate/commons-logging-1.0.4.jar"/>
+ <classpathentry exported="true" kind="lib" path="lib/hibernate/concurrent-1.3.2.jar"/>
+ <classpathentry exported="true" kind="lib" path="lib/hibernate/connector.jar"/>
+ <classpathentry exported="true" kind="lib" path="lib/annotations/hibernate-jpa-2.0-api-1.0.0.Final.jar"/>
<classpathentry exported="true" kind="lib" path="lib/hibernate/hibernate3.jar"/>
<classpathentry exported="true" kind="lib" path="lib/hibernate/jboss-cache.jar"/>
<classpathentry exported="true" kind="lib" path="lib/hibernate/jboss-common.jar"/>
@@ -17,28 +21,20 @@
<classpathentry exported="true" kind="lib" path="lib/hibernate/oscache-2.1.jar"/>
<classpathentry exported="true" kind="lib" path="lib/hibernate/proxool-0.8.3.jar"/>
<classpathentry exported="true" kind="lib" path="lib/hibernate/swarmcache-1.0rc2.jar"/>
+ <classpathentry exported="true" kind="lib" path="lib/tools/freemarker.jar"/>
+ <classpathentry exported="true" kind="lib" path="lib/tools/hibernate-tools.jar"/>
<classpathentry exported="true" kind="lib" path="lib/bsh-core-2.0b4.jar"/>
- <classpathentry exported="true" kind="lib" path="lib/annotations/hibernate-annotations.jar"/>
<classpathentry exported="true" kind="lib" path="lib/hibernate/jgroups-2.2.8.jar"/>
<classpathentry exported="true" kind="lib" path="lib/hibernate/antlr-2.7.6.jar"/>
- <classpathentry exported="true" kind="lib" path="lib/annotations/hibernate-entitymanager.jar"/>
+ <classpathentry exported="true" kind="lib" path="lib/tools/jtidy-r8-20060801.jar"/>
<classpathentry exported="true" kind="lib" path="lib/hibernate/javassist.jar"/>
+ <classpathentry exported="true" kind="lib" path="lib/hibernate/ehcache-1.2.3.jar"/>
+ <classpathentry exported="true" kind="lib" path="lib/hibernate/c3p0-0.9.1.jar"/>
<classpathentry exported="true" kind="lib" path="lib/annotations/hibernate-validator.jar"/>
<classpathentry exported="true" kind="lib" path="lib/hibernate/log4j-1.2.15.jar"/>
- <classpathentry exported="true" kind="lib" path="lib/hibernate/hibernate-jmx.jar"/>
+ <classpathentry exported="true" kind="lib" path="lib/hibernate/cglib-2.2.jar"/>
<classpathentry exported="true" kind="lib" path="lib/hibernate/commons-collections-3.1.jar"/>
<classpathentry exported="true" kind="lib" path="lib/hibernate/slf4j-api-1.5.8.jar"/>
- <classpathentry exported="true" kind="lib" path="lib/hibernate/cglib-2.2.jar"/>
- <classpathentry exported="true" kind="lib" path="lib/annotations/hibernate-commons-annotations.jar"/>
- <classpathentry exported="true" kind="lib" path="lib/annotations/ejb3-persistence.jar"/>
- <classpathentry exported="true" kind="lib" path="lib/hibernate/c3p0-0.9.1.jar"/>
- <classpathentry exported="true" kind="lib" path="lib/hibernate/commons-logging-1.0.4.jar"/>
- <classpathentry exported="true" kind="lib" path="lib/hibernate/concurrent-1.3.2.jar"/>
- <classpathentry exported="true" kind="lib" path="lib/hibernate/connector.jar"/>
- <classpathentry exported="true" kind="lib" path="lib/hibernate/ehcache-1.2.3.jar"/>
<classpathentry exported="true" kind="lib" path="lib/hibernate/slf4j-log4j12-1.5.8.jar"/>
- <classpathentry exported="true" kind="lib" path="lib/tools/freemarker.jar"/>
- <classpathentry exported="true" kind="lib" path="lib/tools/hibernate-tools.jar"/>
- <classpathentry exported="true" kind="lib" path="lib/tools/jtidy-r8-20060801.jar"/>
<classpathentry kind="output" path="build/eclipse"/>
</classpath>
Modified: trunk/hibernatetools/plugins/org.hibernate.eclipse/META-INF/MANIFEST.MF
===================================================================
--- trunk/hibernatetools/plugins/org.hibernate.eclipse/META-INF/MANIFEST.MF 2010-11-01 12:39:23 UTC (rev 26156)
+++ trunk/hibernatetools/plugins/org.hibernate.eclipse/META-INF/MANIFEST.MF 2010-11-01 13:00:20 UTC (rev 26157)
@@ -24,21 +24,17 @@
lib/tools/hibernate-tools.jar,
lib/tools/freemarker.jar,
lib/bsh-core-2.0b4.jar,
- lib/annotations/ejb3-persistence.jar,
- lib/annotations/hibernate-annotations.jar,
lib/hibernate/jgroups-2.2.8.jar,
lib/hibernate/antlr-2.7.6.jar,
lib/tools/jtidy-r8-20060801.jar,
- lib/annotations/hibernate-entitymanager.jar,
+ lib/annotations/hibernate-jpa-2.0-api-1.0.0.Final.jar,
lib/hibernate/javassist.jar,
lib/hibernate/ehcache-1.2.3.jar,
lib/hibernate/c3p0-0.9.1.jar,
- lib/annotations/hibernate-commons-annotations.jar,
lib/annotations/hibernate-validator.jar,
lib/hibernate/log4j-1.2.15.jar,
lib/hibernate/cglib-2.2.jar,
lib/hibernate/commons-collections-3.1.jar,
- lib/hibernate/hibernate-jmx.jar,
lib/hibernate/slf4j-api-1.5.8.jar,
lib/hibernate/slf4j-log4j12-1.5.8.jar,
lib/hibernate/commons-collections-3.1.jar
Modified: trunk/hibernatetools/plugins/org.hibernate.eclipse/build.properties
===================================================================
--- trunk/hibernatetools/plugins/org.hibernate.eclipse/build.properties 2010-11-01 12:39:23 UTC (rev 26156)
+++ trunk/hibernatetools/plugins/org.hibernate.eclipse/build.properties 2010-11-01 13:00:20 UTC (rev 26157)
@@ -3,11 +3,10 @@
hibernate-log4j.properties,\
about.html,\
lib/tools/jtidy-r8-20060801.jar,\
- lib/annotations/hibernate-entitymanager.jar,\
+ lib/annotations/hibernate-jpa-2.0-api-1.0.0.Final.jar,\
lib/hibernate/javassist.jar,\
lib/hibernate/ehcache-1.2.3.jar,\
lib/hibernate/c3p0-0.9.1.jar,\
- lib/annotations/hibernate-commons-annotations.jar,\
lib/annotations/hibernate-validator.jar,\
lib/hibernate/log4j-1.2.15.jar,\
lib/hibernate/slf4j-api-1.5.8.jar,\
@@ -19,7 +18,6 @@
plugin.properties,\
lib/hibernate/cglib-2.2.jar,\
lib/hibernate/commons-collections-3.1.jar,\
- lib/hibernate/hibernate-jmx.jar,\
org.hibernate.eclipse.jar
jars.compile.order = org.hibernate.eclipse.jar
src.includes = about.html,\
Modified: trunk/hibernatetools/plugins/org.hibernate.eclipse/hibernate-build.xml
===================================================================
--- trunk/hibernatetools/plugins/org.hibernate.eclipse/hibernate-build.xml 2010-11-01 12:39:23 UTC (rev 26156)
+++ trunk/hibernatetools/plugins/org.hibernate.eclipse/hibernate-build.xml 2010-11-01 13:00:20 UTC (rev 26157)
@@ -5,7 +5,7 @@
<project name="org.hibernate.eclipse" basedir="." default="update">
- <property name="hibernate.root" location="/home/max/work/os/hibernate/branches/Branch_3_2"/>
+ <property name="hibernate.root" location="C:/dev/workspaces/RedHat/hibernate_trunk-orig/"/>
<available file="${hibernate.root}" property="hibernate.root.exists"/>
<fail unless="hibernate.root.exists">hibernate.root needs to be set to the root of the hibernate svn checkout. Currently it is ${hibernate.root} which does not exist.</fail>
Added: trunk/hibernatetools/plugins/org.hibernate.eclipse/lib/annotations/hibernate-jpa-2.0-api-1.0.0.Final.jar
===================================================================
(Binary files differ)
Property changes on: trunk/hibernatetools/plugins/org.hibernate.eclipse/lib/annotations/hibernate-jpa-2.0-api-1.0.0.Final.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Modified: trunk/hibernatetools/plugins/org.hibernate.eclipse/lib/hibernate/hibernate3.jar
===================================================================
(Binary files differ)
Modified: trunk/hibernatetools/plugins/org.hibernate.eclipse/lib/tools/hibernate-tools.jar
===================================================================
(Binary files differ)
Modified: trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/views/QueryParametersPage.java
===================================================================
--- trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/views/QueryParametersPage.java 2010-11-01 12:39:23 UTC (rev 26156)
+++ trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/views/QueryParametersPage.java 2010-11-01 13:00:20 UTC (rev 26157)
@@ -48,6 +48,7 @@
import org.eclipse.jface.viewers.TableViewer;
import org.eclipse.jface.viewers.TextCellEditor;
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.layout.GridData;
@@ -62,6 +63,7 @@
import org.eclipse.ui.part.Page;
import org.hibernate.console.ConsoleQueryParameter;
import org.hibernate.console.ImageConstants;
+import org.hibernate.console.ParametersListDialog;
import org.hibernate.console.QueryInputModel;
import org.hibernate.eclipse.console.HibernateConsoleMessages;
import org.hibernate.eclipse.console.QueryEditor;
@@ -122,8 +124,6 @@
toggleActive.setChecked(model.ignoreParameters());
tableViewer.getTable().setEnabled(!model.ignoreParameters());
tableViewer.setInput(model);
-
-
}
private void createStatusLabel() {
@@ -224,11 +224,27 @@
}
}
if ( VALUE_PROPERTY.equals( property ) ) {
- cqp.setValueFromString((String) value);
+ String[] inputStrings;
+ if (value instanceof String[]){
+ inputStrings = (String[])value;
+ } else {
+ inputStrings = new String[]{(String) value};
+ }
+ Object[] values = new Object[inputStrings.length];
+ for (int i = 0; i < inputStrings.length; i++) {
+ values[i] = cqp.convertStringToValue(inputStrings[i]);
+ }
+ if (values.length > 1){
+ cqp.setValue(values);
+ } else if (values.length == 1){
+ cqp.setValue(values[0]);
+ } else {
+ cqp.setValue(null);
+ }
}
if ( NULL_PROPERTY.equals( property ) ) {
if(cqp.isNull()) {
- cqp.setValueFromString( "" ); // best attempt to "unnull" //$NON-NLS-1$
+ cqp.setValue(cqp.convertStringToValue( "" )); // best attempt to "unnull" //$NON-NLS-1$
} else {
cqp.setNull();
}
@@ -253,7 +269,11 @@
}
}
if ( VALUE_PROPERTY.equals( property ) ) {
- return cqp.getValueAsString();
+ return cqp.getStringValues();
+ /*if (cqp.isArrayValue()){
+ return cqp.convertValueToString(((Object[])cqp.getValue())[0]);
+ }
+ return cqp.convertValueToString(cqp.getValue());*/
}
if ( NULL_PROPERTY.equals( property )) {
return Boolean.valueOf(cqp.isNull());
@@ -294,7 +314,21 @@
CellEditor[] editors = new CellEditor[columnProperties.length];
editors[0] = new TextCellEditor( queryParametersTable );
editors[1] = new ComboBoxCellEditor( queryParametersTable, valueTypes );
- editors[2] = new TextCellEditor( queryParametersTable );
+ editors[2] = new TextDialogCellEditor(queryParametersTable) {
+
+ @Override
+ protected Object openDialogBox(Control cellEditorWindow) {
+ Object firstElement = ((IStructuredSelection)tableViewer.getSelection()).getFirstElement();
+ if(firstElement instanceof ConsoleQueryParameter) {
+ ParametersListDialog pld = new ParametersListDialog(null, (ConsoleQueryParameter) firstElement);
+ if (pld.open()==Window.OK){
+ return pld.getValue();//String[]
+ }
+ }
+ return getValue();//could be String or String[]
+ }
+ };
+
editors[3] = new CheckboxCellEditor( queryParametersTable );
tableViewer.setCellEditors( editors );
@@ -323,7 +357,7 @@
case 1:
return cqp.getType().getName();
case 2:
- return cqp.getValueAsString();
+ return cqp.getStringValues()[0];
case 3:
return null; //cqp.isNull()?"X":"";
default:
Added: trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/views/TextDialogCellEditor.java
===================================================================
--- trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/views/TextDialogCellEditor.java (rev 0)
+++ trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/views/TextDialogCellEditor.java 2010-11-01 13:00:20 UTC (rev 26157)
@@ -0,0 +1,243 @@
+/*******************************************************************************
+ * Copyright (c) 2010 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.hibernate.eclipse.console.views;
+
+import java.text.MessageFormat;
+
+import org.eclipse.jface.viewers.TextCellEditor;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.FocusEvent;
+import org.eclipse.swt.events.FocusListener;
+import org.eclipse.swt.events.KeyAdapter;
+import org.eclipse.swt.events.KeyEvent;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.Font;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.graphics.Rectangle;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Layout;
+import org.eclipse.swt.widgets.Text;
+
+/**
+ * @author Dmitry Geraskov
+ *
+ */
+public abstract class TextDialogCellEditor extends TextCellEditor {
+
+ private Text text;
+
+ /**
+ * The button.
+ */
+ private Button button;
+
+ /**
+ * The editor control.
+ */
+ private Composite editor;
+
+ private String[] strValues = null;
+
+ private FocusListener buttonFocusListener;
+
+ protected TextDialogCellEditor(Composite parent) {
+ super(parent);
+ }
+
+ @Override
+ protected Control createControl(Composite parent) {
+ Font font = parent.getFont();
+ Color bg = parent.getBackground();
+
+ editor = new Composite(parent, getStyle());
+ editor.setFont(font);
+ editor.setBackground(bg);
+ editor.setLayout(new DialogCellLayout());
+
+ text = (Text) super.createControl(editor);
+ updateContents(strValues);
+
+ button = createButton(editor);
+ button.setFont(font);
+
+ button.addKeyListener(new KeyAdapter() {
+ /* (non-Javadoc)
+ * @see org.eclipse.swt.events.KeyListener#keyReleased(org.eclipse.swt.events.KeyEvent)
+ */
+ public void keyReleased(KeyEvent e) {
+ if (e.character == '\u001b') { // Escape
+ fireCancelEditor();
+ }
+ }
+ });
+
+ button.addFocusListener(getButtonFocusListener());
+
+ button.addSelectionListener(new SelectionAdapter() {
+ /* (non-Javadoc)
+ * @see org.eclipse.swt.events.SelectionListener#widgetSelected(org.eclipse.swt.events.SelectionEvent)
+ */
+ public void widgetSelected(SelectionEvent event) {
+ // Remove the button's focus listener since it's guaranteed
+ // to lose focus when the dialog opens
+ button.removeFocusListener(getButtonFocusListener());
+
+ Object newValue = openDialogBox(editor);
+
+ // Re-add the listener once the dialog closes
+ button.addFocusListener(getButtonFocusListener());
+
+ if (newValue != null) {
+ boolean newValidState = isCorrect(newValue);
+ if (newValidState) {
+ markDirty();
+ doSetValue(newValue);
+ } else {
+ // try to insert the current value into the error message.
+ setErrorMessage(MessageFormat.format(getErrorMessage(),
+ new Object[] { newValue.toString() }));
+ }
+ fireApplyEditorValue();
+ }
+ }
+
+
+ });
+
+ setValueValid(true);
+
+ return editor;
+ }
+
+ @Override
+ protected void focusLost() {
+ if (isActivated()) {
+ if (button != null && !button.isDisposed() && !button.isFocusControl()) {
+ if (text != null && !text.isDisposed() && !text.isFocusControl()){
+ fireApplyEditorValue();
+ deactivate();
+ }
+ }
+ }
+ }
+
+ protected abstract Object openDialogBox(Control cellEditorWindow);
+
+ private FocusListener getButtonFocusListener() {
+ if (buttonFocusListener == null) {
+ buttonFocusListener = new FocusListener() {
+
+ /* (non-Javadoc)
+ * @see org.eclipse.swt.events.FocusListener#focusGained(org.eclipse.swt.events.FocusEvent)
+ */
+ public void focusGained(FocusEvent e) {
+
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.swt.events.FocusListener#focusLost(org.eclipse.swt.events.FocusEvent)
+ */
+ public void focusLost(FocusEvent e) {
+ TextDialogCellEditor.this.focusLost();
+ }
+ };
+ }
+
+ return buttonFocusListener;
+ }
+
+ protected Button createButton(Composite parent) {
+ Button result = new Button(parent, SWT.DOWN);
+ result.setText("..."); //$NON-NLS-1$
+ return result;
+ }
+
+ public void deactivate() {
+ if (button != null && !button.isDisposed()) {
+ button.removeFocusListener(getButtonFocusListener());
+ }
+
+ super.deactivate();
+ }
+
+ @Override
+ protected void editOccured(ModifyEvent e) {
+ String text = this.text.getText();
+ if (strValues == null || strValues.length == 0){
+ strValues = new String[]{text};
+ } else {
+ strValues[0] = text;
+ }
+ super.editOccured(e);
+ }
+
+ protected Object doGetValue() {
+ return strValues;
+ }
+
+ protected void doSetValue(Object value) {
+ if (value == null) {
+ value = "";
+ this.strValues = new String[]{""};
+ } else if (value.getClass().isArray()){
+ this.strValues = (String[])value;
+ value = this.strValues[0];
+ }
+ super.doSetValue(value);
+ }
+
+ protected void updateContents(String[] value) {
+ if (text == null) {
+ return;
+ }
+
+ String strVal = "";//$NON-NLS-1$
+ if (value != null && value.length > 0) {
+ strVal = value[0];
+ }
+ text.setText(strVal);
+ }
+
+ private class DialogCellLayout extends Layout {
+ public void layout(Composite editor, boolean force) {
+ Rectangle bounds = editor.getClientArea();
+ Point size = button.computeSize(SWT.DEFAULT, SWT.DEFAULT, force);
+ if (text != null) {
+ text.setBounds(0, 0, bounds.width - size.x, bounds.height);
+ }
+ button.setBounds(bounds.width - size.x, 0, size.x, bounds.height);
+ }
+
+ public Point computeSize(Composite editor, int wHint, int hHint,
+ boolean force) {
+ if (wHint != SWT.DEFAULT && hHint != SWT.DEFAULT) {
+ return new Point(wHint, hHint);
+ }
+ Point contentsSize = text.computeSize(SWT.DEFAULT, SWT.DEFAULT,
+ force);
+ Point buttonSize = button.computeSize(SWT.DEFAULT, SWT.DEFAULT,
+ force);
+ // Just return the button width to ensure the button is not clipped
+ // if the label is long.
+ // The label will just use whatever extra width there is
+ Point result = new Point(buttonSize.x, Math.max(contentsSize.y,
+ buttonSize.y));
+ return result;
+ }
+ }
+
+
+}
\ No newline at end of file
Modified: trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/mappingproject/OpenSourceFileTest.java
===================================================================
--- trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/mappingproject/OpenSourceFileTest.java 2010-11-01 12:39:23 UTC (rev 26156)
+++ trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/mappingproject/OpenSourceFileTest.java 2010-11-01 13:00:20 UTC (rev 26157)
@@ -124,6 +124,9 @@
Throwable ex = null;
try {
editor = OpenSourceAction.run(consCFG, selection, fullyQualifiedName);
+ if (Object.class.getName().equals(fullyQualifiedName)){
+ return;
+ }
boolean highlighted = Utils.hasSelection(editor);
if (!highlighted) {
String out = NLS.bind(ConsoleTestMessages.OpenSourceFileTest_highlighted_region_for_is_empty, selection);
Modified: trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/project/ConfigurableTestProject.java
===================================================================
--- trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/project/ConfigurableTestProject.java 2010-11-01 12:39:23 UTC (rev 26156)
+++ trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/project/ConfigurableTestProject.java 2010-11-01 13:00:20 UTC (rev 26157)
@@ -170,7 +170,8 @@
public void fullBuild() throws CoreException {
IPackageFragmentRoot sourcePackageFragment = createSourceFolder();
- sourcePackageFragment.getResource().refreshLocal(IResource.DEPTH_INFINITE, null);
+ project.refreshLocal(IResource.DEPTH_INFINITE, null);
+ //sourcePackageFragment.getResource().refreshLocal();
project.build(IncrementalProjectBuilder.FULL_BUILD, new NullProgressMonitor());
}
}
Modified: trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/project/TestProject.java
===================================================================
--- trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/project/TestProject.java 2010-11-01 12:39:23 UTC (rev 26156)
+++ trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/project/TestProject.java 2010-11-01 13:00:20 UTC (rev 26157)
@@ -5,6 +5,7 @@
import java.util.ArrayList;
import java.util.List;
+import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IFolder;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IProjectDescription;
@@ -73,7 +74,9 @@
public void deleteIProject(boolean deleteContent) {
try {
+ IContainer container = project.getParent();
project.delete(deleteContent, true, null);
+ container.refreshLocal(IResource.DEPTH_ONE, null);
} catch (CoreException ce) {
throw new RuntimeException(ce);
}
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 2010-11-01 12:39:23 UTC (rev 26156)
+++ trunk/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/src/org/hibernate/eclipse/jdt/ui/test/HQLQueryValidatorTest.java 2010-11-01 13:00:20 UTC (rev 26157)
@@ -67,8 +67,12 @@
assertEquals(3,getIJavaProject().getRawClasspath().length);
getIProject().getFolder("src/META-INF").create(true, true, new NullProgressMonitor()); //$NON-NLS-1$
- getIProject().getFile("src/META-INF/persistence.xml").create( //$NON-NLS-1$
- new ByteArrayInputStream(("<persistence>\n" + //$NON-NLS-1$
+ getIProject().getFile("src/META-INF/persistence.xml").create( //$NON-NLS-1$
+ new ByteArrayInputStream(("<persistence version=\"1.0\" xmlns=\"http://java.sun.com/xml/ns/persistence\"\n" +
+ "xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n" +
+ "xsi:schemaLocation=\"http://java.sun.com/xml/ns/persistence " +
+ "http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd\">\n" +
+ " \n" + //$NON-NLS-1$
" <persistence-unit name=\"manager1\" transaction-type=\"RESOURCE_LOCAL\">\n" + //$NON-NLS-1$
" <class>test.TestClass</class>\n" + //$NON-NLS-1$
" <properties>\n" + //$NON-NLS-1$
13 years, 5 months