JBoss Tools SVN: r11761 - in trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/attribute: editor and 1 other directory.
by jbosstools-commits@lists.jboss.org
Author: scabanovich
Date: 2008-11-13 10:03:24 -0500 (Thu, 13 Nov 2008)
New Revision: 11761
Added:
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/attribute/AttributeContentProposalProviderFactory.java
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/attribute/IAttributeContentProposalProvider.java
Modified:
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/attribute/editor/ComboBoxFieldEditor.java
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/attribute/editor/StringButtonFieldEditorEx.java
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/attribute/editor/StringFieldEditor.java
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/attribute/editor/StringFieldEditorEx.java
Log:
JBIDE-2575
Added: trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/attribute/AttributeContentProposalProviderFactory.java
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/attribute/AttributeContentProposalProviderFactory.java (rev 0)
+++ trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/attribute/AttributeContentProposalProviderFactory.java 2008-11-13 15:03:24 UTC (rev 11761)
@@ -0,0 +1,144 @@
+package org.jboss.tools.common.model.ui.attribute;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.jface.bindings.keys.KeyStroke;
+import org.eclipse.jface.bindings.keys.ParseException;
+import org.eclipse.jface.fieldassist.ComboContentAdapter;
+import org.eclipse.jface.fieldassist.ContentProposalAdapter;
+import org.eclipse.jface.fieldassist.IContentProposal;
+import org.eclipse.jface.fieldassist.IContentProposalProvider;
+import org.eclipse.jface.fieldassist.IControlContentAdapter;
+import org.eclipse.jface.fieldassist.TextContentAdapter;
+import org.eclipse.swt.events.DisposeEvent;
+import org.eclipse.swt.events.DisposeListener;
+import org.eclipse.swt.widgets.Combo;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Text;
+import org.jboss.tools.common.meta.XAttribute;
+import org.jboss.tools.common.model.XModelObject;
+import org.jboss.tools.common.model.ui.ModelUIPlugin;
+import org.jboss.tools.common.model.ui.attribute.adapter.DefaultValueAdapter;
+
+public class AttributeContentProposalProviderFactory {
+ private static List<IAttributeContentProposalProvider> EMPTY = new ArrayList<IAttributeContentProposalProvider>();
+
+ public static KeyStroke getCtrlSpaceKeyStroke() {
+ KeyStroke ks = null;
+
+ try {
+ ks = KeyStroke.getInstance("Ctrl+Space");
+ } catch (ParseException e) {
+ //Cannot happen, this code is safe.
+ ModelUIPlugin.getPluginLog().logError(e);
+ }
+
+ return ks;
+ }
+
+ public static void registerContentAssist(DefaultValueAdapter valueAdapter, Control control) {
+ IControlContentAdapter controlAdapter = control instanceof Text
+ ? new TextContentAdapter()
+ : control instanceof Combo
+ ? new ComboContentAdapter()
+ : null;
+ if(controlAdapter == null) {
+ return;
+ }
+ XModelObject object = valueAdapter.getModelObject();
+ XAttribute attr = valueAdapter.getAttribute();
+ if (attr == null && valueAdapter.getAttributeData() != null) {
+ attr = valueAdapter.getAttributeData().getAttribute();
+ }
+ AttributeContentProposalProviderFactory factory = new AttributeContentProposalProviderFactory();
+ final List<IAttributeContentProposalProvider> ps = factory
+ .getContentProposalProviders(object, attr);
+ for (IAttributeContentProposalProvider p : ps) {
+ p.init(object, attr);
+ IContentProposalProvider cpp = p.getContentProposalProvider();
+ if (cpp == null)
+ continue;
+ ContentProposalAdapter adapter = new ContentProposalAdapter(
+ control,
+ controlAdapter,
+ cpp,
+ AttributeContentProposalProviderFactory.getCtrlSpaceKeyStroke(),
+ null);
+ adapter.setPropagateKeys(true);
+ adapter.setProposalAcceptanceStyle(p.getProposalAcceptanceStyle());
+ }
+ if (!ps.isEmpty()) {
+ control.addDisposeListener(new DisposeListener() {
+ public void widgetDisposed(DisposeEvent e) {
+ System.out.println("dispose");
+ for (IAttributeContentProposalProvider p : ps) {
+ p.dispose();
+ }
+ }
+ });
+ }
+ }
+
+ public List<IAttributeContentProposalProvider> getContentProposalProviders(XModelObject object, XAttribute attribute) {
+ if(true) {
+ List<IAttributeContentProposalProvider> list = new ArrayList<IAttributeContentProposalProvider>();
+ list.add(new TestAttributeContentProposalProvider());
+ return list;
+ }
+
+ return EMPTY;
+ }
+}
+
+class TestAttributeContentProposalProvider implements IAttributeContentProposalProvider {
+
+ public void dispose() {
+ }
+
+ public IContentProposalProvider getContentProposalProvider() {
+ IContentProposalProvider cpp = new IContentProposalProvider() {
+
+ public IContentProposal[] getProposals(String contents,
+ int position) {
+ ArrayList<IContentProposal> ps = new ArrayList<IContentProposal>();
+
+ if(position <= contents.length() && position > 0 && 'b' == contents.charAt(position - 1))
+ ps.add(makeContentProposal("aaa", ".aaa"));
+
+ return ps.toArray(new IContentProposal[0]);
+ }
+
+ };
+ return cpp;
+ }
+
+ public int getProposalAcceptanceStyle() {
+ return ContentProposalAdapter.PROPOSAL_INSERT;
+ }
+
+ public void init(XModelObject object, XAttribute attribute) {
+ }
+
+ private IContentProposal makeContentProposal(final String proposal, final String label) {
+ return new IContentProposal() {
+ public String getContent() {
+ return proposal;
+ }
+
+ public String getDescription() {
+ return null;
+ }
+
+ public String getLabel() {
+ return label;
+ }
+
+ public int getCursorPosition() {
+ return proposal.length();
+ }
+ };
+ }
+
+
+}
\ No newline at end of file
Added: trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/attribute/IAttributeContentProposalProvider.java
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/attribute/IAttributeContentProposalProvider.java (rev 0)
+++ trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/attribute/IAttributeContentProposalProvider.java 2008-11-13 15:03:24 UTC (rev 11761)
@@ -0,0 +1,22 @@
+package org.jboss.tools.common.model.ui.attribute;
+
+import org.eclipse.jface.fieldassist.IContentProposalProvider;
+import org.jboss.tools.common.meta.XAttribute;
+import org.jboss.tools.common.model.XModelObject;
+
+public interface IAttributeContentProposalProvider {
+
+ public void init(XModelObject object, XAttribute attribute);
+
+ public IContentProposalProvider getContentProposalProvider();
+
+ /**
+ * ContentProposalAdapter.PROPOSAL_INSERT
+ * ContentProposalAdapter.PROPOSAL_REPLACE
+ * @return
+ */
+ public int getProposalAcceptanceStyle();
+
+ public void dispose();
+
+}
Modified: trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/attribute/editor/ComboBoxFieldEditor.java
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/attribute/editor/ComboBoxFieldEditor.java 2008-11-13 15:03:19 UTC (rev 11760)
+++ trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/attribute/editor/ComboBoxFieldEditor.java 2008-11-13 15:03:24 UTC (rev 11761)
@@ -49,6 +49,7 @@
import org.jboss.tools.common.model.ui.IAttributeErrorProvider;
import org.jboss.tools.common.model.ui.IValueChangeListener;
import org.jboss.tools.common.model.ui.IValueProvider;
+import org.jboss.tools.common.model.ui.attribute.AttributeContentProposalProviderFactory;
import org.jboss.tools.common.model.ui.attribute.IListContentProvider;
import org.jboss.tools.common.model.ui.attribute.adapter.DefaultValueAdapter;
import org.jboss.tools.common.model.ui.widgets.BorderedControl;
@@ -255,14 +256,8 @@
SimpleContentProposalProvider cpp = new SimpleContentProposalProvider(set.toArray(new String[0]));
- KeyStroke ks = null;
+ KeyStroke ks = AttributeContentProposalProviderFactory.getCtrlSpaceKeyStroke();
- try {
- ks = KeyStroke.getInstance("Ctrl+Space");
- } catch (ParseException e) {
- e.printStackTrace();
- }
-
ContentProposalAdapter adapter = new ContentProposalAdapter(
comboField,
new ComboContentAdapter(),
Modified: trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/attribute/editor/StringButtonFieldEditorEx.java
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/attribute/editor/StringButtonFieldEditorEx.java 2008-11-13 15:03:19 UTC (rev 11760)
+++ trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/attribute/editor/StringButtonFieldEditorEx.java 2008-11-13 15:03:24 UTC (rev 11761)
@@ -16,6 +16,7 @@
import org.jboss.tools.common.model.ui.IAttributeErrorProvider;
import org.jboss.tools.common.model.ui.IValueChangeListener;
import org.jboss.tools.common.model.ui.IValueProvider;
+import org.jboss.tools.common.model.ui.attribute.AttributeContentProposalProviderFactory;
import org.jboss.tools.common.model.ui.attribute.adapter.DefaultValueAdapter;
import org.eclipse.jdt.internal.ui.refactoring.contentassist.ControlContentAssistHelper;
import org.eclipse.jface.action.IAction;
@@ -396,4 +397,12 @@
}
return oldTextValue != null && oldTextValue.equals(newValue);
}
+
+ protected void addContentAssist(Text text) {
+ if(propertyEditor != null && propertyEditor.getInput() instanceof DefaultValueAdapter) {
+ DefaultValueAdapter valueAdapter = (DefaultValueAdapter)propertyEditor.getInput();
+ AttributeContentProposalProviderFactory.registerContentAssist(valueAdapter, text);
+ }
+ }
+
}
Modified: trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/attribute/editor/StringFieldEditor.java
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/attribute/editor/StringFieldEditor.java 2008-11-13 15:03:19 UTC (rev 11760)
+++ trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/attribute/editor/StringFieldEditor.java 2008-11-13 15:03:24 UTC (rev 11761)
@@ -10,6 +10,12 @@
******************************************************************************/
package org.jboss.tools.common.model.ui.attribute.editor;
+import java.util.ArrayList;
+
+import org.eclipse.jface.fieldassist.ContentProposalAdapter;
+import org.eclipse.jface.fieldassist.IContentProposal;
+import org.eclipse.jface.fieldassist.IContentProposalProvider;
+import org.eclipse.jface.fieldassist.TextContentAdapter;
import org.eclipse.jface.util.Assert;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.DisposeEvent;
@@ -214,6 +220,9 @@
if(textLimit > 0){//Only set limits above 0 - see SWT spec
textField.setTextLimit(textLimit);
}
+
+ addContentAssist(textField);
+
} else {
checkParent(textControl, parent);
}
@@ -229,6 +238,9 @@
});
return textControl;
}
+
+ protected void addContentAssist(Text text) {}
+
/**
* We cannot controls to provide READ-ONLY property on the fly.
Modified: trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/attribute/editor/StringFieldEditorEx.java
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/attribute/editor/StringFieldEditorEx.java 2008-11-13 15:03:19 UTC (rev 11760)
+++ trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/attribute/editor/StringFieldEditorEx.java 2008-11-13 15:03:24 UTC (rev 11761)
@@ -12,12 +12,21 @@
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
+import java.util.List;
+import org.jboss.tools.common.meta.XAttribute;
import org.jboss.tools.common.model.ui.IAttributeErrorProvider;
import org.jboss.tools.common.model.ui.IValueChangeListener;
import org.jboss.tools.common.model.ui.IValueProvider;
+import org.jboss.tools.common.model.ui.attribute.AttributeContentProposalProviderFactory;
+import org.jboss.tools.common.model.ui.attribute.IAttributeContentProposalProvider;
import org.jboss.tools.common.model.ui.attribute.adapter.DefaultValueAdapter;
+import org.eclipse.jface.fieldassist.ContentProposalAdapter;
+import org.eclipse.jface.fieldassist.IContentProposalProvider;
+import org.eclipse.jface.fieldassist.TextContentAdapter;
import org.eclipse.jface.util.IPropertyChangeListener;
+import org.eclipse.swt.events.DisposeEvent;
+import org.eclipse.swt.events.DisposeListener;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Text;
@@ -134,4 +143,11 @@
return oldTextValue != null && oldTextValue.equals(newValue);
}
+ protected void addContentAssist(Text text) {
+ if(propertyEditor != null && propertyEditor.getInput() instanceof DefaultValueAdapter) {
+ DefaultValueAdapter valueAdapter = (DefaultValueAdapter)propertyEditor.getInput();
+ AttributeContentProposalProviderFactory.registerContentAssist(valueAdapter, text);
+ }
+ }
+
}
17 years, 5 months
JBoss Tools SVN: r11760 - in trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor: template and 1 other directories.
by jbosstools-commits@lists.jboss.org
Author: sdzmitrovich
Date: 2008-11-13 10:03:19 -0500 (Thu, 13 Nov 2008)
New Revision: 11760
Removed:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/TemplateManagingUtil.java
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeSelectionBuilder.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeVisualKeyHandler.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/IEditableTemplate.java
Log:
cleaned code
Modified: trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeSelectionBuilder.java
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeSelectionBuilder.java 2008-11-13 13:34:48 UTC (rev 11759)
+++ trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeSelectionBuilder.java 2008-11-13 15:03:19 UTC (rev 11760)
@@ -22,11 +22,10 @@
import org.jboss.tools.vpe.editor.mapping.VpeElementMapping;
import org.jboss.tools.vpe.editor.mapping.VpeNodeMapping;
import org.jboss.tools.vpe.editor.selection.VpeSelectionController;
-import org.jboss.tools.vpe.editor.template.ISelectionManager;
import org.jboss.tools.vpe.editor.template.VpePseudoContentCreator;
import org.jboss.tools.vpe.editor.template.VpeTemplate;
import org.jboss.tools.vpe.editor.util.HTML;
-import org.jboss.tools.vpe.editor.util.TemplateManagingUtil;
+import org.jboss.tools.vpe.editor.util.SelectionUtil;
import org.jboss.tools.vpe.editor.util.TextUtil;
import org.jboss.tools.vpe.editor.util.VisualDomUtil;
import org.jboss.tools.vpe.xulrunner.editor.XulRunnerEditor;
@@ -79,9 +78,9 @@
public void setSelection(nsISelection selection) {
- VpeTemplate vpeTemplate = TemplateManagingUtil
- .getTemplateByVisualSelection(visualBuilder.getPageContext(),
- TemplateManagingUtil.getSelectedNode(selection));
+// VpeTemplate vpeTemplate = SelectionUtil
+// .getTemplateByVisualSelection(visualBuilder.getPageContext(),
+// SelectionUtil.getSelectedNode(selection));
// if (vpeTemplate instanceof ITemplateSelectionManager) {
// ((ITemplateSelectionManager) vpeTemplate).setSelection(
// visualBuilder.getPageContext(), selection);
Modified: trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeVisualKeyHandler.java
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeVisualKeyHandler.java 2008-11-13 13:34:48 UTC (rev 11759)
+++ trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeVisualKeyHandler.java 2008-11-13 15:03:19 UTC (rev 11760)
@@ -44,12 +44,10 @@
import org.jboss.tools.vpe.editor.selection.VpeSelectedNodeInfo;
import org.jboss.tools.vpe.editor.selection.VpeSourceSelection;
import org.jboss.tools.vpe.editor.selection.VpeSourceSelectionBuilder;
-import org.jboss.tools.vpe.editor.template.IKeyEventHandler;
import org.jboss.tools.vpe.editor.template.VpeHtmlTemplate;
import org.jboss.tools.vpe.editor.template.VpeTemplate;
import org.jboss.tools.vpe.editor.util.FlatIterator;
import org.jboss.tools.vpe.editor.util.HTML;
-import org.jboss.tools.vpe.editor.util.TemplateManagingUtil;
import org.jboss.tools.vpe.editor.util.TextUtil;
import org.jboss.tools.vpe.xulrunner.editor.XulRunnerVpeUtils;
import org.mozilla.interfaces.nsIDOMElement;
@@ -171,8 +169,8 @@
boolean shiftKey = keyEvent.getShiftKey();
// get template of selected element
- VpeTemplate template = TemplateManagingUtil
- .getTemplateByVisualSelection(pageContext,getSelectedNode());
+// VpeTemplate template = TemplateManagingUtil
+// .getTemplateByVisualSelection(pageContext,getSelectedNode());
// if template an handle keyEvent than pass control to him. And if
// template handled event return true
Modified: trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/IEditableTemplate.java
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/IEditableTemplate.java 2008-11-13 13:34:48 UTC (rev 11759)
+++ trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/IEditableTemplate.java 2008-11-13 15:03:19 UTC (rev 11760)
@@ -18,6 +18,7 @@
* The Interface IEditableTemplate.
*
* @author Evgenij Stherbin
+ * @deprecated
*/
public interface IEditableTemplate {
Deleted: trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/TemplateManagingUtil.java
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/TemplateManagingUtil.java 2008-11-13 13:34:48 UTC (rev 11759)
+++ trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/TemplateManagingUtil.java 2008-11-13 15:03:19 UTC (rev 11760)
@@ -1,464 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 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:
- * Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
-package org.jboss.tools.vpe.editor.util;
-
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.wst.sse.core.internal.provisional.IndexedRegion;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMAttr;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMDocument;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode;
-import org.jboss.tools.vpe.editor.context.VpePageContext;
-import org.jboss.tools.vpe.editor.mapping.VpeElementMapping;
-import org.jboss.tools.vpe.editor.mapping.VpeNodeMapping;
-import org.jboss.tools.vpe.editor.template.VpeTemplate;
-import org.mozilla.interfaces.nsIDOMElement;
-import org.mozilla.interfaces.nsIDOMHTMLInputElement;
-import org.mozilla.interfaces.nsIDOMNSHTMLInputElement;
-import org.mozilla.interfaces.nsIDOMNSHTMLTextAreaElement;
-import org.mozilla.interfaces.nsIDOMNode;
-import org.mozilla.interfaces.nsIDOMRange;
-import org.mozilla.interfaces.nsISelection;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-
-/**
- * @deprecated
- * @author S. Dzmitrovich
- *
- */
-public class TemplateManagingUtil {
-
- /**
- * name of "view" tag
- */
- private static final String VIEW_TAGNAME = "view"; //$NON-NLS-1$
-
- /**
- * name of "locale" attribute
- */
- private static final String LOCALE_ATTRNAME = "locale"; //$NON-NLS-1$
-
- /**
- * get template of selected element
- *
- * @param pageContext
- * @return
- */
- public static VpeTemplate getTemplateByVisualSelection(
- VpePageContext pageContext, nsIDOMNode selectedNode) {
- // get element mapping
-
- VpeElementMapping elementMapping = getElementMappingByVisualSelection(
- pageContext, selectedNode);
-
- if (elementMapping != null)
- return elementMapping.getTemplate();
-
- return null;
- }
-
- /**
- *
- * @param pageContext
- * @param selectedNode
- */
- public static VpeElementMapping getElementMappingByVisualSelection(
- VpePageContext pageContext, nsIDOMNode selectedNode) {
-
- // get element mapping
- VpeElementMapping elementMapping = pageContext.getDomMapping()
- .getNearElementMapping(selectedNode);
-
- if (elementMapping != null)
- return elementMapping;
-
- /*
- * next code is necessary for get template some jsf elements (which have
- * escape="false" attribute). It's necessary for the current
- * implementation of escape="false" attribute's process. When or if the
- * implementation of escape="false" attribute's process will changed,
- * you will must review next code
- */
- VpeNodeMapping nodeMapping = pageContext.getDomMapping()
- .getNearNodeMapping(selectedNode);
-
- if (nodeMapping != null) {
-
- /*
- * get node. This node is not ascribe (may be) to DOM model of page,
- * because "value" attribute is parsed (if escape ="false")
- * separately and is built in vpe. But it has correct offset
- * information
- */
- IDOMNode mappingNode = (IDOMNode) nodeMapping.getSourceNode();
-
- // get document
- IDOMDocument sourceDocument = getSourceDocument(pageContext);
-
- // get source node by ofsset
- Node sourceNode = getSourceNodeByPosition(sourceDocument,
- mappingNode.getStartOffset());
- // find elementMapping by source node
- if (sourceNode != null) {
- VpeElementMapping mapping = pageContext.getDomMapping()
- .getNearElementMapping(sourceNode);
- if (mapping != null)
- return mapping;
- }
-
- }
-
- return null;
-
- }
-
- /**
- * get template by source Selection
- *
- * @param pageContext
- * @param focus
- * @param anchor
- * @return
- */
- public static VpeTemplate getTemplateBySourceSelection(
- VpePageContext pageContext, int focus, int anchor) {
-
- VpeElementMapping elementMapping = getElementMappingBySourceSelection(
- pageContext, focus, anchor);
-
- if (elementMapping != null)
- return elementMapping.getTemplate();
-
- return null;
- }
-
- /**
- *
- * @param pageContext
- * @param selectedRange
- * @return
- */
- public static VpeElementMapping getElementMappingBySourceSelection(
- VpePageContext pageContext, Point selectedRange) {
-
- return getElementMappingBySourceSelection(pageContext, selectedRange.x,
- selectedRange.x + selectedRange.y);
- }
-
- /**
- * get element mapping by source Selection
- *
- * @param pageContext
- * @param focus
- * @param anchor
- * @return
- */
- public static VpeElementMapping getElementMappingBySourceSelection(
- VpePageContext pageContext, int focus, int anchor) {
-
- // get document
- IDOMDocument sourceDocument = getSourceDocument(pageContext);
-
- /*
- * implementation of IDOMModel's method getIndexedRegion(...) has one
- * feature : if cursor is situated at the border of elements then this
- * method return next element. For example ... <h:inputText ../><h:outputText/>... -
- * if cursor will be situated at the right border of "h:inputText"
- * element then getIndexedRegion() return "h:outputText" element. So for
- * focus position we choose smaller value
- */
-
- if (anchor < focus) {
- focus = anchor;
- anchor = focus;
- }
-
- // get source node by offset
- Node focusNode = getSourceNodeByPosition(sourceDocument, focus);
-
- // if focus node also contain anchor point (selected only 1 element)
- if ((focusNode != null) && isNodeContainPosition(focusNode, anchor)) {
-
- return pageContext.getDomMapping().getNearElementMapping(focusNode);
-
- }
- return null;
-
- }
-
- /**
- * get element mapping by source Selection
- *
- * @param pageContext
- * @param focus
- * @param anchor
- * @return
- */
- public static VpeElementMapping getElementMappingBySourcePosition(
- VpePageContext pageContext, int focus) {
-
- // get document
- IDOMDocument sourceDocument = getSourceDocument(pageContext);
-
- // get source node by offset
- Node focusNode = getSourceNodeByPosition(sourceDocument, focus);
-
- // if focus node also contain anchor point (selected only 1 element)
- if ((focusNode != null)) {
-
- VpeElementMapping elementMapping = pageContext.getDomMapping()
- .getNearElementMapping(focusNode);
-
- return elementMapping;
-
- }
- return null;
-
- }
-
- private static boolean isNodeContainPosition(Node node, int position) {
-
- if ((((IDOMNode) node).getStartOffset() <= position)
- && (((IDOMNode) node).getEndOffset() >= position))
- return true;
-
- return false;
- }
-
- /**
- * get source node by position
- *
- * @param pageContext
- * @param position
- * @return
- */
- private static Node getSourceNodeByPosition(IDOMDocument document,
- int position) {
-
- // get source node by position
- IDOMNode node = (IDOMNode) document.getModel().getIndexedRegion(
- position);
-
- return node;
- }
-
- private static IDOMDocument getSourceDocument(VpePageContext pageContext) {
-
- return (IDOMDocument) pageContext.getSourceBuilder()
- .getSourceDocument();
- }
-
- /**
- * get selected element
- *
- * @param pageContext
- * @return
- */
- public static nsIDOMElement getLastSelectedVisualNode(
- VpePageContext pageContext) {
-
- return pageContext.getEditPart().getController().getXulRunnerEditor()
- .getLastSelectedElement();
- }
-
- /**
- *
- * @param selection
- * @return
- */
- public static nsIDOMNode getSelectedNode(nsISelection selection) {
-
- if (selection.getFocusNode() == selection.getAnchorNode()) {
- if (selection.getFocusNode() != null) {
- if ((selection.getFocusNode().getNodeType() != nsIDOMNode.TEXT_NODE)
- && (selection.getFocusOffset() != 0)) {
-
- return selection.getFocusNode().getChildNodes().item(
- selection.getFocusOffset() - 1);
- } else
- return selection.getFocusNode();
-
- }
- } else {
- nsIDOMRange range = selection.getRangeAt(0);
- nsIDOMNode visualAncestor = range.getCommonAncestorContainer();
- return visualAncestor;
- }
- return null;
- }
-
- /**
- * get start offset of node
- *
- * @param node
- * @return
- */
- public static int getStartOffsetNode(Node node) {
-
- if (node instanceof IDOMAttr) {
- return ((IDOMAttr) node).getValueRegionStartOffset() + 1;
- } else if (node instanceof IndexedRegion) {
- return ((IndexedRegion) node).getStartOffset();
- }
- return 0;
- }
-
- /**
- *
- * @param node
- * @return
- */
- public static int getLengthNode(Node node) {
-
- if (node instanceof IDOMAttr) {
- return ((IDOMAttr) node).getValueSource().length();
- } else if (node instanceof IndexedRegion) {
- return ((IndexedRegion) node).getEndOffset()
- - ((IndexedRegion) node).getStartOffset();
- }
- return 0;
- }
-
- /**
- * get end offset of node
- *
- * @param node
- * @return
- */
- public static int getEndOffsetNode(Node node) {
-
- if (node instanceof IndexedRegion) {
- return ((IndexedRegion) node).getEndOffset();
- }
- return 0;
- }
-
- /**
- *
- * @param pageContext
- * @param node
- * @param offset
- * @param length
- */
- public static void setSourceSelection(VpePageContext pageContext,
- Node node, int offset, int length) {
-
- int start = getStartOffsetNode(node);
-
- pageContext.getSourceBuilder().getStructuredTextViewer()
- .setSelectedRange(start + offset, length);
- pageContext.getSourceBuilder().getStructuredTextViewer().revealRange(
- start + offset, length);
-
- }
-
- /**
- *
- * @param pageContext
- * @return
- */
- public static nsISelection getCurrentSelection(VpePageContext pageContext) {
- return pageContext.getEditPart().getController().getXulRunnerEditor()
- .getSelection();
- }
-
- /**
- *
- * @param pageContext
- * @param sourceElement
- * @return
- */
- public static String getPageLocale(VpePageContext pageContext,
- Node sourceNode) {
-
- while (sourceNode != null) {
-
- if (VIEW_TAGNAME.equals(sourceNode.getLocalName())) {
- break;
- }
- sourceNode = sourceNode.getParentNode();
- }
-
- if ((sourceNode == null) || !(sourceNode instanceof Element)
- || !(((Element) sourceNode).hasAttribute(LOCALE_ATTRNAME)))
- return null;
-
- String locale = ((Element) sourceNode).getAttribute(LOCALE_ATTRNAME);
-
- return locale;
-
- }
-
- public static Point getSelectionRangeFromInputElement(nsIDOMNode node) {
-
- Point range = new Point(0, 0);
-
- if (node != null)
- if (HTML.TAG_INPUT.equalsIgnoreCase(node.getLocalName())) {
-
- nsIDOMNSHTMLInputElement inputElement = (nsIDOMNSHTMLInputElement) node
- .queryInterface(nsIDOMNSHTMLInputElement.NS_IDOMNSHTMLINPUTELEMENT_IID);
-
- range.x = inputElement.getSelectionStart();
- range.y = inputElement.getSelectionEnd()
- - inputElement.getSelectionStart();
- } else if (HTML.TAG_TEXTAREA.equalsIgnoreCase(node.getLocalName())) {
-
- nsIDOMNSHTMLTextAreaElement textAreaElement = (nsIDOMNSHTMLTextAreaElement) node
- .queryInterface(nsIDOMNSHTMLTextAreaElement.NS_IDOMNSHTMLTEXTAREAELEMENT_IID);
- range.x = textAreaElement.getSelectionStart();
- range.y = textAreaElement.getSelectionEnd()
- - textAreaElement.getSelectionStart();
-
- }
-
- return range;
-
- }
-
- /**
- *
- * @param node
- * @param range
- */
- public static void setSelectionRangeInInputElement(nsIDOMNode node,
- Point range) {
-
- if ((node != null) && (range != null))
- if (HTML.TAG_INPUT.equalsIgnoreCase(node.getLocalName())) {
-
- nsIDOMHTMLInputElement inputElement = (nsIDOMHTMLInputElement) node
- .queryInterface(nsIDOMHTMLInputElement.NS_IDOMHTMLINPUTELEMENT_IID);
- System.out.print("\ninput:"+inputElement.getType());
-// nsIDOMNSHTMLInputElement inputElement = (nsIDOMNSHTMLInputElement) node
-// .queryInterface(nsIDOMNSHTMLInputElement.NS_IDOMNSHTMLINPUTELEMENT_IID);
-// inputElement.setSelectionRange(range.x, range.x + range.y);
- } else if (HTML.TAG_TEXTAREA.equalsIgnoreCase(node.getLocalName())) {
- nsIDOMNSHTMLTextAreaElement textAreaElement = (nsIDOMNSHTMLTextAreaElement) node
- .queryInterface(nsIDOMNSHTMLTextAreaElement.NS_IDOMNSHTMLTEXTAREAELEMENT_IID);
- textAreaElement.setSelectionRange(range.x, range.x + range.y);
- }
- }
-
- /**
- *
- * @param pageContext
- * @param startPosition
- * @param endPosition
- * @return
- */
- public static String getSourceText(VpePageContext pageContext,
- int startPosition, int endPosition) {
-
- return pageContext.getSourceBuilder().getStructuredTextViewer()
- .getTextWidget().getText(startPosition, endPosition);
- }
-}
17 years, 5 months
JBoss Tools SVN: r11759 - trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/util.
by jbosstools-commits@lists.jboss.org
Author: dazarov
Date: 2008-11-13 08:34:48 -0500 (Thu, 13 Nov 2008)
New Revision: 11759
Modified:
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/util/XModelUtil.java
Log:
Refactoring: XModel action usage in diagram editors
Modified: trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/util/XModelUtil.java
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/util/XModelUtil.java 2008-11-13 13:28:25 UTC (rev 11758)
+++ trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/util/XModelUtil.java 2008-11-13 13:34:48 UTC (rev 11759)
@@ -21,7 +21,7 @@
private static final String DEFAULT_MODEL_VERSION = "5.0";
private static final String PROPERTIES_ACTION = "Properties/Properties";
- private static final String EDIT_ACTION = "5.0";
+ private static final String EDIT_ACTION = "Edit";
public static void addModifyListener(XModel model, Object listener) {
RootImpl impl = (RootImpl)model.getRoot();
17 years, 5 months
JBoss Tools SVN: r11758 - in trunk: jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/model and 4 other directories.
by jbosstools-commits@lists.jboss.org
Author: dazarov
Date: 2008-11-13 08:28:25 -0500 (Thu, 13 Nov 2008)
New Revision: 11758
Modified:
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/util/XModelUtil.java
trunk/jsf/plugins/org.jboss.tools.jsf.ui/src/org/jboss/tools/jsf/ui/editor/actions/JSFCommandFactory.java
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/model/JSFXModelUtil.java
trunk/seam/plugins/org.jboss.tools.seam.pages.xml/src/org/jboss/tools/seam/pages/xml/model/SeamPagesXModelUtil.java
trunk/seam/plugins/org.jboss.tools.seam.ui.pages/src/org/jboss/tools/seam/ui/pages/editor/actions/PagesCommandFactory.java
trunk/struts/plugins/org.jboss.tools.struts/src/org/jboss/tools/struts/model/StrutsXModelUtil.java
Log:
Refactoring: XModel actions usage in diagram editors
Modified: trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/util/XModelUtil.java
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/util/XModelUtil.java 2008-11-13 12:29:39 UTC (rev 11757)
+++ trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/util/XModelUtil.java 2008-11-13 13:28:25 UTC (rev 11758)
@@ -19,6 +19,9 @@
public class XModelUtil {
private static final String DEFAULT_MODEL_VERSION = "5.0";
+
+ private static final String PROPERTIES_ACTION = "Properties/Properties";
+ private static final String EDIT_ACTION = "5.0";
public static void addModifyListener(XModel model, Object listener) {
RootImpl impl = (RootImpl)model.getRoot();
@@ -37,11 +40,11 @@
}
public static void openProperyDialog(XModelObject object){
- XActionInvoker.invoke("Properties/Properties", object, new Properties());
+ XActionInvoker.invoke(PROPERTIES_ACTION, object, new Properties());
}
public static void openEditor(XModelObject object){
- XActionInvoker.invoke("Edit", object, null);
+ XActionInvoker.invoke(EDIT_ACTION, object, null);
}
}
Modified: trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/model/JSFXModelUtil.java
===================================================================
--- trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/model/JSFXModelUtil.java 2008-11-13 12:29:39 UTC (rev 11757)
+++ trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/model/JSFXModelUtil.java 2008-11-13 13:28:25 UTC (rev 11758)
@@ -16,7 +16,9 @@
import org.jboss.tools.common.model.XModelObject;
public class JSFXModelUtil {
+ private static final String ADD_RULE_ACTION = "CreateActions.AddRule";
+
public static void addRule(XModelObject object, Properties properties){
- XActionInvoker.invoke("CreateActions.AddRule", object, properties);
+ XActionInvoker.invoke(ADD_RULE_ACTION, object, properties);
}
}
Modified: trunk/jsf/plugins/org.jboss.tools.jsf.ui/src/org/jboss/tools/jsf/ui/editor/actions/JSFCommandFactory.java
===================================================================
--- trunk/jsf/plugins/org.jboss.tools.jsf.ui/src/org/jboss/tools/jsf/ui/editor/actions/JSFCommandFactory.java 2008-11-13 12:29:39 UTC (rev 11757)
+++ trunk/jsf/plugins/org.jboss.tools.jsf.ui/src/org/jboss/tools/jsf/ui/editor/actions/JSFCommandFactory.java 2008-11-13 13:28:25 UTC (rev 11758)
@@ -18,7 +18,12 @@
import org.jboss.tools.jsf.ui.editor.model.commands.JSFCompoundCommand;
public class JSFCommandFactory {
+ private static final String DELETE_ACTION = "DeleteActions.Delete";
+ private static final String COPY_ACTION = "CopyActions.Copy";
+ private static final String CUT_ACTION = "CopyActions.Cut";
+ private static final String PASTE_ACTION = "CopyActions.Paste";
+
private static Command createCommand(List objects, String commandPath) {
Object source = null;
if (objects.isEmpty())
@@ -36,19 +41,19 @@
}
public static Command createDeleteCommand(List objects) {
- return createCommand(objects, "DeleteActions.Delete");
+ return createCommand(objects, DELETE_ACTION);
}
public static Command createCopyCommand(List objects) {
- return createCommand(objects, "CopyActions.Copy");
+ return createCommand(objects, COPY_ACTION);
}
public static Command createCutCommand(List objects) {
- return createCommand(objects, "CopyActions.Cut");
+ return createCommand(objects, CUT_ACTION);
}
public static Command createPasteCommand(List objects) {
- return createCommand(objects, "CopyActions.Paste");
+ return createCommand(objects, PASTE_ACTION);
}
}
Modified: trunk/seam/plugins/org.jboss.tools.seam.pages.xml/src/org/jboss/tools/seam/pages/xml/model/SeamPagesXModelUtil.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.pages.xml/src/org/jboss/tools/seam/pages/xml/model/SeamPagesXModelUtil.java 2008-11-13 12:29:39 UTC (rev 11757)
+++ trunk/seam/plugins/org.jboss.tools.seam.pages.xml/src/org/jboss/tools/seam/pages/xml/model/SeamPagesXModelUtil.java 2008-11-13 13:28:25 UTC (rev 11758)
@@ -16,11 +16,14 @@
import org.jboss.tools.common.model.XModelObject;
public class SeamPagesXModelUtil {
+ private static final String ADD_PAGE_ACTION = "CreateActions.AddPage";
+ private static final String ADD_EXCEPTION_ACTION = "CreateActions.AddException";
+
public static void addPage(XModelObject object, Properties properties){
- XActionInvoker.invoke("CreateActions.AddPage", object, properties);
+ XActionInvoker.invoke(ADD_PAGE_ACTION, object, properties);
}
public static void addException(XModelObject object, Properties properties){
- XActionInvoker.invoke("CreateActions.AddException", object, properties);
+ XActionInvoker.invoke(ADD_EXCEPTION_ACTION, object, properties);
}
}
Modified: trunk/seam/plugins/org.jboss.tools.seam.ui.pages/src/org/jboss/tools/seam/ui/pages/editor/actions/PagesCommandFactory.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.ui.pages/src/org/jboss/tools/seam/ui/pages/editor/actions/PagesCommandFactory.java 2008-11-13 12:29:39 UTC (rev 11757)
+++ trunk/seam/plugins/org.jboss.tools.seam.ui.pages/src/org/jboss/tools/seam/ui/pages/editor/actions/PagesCommandFactory.java 2008-11-13 13:28:25 UTC (rev 11758)
@@ -20,6 +20,10 @@
import org.jboss.tools.seam.ui.pages.editor.edit.PagesEditPart;
public class PagesCommandFactory {
+ private static final String DELETE_ACTION = "DeleteActions.Delete";
+ private static final String COPY_ACTION = "CopyActions.Copy";
+ private static final String CUT_ACTION = "CopyActions.Cut";
+ private static final String PASTE_ACTION = "CopyActions.Paste";
private static Command createCommand(List objects, String commandPath) {
Object source = null;
@@ -38,19 +42,19 @@
}
public static Command createDeleteCommand(List objects) {
- return createCommand(objects, "DeleteActions.Delete");
+ return createCommand(objects, DELETE_ACTION);
}
public static Command createCopyCommand(List objects) {
- return createCommand(objects, "CopyActions.Copy");
+ return createCommand(objects, COPY_ACTION);
}
public static Command createCutCommand(List objects) {
- return createCommand(objects, "CopyActions.Cut");
+ return createCommand(objects, CUT_ACTION);
}
public static Command createPasteCommand(List objects) {
- return createCommand(objects, "CopyActions.Paste");
+ return createCommand(objects, PASTE_ACTION);
}
}
Modified: trunk/struts/plugins/org.jboss.tools.struts/src/org/jboss/tools/struts/model/StrutsXModelUtil.java
===================================================================
--- trunk/struts/plugins/org.jboss.tools.struts/src/org/jboss/tools/struts/model/StrutsXModelUtil.java 2008-11-13 12:29:39 UTC (rev 11757)
+++ trunk/struts/plugins/org.jboss.tools.struts/src/org/jboss/tools/struts/model/StrutsXModelUtil.java 2008-11-13 13:28:25 UTC (rev 11758)
@@ -16,23 +16,29 @@
import org.jboss.tools.common.model.XModelObject;
public class StrutsXModelUtil {
+ private static final String ADD_RULE_ACTION = "CreateActions.AddRule";
+ private static final String CREATE_ACTION_ACTION = "CreateActions.CreateAction";
+ private static final String CREATE_EXCEPTION_ACTION = "CreateActions.CreateException";
+ private static final String CREATE_FORWARD_ACTION = "CreateActions.CreateForward";
+ private static final String CREATE_PAGE_ACTION = "CreateActions.CreatePage";
+
public static void addRule(XModelObject object, Properties properties){
- XActionInvoker.invoke("CreateActions.AddRule", object, properties);
+ XActionInvoker.invoke(ADD_RULE_ACTION, object, properties);
}
public static void addAction(XModelObject object, Properties properties){
- XActionInvoker.invoke("CreateActions.CreateAction", object, properties);
+ XActionInvoker.invoke(CREATE_ACTION_ACTION, object, properties);
}
public static void addException(XModelObject object, Properties properties){
- XActionInvoker.invoke("CreateActions.CreateException", object, properties);
+ XActionInvoker.invoke(CREATE_EXCEPTION_ACTION, object, properties);
}
public static void addForward(XModelObject object, Properties properties){
- XActionInvoker.invoke("CreateActions.CreateForward", object, properties);
+ XActionInvoker.invoke(CREATE_FORWARD_ACTION, object, properties);
}
public static void addPage(XModelObject object, Properties properties){
- XActionInvoker.invoke("CreateActions.CreatePage", object, properties);
+ XActionInvoker.invoke(CREATE_PAGE_ACTION, object, properties);
}
}
17 years, 5 months
JBoss Tools SVN: r11757 - trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/loaders/impl.
by jbosstools-commits@lists.jboss.org
Author: scabanovich
Date: 2008-11-13 07:29:39 -0500 (Thu, 13 Nov 2008)
New Revision: 11757
Modified:
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/loaders/impl/SimpleWebFileLoader.java
Log:
JBIDE-3111
Modified: trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/loaders/impl/SimpleWebFileLoader.java
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/loaders/impl/SimpleWebFileLoader.java 2008-11-13 12:18:11 UTC (rev 11756)
+++ trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/loaders/impl/SimpleWebFileLoader.java 2008-11-13 12:29:39 UTC (rev 11757)
@@ -49,6 +49,7 @@
String body = XModelObjectLoaderUtil.getTempBody(object);
Document doc = loadDocument(object, body);
if(doc == null) {
+ XModelObjectLoaderUtil.addRequiredChildren(object);
return;
}
Element element = doc.getDocumentElement();
17 years, 5 months
JBoss Tools SVN: r11756 - trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/mappingproject.
by jbosstools-commits@lists.jboss.org
Author: dgeraskov
Date: 2008-11-13 07:18:11 -0500 (Thu, 13 Nov 2008)
New Revision: 11756
Modified:
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/mappingproject/ProjectUtil.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-2734
Modified: trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/mappingproject/ProjectUtil.java
===================================================================
--- trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/mappingproject/ProjectUtil.java 2008-11-13 12:18:06 UTC (rev 11755)
+++ trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/mappingproject/ProjectUtil.java 2008-11-13 12:18:11 UTC (rev 11756)
@@ -20,19 +20,25 @@
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Status;
+import org.eclipse.debug.ui.ILaunchConfigurationTab;
import org.eclipse.jdt.core.IPackageFragment;
import org.eclipse.jface.text.TextSelection;
import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.wizard.WizardDialog;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Text;
import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.internal.ErrorEditorPart;
import org.eclipse.ui.part.MultiPageEditorPart;
import org.eclipse.ui.texteditor.ITextEditor;
-import org.hibernate.console.preferences.ConsoleConfigurationPreferences;
import org.hibernate.eclipse.console.test.ConsoleTestMessages;
import org.hibernate.eclipse.console.wizards.ConsoleConfigurationCreationWizard;
+import org.hibernate.eclipse.console.wizards.ConsoleConfigurationWizardPage;
+import org.hibernate.eclipse.launch.ConsoleConfigurationMainTab;
import org.hibernate.mapping.PersistentClass;
/**
@@ -105,21 +111,34 @@
}
}
- public static void createConsoleCFG() throws CoreException{
- new ConsoleConfigurationCreationWizard2().run();
+ public static void createConsoleCFG() throws CoreException, SecurityException, NoSuchFieldException, IllegalArgumentException, IllegalAccessException{
+ ConsoleConfigurationCreationWizard2 wiz = new ConsoleConfigurationCreationWizard2();
+ IWorkbenchWindow win = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
+ WizardDialog wdialog = new WizardDialog(win.getShell(), wiz);
+ wdialog.create();
+ wiz.run();
+ wdialog.close();
}
private static class ConsoleConfigurationCreationWizard2 extends ConsoleConfigurationCreationWizard{
- public void run() throws CoreException {
+ public void run() throws CoreException, SecurityException, NoSuchFieldException, IllegalArgumentException, IllegalAccessException {
IPath cfgFilePath = new Path(MappingTestProject.PROJECT_NAME + "/" + //$NON-NLS-1$
TestUtilsCommon.SRC_FOLDER + "/" + ProjectUtil.CFG_FILE_NAME); //$NON-NLS-1$
- createConsoleConfiguration(null, null, ConsoleCFGName, ConsoleConfigurationPreferences.ConfigurationMode.CORE,
- MappingTestProject.PROJECT_NAME, true, "", //$NON-NLS-1$
- null, cfgFilePath, new Path[0], new Path[0], "", "", new NullProgressMonitor()); //$NON-NLS-1$//$NON-NLS-2$
-
+ ConsoleConfigurationWizardPage page = ((ConsoleConfigurationWizardPage)getPages()[0]);
+ ILaunchConfigurationTab[] tabs = page.getTabs();
+ ConsoleConfigurationMainTab main = (ConsoleConfigurationMainTab) tabs[0];
+ Class clazz = main.getClass();
+ Field projectName = clazz.getDeclaredField("projectNameText");
+ projectName.setAccessible(true);
+ Text text = (Text) projectName.get(main);
+ text.setText(MappingTestProject.PROJECT_NAME);
+ page.setConfigurationFilePath(cfgFilePath);
+ page.setName(ConsoleCFGName);
+ page.performFinish();
}
}
+
/**
* Sometimes we have exceptions while opening editors.
* IDE catches this exceptions and opens ErrorEditorPart instead of
@@ -195,5 +214,4 @@
}
return new ITextEditor[0];
}
-
}
17 years, 5 months
JBoss Tools SVN: r11755 - trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/wizards.
by jbosstools-commits@lists.jboss.org
Author: dgeraskov
Date: 2008-11-13 07:18:06 -0500 (Thu, 13 Nov 2008)
New Revision: 11755
Modified:
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/wizards/ConsoleConfigurationCreationWizard.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-2734
Modified: trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/wizards/ConsoleConfigurationCreationWizard.java
===================================================================
--- trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/wizards/ConsoleConfigurationCreationWizard.java 2008-11-13 11:58:19 UTC (rev 11754)
+++ trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/wizards/ConsoleConfigurationCreationWizard.java 2008-11-13 12:18:06 UTC (rev 11755)
@@ -108,115 +108,6 @@
return true;
}
- // Only used by tests - see JBIDE-2734
- static protected void createConsoleConfiguration(
- final Shell shell,
- final EclipseConsoleConfiguration oldConfig,
- final String configName,
- ConfigurationMode cmode, final String projectName, boolean useProjectClasspath, String entityResolver, IPath propertyFilename,
- IPath cfgFile, IPath[] mappings, IPath[] classpaths, String persistenceUnitName, String namingStrategy, IProgressMonitor monitor)
- throws CoreException {
-
- monitor.beginTask(HibernateConsoleMessages.ConsoleConfigurationCreationWizard_configuring_hibernate_console, IProgressMonitor.UNKNOWN);
-
- if(oldConfig!=null) {
- KnownConfigurations.getInstance().removeConfiguration( oldConfig, false );
- }
-
- ILaunchManager launchManager = DebugPlugin.getDefault().getLaunchManager();
- ILaunchConfigurationType launchConfigurationType = launchManager.getLaunchConfigurationType( ICodeGenerationLaunchConstants.CONSOLE_CONFIGURATION_LAUNCH_TYPE_ID );
- String launchName = launchManager.generateUniqueLaunchConfigurationNameFrom(configName);
- ILaunchConfigurationWorkingCopy wc = launchConfigurationType.newInstance(null, launchName);
- wc.setAttribute( IConsoleConfigurationLaunchConstants.CONFIGURATION_FACTORY, cmode.toString());
- wc.setAttribute( IConsoleConfigurationLaunchConstants.PROJECT_NAME, projectName );
-
- wc.setAttribute( IConsoleConfigurationLaunchConstants.PROPERTY_FILE, safePathName(propertyFilename) );
- wc.setAttribute( IConsoleConfigurationLaunchConstants.CFG_XML_FILE, safePathName(cfgFile) );
- wc.setAttribute( IConsoleConfigurationLaunchConstants.PERSISTENCE_UNIT_NAME, persistenceUnitName );
-
- wc.setAttribute( IConsoleConfigurationLaunchConstants.NAMING_STRATEGY, namingStrategy );
- wc.setAttribute( IConsoleConfigurationLaunchConstants.ENTITY_RESOLVER, entityResolver );
-
- IRuntimeClasspathEntry[] projectEntries = new IRuntimeClasspathEntry[0];
- if(useProjectClasspath) {
- wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_DEFAULT_CLASSPATH, true);
- projectEntries = JavaRuntime.computeUnresolvedRuntimeClasspath(wc);
-
- }
-
- if(classpaths.length>0) {
- List<String> user = new ArrayList<String>();
- for (int i = 0; i < projectEntries.length; i++) {
- user.add( projectEntries[i].getMemento() );
- }
- for (int i = 0; i < classpaths.length; i++) {
- IPath entry = classpaths[i];
- IRuntimeClasspathEntry userEntry = JavaRuntime.newArchiveRuntimeClasspathEntry( entry );
- user.add( userEntry.getMemento() );
- }
- wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_DEFAULT_CLASSPATH, false);
- wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_CLASSPATH, user);
- } else {
- wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_DEFAULT_CLASSPATH, true);
- wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_CLASSPATH, (String)null);
- }
-
- List<String> mappingFiles = new ArrayList<String>();
- for (int i = 0; i < mappings.length; i++) {
- mappingFiles.add(mappings[i].toPortableString());
- }
- wc.setAttribute( IConsoleConfigurationLaunchConstants.FILE_MAPPINGS, mappingFiles );
-
- wc.doSave();
-
- Display.getDefault().syncExec(new Runnable() {
- public void run() {
- if(StringHelper.isNotEmpty( projectName )) {
- IJavaProject project = ProjectUtils.findJavaProject( projectName );
- if(project.exists()) {
- HibernateNature hibernateNature = HibernateNature.getHibernateNature( project );
- if(hibernateNature==null) { // project not enabled at all
- String out = NLS.bind(HibernateConsoleMessages.ConsoleConfigurationCreationWizard_the_project, projectName, configName);
- if( MessageDialog.openConfirm( shell, HibernateConsoleMessages.ConsoleConfigurationCreationWizard_enable_hibernate_features, out)) {
- ProjectUtils.toggleHibernateOnProject( project.getProject(), true, configName );
- }
- }
- else {
- String defaultConsoleConfigurationName = hibernateNature.getDefaultConsoleConfigurationName();
-
- if((oldConfig!=null && oldConfig.getName().equals(defaultConsoleConfigurationName)) ||
- defaultConsoleConfigurationName.equals(hibernateNature.getDefaultConsoleConfigurationName())) { // an update so its just forced in there.
- ProjectUtils.toggleHibernateOnProject( project.getProject(), true, configName );
- } else if(defaultConsoleConfigurationName==null) {
- String out = NLS.bind(HibernateConsoleMessages.ConsoleConfigurationCreationWizard_the_project_named, projectName, configName);
- if(MessageDialog.openConfirm( shell, HibernateConsoleMessages.ConsoleConfigurationCreationWizard_enable_hibernate_features, out)) {
- ProjectUtils.toggleHibernateOnProject( project.getProject(), true, configName );
- }
- } else { // hibernate enabled, but not this exact one
- String out = NLS.bind(HibernateConsoleMessages.ConsoleConfigurationCreationWizard_the_project_named_have, new Object[]{ projectName, defaultConsoleConfigurationName, configName });
- if(MessageDialog.openConfirm( shell, HibernateConsoleMessages.ConsoleConfigurationCreationWizard_enable_hibernate_features, out)) {
- ProjectUtils.toggleHibernateOnProject( project.getProject(), true, configName );
- }
- }
- }
- }
- }
-
- }});
- monitor.worked(1);
- }
-
- private static String safePathName(IPath propertyFilename) {
- if(propertyFilename==null) {
- return null;
- } else {
- return propertyFilename.toOSString();
- }
- }
-
-
-
-
/**
* We will accept the selection in the workbench to see if
* we can initialize from it.
17 years, 5 months
JBoss Tools SVN: r11754 - trunk/archives/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/util/composites.
by jbosstools-commits@lists.jboss.org
Author: rob.stryker(a)jboss.com
Date: 2008-11-13 06:58:19 -0500 (Thu, 13 Nov 2008)
New Revision: 11754
Modified:
trunk/archives/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/util/composites/ArchiveSourceDestinationComposite.java
Log:
JBIDE-3049 - archives variables not using argument
Modified: trunk/archives/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/util/composites/ArchiveSourceDestinationComposite.java
===================================================================
--- trunk/archives/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/util/composites/ArchiveSourceDestinationComposite.java 2008-11-13 11:45:43 UTC (rev 11753)
+++ trunk/archives/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/util/composites/ArchiveSourceDestinationComposite.java 2008-11-13 11:58:19 UTC (rev 11754)
@@ -157,10 +157,10 @@
protected void variablesPressed() {
StringVariableSelectionDialog d = new StringVariableSelectionDialog(Display.getDefault().getActiveShell());
if(d.open() == Window.OK) {
- Object o = d.getFirstResult();
- if( o != null && o instanceof IStringVariable) {
+ String expr = d.getVariableExpression();
+ if( expr != null ) {
destinationNode = null;
- path = path + "${" + ((IStringVariable)o).getName() + "}"; //$NON-NLS-1$ //$NON-NLS-2$
+ path = path + expr;
validateAndUpdateWidgets();;
}
}
17 years, 5 months
JBoss Tools SVN: r11753 - trunk/as/plugins/org.jboss.ide.eclipse.as.ui.
by jbosstools-commits@lists.jboss.org
Author: rob.stryker(a)jboss.com
Date: 2008-11-13 06:45:43 -0500 (Thu, 13 Nov 2008)
New Revision: 11753
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/plugin.xml
Log:
JBIDE-3107 - server view missing icons initially
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.ui/plugin.xml
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.ui/plugin.xml 2008-11-13 11:33:27 UTC (rev 11752)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.ui/plugin.xml 2008-11-13 11:45:43 UTC (rev 11753)
@@ -327,6 +327,9 @@
<instanceof
value="org.eclipse.wst.server.ui.internal.view.servers.ModuleServer">
</instanceof>
+ <instanceof
+ value="org.eclipse.core.resources.IWorkspaceRoot">
+ </instanceof>
<adapt
type="java.util.Collection">
<count
17 years, 5 months
JBoss Tools SVN: r11752 - trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/launch.
by jbosstools-commits@lists.jboss.org
Author: rob.stryker(a)jboss.com
Date: 2008-11-13 06:33:27 -0500 (Thu, 13 Nov 2008)
New Revision: 11752
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/launch/JBossServerStartupLaunchConfiguration.java
Log:
JBIDE-3184 - cleanup legacy keys and restore backwards compat.
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/launch/JBossServerStartupLaunchConfiguration.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/launch/JBossServerStartupLaunchConfiguration.java 2008-11-13 10:53:25 UTC (rev 11751)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/launch/JBossServerStartupLaunchConfiguration.java 2008-11-13 11:33:27 UTC (rev 11752)
@@ -69,8 +69,13 @@
forceDefaultsSet(workingCopy, server);
}
- // Cleanup legacy keys
- workingCopy.setAttribute(IJavaLaunchConfigurationConstants.ATTR_CLASSPATH_PROVIDER, (String)null);
+ // Upgrade old launch configs
+ JBossServer jbs = findJBossServer(server.getId());
+ if( workingCopy.getAttribute(IJavaLaunchConfigurationConstants.ATTR_CLASSPATH_PROVIDER, (String)null) != null ) {
+ workingCopy.setAttribute(IJavaLaunchConfigurationConstants.ATTR_CLASSPATH_PROVIDER, (String)null);
+ workingCopy.setAttribute(IJavaLaunchConfigurationConstants.ATTR_CLASSPATH, getClasspath(jbs));
+ workingCopy.setAttribute(IJavaLaunchConfigurationConstants.ATTR_DEFAULT_CLASSPATH, false);
+ }
}
public static void forceDefaultsSet(ILaunchConfigurationWorkingCopy wc, IServer server) throws CoreException {
17 years, 5 months