JBoss Tools SVN: r3762 - trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/internal/project/facet.
by jbosstools-commits@lists.jboss.org
Author: vrubezhny
Date: 2007-09-21 13:50:13 -0400 (Fri, 21 Sep 2007)
New Revision: 3762
Modified:
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/internal/project/facet/SeamInstallWizardPage.java
Log:
http://jira.jboss.org/jira/browse/JBIDE-932 Seam facet wizard forgets what was chosen last
Last saved profiles loading is added
Modified: trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/internal/project/facet/SeamInstallWizardPage.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/internal/project/facet/SeamInstallWizardPage.java 2007-09-21 17:40:42 UTC (rev 3761)
+++ trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/internal/project/facet/SeamInstallWizardPage.java 2007-09-21 17:50:13 UTC (rev 3762)
@@ -90,8 +90,12 @@
final IFieldEditor jBossSeamHomeEditor = IFieldEditorFactory.INSTANCE
.createComboWithButton(ISeamFacetDataModelProperties.SEAM_RUNTIME_NAME,
"Seam Runtime", getRuntimeNames(),
- SeamRuntimeManager.getInstance().getDefaultRuntime()==null?
- "":SeamRuntimeManager.getInstance().getDefaultRuntime().getName(),
+ ("".equals(SeamFacetPreference
+ .getStringPreference(SeamFacetPreference.SEAM_RUNTIME_NAME)) ?
+ (SeamRuntimeManager.getInstance().getDefaultRuntime()==null?
+ "":SeamRuntimeManager.getInstance().getDefaultRuntime().getName()) :
+ SeamFacetPreference
+ .getStringPreference(SeamFacetPreference.SEAM_RUNTIME_NAME)),
true, new NewSeamRuntimeAction(), (IValidator)null);
// IFieldEditor jBossSeamHomeEditor = IFieldEditorFactory.INSTANCE
@@ -114,7 +118,11 @@
ISeamFacetDataModelProperties.SEAM_CONNECTION_PROFILE,
"Connection profile:",
getProfileNameList(),
- getProfileNameList().contains("DefaultDS")?"DefaultDS":"",
+ ("".equals(SeamCorePlugin.getDefault().getPluginPreferences()
+ .getString((SeamFacetPreference.SEAM_DEFAULT_CONNECTION_PROFILE))) ?
+ (getProfileNameList().contains("DefaultDS")?"DefaultDS":""):
+ SeamCorePlugin.getDefault().getPluginPreferences()
+ .getString((SeamFacetPreference.SEAM_DEFAULT_CONNECTION_PROFILE))),
true, new EditConnectionProfileAction(),
new NewConnectionProfileAction(),
ValidatorFactory.NO_ERRORS_VALIDATOR);
17 years, 3 months
JBoss Tools SVN: r3761 - trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/server/providers.
by jbosstools-commits@lists.jboss.org
Author: rob.stryker(a)jboss.com
Date: 2007-09-21 13:40:42 -0400 (Fri, 21 Sep 2007)
New Revision: 3761
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/server/providers/ModuleViewProvider.java
Log:
null check
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/server/providers/ModuleViewProvider.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/server/providers/ModuleViewProvider.java 2007-09-21 17:38:07 UTC (rev 3760)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/server/providers/ModuleViewProvider.java 2007-09-21 17:40:42 UTC (rev 3761)
@@ -252,8 +252,10 @@
Properties props = new Properties();
if( selected != null && selected instanceof ModuleServer) {
IModule mod = ((ModuleServer)selected).module[0];
- props.setProperty(Messages.ModulePropertyType, mod.getModuleType().getId());
- props.setProperty(Messages.ModulePropertyProject, mod.getProject().getName());
+ if( mod != null && mod.getProject() != null ) {
+ props.setProperty(Messages.ModulePropertyType, mod.getModuleType().getId());
+ props.setProperty(Messages.ModulePropertyProject, mod.getProject().getName());
+ }
}
return props;
}
17 years, 3 months
JBoss Tools SVN: r3760 - trunk/vpe/tests/org.jboss.tools.vpe.mozilla.test/src/org/jboss/tools/vpe/mozilla/tests.
by jbosstools-commits@lists.jboss.org
Author: dgolovin
Date: 2007-09-21 13:38:07 -0400 (Fri, 21 Sep 2007)
New Revision: 3760
Modified:
trunk/vpe/tests/org.jboss.tools.vpe.mozilla.test/src/org/jboss/tools/vpe/mozilla/tests/DOMCreatingTest.java
Log:
fix JUnit test error
testAddRemovingDOMElements Error XPCOM error -2147467262
org.jboss.tools.vpe.mozilla.internal.swt.xpl.XPCOMError: XPCOM error -2147467262
at org.jboss.tools.vpe.mozilla.browser.MozillaBrowser.error(MozillaBrowser.java:1111)
at org.jboss.tools.vpe.mozilla.browser.MozillaBrowser.getPresShell(MozillaBrowser.java:2639)
at org.jboss.tools.vpe.mozilla.browser.MozillaBrowser.getSelectionController(MozillaBrowser.java:2678)
at org.jboss.tools.vpe.mozilla.browser.MozillaBrowser.onFocusGained(MozillaBrowser.java:1195)
at org.jboss.tools.vpe.mozilla.browser.MozillaBrowser$1.handleEvent(MozillaBrowser.java:456)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:66)
Modified: trunk/vpe/tests/org.jboss.tools.vpe.mozilla.test/src/org/jboss/tools/vpe/mozilla/tests/DOMCreatingTest.java
===================================================================
--- trunk/vpe/tests/org.jboss.tools.vpe.mozilla.test/src/org/jboss/tools/vpe/mozilla/tests/DOMCreatingTest.java 2007-09-21 17:36:21 UTC (rev 3759)
+++ trunk/vpe/tests/org.jboss.tools.vpe.mozilla.test/src/org/jboss/tools/vpe/mozilla/tests/DOMCreatingTest.java 2007-09-21 17:38:07 UTC (rev 3760)
@@ -108,6 +108,7 @@
@Override
protected void setUp() throws Exception {
super.setUp();
+ delay(3000);
waitForJobs();
MozillaView mozilla
= ((MozillaView) PlatformUI.getWorkbench()
17 years, 3 months
JBoss Tools SVN: r3759 - trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist.
by jbosstools-commits@lists.jboss.org
Author: akazakov
Date: 2007-09-21 13:36:21 -0400 (Fri, 21 Sep 2007)
New Revision: 3759
Modified:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/RedHatHtmlContentAssistProcessor.java
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/RedHatJSPContentAssistProcessor.java
Log:
http://jira.jboss.com/jira/browse/JBIDE-817
Modified: trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/RedHatHtmlContentAssistProcessor.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/RedHatHtmlContentAssistProcessor.java 2007-09-21 17:30:00 UTC (rev 3758)
+++ trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/RedHatHtmlContentAssistProcessor.java 2007-09-21 17:36:21 UTC (rev 3759)
@@ -23,7 +23,6 @@
import org.eclipse.jst.jsp.core.internal.contentmodel.TaglibController;
import org.eclipse.jst.jsp.core.internal.contentmodel.tld.TLDCMDocumentManager;
import org.eclipse.jst.jsp.core.internal.contentmodel.tld.TaglibTracker;
-import org.eclipse.jst.jsp.ui.internal.preferences.JSPUIPreferenceNames;
import org.eclipse.swt.graphics.Image;
import org.eclipse.ui.IEditorInput;
import org.eclipse.wst.html.ui.internal.HTMLUIPlugin;
@@ -511,27 +510,27 @@
}
}
- private char[] autoActivChars;
-
public char[] getCompletionProposalAutoActivationCharacters() {
- if(autoActivChars==null) {
- IPreferenceStore store = HTMLUIPlugin.getDefault().getPreferenceStore();
- if(store.isDefault(JSPUIPreferenceNames.AUTO_PROPOSE_CODE)) {
- String superDefaultChars = store.getDefaultString(HTMLUIPreferenceNames.AUTO_PROPOSE_CODE);
- StringBuffer customDefaultChars = new StringBuffer(superDefaultChars);
- if(superDefaultChars.indexOf(".")<0) {
- customDefaultChars.append('.');
- store.setDefault(HTMLUIPreferenceNames.AUTO_PROPOSE_CODE, customDefaultChars.toString());
- store.setValue(HTMLUIPreferenceNames.AUTO_PROPOSE_CODE, customDefaultChars.toString());
- }
- if(autoActivChars==null) {
- autoActivChars = new char[customDefaultChars.length()];
- customDefaultChars.getChars(0, customDefaultChars.length(), autoActivChars, 0);
- }
- } else {
- return super.getCompletionProposalAutoActivationCharacters();
+ char[] autoActivChars = null;
+ char[] superAutoActivChars = super.getCompletionProposalAutoActivationCharacters();
+ if(superAutoActivChars==null) {
+ return superAutoActivChars;
+ }
+
+ autoActivChars = superAutoActivChars;
+ IPreferenceStore store = HTMLUIPlugin.getDefault().getPreferenceStore();
+ if(store.isDefault(HTMLUIPreferenceNames.AUTO_PROPOSE_CODE)) {
+// String superDefaultChars = store.getDefaultString(JSPUIPreferenceNames.AUTO_PROPOSE_CODE);
+ StringBuffer redhatDefaultChars = new StringBuffer(new String(superAutoActivChars));
+ if(redhatDefaultChars.indexOf(".")<0) {
+ redhatDefaultChars.append('.');
+ store.setDefault(HTMLUIPreferenceNames.AUTO_PROPOSE_CODE, redhatDefaultChars.toString());
+ store.setValue(HTMLUIPreferenceNames.AUTO_PROPOSE_CODE, redhatDefaultChars.toString());
}
+ autoActivChars = new char[redhatDefaultChars.length()];
+ redhatDefaultChars.getChars(0, redhatDefaultChars.length(), autoActivChars, 0);
}
+
return autoActivChars;
}
Modified: trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/RedHatJSPContentAssistProcessor.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/RedHatJSPContentAssistProcessor.java 2007-09-21 17:30:00 UTC (rev 3758)
+++ trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/RedHatJSPContentAssistProcessor.java 2007-09-21 17:36:21 UTC (rev 3759)
@@ -94,7 +94,6 @@
document = viewer.getDocument();
registerToTldManager(viewer);
-// updateActiveContentAssistProcessor(document);
ICompletionProposal[] proposals = super.computeCompletionProposals(viewer, documentPosition);
// If proposal list from super is empty to try to get it from Red Hat dinamic jsp content assist processor.
try {
@@ -150,29 +149,27 @@
super.initPartitionToProcessorMap();
}
- private char[] autoActivChars;
-
public char[] getCompletionProposalAutoActivationCharacters() {
+ char[] autoActivChars = null;
char[] superAutoActivChars = super.getCompletionProposalAutoActivationCharacters();
if(superAutoActivChars==null) {
return superAutoActivChars;
}
- if(autoActivChars==null) {
- autoActivChars = superAutoActivChars;
- IPreferenceStore store = JSPUIPlugin.getDefault().getPreferenceStore();
- if(store.isDefault(JSPUIPreferenceNames.AUTO_PROPOSE_CODE)) {
- String superDefaultChars = store.getDefaultString(JSPUIPreferenceNames.AUTO_PROPOSE_CODE);
- StringBuffer redhatDefaultChars = new StringBuffer(superDefaultChars);
- if(superDefaultChars.indexOf(".")<0) {
- redhatDefaultChars.append('.');
- store.setDefault(JSPUIPreferenceNames.AUTO_PROPOSE_CODE, redhatDefaultChars.toString());
- store.setValue(JSPUIPreferenceNames.AUTO_PROPOSE_CODE, redhatDefaultChars.toString());
- }
- autoActivChars = new char[redhatDefaultChars.length()];
- redhatDefaultChars.getChars(0, redhatDefaultChars.length(), autoActivChars, 0);
+ autoActivChars = superAutoActivChars;
+ IPreferenceStore store = JSPUIPlugin.getDefault().getPreferenceStore();
+ if(store.isDefault(JSPUIPreferenceNames.AUTO_PROPOSE_CODE)) {
+// String superDefaultChars = store.getDefaultString(JSPUIPreferenceNames.AUTO_PROPOSE_CODE);
+ StringBuffer redhatDefaultChars = new StringBuffer(new String(superAutoActivChars));
+ if(redhatDefaultChars.indexOf(".")<0) {
+ redhatDefaultChars.append('.');
+ store.setDefault(JSPUIPreferenceNames.AUTO_PROPOSE_CODE, redhatDefaultChars.toString());
+ store.setValue(JSPUIPreferenceNames.AUTO_PROPOSE_CODE, redhatDefaultChars.toString());
}
+ autoActivChars = new char[redhatDefaultChars.length()];
+ redhatDefaultChars.getChars(0, redhatDefaultChars.length(), autoActivChars, 0);
}
+
return autoActivChars;
}
@@ -313,9 +310,6 @@
Node parent = contentAssistRequest.getParent();
String error = null;
- // CMVC #242943 shouldn't have proposals before XMLPI
- // (nsd) This is only valid at the document element level
- // only valid if it's XML (check added 2/17/2004)
if (parent != null && parent.getNodeType() == Node.DOCUMENT_NODE && ((IDOMDocument) parent).isXMLType() && !isCursorAfterXMLPI(contentAssistRequest)) {
return;
}
@@ -323,10 +317,6 @@
if (!isCursorAfterDoctype(contentAssistRequest))
return;
- // CMVC 248081
- // fix for meta-info comment nodes.. they currently "hide" other
- // proposals because the don't
- // have a content model (so can't propose any children..)
if (parent != null && parent instanceof IDOMNode && isCommentNode((IDOMNode) parent)) {
// loop and find non comment node?
while (parent != null && isCommentNode((IDOMNode) parent)) {
@@ -354,11 +344,7 @@
}
String proposedInfo = getAdditionalInfo(parentDecl, childType);
for (int i = 0; i < childStrings.length; i++) {
- // Start Red Hat changes
- // WTP native code:
- // CustomCompletionProposal textProposal = new CustomCompletionProposal(childStrings[i], begin, length, childStrings[i].length(), XMLEditorPluginImageHelper.getInstance().getImage(XMLEditorPluginImages.IMG_OBJ_ENUM), childStrings[i], null, proposedInfo, XMLRelevanceConstants.R_TAG_INSERTION);
CustomCompletionProposal textProposal = new RedHatCustomCompletionProposal(childStrings[i].indexOf("=")>-1, childStrings[i], begin, length, childStrings[i].length(), XMLEditorPluginImageHelper.getInstance().getImage(XMLEditorPluginImages.IMG_OBJ_ENUM), childStrings[i], null, proposedInfo, XMLRelevanceConstants.R_TAG_INSERTION);
- // End Red Hat changes
contentAssistRequest.addProposal(textProposal);
}
}
@@ -424,11 +410,7 @@
String proposedInfo = getAdditionalInfo(parentDecl, elementDecl);
int relevance = isStrictCMNodeSuggestion ? XMLRelevanceConstants.R_STRICTLY_VALID_TAG_INSERTION : XMLRelevanceConstants.R_TAG_INSERTION;
- // Start Red Hat changes
- // WTP native code:
- // CustomCompletionProposal proposal = new CustomCompletionProposal(proposedText, contentAssistRequest.getReplacementBeginPosition(), contentAssistRequest.getReplacementLength(), markupAdjustment, image, tagname, null, proposedInfo, relevance);
CustomCompletionProposal proposal = new RedHatCustomCompletionProposal(true, proposedText, contentAssistRequest.getReplacementBeginPosition(), contentAssistRequest.getReplacementLength(), markupAdjustment, image, tagname, null, proposedInfo, relevance);
- // End Red Hat changes
contentAssistRequest.addProposal(proposal);
}
}
@@ -476,11 +458,7 @@
// account for the < and >
int markupAdjustment = getContentGenerator().getMinimalStartTagLength(parent, ed);
String proposedInfo = getAdditionalInfo(null, ed);
- // Start Red Hat changes
- // WTP native code:
-// CustomCompletionProposal proposal = new CustomCompletionProposal(proposedText, contentAssistRequest.getReplacementBeginPosition(), contentAssistRequest.getReplacementLength(), markupAdjustment, image, tagname, null, proposedInfo, XMLRelevanceConstants.R_TAG_INSERTION);
CustomCompletionProposal proposal = new RedHatCustomCompletionProposal(false, proposedText, contentAssistRequest.getReplacementBeginPosition(), contentAssistRequest.getReplacementLength(), markupAdjustment, image, tagname, null, proposedInfo, XMLRelevanceConstants.R_TAG_INSERTION);
- // End Red Hat changes
contentAssistRequest.addProposal(proposal);
}
@@ -510,7 +488,6 @@
String matchString = contentAssistRequest.getMatchString();
if (parent.getNodeType() == Node.ELEMENT_NODE) {
// retrieve the list of children
- //validActions = getAvailableChildrenAtIndex((Element) parent, childPosition);
cmnodes = getAvailableChildElementDeclarations((Element)parent, childPosition, ModelQueryAction.INSERT);
Iterator nodeIterator = cmnodes.iterator();
// chop off any leading <'s and whitespace from the matchstring
@@ -536,21 +513,7 @@
}
else {
proposedText = getRequiredName(parent, elementDecl);
- // Start Red Hat changes
- // WTP native code:
- // cursorAdjustment = proposedText.length();
- // if (elementDecl instanceof CMElementDeclaration) {
- // CMElementDeclaration ed = (CMElementDeclaration) elementDecl;
- // if (ed.getContentType() == CMElementDeclaration.EMPTY) {
- // proposedText += getContentGenerator().getStartTagClose(parent, ed);
- // cursorAdjustment = proposedText.length();
- // }
- // else {
- // cursorAdjustment = proposedText.length() + 1;
- // proposedText += "></" + getRequiredName(parent, elementDecl) + ">"; //$NON-NLS-2$//$NON-NLS-1$
- // }
-
StringBuffer buffer = new StringBuffer();
KbProposal proposal;
TagDescriptor info;
@@ -593,23 +556,14 @@
} catch (KbException e) {
JspEditorPlugin.getPluginLog().logError(e);
}
- // End Red Hat changes
}
- // Start Red Hat changes
- // WTP native code:
- // if (beginsWith(proposedText, matchString)) {
if (beginsWith(proposedText, matchString) || beginsWith(proposedText, "<" + matchString)) {
- // End Red Hat changes
Image image = CMImageUtil.getImage(elementDecl);
if (image == null) {
image = XMLEditorPluginImageHelper.getInstance().getImage(XMLEditorPluginImages.IMG_OBJ_TAG_GENERIC);
}
String proposedInfo = getAdditionalInfo(getCMElementDeclaration(parent), elementDecl);
- // Start Red Hat changes
- // WTP native code:
- // CustomCompletionProposal proposal = new CustomCompletionProposal(proposedText, contentAssistRequest.getReplacementBeginPosition(), contentAssistRequest.getReplacementLength(), cursorAdjustment, image, getRequiredName(parent, elementDecl), null, proposedInfo, XMLRelevanceConstants.R_TAG_NAME);
CustomCompletionProposal proposal = new RedHatCustomCompletionProposal(proposedText.indexOf('\"')>-1 && proposedText.indexOf("=")>-1, proposedText, contentAssistRequest.getReplacementBeginPosition(), contentAssistRequest.getReplacementLength(), cursorAdjustment, image, getRequiredName(parent, elementDecl), null, proposedInfo, XMLRelevanceConstants.R_TAG_NAME);
- // End Red Hat changes
contentAssistRequest.addProposal(proposal);
}
}
@@ -657,11 +611,7 @@
if (image == null) {
image = XMLEditorPluginImageHelper.getInstance().getImage(XMLEditorPluginImages.IMG_OBJ_TAG_GENERIC);
}
- // Start Red Hat changes
- // WTP native code:
-// CustomCompletionProposal proposal = new CustomCompletionProposal(proposedText, contentAssistRequest.getReplacementBeginPosition(), contentAssistRequest.getReplacementLength(), cursorAdjustment, image, getRequiredName(parent, ed), null, proposedInfo, XMLRelevanceConstants.R_TAG_NAME);
CustomCompletionProposal proposal = new RedHatCustomCompletionProposal(proposedText.indexOf('\"')>-1, proposedText, contentAssistRequest.getReplacementBeginPosition(), contentAssistRequest.getReplacementLength(), cursorAdjustment, image, getRequiredName(parent, ed), null, proposedInfo, XMLRelevanceConstants.R_TAG_NAME);
- // End Red Hat changes
contentAssistRequest.addProposal(proposal);
contentAssistRequest.addProposal(proposal);
}
@@ -669,9 +619,6 @@
}
}
- /*
- * Red Hat: Get from AbstractContentAssistProcessor becouse it is private.
- */
private boolean isCommentNode(IDOMNode node) {
return (node != null && node instanceof IDOMElement && ((IDOMElement) node).isCommentTag());
}
17 years, 3 months
JBoss Tools SVN: r3758 - trunk/tests/tests/org.jboss.tools.test/src/org/jboss/tools/tests.
by jbosstools-commits@lists.jboss.org
Author: dgolovin
Date: 2007-09-21 13:30:00 -0400 (Fri, 21 Sep 2007)
New Revision: 3758
Modified:
trunk/tests/tests/org.jboss.tools.test/src/org/jboss/tools/tests/PlugInLoadTest.java
Log:
fix JUnit error
testVpePluginsResolved Failure org.jboss.tools.vpe.ui failed to load.
junit.framework.AssertionFailedError: org.jboss.tools.vpe.ui failed to load.
at org.jboss.tools.tests.PlugInLoadTest.isPluginResolved(PlugInLoadTest.java:30)
at org.jboss.tools.tests.PlugInLoadTest.assertPluginsResolved(PlugInLoadTest.java:45)
at org.jboss.tools.tests.PlugInLoadTest.testVpePluginsResolved(PlugInLoadTest.java:100)
at org.eclipse.test.EclipseTestRunner.run(EclipseTestRunner.java:354)
at org.eclipse.test.EclipseTestRunner.run(EclipseTestRunner.java:206)
at org.eclipse.test.CoreTestApplication.runTests(CoreTestApplication.java:35)
at org.eclipse.test.CoreTestApplication.run(CoreTestApplication.java:31)
Modified: trunk/tests/tests/org.jboss.tools.test/src/org/jboss/tools/tests/PlugInLoadTest.java
===================================================================
--- trunk/tests/tests/org.jboss.tools.test/src/org/jboss/tools/tests/PlugInLoadTest.java 2007-09-21 15:19:19 UTC (rev 3757)
+++ trunk/tests/tests/org.jboss.tools.test/src/org/jboss/tools/tests/PlugInLoadTest.java 2007-09-21 17:30:00 UTC (rev 3758)
@@ -99,7 +99,6 @@
{
assertPluginsResolved(new String[] {
rhdsNS+"vpe.mozilla",
- rhdsNS+"vpe.ui",
rhdsNS+"vpe",
rhdsNS+"vpe.ui.palette"
});
17 years, 3 months
JBoss Tools SVN: r3757 - in trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.view: src/org/jboss/tools/hibernate/ui/view/views and 1 other directory.
by jbosstools-commits@lists.jboss.org
Author: mdryakhlenkov
Date: 2007-09-21 11:19:19 -0400 (Fri, 21 Sep 2007)
New Revision: 3757
Added:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.view/src/org/jboss/tools/hibernate/ui/view/views/OpenMappingActionDelegate.java
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.view/plugin.xml
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.view/src/org/jboss/tools/hibernate/ui/view/views/OpenDiagramActionDelegate.java
Log:
JBIDE-611: Open .hbm.xml/java class in xml editor for Hibernate Console Perspective
Modified: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.view/plugin.xml
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.view/plugin.xml 2007-09-21 14:19:43 UTC (rev 3756)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.view/plugin.xml 2007-09-21 15:19:19 UTC (rev 3757)
@@ -11,5 +11,14 @@
class="org.jboss.tools.hibernate.ui.view.views.OpenDiagramActionDelegate">
</action>
</objectContribution>
+ <objectContribution id="mappingEditorAction" objectClass="org.hibernate.mapping.RootClass">
+ <menu id="org.jboss.tools.hibernate.ui.view.openMapping" label="Open Mapping File" path="mappingEditorAction"/>
+ <action
+ id="com.xyz.runXYZ"
+ label="Open Mapping File"
+ icon="icons/runXYZ.gif"
+ class="org.jboss.tools.hibernate.ui.view.views.OpenMappingActionDelegate">
+ </action>
+ </objectContribution>
</extension>
</plugin>
Modified: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.view/src/org/jboss/tools/hibernate/ui/view/views/OpenDiagramActionDelegate.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.view/src/org/jboss/tools/hibernate/ui/view/views/OpenDiagramActionDelegate.java 2007-09-21 14:19:43 UTC (rev 3756)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.view/src/org/jboss/tools/hibernate/ui/view/views/OpenDiagramActionDelegate.java 2007-09-21 15:19:19 UTC (rev 3757)
@@ -42,7 +42,6 @@
ObjectPluginAction objectPluginAction = (ObjectPluginAction)action;
Object rootClass = ((TreeSelection)objectPluginAction.getSelection()).getFirstElement();
ObjectEditorInput input = (ObjectEditorInput)hashMap.get(rootClass);
-// Configuration configuration = (Configuration)(((TreeSelection)objectPluginAction.getSelection()).getPaths()[0]).getSegment(1);
ConsoleConfiguration consoleConfiguration = (ConsoleConfiguration)(((TreeSelection)objectPluginAction.getSelection()).getPaths()[0]).getSegment(0);
ILaunchManager launchManager = DebugPlugin.getDefault().getLaunchManager();
Added: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.view/src/org/jboss/tools/hibernate/ui/view/views/OpenMappingActionDelegate.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.view/src/org/jboss/tools/hibernate/ui/view/views/OpenMappingActionDelegate.java (rev 0)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.view/src/org/jboss/tools/hibernate/ui/view/views/OpenMappingActionDelegate.java 2007-09-21 15:19:19 UTC (rev 3757)
@@ -0,0 +1,203 @@
+/*******************************************************************************
+ * 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
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.hibernate.ui.view.views;
+
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+
+import org.dom4j.Attribute;
+import org.dom4j.Document;
+import org.dom4j.DocumentException;
+import org.dom4j.Element;
+import org.eclipse.core.internal.resources.File;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.debug.core.DebugPlugin;
+import org.eclipse.debug.core.ILaunchConfiguration;
+import org.eclipse.debug.core.ILaunchConfigurationType;
+import org.eclipse.debug.core.ILaunchManager;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.TreeSelection;
+import org.eclipse.ui.IObjectActionDelegate;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.ide.IDE;
+import org.eclipse.ui.internal.ObjectPluginAction;
+import org.hibernate.HibernateException;
+import org.hibernate.MappingException;
+import org.hibernate.cfg.Configuration;
+import org.hibernate.console.ConsoleConfiguration;
+import org.hibernate.eclipse.console.utils.ProjectUtils;
+import org.hibernate.eclipse.launch.IConsoleConfigurationLaunchConstants;
+import org.hibernate.mapping.RootClass;
+import org.hibernate.util.XMLHelper;
+import org.jboss.tools.hibernate.ui.view.ViewPlugin;
+import org.xml.sax.InputSource;
+
+public class OpenMappingActionDelegate implements IObjectActionDelegate {
+ private static XMLHelper helper = new XMLHelper();
+ private HashMap map = new HashMap();
+
+ public void setActivePart(IAction action, IWorkbenchPart targetPart) {
+ }
+
+ public void run(IAction action) {
+ ObjectPluginAction objectPluginAction = (ObjectPluginAction)action;
+ RootClass rootClass = (RootClass)((TreeSelection)objectPluginAction.getSelection()).getFirstElement();
+ ConsoleConfiguration consoleConfiguration = (ConsoleConfiguration)(((TreeSelection)objectPluginAction.getSelection()).getPaths()[0]).getSegment(0);
+ IJavaProject proj = findJavaProject(consoleConfiguration);
+ java.io.File configXMLFile = consoleConfiguration.getPreferences().getConfigXMLFile();
+ Document doc = getDocument(consoleConfiguration, configXMLFile);
+ IResource resource = getResource(consoleConfiguration, proj, doc, configXMLFile, rootClass);
+
+ if (resource instanceof IFile){
+ try {
+ IDE.openEditor(ViewPlugin.getPage(), (IFile) resource);
+ } catch (PartInitException e) {
+ ViewPlugin.getDefault().logError("Can't open mapping file.", e);
+ }
+ }
+ }
+
+ private boolean classInResource(ConsoleConfiguration consoleConfiguration, IResource resource, RootClass rootClass) {
+ Document doc = getDocument(consoleConfiguration, resource.getLocation().toFile());
+ Element hmNode = doc.getRootElement();
+
+ Iterator rootChildren = hmNode.elementIterator();
+ while ( rootChildren.hasNext() ) {
+ Element element = (Element) rootChildren.next();
+ String elementName = element.getName();
+
+ if ( "class".equals( elementName ) ) {
+ Attribute classAttr = element.attribute( "name" );
+ if (classAttr != null) {
+ if (classAttr.getValue().equals(rootClass.getClassName())) {
+ if (map.get(rootClass.getClassName()) == null) map.put(rootClass.getClassName(), resource);
+ return true;
+ } else {
+ Attribute packNode = hmNode.attribute( "package" );
+ String packageName = null;
+ if ( packNode != null ) {
+ packageName = packNode.getValue();
+ String className = packageName + "." + classAttr.getValue();
+ if (className.equals(rootClass.getClassName())) {
+ if (map.get(rootClass.getClassName()) == null) map.put(rootClass.getClassName(), resource);
+ return true;
+ }
+ }
+ }
+ }
+ }
+ }
+ return false;
+ }
+
+ private IResource getResource(ConsoleConfiguration consoleConfiguration, IJavaProject proj, Document doc, java.io.File configXMLFile, RootClass rootClass) {
+ if (map.get(rootClass.getClassName()) != null) {
+ return (IResource)map.get(rootClass.getClassName());
+ } else {
+ IResource resource = null;
+ if (consoleConfiguration != null && proj != null && doc != null) {
+ Element sfNode = doc.getRootElement().element( "session-factory" );
+ Iterator elements = sfNode.elementIterator();
+ while ( elements.hasNext() ) {
+ Element subelement = (Element) elements.next();
+ String subelementName = subelement.getName();
+ if ( "mapping".equals( subelementName ) ) {
+ Attribute file = subelement.attribute( "resource" );
+ if (file != null) {
+ resource = ResourcesPlugin.getWorkspace().getRoot().getFileForLocation(new Path(configXMLFile.getParent()).append(file.getValue()));
+ if (classInResource(consoleConfiguration, resource, rootClass)) return resource;
+ }
+ }
+ }
+ java.io.File[] files = consoleConfiguration.getPreferences().getMappingFiles();
+ for (int i = 0; i < files.length; i++) {
+ java.io.File file = files[i];
+ if (file != null) {
+ resource = ResourcesPlugin.getWorkspace().getRoot().getFileForLocation(new Path(file.getPath()));
+// resource = proj.getProject().getFile(new Path(file.getPath()).removeFirstSegments(1));
+ if (classInResource(consoleConfiguration, resource, rootClass)) return resource;
+ }
+ }
+ }
+ return null;
+ }
+ }
+
+ private Document getDocument(ConsoleConfiguration consoleConfiguration, java.io.File configXMLFile) {
+ Document doc = null;
+ if (consoleConfiguration != null && configXMLFile != null) {
+ InputStream stream = null;
+ try {
+ stream = new FileInputStream( configXMLFile );
+ } catch (FileNotFoundException e) {
+ ViewPlugin.getDefault().logError("Configuration file not found", e);
+ }
+ try {
+ List errors = new ArrayList();
+ doc = helper.createSAXReader( configXMLFile.getPath(), errors, consoleConfiguration.getConfiguration().getEntityResolver() )
+ .read( new InputSource( stream ) );
+ if ( errors.size() != 0 ) {
+ ViewPlugin.getDefault().logError("invalid configuration");
+ }
+ }
+ catch (DocumentException e) {
+ ViewPlugin.getDefault().logError("Could not parse configuration", e);
+ }
+ finally {
+ try {
+ stream.close();
+ }
+ catch (IOException ioe) {
+ ViewPlugin.getDefault().logError("could not close input stream for", ioe);
+ }
+ }
+ }
+ return doc;
+ }
+
+ private IJavaProject findJavaProject(ConsoleConfiguration consoleConfiguration) {
+ IJavaProject proj = null;
+ if (consoleConfiguration != null) {
+ ILaunchManager launchManager = DebugPlugin.getDefault().getLaunchManager();
+ ILaunchConfigurationType launchConfigurationType = launchManager.getLaunchConfigurationType( "org.hibernate.eclipse.launch.ConsoleConfigurationLaunchConfigurationType" );
+ ILaunchConfiguration[] launchConfigurations;
+ try {
+ launchConfigurations = launchManager.getLaunchConfigurations( launchConfigurationType );
+ for (int i = 0; i < launchConfigurations.length; i++) { // can't believe there is no look up by name API
+ ILaunchConfiguration launchConfiguration = launchConfigurations[i];
+ if(launchConfiguration.getName().equals(consoleConfiguration.getName())) {
+ proj = ProjectUtils.findJavaProject(launchConfiguration.getAttribute(IConsoleConfigurationLaunchConstants.PROJECT_NAME, ""));
+ }
+ }
+ } catch (CoreException e1) {
+ ViewPlugin.getDefault().logError("Can't find java project.", e1);
+ }
+ }
+ return proj;
+ }
+
+ public void selectionChanged(IAction action, ISelection selection) {
+ }
+}
\ No newline at end of file
17 years, 3 months
JBoss Tools SVN: r3756 - trunk/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/action/server.
by jbosstools-commits@lists.jboss.org
Author: scabanovich
Date: 2007-09-21 10:19:43 -0400 (Fri, 21 Sep 2007)
New Revision: 3756
Modified:
trunk/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/action/server/ChangeTimeStampActionDelegate.java
Log:
JBIDE-929
Modified: trunk/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/action/server/ChangeTimeStampActionDelegate.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/action/server/ChangeTimeStampActionDelegate.java 2007-09-21 13:51:48 UTC (rev 3755)
+++ trunk/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/action/server/ChangeTimeStampActionDelegate.java 2007-09-21 14:19:43 UTC (rev 3756)
@@ -10,23 +10,52 @@
******************************************************************************/
package org.jboss.tools.jst.web.ui.action.server;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+import java.util.Set;
+
+import org.eclipse.jdt.core.IJavaElement;
import org.eclipse.jface.action.*;
import org.eclipse.jface.viewers.*;
+import org.eclipse.jst.j2ee.internal.project.J2EEProjectUtilities;
import org.eclipse.ui.*;
+import org.eclipse.wst.common.componentcore.ComponentCore;
+import org.eclipse.wst.common.componentcore.resources.IVirtualComponent;
+import org.eclipse.wst.common.componentcore.resources.IVirtualFolder;
+import org.eclipse.wst.common.project.facet.core.IFacetedProject;
+import org.eclipse.wst.common.project.facet.core.IProjectFacet;
+import org.eclipse.wst.common.project.facet.core.ProjectFacetsManager;
+import org.eclipse.wst.common.project.facet.core.runtime.IRuntime;
import org.jboss.tools.common.meta.action.*;
import org.jboss.tools.common.model.*;
import org.jboss.tools.common.model.util.EclipseResourceUtil;
-import org.jboss.tools.common.model.ui.ModelUIPlugin;
import org.jboss.tools.jst.web.messages.xpl.WebUIMessages;
import org.jboss.tools.jst.web.model.helpers.WebAppHelper;
import org.jboss.tools.jst.web.ui.WebUiPlugin;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.NullProgressMonitor;
public class ChangeTimeStampActionDelegate implements IWorkbenchWindowActionDelegate {
- protected XModelObject object = null;
+ static Set<String> warFilesToTouch = new HashSet<String>();
+ static Set<String> earFilesToTouch = new HashSet<String>();
+
+ static {
+ warFilesToTouch.add("web.xml");
+ earFilesToTouch.add("manifest.mf");
+ }
+
protected IWorkbenchWindow window;
String tooltip = null;
+
+ IProject project = null;
protected String getActionPath() {
return "SaveActions.ChangeTimeStamp"; //$NON-NLS-1$
@@ -37,26 +66,71 @@
}
public void selectionChanged(IAction action, ISelection selection) {
- if(object == null && action.isEnabled()) action.setEnabled(false);
+ if(project == null && action.isEnabled()) action.setEnabled(false);
if(tooltip == null) tooltip = action.getToolTipText();
if(!(selection instanceof IStructuredSelection)) return;
Object o = ((IStructuredSelection)selection).getFirstElement();
- XModelObject adapter = (o instanceof XModelObject) ? (XModelObject)o : null;
- if(adapter == null) return;
- object = adapter;
+ IProject p = getProject(o);
+ if(p == null) return;
+ project = p;
action.setEnabled(computeEnabled());
- if(object == null) {
+ if(project == null) {
action.setToolTipText(tooltip);
} else {
- IResource r = EclipseResourceUtil.getResource(object);
- if(r != null && r.exists()) action.setToolTipText(WebUIMessages.CHANGE_TIME_STAMP + r.getLocation().toString());
+ action.setToolTipText(WebUIMessages.CHANGE_TIME_STAMP + project.getName());
}
+
}
+ IProject getProject(Object selection) {
+ if(selection instanceof IResource) {
+ return ((IResource)selection).getProject();
+ } else if(selection instanceof IAdaptable) {
+ Object r = ((IAdaptable)selection).getAdapter(IResource.class);
+ return r instanceof IResource ? ((IResource)r).getProject() : null;
+ }
+ return null;
+ }
+
protected boolean computeEnabled() {
- object = (object == null) ? null : WebAppHelper.getWebApp(object.getModel());
- return object != null;
+ if(project == null || !project.isAccessible()) return false;
+ boolean isWar = J2EEProjectUtilities.isDynamicWebProject(project);
+ boolean isEar = J2EEProjectUtilities.isEARProject(project);
+ boolean isEJB = J2EEProjectUtilities.isEJBProject(project);
+ return isEar || isEJB || isWar;
}
+
+ List<IFile> getFilesToTouch(IProject project) {
+ List<IFile> fs = new ArrayList<IFile>();
+ if(project == null || !project.isAccessible()) return fs;
+ boolean isWar = J2EEProjectUtilities.isDynamicWebProject(project);
+ boolean isEar = J2EEProjectUtilities.isEARProject(project);
+ boolean isEJB = J2EEProjectUtilities.isEJBProject(project);
+
+ if(!isEar) {
+ IProject[] ps = J2EEProjectUtilities.getReferencingEARProjects(project);
+ for (int i = 0; i < ps.length; i++) {
+ fs.addAll(getFilesToTouch(ps[i]));
+ }
+ }
+ if(isEar) {
+ List l = J2EEProjectUtilities.getAllProjectFiles(project);
+ for (int i = 0; i < l.size(); i++) {
+ IFile f = (IFile)l.get(i);
+ String n = f.getName().toLowerCase();
+ if(earFilesToTouch.contains(n)) fs.add(f);
+ }
+ }
+ if(isWar) {
+ List l = J2EEProjectUtilities.getAllProjectFiles(project);
+ for (int i = 0; i < l.size(); i++) {
+ IFile f = (IFile)l.get(i);
+ String n = f.getName().toLowerCase();
+ if(warFilesToTouch.contains(n)) fs.add(f);
+ }
+ }
+ return fs;
+ }
public void run(IAction action) {
try {
@@ -67,9 +141,16 @@
}
protected void doRun() throws Exception {
- XActionInvoker.invoke(getActionPath(), object, null);
+ if(project == null || !project.isAccessible()) return;
+ List<IFile> fs = getFilesToTouch(project);
+ for (int i = 0; i < fs.size(); i++) {
+ IFile f = (IFile)fs.get(i);
+ f.touch(new NullProgressMonitor());
+ }
}
- public void dispose() {}
+ public void dispose() {
+ window = null;
+ }
}
17 years, 3 months
JBoss Tools SVN: r3755 - in branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor: template and 1 other directories.
by jbosstools-commits@lists.jboss.org
Author: ezheleznyakov
Date: 2007-09-21 09:51:48 -0400 (Fri, 21 Sep 2007)
New Revision: 3755
Modified:
branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeVisualDomBuilder.java
branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeCopyCreator.java
branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeStyleCreator.java
branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/VpeStyleUtil.java
Log:
http://jira.jboss.com/jira/browse/JBIDE-897
Modified: branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeVisualDomBuilder.java
===================================================================
--- branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeVisualDomBuilder.java 2007-09-21 13:45:20 UTC (rev 3754)
+++ branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeVisualDomBuilder.java 2007-09-21 13:51:48 UTC (rev 3755)
@@ -925,8 +925,12 @@
while ((str = in.readLine()) != null) {
styleText.append(str);
}
+
+ String styleForParse = styleText.toString();
+ styleForParse = VpeStyleUtil.addFullPathIntoURLValue(styleForParse, href_val);
+
in.close();
- nsIDOMText textNode = visualDocument.createTextNode(styleText.toString());
+ nsIDOMText textNode = visualDocument.createTextNode(styleForParse);
linkNode.appendChild(textNode);
return linkNode;
} catch (FileNotFoundException fnfe) {
Modified: branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeCopyCreator.java
===================================================================
--- branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeCopyCreator.java 2007-09-21 13:45:20 UTC (rev 3754)
+++ branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeCopyCreator.java 2007-09-21 13:51:48 UTC (rev 3755)
@@ -7,7 +7,7 @@
*
* Contributors:
* Exadel, Inc. and Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
+ ******************************************************************************/
package org.jboss.tools.vpe.editor.template;
import java.util.ArrayList;
@@ -17,6 +17,7 @@
import org.jboss.tools.vpe.editor.context.VpePageContext;
import org.jboss.tools.vpe.editor.template.expression.VpeExpressionBuilder;
+import org.jboss.tools.vpe.editor.util.VpeStyleUtil;
import org.mozilla.interfaces.nsIDOMAttr;
import org.mozilla.interfaces.nsIDOMDocument;
import org.mozilla.interfaces.nsIDOMElement;
@@ -27,23 +28,28 @@
import org.w3c.dom.NodeList;
public class VpeCopyCreator extends VpeAbstractCreator {
+
+ private static String STYLE_ATTR_NAME = "style";
+
private boolean caseSensitive;
private HashSet attrSet;
private VpeCreator attrs[];
-
- VpeCopyCreator(Element copyElement, VpeDependencyMap dependencyMap, boolean caseSensitive) {
+
+ VpeCopyCreator(Element copyElement, VpeDependencyMap dependencyMap,
+ boolean caseSensitive) {
this.caseSensitive = caseSensitive;
build(copyElement, dependencyMap);
}
private void build(Element copyElement, VpeDependencyMap dependencyMap) {
dependencyMap.setCreator(this, VpeExpressionBuilder.SIGNATURE_ANY_ATTR);
- Attr attrsAttr = copyElement.getAttributeNode(VpeTemplateManager.ATTR_COPY_ATTRS);
+ Attr attrsAttr = copyElement
+ .getAttributeNode(VpeTemplateManager.ATTR_COPY_ATTRS);
if (attrsAttr != null) {
attrSet = new HashSet();
String attrsValue = attrsAttr.getValue();
String[] attrsArr = attrsValue.split(",");
- for (int i = 0; i < attrsArr.length; i++) {
+ for (int i = 0; i < attrsArr.length; i++) {
String attr = attrsArr[i].trim();
if (attr.length() > 0) {
attrSet.add(caseSensitive ? attr : attr.toLowerCase());
@@ -54,34 +60,47 @@
if (copyChildren != null) {
int len = copyChildren.getLength();
if (len > 0) {
- List creatorAttrs = new ArrayList(len);
+ List creatorAttrs = new ArrayList(len);
for (int i = 0; i < len; i++) {
Node innerNode = copyChildren.item(i);
- if (innerNode.getNodeType() == Node.ELEMENT_NODE &&
- VpeTemplateManager.TAG_ATTRIBUTE.equals(innerNode.getNodeName())) {
- String attrName = ((Element)innerNode).getAttribute(VpeTemplateManager.ATTR_ATTRIBUTE_NAME).trim();
+ if (innerNode.getNodeType() == Node.ELEMENT_NODE
+ && VpeTemplateManager.TAG_ATTRIBUTE
+ .equals(innerNode.getNodeName())) {
+ String attrName = ((Element) innerNode).getAttribute(
+ VpeTemplateManager.ATTR_ATTRIBUTE_NAME).trim();
if (attrName.length() > 0) {
- String attrValue = ((Element)innerNode).getAttribute(VpeTemplateManager.ATTR_ATTRIBUTE_VALUE).trim();
- creatorAttrs.add(new VpeAttributeCreator(attrName, attrValue, dependencyMap, caseSensitive));
+ String attrValue = ((Element) innerNode)
+ .getAttribute(
+ VpeTemplateManager.ATTR_ATTRIBUTE_VALUE)
+ .trim();
+ creatorAttrs.add(new VpeAttributeCreator(attrName,
+ attrValue, dependencyMap, caseSensitive));
}
}
}
if (creatorAttrs.size() > 0) {
- attrs = (VpeCreator[]) creatorAttrs.toArray(new VpeCreator[creatorAttrs.size()]);
+ attrs = (VpeCreator[]) creatorAttrs
+ .toArray(new VpeCreator[creatorAttrs.size()]);
}
}
}
}
- public VpeCreatorInfo create(VpePageContext pageContext, Node sourceNode, nsIDOMDocument visualDocument, nsIDOMElement visualElement, Map visualNodeMap) {
- nsIDOMElement visualNewElement = visualDocument.createElement(sourceNode.getNodeName());
+ public VpeCreatorInfo create(VpePageContext pageContext, Node sourceNode,
+ nsIDOMDocument visualDocument, nsIDOMElement visualElement,
+ Map visualNodeMap) {
+ nsIDOMElement visualNewElement = visualDocument
+ .createElement(sourceNode.getNodeName());
visualNodeMap.put(this, visualNewElement);
- addAttributes((Element)sourceNode, visualNewElement);
+ addAttributes((Element) sourceNode, visualNewElement, pageContext);
if (attrs != null) {
for (int i = 0; i < attrs.length; i++) {
- VpeCreatorInfo attributeInfo = attrs[i].create(pageContext, (Element) sourceNode, visualDocument, visualNewElement, visualNodeMap);
+ VpeCreatorInfo attributeInfo = attrs[i].create(pageContext,
+ (Element) sourceNode, visualDocument, visualNewElement,
+ visualNodeMap);
if (attributeInfo != null) {
- nsIDOMAttr newVisualAttribute = (nsIDOMAttr)attributeInfo.getVisualNode();
+ nsIDOMAttr newVisualAttribute = (nsIDOMAttr) attributeInfo
+ .getVisualNode();
if (newVisualAttribute != null) {
visualNewElement.setAttributeNode(newVisualAttribute);
}
@@ -90,26 +109,30 @@
}
return new VpeCreatorInfo(visualNewElement);
}
-
- public void setAttribute(VpePageContext pageContext, Element sourceElement, Map visualNodeMap, String name, String value) {
+
+ public void setAttribute(VpePageContext pageContext, Element sourceElement,
+ Map visualNodeMap, String name, String value) {
if (isAttribute(name)) {
Element visualElement = (Element) visualNodeMap.get(this);
visualElement.setAttribute(name, value);
}
}
- public void removeAttribute(VpePageContext pageContext, Element sourceElement, Map visualNodeMap, String name) {
+ public void removeAttribute(VpePageContext pageContext,
+ Element sourceElement, Map visualNodeMap, String name) {
if (isAttribute(name)) {
Element visualElement = (Element) visualNodeMap.get(this);
visualElement.removeAttribute(name);
}
}
- public void pseudo(VpePageContext pageContext, Node sourceNode, Node visualNode, Map visualNodeMap) {
+ public void pseudo(VpePageContext pageContext, Node sourceNode,
+ Node visualNode, Map visualNodeMap) {
visualNodeMap.put(this, visualNode);
}
- private void addAttributes(Element sourceElement, nsIDOMElement visualElement) {
+ private void addAttributes(Element sourceElement,
+ nsIDOMElement visualElement, VpePageContext pageContext) {
NamedNodeMap sourceAttributes = sourceElement.getAttributes();
if (sourceAttributes == null) {
return;
@@ -118,8 +141,13 @@
for (int i = 0; i < len; i++) {
Attr sourceAttr = (Attr) sourceAttributes.item(i);
String name = sourceAttr.getName();
+
+ String value = sourceAttr.getValue();
+ if (name.equalsIgnoreCase(STYLE_ATTR_NAME))
+ value = VpeStyleUtil.addFullPathIntoURLValue(sourceAttr.getValue(), pageContext.getEditPart().getEditorInput());
+
if (isAttribute(name)) {
- visualElement.setAttribute(name, sourceAttr.getValue());
+ visualElement.setAttribute(name, value);
}
}
}
Modified: branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeStyleCreator.java
===================================================================
--- branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeStyleCreator.java 2007-09-21 13:45:20 UTC (rev 3754)
+++ branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeStyleCreator.java 2007-09-21 13:51:48 UTC (rev 3755)
@@ -7,69 +7,77 @@
*
* Contributors:
* Exadel, Inc. and Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
+ ******************************************************************************/
package org.jboss.tools.vpe.editor.template;
import java.util.Map;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-
import org.jboss.tools.vpe.editor.context.VpePageContext;
+import org.jboss.tools.vpe.editor.util.VpeStyleUtil;
import org.mozilla.interfaces.nsIDOMDocument;
import org.mozilla.interfaces.nsIDOMElement;
import org.mozilla.interfaces.nsIDOMNode;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
-public class VpeStyleCreator extends VpeAbstractCreator{
-
- public VpeStyleCreator(Element element, VpeDependencyMap dependencyMap, boolean caseSensitive) {
- //this.caseSensitive = caseSensitive;
- //build(element, dependencyMap);
+public class VpeStyleCreator extends VpeAbstractCreator {
+
+ public VpeStyleCreator(Element element, VpeDependencyMap dependencyMap,
+ boolean caseSensitive) {
+ // this.caseSensitive = caseSensitive;
+ // build(element, dependencyMap);
}
public VpeCreatorInfo create(VpePageContext pageContext, Node sourceNode,
nsIDOMDocument visualDocument, nsIDOMElement visualElement,
Map visualNodeMap) {
-
+
Node textNode = sourceNode.getFirstChild();
String text = null;
- if(textNode != null){
+ if (textNode != null) {
text = textNode.getNodeValue();
+ text = VpeStyleUtil.addFullPathIntoURLValue(text, pageContext.getEditPart().getEditorInput());
}
- nsIDOMNode newStyle = pageContext.getVisualBuilder().addStyleNodeToHead(text);
+
+ nsIDOMNode newStyle = pageContext.getVisualBuilder()
+ .addStyleNodeToHead(text);
visualNodeMap.put(this, newStyle);
return null;
}
- public void removeElement(VpePageContext pageContext, Element sourceElement, Map visualNodeMap) {
-
- nsIDOMNode styleNode = (nsIDOMNode)visualNodeMap.get(this);
-
- if(styleNode != null){
+ public void removeElement(VpePageContext pageContext,
+ Element sourceElement, Map visualNodeMap) {
+
+ nsIDOMNode styleNode = (nsIDOMNode) visualNodeMap.get(this);
+
+ if (styleNode != null) {
pageContext.getVisualBuilder().removeStyleNodeFromHead(styleNode);
visualNodeMap.remove(this);
}
-
+
}
- public void refreshElement(VpePageContext pageContext, Element sourceElement, Map visualNodeMap) {
- nsIDOMNode oldStyleNode = (nsIDOMNode)visualNodeMap.get(this);
-
+ public void refreshElement(VpePageContext pageContext,
+ Element sourceElement, Map visualNodeMap) {
+ nsIDOMNode oldStyleNode = (nsIDOMNode) visualNodeMap.get(this);
+
Node textNode = sourceElement.getFirstChild();
String text = null;
- if(textNode != null){
+ if (textNode != null) {
text = textNode.getNodeValue();
}
nsIDOMNode newStyleNode;
- if(oldStyleNode == null){
- newStyleNode = pageContext.getVisualBuilder().addStyleNodeToHead(text);
+ if (oldStyleNode == null) {
+ newStyleNode = pageContext.getVisualBuilder().addStyleNodeToHead(
+ text);
visualNodeMap.put(this, newStyleNode);
- }else{
- newStyleNode = pageContext.getVisualBuilder().replaceStyleNodeToHead(oldStyleNode, text);
- if(visualNodeMap.containsKey(this)) visualNodeMap.remove(this);
+ } else {
+ newStyleNode = pageContext.getVisualBuilder()
+ .replaceStyleNodeToHead(oldStyleNode, text);
+ if (visualNodeMap.containsKey(this))
+ visualNodeMap.remove(this);
visualNodeMap.put(this, newStyleNode);
}
-
+
}
}
Modified: branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/VpeStyleUtil.java
===================================================================
--- branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/VpeStyleUtil.java 2007-09-21 13:45:20 UTC (rev 3754)
+++ branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/VpeStyleUtil.java 2007-09-21 13:51:48 UTC (rev 3755)
@@ -10,6 +10,15 @@
******************************************************************************/
package org.jboss.tools.vpe.editor.util;
+import java.io.File;
+import java.net.MalformedURLException;
+import java.net.URL;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IFileEditorInput;
+import org.eclipse.ui.editors.text.ILocationProvider;
import org.w3c.dom.Element;
public class VpeStyleUtil {
@@ -31,7 +40,14 @@
public static final String SPACE_STRING = " ";
public static final String EMPTY_STRING = "";
+ public static String ATTR_URL = "url";
+ public static String OPEN_BRACKET = "(";
+ public static String CLOSE_BRACKET = ")";
+ public static String FILE_PRTOCOL = "file:///";
+ public static String FILE_STR = "file:";
+ public static String FILE_SEPARAROT = "/";
+
// sets parameter position in atribute style to absolute value
public static void setAbsolute(Element sourceElement){
String style = sourceElement.getAttribute(ATTRIBUTE_STYLE);
@@ -225,5 +241,185 @@
return result;
}
+
+
+ /**
+ *
+ * @param value
+ * Css string
+ * @param input
+ * The editor input
+ * @return format style string
+ */
+ public static String addFullPathIntoURLValue(String value,
+ IEditorInput input) {
-}
+ String urls[] = value.split(ATTR_URL);
+
+ if (urls.length == 1)
+ return value;
+
+ String finalStr = EMPTY_STRING;
+ for (int i = 1; i < urls.length; i++) {
+
+ urls[i] = urls[i].replace("\'", EMPTY_STRING);
+ urls[i] = ATTR_URL + urls[i];
+
+ int startAttr = urls[i].indexOf(ATTR_URL);
+
+ int startPathIndex = urls[i].indexOf(OPEN_BRACKET, startAttr);
+ int endPathIndex = urls[i].indexOf(CLOSE_BRACKET,
+ startPathIndex + 1);
+
+ if (startPathIndex == -1 || endPathIndex == -1)
+ continue;
+
+ String filePath = urls[i].substring(startPathIndex + 1,
+ endPathIndex);
+ if (filePath.indexOf(FILE_STR) != -1)
+ continue;
+
+ if (!new File(filePath).isAbsolute())
+ filePath = getFilePath(input, filePath);
+
+ filePath = FILE_PRTOCOL + filePath;
+ URL url = null;
+ try {
+ url = new URL(filePath);
+ } catch (MalformedURLException e) {
+ continue;
+ }
+ filePath = url.toString();
+
+ String firstPartValue = urls[i].substring(0, startPathIndex + 1);
+ String secondPartValue = urls[i].substring(endPathIndex, urls[i]
+ .length());
+
+ urls[i] = firstPartValue + filePath + secondPartValue;
+ }
+ for (int i = 0; i < urls.length; i++)
+ finalStr += urls[i];
+ return finalStr;
+ }
+
+ /**
+ *
+ * @param nput
+ * The editor input
+ * @param fileName
+ * Relative path file
+ * @return Absolute path file
+ */
+ public static String getFilePath(IEditorInput input, String fileName) {
+ IPath inputPath = getInputParentPath(input);
+ return inputPath.toOSString() + File.separator + fileName;
+ }
+
+ /**
+ *
+ * @param input
+ * The editor input
+ * @return Path
+ */
+ public static IPath getInputParentPath(IEditorInput input) {
+ IPath inputPath = null;
+ if (input instanceof ILocationProvider) {
+ inputPath = ((ILocationProvider) input).getPath(input);
+ } else if (input instanceof IFileEditorInput) {
+ IFile inputFile = ((IFileEditorInput) input).getFile();
+ if (inputFile != null) {
+ inputPath = inputFile.getLocation();
+ }
+ }
+ if (inputPath != null && !inputPath.isEmpty()) {
+ inputPath = inputPath.removeLastSegments(1);
+ }
+ return inputPath;
+ }
+
+ /**
+ *
+ * @param value
+ * Css string
+ * @param href_val
+ * Path of css file
+ * @return Format style string
+ */
+ public static String addFullPathIntoURLValue(String value, String href_val) {
+
+ String urls[] = value.split(ATTR_URL);
+
+ if (urls.length == 1)
+ return value;
+
+ String finalStr = EMPTY_STRING;
+
+ for (int i = 1; i < urls.length; i++) {
+
+ urls[i] = urls[i].replace("\'", EMPTY_STRING);
+ urls[i] = ATTR_URL + urls[i];
+
+ int startAttr = urls[i].indexOf(ATTR_URL);
+
+ int startPathIndex = urls[i].indexOf(OPEN_BRACKET, startAttr);
+ int endPathIndex = urls[i].indexOf(CLOSE_BRACKET,
+ startPathIndex + 1);
+
+ String filePath = urls[i].substring(startPathIndex + 1,
+ endPathIndex);
+ if (filePath.indexOf(FILE_STR) != -1)
+ continue;
+
+ if (!new File(filePath).isAbsolute())
+ filePath = getAbsolutePathImage(filePath, href_val);
+ else
+ filePath = FILE_PRTOCOL + filePath;
+
+ URL url = null;
+ try {
+ url = new URL(filePath);
+ } catch (MalformedURLException e) {
+ continue;
+ }
+ filePath = url.toString();
+
+ String firstPartValue = urls[i].substring(0, startPathIndex + 1);
+ String secondPartValue = urls[i].substring(endPathIndex, urls[i]
+ .length());
+
+ urls[i] = firstPartValue + filePath + secondPartValue;
+ }
+ for (int i = 0; i < urls.length; i++)
+ finalStr += urls[i];
+ return finalStr;
+ }
+
+ /**
+ *
+ * @param pathImgRelative
+ * Relative path img file
+ * @param pathCssAbsolute
+ * Absolute path css file
+ * @return Absolute path img file
+ */
+ private static String getAbsolutePathImage(String pathImgRelative,
+ String pathCssAbsolute) {
+
+ int k = 0;
+ int j = 0;
+ URL url = null;
+ try {
+ url = new URL(pathCssAbsolute);
+ } catch (MalformedURLException e) {
+
+ }
+ pathCssAbsolute = url.toString();
+ while (j != -1) {
+ j = pathCssAbsolute.indexOf(FILE_SEPARAROT, j + 1);
+ if (j == -1)
+ break;
+ k = j;
+ }
+ return pathCssAbsolute.substring(0, k + 1) + pathImgRelative;
+ }
+}
\ No newline at end of file
17 years, 3 months
JBoss Tools SVN: r3754 - 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: ezheleznyakov
Date: 2007-09-21 09:45:20 -0400 (Fri, 21 Sep 2007)
New Revision: 3754
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/VpeVisualDomBuilder.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeCopyCreator.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeStyleCreator.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/VpeStyleUtil.java
Log:
http://jira.jboss.com/jira/browse/JBIDE-897
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 2007-09-21 09:27:07 UTC (rev 3753)
+++ trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeEditorPart.java 2007-09-21 13:45:20 UTC (rev 3754)
@@ -53,7 +53,6 @@
import org.jboss.tools.common.model.event.XModelTreeEvent;
import org.jboss.tools.common.model.event.XModelTreeListener;
import org.jboss.tools.common.model.ui.util.ModelUtilities;
-import org.jboss.tools.common.model.util.XModelTreeListenerSWTSync;
import org.jboss.tools.jst.jsp.editor.IVisualEditor;
import org.jboss.tools.jst.jsp.preferences.VpePreference;
import org.jboss.tools.vpe.VpePlugin;
Modified: trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeVisualDomBuilder.java
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeVisualDomBuilder.java 2007-09-21 09:27:07 UTC (rev 3753)
+++ trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeVisualDomBuilder.java 2007-09-21 13:45:20 UTC (rev 3754)
@@ -990,8 +990,12 @@
while ((str = in.readLine()) != null) {
styleText.append(str);
}
+
+ String styleForParse = styleText.toString();
+ styleForParse = VpeStyleUtil.addFullPathIntoURLValue(styleForParse, href_val);
+
in.close();
- Node textNode = visualDocument.createTextNode(styleText.toString());
+ Node textNode = visualDocument.createTextNode(styleForParse);
linkNode.appendChild(textNode);
return linkNode;
} catch (FileNotFoundException fnfe) {
Modified: trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeCopyCreator.java
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeCopyCreator.java 2007-09-21 09:27:07 UTC (rev 3753)
+++ trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeCopyCreator.java 2007-09-21 13:45:20 UTC (rev 3754)
@@ -25,8 +25,12 @@
import org.jboss.tools.vpe.editor.context.VpePageContext;
import org.jboss.tools.vpe.editor.template.expression.VpeExpressionBuilder;
import org.jboss.tools.vpe.editor.util.MozillaSupports;
+import org.jboss.tools.vpe.editor.util.VpeStyleUtil;
public class VpeCopyCreator extends VpeAbstractCreator {
+
+ private static String STYLE_ATTR_NAME = "style";
+
private boolean caseSensitive;
private HashSet attrSet;
private VpeCreator attrs[];
@@ -76,7 +80,7 @@
public VpeCreatorInfo create(VpePageContext pageContext, Node sourceNode, Document visualDocument, Element visualElement, Map visualNodeMap) {
Element visualNewElement = visualDocument.createElement(sourceNode.getNodeName());
visualNodeMap.put(this, visualNewElement);
- addAttributes((Element)sourceNode, visualNewElement);
+ addAttributes((Element)sourceNode, visualNewElement, pageContext);
if (attrs != null) {
for (int i = 0; i < attrs.length; i++) {
VpeCreatorInfo attributeInfo = attrs[i].create(pageContext, (Element) sourceNode, visualDocument, visualNewElement, visualNodeMap);
@@ -110,17 +114,22 @@
visualNodeMap.put(this, visualNode);
}
- private void addAttributes(Element sourceElement, Element visualElement) {
+ private void addAttributes(Element sourceElement, Element visualElement, VpePageContext pageContext) {
NamedNodeMap sourceAttributes = sourceElement.getAttributes();
if (sourceAttributes == null) {
return;
}
int len = sourceAttributes.getLength();
for (int i = 0; i < len; i++) {
- Attr sourceAttr = (Attr) sourceAttributes.item(i);
+ Attr sourceAttr = (Attr) sourceAttributes.item(i);
String name = sourceAttr.getName();
+
+ String value = sourceAttr.getValue();
+ if (name.equalsIgnoreCase(STYLE_ATTR_NAME))
+ value = VpeStyleUtil.addFullPathIntoURLValue(sourceAttr.getValue(), pageContext.getEditPart().getEditorInput());
+
if (isAttribute(name)) {
- visualElement.setAttribute(name, sourceAttr.getValue());
+ visualElement.setAttribute(name, value);
}
}
}
Modified: trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeStyleCreator.java
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeStyleCreator.java 2007-09-21 09:27:07 UTC (rev 3753)
+++ trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeStyleCreator.java 2007-09-21 13:45:20 UTC (rev 3754)
@@ -17,6 +17,7 @@
import org.w3c.dom.Node;
import org.jboss.tools.vpe.editor.context.VpePageContext;
+import org.jboss.tools.vpe.editor.util.VpeStyleUtil;
public class VpeStyleCreator extends VpeAbstractCreator{
@@ -33,6 +34,7 @@
String text = null;
if(textNode != null){
text = textNode.getNodeValue();
+ text = VpeStyleUtil.addFullPathIntoURLValue(text, pageContext.getEditPart().getEditorInput());
}
Node newStyle = pageContext.getVisualBuilder().addStyleNodeToHead(text);
visualNodeMap.put(this, newStyle);
Modified: trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/VpeStyleUtil.java
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/VpeStyleUtil.java 2007-09-21 09:27:07 UTC (rev 3753)
+++ trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/VpeStyleUtil.java 2007-09-21 13:45:20 UTC (rev 3754)
@@ -10,6 +10,15 @@
******************************************************************************/
package org.jboss.tools.vpe.editor.util;
+import java.io.File;
+import java.net.MalformedURLException;
+import java.net.URL;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IFileEditorInput;
+import org.eclipse.ui.editors.text.ILocationProvider;
import org.w3c.dom.Element;
public class VpeStyleUtil {
@@ -31,7 +40,14 @@
public static final String SPACE_STRING = " ";
public static final String EMPTY_STRING = "";
+ public static String ATTR_URL = "url";
+ public static String OPEN_BRACKET = "(";
+ public static String CLOSE_BRACKET = ")";
+ public static String FILE_PRTOCOL = "file:///";
+ public static String FILE_STR = "file:";
+ public static String FILE_SEPARAROT = "/";
+
// sets parameter position in atribute style to absolute value
public static void setAbsolute(Element sourceElement){
String style = sourceElement.getAttribute(ATTRIBUTE_STYLE);
@@ -225,5 +241,184 @@
return result;
}
+
+ /**
+ *
+ * @param value
+ * Css string
+ * @param input
+ * The editor input
+ * @return format style string
+ */
+ public static String addFullPathIntoURLValue(String value,
+ IEditorInput input) {
-}
+ String urls[] = value.split(ATTR_URL);
+
+ if (urls.length == 1)
+ return value;
+
+ String finalStr = EMPTY_STRING;
+ for (int i = 1; i < urls.length; i++) {
+
+ urls[i] = urls[i].replace("\'", EMPTY_STRING);
+ urls[i] = ATTR_URL + urls[i];
+
+ int startAttr = urls[i].indexOf(ATTR_URL);
+
+ int startPathIndex = urls[i].indexOf(OPEN_BRACKET, startAttr);
+ int endPathIndex = urls[i].indexOf(CLOSE_BRACKET,
+ startPathIndex + 1);
+
+ if (startPathIndex == -1 || endPathIndex == -1)
+ continue;
+
+ String filePath = urls[i].substring(startPathIndex + 1,
+ endPathIndex);
+ if (filePath.indexOf(FILE_STR) != -1)
+ continue;
+
+ if (!new File(filePath).isAbsolute())
+ filePath = getFilePath(input, filePath);
+
+ filePath = FILE_PRTOCOL + filePath;
+ URL url = null;
+ try {
+ url = new URL(filePath);
+ } catch (MalformedURLException e) {
+ continue;
+ }
+ filePath = url.toString();
+
+ String firstPartValue = urls[i].substring(0, startPathIndex + 1);
+ String secondPartValue = urls[i].substring(endPathIndex, urls[i]
+ .length());
+
+ urls[i] = firstPartValue + filePath + secondPartValue;
+ }
+ for (int i = 0; i < urls.length; i++)
+ finalStr += urls[i];
+ return finalStr;
+ }
+
+ /**
+ *
+ * @param nput
+ * The editor input
+ * @param fileName
+ * Relative path file
+ * @return Absolute path file
+ */
+ public static String getFilePath(IEditorInput input, String fileName) {
+ IPath inputPath = getInputParentPath(input);
+ return inputPath.toOSString() + File.separator + fileName;
+ }
+
+ /**
+ *
+ * @param input
+ * The editor input
+ * @return Path
+ */
+ public static IPath getInputParentPath(IEditorInput input) {
+ IPath inputPath = null;
+ if (input instanceof ILocationProvider) {
+ inputPath = ((ILocationProvider) input).getPath(input);
+ } else if (input instanceof IFileEditorInput) {
+ IFile inputFile = ((IFileEditorInput) input).getFile();
+ if (inputFile != null) {
+ inputPath = inputFile.getLocation();
+ }
+ }
+ if (inputPath != null && !inputPath.isEmpty()) {
+ inputPath = inputPath.removeLastSegments(1);
+ }
+ return inputPath;
+ }
+
+ /**
+ *
+ * @param value
+ * Css string
+ * @param href_val
+ * Path of css file
+ * @return Format style string
+ */
+ public static String addFullPathIntoURLValue(String value, String href_val) {
+
+ String urls[] = value.split(ATTR_URL);
+
+ if (urls.length == 1)
+ return value;
+
+ String finalStr = EMPTY_STRING;
+
+ for (int i = 1; i < urls.length; i++) {
+
+ urls[i] = urls[i].replace("\'", EMPTY_STRING);
+ urls[i] = ATTR_URL + urls[i];
+
+ int startAttr = urls[i].indexOf(ATTR_URL);
+
+ int startPathIndex = urls[i].indexOf(OPEN_BRACKET, startAttr);
+ int endPathIndex = urls[i].indexOf(CLOSE_BRACKET,
+ startPathIndex + 1);
+
+ String filePath = urls[i].substring(startPathIndex + 1,
+ endPathIndex);
+ if (filePath.indexOf(FILE_STR) != -1)
+ continue;
+
+ if (!new File(filePath).isAbsolute())
+ filePath = getAbsolutePathImage(filePath, href_val);
+ else
+ filePath = FILE_PRTOCOL + filePath;
+
+ URL url = null;
+ try {
+ url = new URL(filePath);
+ } catch (MalformedURLException e) {
+ continue;
+ }
+ filePath = url.toString();
+
+ String firstPartValue = urls[i].substring(0, startPathIndex + 1);
+ String secondPartValue = urls[i].substring(endPathIndex, urls[i]
+ .length());
+
+ urls[i] = firstPartValue + filePath + secondPartValue;
+ }
+ for (int i = 0; i < urls.length; i++)
+ finalStr += urls[i];
+ return finalStr;
+ }
+
+ /**
+ *
+ * @param pathImgRelative
+ * Relative path img file
+ * @param pathCssAbsolute
+ * Absolute path css file
+ * @return Absolute path img file
+ */
+ private static String getAbsolutePathImage(String pathImgRelative,
+ String pathCssAbsolute) {
+
+ int k = 0;
+ int j = 0;
+ URL url = null;
+ try {
+ url = new URL(pathCssAbsolute);
+ } catch (MalformedURLException e) {
+
+ }
+ pathCssAbsolute = url.toString();
+ while (j != -1) {
+ j = pathCssAbsolute.indexOf(FILE_SEPARAROT, j + 1);
+ if (j == -1)
+ break;
+ k = j;
+ }
+ return pathCssAbsolute.substring(0, k + 1) + pathImgRelative;
+ }
+}
\ No newline at end of file
17 years, 3 months
JBoss Tools SVN: r3753 - in trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core: validation and 1 other directory.
by jbosstools-commits@lists.jboss.org
Author: scabanovich
Date: 2007-09-21 05:27:07 -0400 (Fri, 21 Sep 2007)
New Revision: 3753
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamJavaContextVariable.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/validation/SeamCoreValidator.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/validation/SeamValidationHelper.java
Log:
JBIDE-922
Modified: trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamJavaContextVariable.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamJavaContextVariable.java 2007-09-21 07:57:02 UTC (rev 3752)
+++ trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamJavaContextVariable.java 2007-09-21 09:27:07 UTC (rev 3753)
@@ -42,7 +42,7 @@
}
public IResource getResource() {
- return javaSource == null ? super.getResource() : javaSource.getTypeRoot().getResource();
+ return javaSource == null || javaSource.getTypeRoot().getResource() == null ? super.getResource() : javaSource.getTypeRoot().getResource();
}
public int getStartPosition() {
Modified: trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/validation/SeamCoreValidator.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/validation/SeamCoreValidator.java 2007-09-21 07:57:02 UTC (rev 3752)
+++ trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/validation/SeamCoreValidator.java 2007-09-21 09:27:07 UTC (rev 3753)
@@ -206,24 +206,9 @@
}
private void validateFactory(ISeamFactory factory, Set<String> markedDuplicateFactoryNames) {
-
- if(factory.getResource() == null) {
- IPath source = factory.getSourcePath();
- String name = factory.getName();
- String message = null;
- if(factory.getSeamProject() != null) {
- factory.getSeamProject().removeFactory(factory);
- message = "Seam core validator detected factory with null resource " + "(name=" + name + " source=" + source + ").";
- } else {
- message = "Seam core validator detected factory with null resource " + "(name=" + name + " source=" + source + ")" + " and null parent in seam model.";
- }
- SeamCorePlugin.getPluginLog().logInfo(message);
+ if(coreHelper.isJar(factory.getSourcePath())) {
return;
}
-
- if(coreHelper.isJar(factory.getResource())) {
- return;
- }
if(factory instanceof ISeamAnnotatedFactory) {
validateAnnotatedFactory((ISeamAnnotatedFactory)factory, markedDuplicateFactoryNames);
} else {
@@ -292,8 +277,8 @@
this.addError(DUPLICATE_VARIABLE_NAME_MESSAGE_ID, SeamPreferences.DUPLICATE_VARIABLE_NAME, new String[]{factoryName}, location, factory.getResource());
}
// mark duplicate variable
- IResource resource = coreHelper.getComponentResourceWithName(variable);
- if(!coreHelper.isJar(resource)) {
+ if(!coreHelper.isJar(variable.getSourcePath())) {
+ IResource resource = coreHelper.getComponentResourceWithName(variable);
validationContext.addLinkedCoreResource(factoryName, resource.getFullPath());
location = coreHelper.getLocationOfName(variable);
this.addError(DUPLICATE_VARIABLE_NAME_MESSAGE_ID, SeamPreferences.DUPLICATE_VARIABLE_NAME, new String[]{factoryName}, location, resource);
Modified: trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/validation/SeamValidationHelper.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/validation/SeamValidationHelper.java 2007-09-21 07:57:02 UTC (rev 3752)
+++ trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/validation/SeamValidationHelper.java 2007-09-21 09:27:07 UTC (rev 3753)
@@ -18,6 +18,7 @@
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IWorkspaceRoot;
import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jdt.core.IMethod;
@@ -117,12 +118,12 @@
* @param resource
* @return true if resource is Jar file
*/
- public boolean isJar(IResource resource) {
- if(resource==null) {
+ public boolean isJar(IPath path) {
+ if(path == null) {
throw new IllegalArgumentException("Resource must not be null");
}
- String ext = resource.getFileExtension();
- return ext!=null && ext.equalsIgnoreCase("jar");
+ String ext = path.getFileExtension();
+ return ext != null && ext.equalsIgnoreCase("jar");
}
/**
@@ -130,7 +131,7 @@
* @return true if seam element packed in Jar file
*/
public boolean isJar(ISeamElement element) {
- return isJar(element.getResource());
+ return isJar(element.getSourcePath());
}
/**
17 years, 3 months