JBoss Tools SVN: r6797 - trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/util.
by jbosstools-commits@lists.jboss.org
Author: rob.stryker(a)jboss.com
Date: 2008-03-07 18:14:47 -0500 (Fri, 07 Mar 2008)
New Revision: 6797
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/util/ServerConverter.java
Log:
Continued API change. Bug consisted of poll threads continuing to run even if somehow the server state changed adn the poll thread was unaware. This leads to continued polling even when the process has been canceled, for example. Fixed.
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/util/ServerConverter.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/util/ServerConverter.java 2008-03-07 23:08:31 UTC (rev 6796)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/util/ServerConverter.java 2008-03-07 23:14:47 UTC (rev 6797)
@@ -25,6 +25,7 @@
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.wst.server.core.IServer;
+import org.eclipse.wst.server.core.IServerWorkingCopy;
import org.eclipse.wst.server.core.ServerCore;
import org.jboss.ide.eclipse.as.core.server.IDeployableServer;
import org.jboss.ide.eclipse.as.core.server.internal.DeployableServerBehavior;
@@ -42,6 +43,13 @@
}
return jbServer;
}
+ public static JBossServer getJBossServer(IServerWorkingCopy server) {
+ JBossServer jbServer = (JBossServer)server.getAdapter(JBossServer.class);
+ if (jbServer == null) {
+ jbServer = (JBossServer) server.loadAdapter(JBossServer.class, new NullProgressMonitor());
+ }
+ return jbServer;
+ }
public static IDeployableServer getDeployableServer(IServer server) {
IDeployableServer dep = (IDeployableServer)server.getAdapter(IDeployableServer.class);
18 years, 1 month
JBoss Tools SVN: r6796 - in trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core: server and 1 other directories.
by jbosstools-commits@lists.jboss.org
Author: rob.stryker(a)jboss.com
Date: 2008-03-07 18:08:31 -0500 (Fri, 07 Mar 2008)
New Revision: 6796
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/extensions/polling/JMXPoller.java
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/extensions/polling/ProcessTerminatedPoller.java
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/extensions/polling/TimeoutPoller.java
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/IServerStatePoller.java
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/PollThread.java
Log:
Continued API change. Bug consisted of poll threads continuing to run even if somehow the server state changed adn the poll thread was unaware. This leads to continued polling even when the process has been canceled, for example. Fixed.
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/extensions/polling/JMXPoller.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/extensions/polling/JMXPoller.java 2008-03-07 22:12:25 UTC (rev 6795)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/extensions/polling/JMXPoller.java 2008-03-07 23:08:31 UTC (rev 6796)
@@ -268,4 +268,8 @@
public void setPollerType(ServerStatePollerType type) {
this.type = type;
}
+
+ public IServer getServer() {
+ return server;
+ }
}
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/extensions/polling/ProcessTerminatedPoller.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/extensions/polling/ProcessTerminatedPoller.java 2008-03-07 22:12:25 UTC (rev 6795)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/extensions/polling/ProcessTerminatedPoller.java 2008-03-07 23:08:31 UTC (rev 6796)
@@ -51,6 +51,10 @@
this.server = (JBossServerBehavior)server.loadAdapter(JBossServerBehavior.class, new NullProgressMonitor());
}
+ public IServer getServer() {
+ return server.getServer();
+ }
+
public void cancel(int type) {
}
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/extensions/polling/TimeoutPoller.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/extensions/polling/TimeoutPoller.java 2008-03-07 22:12:25 UTC (rev 6795)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/extensions/polling/TimeoutPoller.java 2008-03-07 23:08:31 UTC (rev 6796)
@@ -54,6 +54,10 @@
this.server = server;
this.endTime = new Date().getTime() + getTimeout() - 2000;
}
+
+ public IServer getServer() {
+ return server;
+ }
public void cancel(int type) {
}
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/IServerStatePoller.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/IServerStatePoller.java 2008-03-07 22:12:25 UTC (rev 6795)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/IServerStatePoller.java 2008-03-07 23:08:31 UTC (rev 6796)
@@ -40,11 +40,13 @@
public static final int CANCEL = 0;
public static final int TIMEOUT_REACHED = 1;
+ public static final int SUCCESS = 2;
+ public static final int FAILED = 3;
public ServerStatePollerType getPollerType();
public void setPollerType(ServerStatePollerType type);
public void beginPolling(IServer server, boolean expectedState, PollThread pt); // expected to launch own thread
-
+ public IServer getServer();
public boolean isComplete() throws PollingException, RequiresInfoException;
public boolean getState() throws PollingException, RequiresInfoException;
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/PollThread.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/PollThread.java 2008-03-07 22:12:25 UTC (rev 6795)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/PollThread.java 2008-03-07 23:08:31 UTC (rev 6796)
@@ -58,9 +58,8 @@
public static final String POLL_THREAD_EXCEPTION_MESSAGE = "org.jboss.ide.eclipse.as.core.runtime.server.PollThread.exception.message";
- private boolean expectedState;
+ private boolean expectedState, abort, stateStartedOrStopped;
private IServerStatePoller poller;
- private boolean abort;
private String abortMessage;
private JBossServerBehavior behavior;
private EventLogRoot eventRoot;
@@ -138,7 +137,8 @@
poller.beginPolling(getServer(), expectedState, this);
// begin the loop; ask the poller every so often
- while( !abort && !done && new Date().getTime() < startTime + maxWait ) {
+ while( !stateStartedOrStopped && !abort && !done &&
+ new Date().getTime() < startTime + maxWait ) {
try {
Thread.sleep(100);
} catch( InterruptedException ie ) { }
@@ -161,15 +161,26 @@
handler.handle(poller, action, poller.getRequiredProperties());
}
}
+ stateStartedOrStopped = checkServerState();
}
- boolean currentState = !expectedState;
// we stopped. Did we abort?
- if( abort ) {
+ if( stateStartedOrStopped ) {
+ int state = behavior.getServer().getServerState();
+ boolean success = false;
+ if( expectedState == IServerStatePoller.SERVER_UP)
+ success = state == IServer.STATE_STARTED;
+ else
+ success = state == IServer.STATE_STOPPED;
+
+ poller.cancel(success ? IServerStatePoller.SUCCESS : IServerStatePoller.FAILED);
+ poller.cleanup();
+ } else if( abort ) {
poller.cancel(IServerStatePoller.CANCEL);
poller.cleanup();
alertEventLogAbort();
} else {
+ boolean currentState = !expectedState;
boolean finalAlert = true;
if( done ) {
// the poller has an answer
@@ -198,6 +209,13 @@
}
}
+ protected boolean checkServerState() {
+ int state = behavior.getServer().getServerState();
+ if( state == IServer.STATE_STARTED ) return true;
+ if( state == IServer.STATE_STOPPED ) return true;
+ return false;
+ }
+
protected void alertBehavior(boolean currentState, boolean finalAlert) {
if( currentState != expectedState ) {
// it didnt work... cancel all processes! force stop
18 years, 1 month
JBoss Tools SVN: r6795 - in trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core: util and 1 other directory.
by jbosstools-commits@lists.jboss.org
Author: rob.stryker(a)jboss.com
Date: 2008-03-07 17:12:25 -0500 (Fri, 07 Mar 2008)
New Revision: 6795
Modified:
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/ArchivesModel.java
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/util/ModelUtil.java
Log:
removed unused variable from method signature.
Modified: trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/ArchivesModel.java
===================================================================
--- trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/ArchivesModel.java 2008-03-07 22:09:37 UTC (rev 6794)
+++ trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/ArchivesModel.java 2008-03-07 22:12:25 UTC (rev 6795)
@@ -245,7 +245,7 @@
ArchiveModelNode oldRoot = archivesRoot.get(project);
xbPackages.put(project, packages);
archivesRoot.put(project, root);
- ModelUtil.createPackagesNodeImpl(project, packages, (ArchiveModelNode)getRoot(project));
+ ModelUtil.createPackagesNodeImpl(packages, (ArchiveModelNode)getRoot(project));
root.clearDeltas();
fireRegisterProjectEvent(oldRoot, root);
monitor.worked(1);
Modified: trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/util/ModelUtil.java
===================================================================
--- trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/util/ModelUtil.java 2008-03-07 22:09:37 UTC (rev 6794)
+++ trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/util/ModelUtil.java 2008-03-07 22:12:25 UTC (rev 6795)
@@ -222,7 +222,7 @@
return projectPath.append(workspacePath.removeFirstSegments(1));
}
- public static ArchiveNodeImpl createPackagesNodeImpl (IPath project, XbPackages node, IArchiveModelNode modelNode) {
+ public static ArchiveNodeImpl createPackagesNodeImpl( XbPackages node, IArchiveModelNode modelNode) {
for (Iterator iter = node.getAllChildren().iterator(); iter.hasNext(); ) {
XbPackageNode child = (XbPackageNode) iter.next();
ArchiveNodeImpl childImpl = (ArchiveNodeImpl)createPackageNodeImpl(child, modelNode);
18 years, 1 month
JBoss Tools SVN: r6794 - trunk/core/tests/org.jboss.ide.eclipse.archives.test/src/org/jboss/ide/eclipse/archives/test/xb.
by jbosstools-commits@lists.jboss.org
Author: rob.stryker(a)jboss.com
Date: 2008-03-07 17:09:37 -0500 (Fri, 07 Mar 2008)
New Revision: 6794
Modified:
trunk/core/tests/org.jboss.ide.eclipse.archives.test/src/org/jboss/ide/eclipse/archives/test/xb/MarshallTest.java
trunk/core/tests/org.jboss.ide.eclipse.archives.test/src/org/jboss/ide/eclipse/archives/test/xb/UnmarshallTest.java
Log:
javadoc
Modified: trunk/core/tests/org.jboss.ide.eclipse.archives.test/src/org/jboss/ide/eclipse/archives/test/xb/MarshallTest.java
===================================================================
--- trunk/core/tests/org.jboss.ide.eclipse.archives.test/src/org/jboss/ide/eclipse/archives/test/xb/MarshallTest.java 2008-03-07 22:01:13 UTC (rev 6793)
+++ trunk/core/tests/org.jboss.ide.eclipse.archives.test/src/org/jboss/ide/eclipse/archives/test/xb/MarshallTest.java 2008-03-07 22:09:37 UTC (rev 6794)
@@ -44,6 +44,13 @@
import org.osgi.framework.Bundle;
/**
+ *
+ * This class tests marshalling each type of xb object,
+ * expecting the XMLBinding class (and XB itself) to throw
+ * errors if required fields are missing.
+ *
+ * It also verifies correct models are properly marshalled.
+ *
* @author rob.stryker <rob.stryker(a)redhat.com>
*
*/
Modified: trunk/core/tests/org.jboss.ide.eclipse.archives.test/src/org/jboss/ide/eclipse/archives/test/xb/UnmarshallTest.java
===================================================================
--- trunk/core/tests/org.jboss.ide.eclipse.archives.test/src/org/jboss/ide/eclipse/archives/test/xb/UnmarshallTest.java 2008-03-07 22:01:13 UTC (rev 6793)
+++ trunk/core/tests/org.jboss.ide.eclipse.archives.test/src/org/jboss/ide/eclipse/archives/test/xb/UnmarshallTest.java 2008-03-07 22:09:37 UTC (rev 6794)
@@ -42,7 +42,9 @@
import org.osgi.framework.Bundle;
/**
- * Tests whether the xml files can be validated
+ * Tests unmarshalling and validating packaging files.
+ * The tests expect XB to throw exceptions when improper
+ * nonconformant files are parsed.
*
* @author rob.stryker <rob.stryker(a)redhat.com>
*
18 years, 1 month
JBoss Tools SVN: r6793 - trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/extensions/polling.
by jbosstools-commits@lists.jboss.org
Author: rob.stryker(a)jboss.com
Date: 2008-03-07 17:01:13 -0500 (Fri, 07 Mar 2008)
New Revision: 6793
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/extensions/polling/JMXPoller.java
Log:
JBIDE-1646 - poller threw multiple dialogs
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/extensions/polling/JMXPoller.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/extensions/polling/JMXPoller.java 2008-03-07 21:10:15 UTC (rev 6792)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/extensions/polling/JMXPoller.java 2008-03-07 22:01:13 UTC (rev 6793)
@@ -117,19 +117,22 @@
new JMXEvent(event, b);
}
} catch (SecurityException se) {
- if( !waitingForCredentials ) {
- waitingForCredentials = true;
- requiresInfoException = new PollingSecurityException(
- "Security Exception: " + se.getMessage());
- } else {
- // we're waiting. are they back yet?
- if( requiredPropertiesReturned != null ) {
- requiresInfoException = null;
- String user, pass;
- user = (String)requiredPropertiesReturned.get(REQUIRED_USER);
- pass = (String)requiredPropertiesReturned.get(REQUIRED_PASS);
- setCredentials(user, pass);
- waitingForCredentials = false;
+ synchronized(this) {
+ if( !waitingForCredentials ) {
+ waitingForCredentials = true;
+ requiresInfoException = new PollingSecurityException(
+ "Security Exception: " + se.getMessage());
+ } else {
+ // we're waiting. are they back yet?
+ if( requiredPropertiesReturned != null ) {
+ requiresInfoException = null;
+ String user, pass;
+ user = (String)requiredPropertiesReturned.get(REQUIRED_USER);
+ pass = (String)requiredPropertiesReturned.get(REQUIRED_PASS);
+ requiredPropertiesReturned = null;
+ setCredentials(user, pass);
+ waitingForCredentials = false;
+ }
}
}
} catch (CommunicationException ce) {
18 years, 1 month
JBoss Tools SVN: r6792 - in trunk/seam/plugins: org.jboss.tools.seam.core/src/org/jboss/tools/seam/core and 6 other directories.
by jbosstools-commits@lists.jboss.org
Author: akazakov
Date: 2008-03-07 16:10:15 -0500 (Fri, 07 Mar 2008)
New Revision: 6792
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/META-INF/MANIFEST.MF
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/SeamProjectsSet.java
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/SeamUIMessages.java
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/messages.properties
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/preferences/SeamPreferencesMessages.java
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/preferences/SeamPreferencesMessages.properties
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/preferences/SeamSettingsPreferencePageNew.java
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/widget/editor/BaseFieldEditor.java
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/widget/editor/ComboFieldEditor.java
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/widget/editor/CompositeEditor.java
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/widget/editor/IFieldEditorFactory.java
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/widget/editor/RadioFieldEditor.java
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/widget/editor/SwtFieldEditorFactory.java
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/widget/field/RadioField.java
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamProjectSelectionDialog.java
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamWizardFactory.java
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SelectSeamProjectAction.java
Log:
http://jira.jboss.com/jira/browse/JBIDE-1322
Modified: trunk/seam/plugins/org.jboss.tools.seam.core/META-INF/MANIFEST.MF
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.core/META-INF/MANIFEST.MF 2008-03-07 20:58:26 UTC (rev 6791)
+++ trunk/seam/plugins/org.jboss.tools.seam.core/META-INF/MANIFEST.MF 2008-03-07 21:10:15 UTC (rev 6792)
@@ -51,14 +51,15 @@
org.jboss.tools.seam.internal.core.refactoring
Bundle-Version: 2.0.0
Export-Package: org.jboss.tools.seam.core,
+ org.jboss.tools.seam.core.commands,
org.jboss.tools.seam.core.event,
org.jboss.tools.seam.core.project.facet,
org.jboss.tools.seam.internal.core,
org.jboss.tools.seam.internal.core.el,
org.jboss.tools.seam.internal.core.project.facet,
+ org.jboss.tools.seam.internal.core.refactoring,
org.jboss.tools.seam.internal.core.scanner,
org.jboss.tools.seam.internal.core.scanner.java,
org.jboss.tools.seam.internal.core.scanner.lib,
org.jboss.tools.seam.internal.core.scanner.xml,
- org.jboss.tools.seam.internal.core.validation,
- org.jboss.tools.seam.internal.core.refactoring
+ org.jboss.tools.seam.internal.core.validation
Modified: trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/SeamProjectsSet.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/SeamProjectsSet.java 2008-03-07 20:58:26 UTC (rev 6791)
+++ trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/SeamProjectsSet.java 2008-03-07 21:10:15 UTC (rev 6792)
@@ -79,10 +79,7 @@
if(prefs==null) {
return false;
}
- return prefs.get(
- ISeamFacetDataModelProperties.JBOSS_AS_DEPLOY_AS,
- ISeamFacetDataModelProperties.DEPLOY_AS_WAR)
- .equals(ISeamFacetDataModelProperties.DEPLOY_AS_WAR);
+ return prefs.get(ISeamFacetDataModelProperties.JBOSS_AS_DEPLOY_AS, ISeamFacetDataModelProperties.DEPLOY_AS_WAR).equals(ISeamFacetDataModelProperties.DEPLOY_AS_WAR);
}
/**
@@ -122,11 +119,14 @@
* @return the action folder (this folder is not guaranteed to exist!)
*/
public IFolder getActionFolder() {
- if(prefs==null) {
+ String folderPath = null;
+ if(prefs!=null) {
+ folderPath = prefs.get(ISeamFacetDataModelProperties.SESSION_BEAN_SOURCE_FOLDER, null);
+ }
+ if(folderPath==null) {
return getSourceFolder();
}
- String folderPath = prefs.get(ISeamFacetDataModelProperties.SESSION_BEAN_SOURCE_FOLDER, null);
return (IFolder)ResourcesPlugin.getWorkspace().getRoot().findMember(folderPath);
}
@@ -135,11 +135,14 @@
* @return the model folder if exists (this folder is not guaranteed to exist!)
*/
public IFolder getModelFolder() {
- if(prefs==null) {
+ String folderPath = null;
+ if(prefs!=null) {
+ folderPath = prefs.get(ISeamFacetDataModelProperties.ENTITY_BEAN_SOURCE_FOLDER, null);
+ }
+ if(folderPath==null) {
return getSourceFolder();
}
- String folderPath = prefs.get(ISeamFacetDataModelProperties.ENTITY_BEAN_SOURCE_FOLDER, null);
return (IFolder)ResourcesPlugin.getWorkspace().getRoot().findMember(folderPath);
}
@@ -167,7 +170,11 @@
* @return
*/
public IFolder getViewsFolder() {
- if(prefs==null) {
+ String folderPath = null;
+ if(prefs!=null) {
+ folderPath = prefs.get(ISeamFacetDataModelProperties.WEB_CONTENTS_FOLDER, null);
+ }
+ if(folderPath==null) {
IVirtualComponent com = ComponentCore.createComponent(war);
if(com!=null) {
IVirtualFolder webRootFolder = com.getRootFolder().getFolder(new Path("/")); //$NON-NLS-1$
@@ -178,7 +185,6 @@
return null;
}
- String folderPath = prefs.get(ISeamFacetDataModelProperties.WEB_CONTENTS_FOLDER, null);
return (IFolder)ResourcesPlugin.getWorkspace().getRoot().findMember(folderPath);
}
@@ -187,15 +193,21 @@
* @return
*/
public IFolder getTestsFolder() {
- if(prefs==null) {
+ String folderPath = null;
+ if(prefs!=null) {
+ folderPath = prefs.get(ISeamFacetDataModelProperties.TEST_SOURCE_FOLDER, null);
+ }
+ if(folderPath==null) {
return getSourceFolder();
}
- String folderPath = prefs.get(ISeamFacetDataModelProperties.TEST_SOURCE_FOLDER, null);
return (IFolder)ResourcesPlugin.getWorkspace().getRoot().findMember(folderPath);
}
public String getEntityPackage(){
+ if(prefs==null) {
+ return "entity";
+ }
return prefs.get(ISeamFacetDataModelProperties.ENTITY_BEAN_PACKAGE_NAME, "entity"); //$NON-NLS-1$
}
Modified: trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/SeamUIMessages.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/SeamUIMessages.java 2008-03-07 20:58:26 UTC (rev 6791)
+++ trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/SeamUIMessages.java 2008-03-07 21:10:15 UTC (rev 6792)
@@ -305,8 +305,6 @@
public static String SEAM_WIZARD_FACTORY_SEAM_PROJECT;
- public static String SEAM_SETTINGS_PREFERENCES_PAGE_SEAM_PROJECT;
-
public static String SELECT_SEAM_PROJECT_ACTION_BROWSE;
public static String SWT_FIELD_EDITOR_FACTORY_BROWS;
@@ -412,6 +410,8 @@
public static String RUNTIME_DELETE_NOT_USED_CONFIRM;
public static String RUNTIME_DELETE_USED_CONFIRM;
+
+ public static String VIEW_FOLDER_FILED_EDITOR;
public static String FIND_DECLARATIONS_ACTION_ACTION_NAME;
public static String FIND_DECLARATIONS_ACTION_DESCRIPTION;
@@ -423,6 +423,9 @@
public static String FIND_REFERENCES_ACTION_MESSAGE;
public static String FIND_REFERENCES_ACTION_TOOL_TIP;
+ public static String SELECT_WORKSPACE_FOLDER_DIALOG_TITLE;
+ public static String SELECT_WORKSPACE_FOLDER_DIALOG_MESSAGE;
+
public static String SeamSearchQuery_task_label;
public static String SeamSearchQuery_label;
public static String SeamSearchQuery_error_unsupported_pattern;
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 2008-03-07 20:58:26 UTC (rev 6791)
+++ trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/internal/project/facet/SeamInstallWizardPage.java 2008-03-07 21:10:15 UTC (rev 6792)
@@ -18,28 +18,20 @@
import java.util.Map;
import org.eclipse.core.runtime.IStatus;
-import org.eclipse.datatools.connectivity.ConnectionProfileException;
import org.eclipse.datatools.connectivity.IConnectionProfile;
-import org.eclipse.datatools.connectivity.IProfileListener;
import org.eclipse.datatools.connectivity.ProfileManager;
-import org.eclipse.datatools.connectivity.db.generic.ui.NewConnectionProfileWizard;
-import org.eclipse.datatools.connectivity.internal.ui.wizards.NewCPWizard;
-import org.eclipse.datatools.connectivity.internal.ui.wizards.NewCPWizardCategoryFilter;
import org.eclipse.jdt.core.JavaConventions;
import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.wizard.IWizard;
-import org.eclipse.jface.wizard.WizardDialog;
import org.eclipse.jst.j2ee.project.facet.IJ2EEModuleFacetInstallDataModelProperties;
import org.eclipse.osgi.util.NLS;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Group;
-import org.eclipse.ui.internal.dialogs.PropertyDialog;
import org.eclipse.wst.common.componentcore.datamodel.properties.IFacetDataModelProperties;
import org.eclipse.wst.common.componentcore.internal.util.IModuleConstants;
import org.eclipse.wst.common.frameworks.datamodel.DataModelEvent;
@@ -62,7 +54,6 @@
import org.jboss.tools.seam.core.project.facet.SeamVersion;
import org.jboss.tools.seam.internal.core.project.facet.ISeamFacetDataModelProperties;
import org.jboss.tools.seam.ui.SeamUIMessages;
-import org.jboss.tools.seam.ui.widget.editor.ButtonFieldEditor;
import org.jboss.tools.seam.ui.widget.editor.CompositeEditor;
import org.jboss.tools.seam.ui.widget.editor.IFieldEditor;
import org.jboss.tools.seam.ui.widget.editor.IFieldEditorFactory;
@@ -81,8 +72,6 @@
private static final DriverClassHelpers HIBERNATE_HELPER = new DriverClassHelpers();
- private static final List<String> DIALECT_CLASSES = getDialectClasses();
-
private IDataModel model = null;
private DataModelValidatorDelegate validatorDelegate;
@@ -97,18 +86,13 @@
Arrays.asList(new Object[] { ISeamFacetDataModelProperties.DEPLOY_AS_WAR, ISeamFacetDataModelProperties.DEPLOY_AS_EAR }),
getDeployAsDefaultValue());
- String lastCreatedCPName = ""; //$NON-NLS-1$
-
// Database group
- private IFieldEditor connProfileSelEditor = IFieldEditorFactory.INSTANCE
- .createComboWithTwoButtons(
- ISeamFacetDataModelProperties.SEAM_CONNECTION_PROFILE,
- SeamUIMessages.SEAM_INSTALL_WIZARD_PAGE_CONNECTION_PROFILE,
- getProfileNameList(),
- getConnectionProfileDefaultValue(),
- false, new EditConnectionProfileAction(),
- new NewConnectionProfileAction(),
- ValidatorFactory.NO_ERRORS_VALIDATOR);
+ private IFieldEditor connProfileSelEditor = SeamWizardFactory.createConnectionProfileSelectionFieldEditor(getConnectionProfileDefaultValue(), new IValidator() {
+ public Map<String, String> validate(Object value, Object context) {
+ SeamInstallWizardPage.this.validate();
+ return ValidatorFactory.NO_ERRORS;
+ }
+ });
private IFieldEditor jBossHibernateDbTypeEditor = IFieldEditorFactory.INSTANCE
.createComboEditor(ISeamFacetDataModelProperties.DB_TYPE,
@@ -163,17 +147,6 @@
/**
* @return
*/
- private static List<String> getDialectClasses() {
- List<String> dialects = new ArrayList<String>();
- for (String dialectName : HIBERNATE_HELPER.getDialectNames()) {
- dialects.add(HIBERNATE_HELPER.getDialectClass(dialectName));
- }
- return dialects;
- }
-
- /**
- * @return
- */
private String getDefaultDbType() {
return SeamProjectPreferences.getStringPreference(
SeamProjectPreferences.HIBERNATE_DEFAULT_DB_TYPE);
@@ -193,9 +166,19 @@
private Object getConnectionProfileDefaultValue() {
String defaultDs = SeamProjectPreferences.getStringPreference(
SeamProjectPreferences.SEAM_DEFAULT_CONNECTION_PROFILE);
- return getProfileNameList().contains(defaultDs)?defaultDs:""; //$NON-NLS-1$
+ return getConnectionProfileNameList().contains(defaultDs)?defaultDs:""; //$NON-NLS-1$
}
+ private static List<String> getConnectionProfileNameList() {
+ IConnectionProfile[] profiles = ProfileManager.getInstance()
+ .getProfilesByCategory("org.eclipse.datatools.connectivity.db.category"); //$NON-NLS-1$
+ List<String> names = new ArrayList<String>();
+ for (IConnectionProfile connectionProfile : profiles) {
+ names.add(connectionProfile.getName());
+ }
+ return names;
+ }
+
/**
*
* @return
@@ -395,109 +378,7 @@
}
}
- private List<String> getProfileNameList() {
- IConnectionProfile[] profiles = ProfileManager.getInstance()
- .getProfilesByCategory("org.eclipse.datatools.connectivity.db.category"); //$NON-NLS-1$
- List<String> names = new ArrayList<String>();
- for (IConnectionProfile connectionProfile : profiles) {
- names.add(connectionProfile.getName());
- }
- return names;
- }
-
/**
- *
- */
- public class EditConnectionProfileAction extends
- ButtonFieldEditor.ButtonPressedAction {
-
- /**
- * @param label
- */
- public EditConnectionProfileAction() {
- super(SeamUIMessages.SEAM_INSTALL_WIZARD_PAGE_EDIT);
- }
-
- /**
- *
- */
- @Override
- public void run() {
- IConnectionProfile selectedProfile = ProfileManager.getInstance()
- .getProfileByName(getFieldEditor().getValue().toString());
- String oldName = getFieldEditor().getValue().toString();
-
- if (selectedProfile == null)
- return;
- PropertyDialog
- .createDialogOn(
- Display.getCurrent().getActiveShell(),
- "org.eclipse.datatools.connectivity.db.generic.profileProperties", //$NON-NLS-1$
- selectedProfile).open();
-
- if (!oldName.equals(selectedProfile.getName())) {
- getFieldEditor().setValue(selectedProfile.getName());
- ((ITaggedFieldEditor) ((CompositeEditor) connProfileSelEditor)
- .getEditors().get(1)).setTags(getProfileNameList()
- .toArray(new String[0]));
- oldName = selectedProfile.getName();
- }
- validate();
- }
- };
-
- /**
- * Handler for ButtonFieldEditor that shows Property Editor dialog for
- * selected ConnectionProfile
- *
- * @author eskimo
- */
- public class NewConnectionProfileAction extends
- ButtonFieldEditor.ButtonPressedAction {
- /**
- * @param label
- */
- public NewConnectionProfileAction() {
- super(SeamUIMessages.SEAM_INSTALL_WIZARD_PAGE_NEW);
- }
-
- @Override
- public void run() {
- IProfileListener listener = new ConnectionProfileChangeListener();
-
- ProfileManager.getInstance().addProfileListener(listener);
- NewCPWizardCategoryFilter filter = new NewCPWizardCategoryFilter("org.eclipse.datatools.connectivity.db.category"); //$NON-NLS-1$
- NewCPWizard wizard = new NewCPWizard(filter, null);
- new NewConnectionProfileWizard() {
- public boolean performFinish() {
- // create profile only
- try {
- ProfileManager.getInstance().createProfile(
- getProfileName() == null ? "" //$NON-NLS-1$
- : getProfileName(),
- getProfileDescription() == null ? "" //$NON-NLS-1$
- : getProfileDescription(),
- mProviderID,
- getProfileProperties(),
- mProfilePage.getRepository() == null ? "" //$NON-NLS-1$
- : mProfilePage.getRepository()
- .getName(), false);
- lastCreatedCPName = getProfileName();
- } catch (ConnectionProfileException e) {
- SeamCorePlugin.getPluginLog().logError(e);
- }
-
- return true;
- }
- };
- WizardDialog wizardDialog = new WizardDialog(Display.getCurrent()
- .getActiveShell(), wizard);
- wizardDialog.open();
- ProfileManager.getInstance().removeProfileListener(listener);
- }
- }
-
- /**
* It is overridden to fill Code Generation group with the default package
* names
*/
@@ -704,34 +585,6 @@
}
}
- public class ConnectionProfileChangeListener implements IProfileListener {
- /* (non-Javadoc)
- * @see org.eclipse.datatools.connectivity.IProfileListener#profileAdded(org.eclipse.datatools.connectivity.IConnectionProfile)
- */
- public void profileAdded(IConnectionProfile profile) {
- connProfileSelEditor.setValue(profile.getName());
- ((ITaggedFieldEditor) ((CompositeEditor) connProfileSelEditor)
- .getEditors().get(1)).setTags(getProfileNameList()
- .toArray(new String[0]));
- validate();
-
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.datatools.connectivity.IProfileListener#profileChanged(org.eclipse.datatools.connectivity.IConnectionProfile)
- */
- public void profileChanged(IConnectionProfile profile) {
- profileAdded(profile);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.datatools.connectivity.IProfileListener#profileDeleted(org.eclipse.datatools.connectivity.IConnectionProfile)
- */
- public void profileDeleted(IConnectionProfile profile) {
- // this event never happens
- }
- }
-
/**
*
*/
Modified: trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/messages.properties
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/messages.properties 2008-03-07 20:58:26 UTC (rev 6791)
+++ trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/messages.properties 2008-03-07 21:10:15 UTC (rev 6792)
@@ -202,7 +202,6 @@
OPEN_SEAM_COMPONENT_ACTION_MESSAGE=Enter seam component name prefix or pattern (? = any character, * = any string):
OPEN_SEAM_COMPONENT_DIALOG_LOADING=Seam components loading
OPEN_SEAM_COMPONENT_DIALOG_NAME=OpenSeamComponentDialog
-SEAM_SETTINGS_PREFERENCES_PAGE_SEAM_PROJECT=Main Seam Project:
FIND_DECLARATIONS_ACTION_ACTION_NAME=Find Seam Declarations
FIND_DECLARATIONS_ACTION_DESCRIPTION=Find Seam Declarations
FIND_DECLARATIONS_ACTION_TOOL_TIP=Find Seam Declarations
@@ -211,6 +210,9 @@
FIND_REFERENCES_ACTION_DESCRIPTION=Find Seam References
FIND_REFERENCES_ACTION_TOOL_TIP=Find Seam References
FIND_REFERENCES_ACTION_MESSAGE=&Choose a name of the seam variable or pattern (? = any character, * = any string):
+VIEW_FOLDER_FILED_EDITOR=View Folder:
+SELECT_WORKSPACE_FOLDER_DIALOG_TITLE=Folder Selection
+SELECT_WORKSPACE_FOLDER_DIALOG_MESSAGE=&Chose a folder
SeamSearchQuery_task_label=Searching for ''{0}''...
SeamSearchQuery_label=Seam {0} Search
SeamSearchQuery_error_unsupported_pattern=Unsupported search pattern: "{0}"
Modified: trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/preferences/SeamPreferencesMessages.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/preferences/SeamPreferencesMessages.java 2008-03-07 20:58:26 UTC (rev 6791)
+++ trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/preferences/SeamPreferencesMessages.java 2008-03-07 21:10:15 UTC (rev 6792)
@@ -18,7 +18,25 @@
*/
public class SeamPreferencesMessages extends NLS {
private static final String BUNDLE_NAME = "org.jboss.tools.seam.ui.preferences.SeamPreferencesMessages"; //$NON-NLS-1$
-
+
+ public static String SEAM_SETTINGS_PREFERENCES_PAGE_SEAM_PROJECT;
+
+ public static String SEAM_SETTINGS_PREFERENCES_PAGE_EJB_PROJECT;
+
+ public static String SEAM_SETTINGS_PREFERENCES_PAGE_DEPLOYMENT;
+
+ public static String SEAM_SETTINGS_PREFERENCES_PAGE_VIEW;
+
+ public static String SEAM_SETTINGS_PREFERENCES_PAGE_MODEL;
+
+ public static String SEAM_SETTINGS_PREFERENCES_PAGE_ACTION;
+
+ public static String SEAM_SETTINGS_PREFERENCES_PAGE_SOURCE_FOLDER;
+
+ public static String SEAM_SETTINGS_PREFERENCES_PAGE_PACKAGE;
+
+ public static String SEAM_SETTINGS_PREFERENCE_PAGE_SEAM_SUPPORT;
+
public static String SEAM_PREFERENCE_PAGE_SEAM_RUNTIMES;
public static String SEAM_SETTINGS_PREFERENCE_PAGE_ADD;
@@ -29,8 +47,6 @@
public static String SEAM_SETTINGS_PREFERENCE_PAGE_SEAM_RUNTIME_IS_NOT_SELECTED;
- public static String SEAM_SETTINGS_PREFERENCE_PAGE_SEAM_SUPPORT;
-
public static String SEAM_VALIDATOR_CONFIGURATION_BLOCK_ERROR;
public static String SEAM_VALIDATOR_CONFIGURATION_BLOCK_IGNORE;
Modified: trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/preferences/SeamPreferencesMessages.properties
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/preferences/SeamPreferencesMessages.properties 2008-03-07 20:58:26 UTC (rev 6791)
+++ trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/preferences/SeamPreferencesMessages.properties 2008-03-07 21:10:15 UTC (rev 6792)
@@ -62,12 +62,23 @@
SeamValidatorConfigurationBlock_pb_unpairedGetterOrSetter_label=Unpaired Getter/Setter:
SEAM_VALIDATOR_CONFIGURATION_BLOCK_SEAM_VALIDATOR_CONFIGURATION_BLOCK=SeamValidatorConfigurationBlock
SEAM_VALIDATOR_CONFIGURATION_BLOCK_ERROR=Error
-SEAM_SETTINGS_PREFERENCE_PAGE_RUNTIME=Runtime
SEAM_VALIDATOR_CONFIGURATION_BLOCK_WARNING=Warning
-SEAM_SETTINGS_PREFERENCE_PAGE_SEAM_SUPPORT=Seam support
+
SEAM_VALIDATOR_PREFERENCE_PAGE_SEAM_VALIDATOR=Seam Validator
SEAM_VALIDATOR_CONFIGURATION_BLOCK_IGNORE=Ignore
+
+SEAM_SETTINGS_PREFERENCES_PAGE_SEAM_PROJECT=Main Seam Project:
+SEAM_SETTINGS_PREFERENCES_PAGE_EJB_PROJECT=Seam EJB Project:
+SEAM_SETTINGS_PREFERENCES_PAGE_DEPLOYMENT=Deployment
+SEAM_SETTINGS_PREFERENCES_PAGE_VIEW=View
+SEAM_SETTINGS_PREFERENCES_PAGE_MODEL=Model
+SEAM_SETTINGS_PREFERENCES_PAGE_SOURCE_FOLDER=Source Folder:
+SEAM_SETTINGS_PREFERENCES_PAGE_PACKAGE=Package:
+SEAM_SETTINGS_PREFERENCES_PAGE_ACTION=Action/Form/Conversation
+SEAM_SETTINGS_PREFERENCE_PAGE_SEAM_SUPPORT=Seam support:
+
+SEAM_SETTINGS_PREFERENCE_PAGE_RUNTIME=Runtime
SEAM_SETTINGS_PREFERENCE_PAGE_SEAM_RUNTIME_IS_NOT_SELECTED=Seam runtime is not selected
SEAM_SETTINGS_PREFERENCE_PAGE_ADD=Add
SEAM_PREFERENCE_PAGE_SEAM_RUNTIMES=Seam Runtimes
-SEAM_SETTINGS_PREFERENCE_PAGE_INSTALLED_RUNTIMES=Installed Runtimes
+SEAM_SETTINGS_PREFERENCE_PAGE_INSTALLED_RUNTIMES=Installed Runtimes
\ No newline at end of file
Modified: trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/preferences/SeamSettingsPreferencePageNew.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/preferences/SeamSettingsPreferencePageNew.java 2008-03-07 20:58:26 UTC (rev 6791)
+++ trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/preferences/SeamSettingsPreferencePageNew.java 2008-03-07 21:10:15 UTC (rev 6792)
@@ -12,54 +12,58 @@
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
-import java.io.File;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IFolder;
import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.preferences.IEclipsePreferences;
-import org.eclipse.jdt.core.IClasspathEntry;
-import org.eclipse.jdt.core.IJavaProject;
-import org.eclipse.jdt.core.JavaModelException;
+import org.eclipse.datatools.connectivity.IConnectionProfile;
+import org.eclipse.datatools.connectivity.ProfileManager;
import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Group;
import org.eclipse.ui.dialogs.PropertyPage;
import org.jboss.tools.common.model.util.EclipseResourceUtil;
import org.jboss.tools.seam.core.ISeamProject;
import org.jboss.tools.seam.core.SeamCorePlugin;
-import org.jboss.tools.seam.core.project.facet.SeamRuntime;
+import org.jboss.tools.seam.core.SeamProjectsSet;
+import org.jboss.tools.seam.core.project.facet.SeamProjectPreferences;
import org.jboss.tools.seam.core.project.facet.SeamVersion;
import org.jboss.tools.seam.internal.core.project.facet.ISeamFacetDataModelProperties;
import org.jboss.tools.seam.ui.SeamGuiPlugin;
import org.jboss.tools.seam.ui.SeamUIMessages;
+import org.jboss.tools.seam.ui.internal.project.facet.IValidator;
+import org.jboss.tools.seam.ui.internal.project.facet.ValidatorFactory;
import org.jboss.tools.seam.ui.widget.editor.IFieldEditor;
import org.jboss.tools.seam.ui.widget.editor.IFieldEditorFactory;
-import org.jboss.tools.seam.ui.widget.editor.SeamRuntimeListFieldEditor;
import org.jboss.tools.seam.ui.wizard.IParameter;
import org.jboss.tools.seam.ui.wizard.SeamWizardFactory;
import org.jboss.tools.seam.ui.wizard.SeamWizardUtils;
import org.osgi.service.prefs.BackingStoreException;
/**
+ * Seam Settings Preference Page
* @author Alexey Kazakov
*/
public class SeamSettingsPreferencePageNew extends PropertyPage implements PropertyChangeListener {
private Map<String,IFieldEditor> editorRegistry = new HashMap<String,IFieldEditor>();
- private List<IFieldEditor> editorOrder = new ArrayList<IFieldEditor>();
private IProject project;
private IProject warProject;
private IEclipsePreferences preferences;
private ISeamProject warSeamProject;
+ private boolean suportSeam;
+ private boolean runtimeIsSelected;
+ private List<Group> groups = new ArrayList<Group>();
/*
* (non-Javadoc)
@@ -73,6 +77,8 @@
if(warProject!=null) {
preferences = SeamCorePlugin.getSeamPreferences(warProject);
warSeamProject = SeamCorePlugin.getSeamProject(warProject, false);
+ } else {
+ preferences = SeamCorePlugin.getSeamPreferences(project);
}
}
@@ -81,17 +87,197 @@
*/
@Override
protected Control createContents(Composite parent) {
- IFieldEditor projectNameEditor = IFieldEditorFactory.INSTANCE.createUneditableTextEditor(IParameter.SEAM_PROJECT_NAME, SeamUIMessages.SEAM_SETTINGS_PREFERENCES_PAGE_SEAM_PROJECT, getSeamProjectName());
- addEditor(projectNameEditor);
+ Composite root = new Composite(parent, SWT.NONE);
+ GridData gd = new GridData();
+ gd.horizontalSpan = 1;
+ gd.horizontalAlignment = GridData.FILL;
+ gd.grabExcessHorizontalSpace = true;
+ gd.grabExcessVerticalSpace = false;
+
+ GridLayout gridLayout = new GridLayout(1, false);
+ root.setLayout(gridLayout);
+ Composite generalGroup = new Composite(root, SWT.NONE);
+ generalGroup.setLayoutData(gd);
+ gridLayout = new GridLayout(4, false);
+
+ generalGroup.setLayout(gridLayout);
+
+ IFieldEditor seamSupportCheckBox = IFieldEditorFactory.INSTANCE.createCheckboxEditor(
+ SeamPreferencesMessages.SEAM_SETTINGS_PREFERENCE_PAGE_SEAM_SUPPORT, SeamPreferencesMessages.SEAM_SETTINGS_PREFERENCE_PAGE_SEAM_SUPPORT, warSeamProject!=null);
+ seamSupportCheckBox.addPropertyChangeListener(new PropertyChangeListener() {
+ public void propertyChange(PropertyChangeEvent evt) {
+ Object value = evt.getNewValue();
+ if (value instanceof Boolean) {
+ boolean v = ((Boolean) value).booleanValue();
+ setEnabledSeamSuport(v);
+ validate();
+ }
+ }
+ });
+ registerEditor(seamSupportCheckBox, generalGroup);
+
IFieldEditor seamRuntimeEditor = SeamWizardFactory.createSeamRuntimeSelectionFieldEditor(getSeamVersions(), getSeamRuntimeName());
- addEditor(seamRuntimeEditor);
+ seamRuntimeEditor.addPropertyChangeListener(new PropertyChangeListener() {
+ public void propertyChange(PropertyChangeEvent evt) {
+ Object value = evt.getNewValue();
+ if(value.toString().length()>0) {
+ setRuntimeIsSelected(true);
+ } else {
+ setRuntimeIsSelected(false);
+ }
+ validate();
+ }
+ });
+ registerEditor(seamRuntimeEditor, generalGroup);
- Control control = new GridLayoutComposite(parent);
+ IFieldEditor projectNameEditor = IFieldEditorFactory.INSTANCE.createUneditableTextEditor(IParameter.SEAM_PROJECT_NAME, SeamPreferencesMessages.SEAM_SETTINGS_PREFERENCES_PAGE_SEAM_PROJECT, getSeamProjectName());
+ registerEditor(projectNameEditor, generalGroup);
- return control;
+ IFieldEditor connProfileEditor = SeamWizardFactory.createConnectionProfileSelectionFieldEditor(getConnectionProfile(), new IValidator() {
+ public Map<String, String> validate(Object value, Object context) {
+ SeamSettingsPreferencePageNew.this.validate();
+ return ValidatorFactory.NO_ERRORS;
+ }
+ });
+ registerEditor(connProfileEditor, generalGroup);
+
+ gd = new GridData();
+ gd.horizontalSpan = 1;
+ gd.horizontalAlignment = GridData.FILL;
+ gd.grabExcessHorizontalSpace = true;
+ gd.grabExcessVerticalSpace = false;
+
+ Group deploymentGroup = new Group(root, SWT.NONE);
+ groups.add(deploymentGroup);
+ deploymentGroup.setLayoutData(gd);
+ deploymentGroup.setText(SeamPreferencesMessages.SEAM_SETTINGS_PREFERENCES_PAGE_DEPLOYMENT);
+ gridLayout = new GridLayout(4, false);
+ deploymentGroup.setLayout(gridLayout);
+
+ IFieldEditor deployTypeEditor = IFieldEditorFactory.INSTANCE.createRadioEditor(
+ ISeamFacetDataModelProperties.JBOSS_AS_DEPLOY_AS,
+ SeamUIMessages.SEAM_INSTALL_WIZARD_PAGE_DEPLOY_AS,
+ Arrays.asList(new String[] {ISeamFacetDataModelProperties.DEPLOY_AS_WAR.toUpperCase(), ISeamFacetDataModelProperties.DEPLOY_AS_EAR.toUpperCase()}),
+ Arrays.asList(new Object[] {ISeamFacetDataModelProperties.DEPLOY_AS_WAR, ISeamFacetDataModelProperties.DEPLOY_AS_EAR}),
+ getDeployAsValue());
+
+ registerEditor(deployTypeEditor, deploymentGroup);
+
+ IFieldEditor ejbProjectEditor = SeamWizardFactory.createSeamProjectSelectionFieldEditor(ISeamFacetDataModelProperties.SEAM_EJB_PROJECT, SeamPreferencesMessages.SEAM_SETTINGS_PREFERENCES_PAGE_EJB_PROJECT, getEjbProjectName(), true);
+ registerEditor(ejbProjectEditor, deploymentGroup);
+
+ Group viewGroup = new Group(root, SWT.NONE);
+ groups.add(viewGroup);
+ gd = new GridData();
+ gd.horizontalSpan = 1;
+ gd.horizontalAlignment = GridData.FILL;
+ gd.grabExcessHorizontalSpace = true;
+ gd.grabExcessVerticalSpace = false;
+
+ viewGroup.setLayoutData(gd);
+ viewGroup.setText(SeamPreferencesMessages.SEAM_SETTINGS_PREFERENCES_PAGE_VIEW);
+ gridLayout = new GridLayout(3, false);
+ viewGroup.setLayout(gridLayout);
+
+ IFieldEditor viewFolderEditor = SeamWizardFactory.createViewFolderFieldEditor(getViewFolder());
+ registerEditor(viewFolderEditor, viewGroup);
+
+ Group modelGroup = new Group(root, SWT.NONE);
+ groups.add(modelGroup);
+ gd = new GridData();
+ gd.horizontalSpan = 1;
+ gd.horizontalAlignment = GridData.FILL;
+ gd.grabExcessHorizontalSpace = true;
+ gd.grabExcessVerticalSpace = false;
+
+ modelGroup.setLayoutData(gd);
+ modelGroup.setText(SeamPreferencesMessages.SEAM_SETTINGS_PREFERENCES_PAGE_MODEL);
+ gridLayout = new GridLayout(3, false);
+ modelGroup.setLayout(gridLayout);
+
+ IFieldEditor modelSourceFolderEditor = IFieldEditorFactory.INSTANCE.createBrowseSourceFolderEditor(ISeamFacetDataModelProperties.ENTITY_BEAN_SOURCE_FOLDER, SeamPreferencesMessages.SEAM_SETTINGS_PREFERENCES_PAGE_SOURCE_FOLDER, getModelSourceFolder());
+ registerEditor(modelSourceFolderEditor, modelGroup);
+
+ setEnabledSeamSuport(warSeamProject!=null);
+ setRuntimeIsSelected(getSeamRuntimeName().length()>0);
+
+ return root;
}
+ private String getModelSourceFolder() {
+ String folder = null;
+ if(preferences!=null) {
+ folder = preferences.get(ISeamFacetDataModelProperties.ENTITY_BEAN_SOURCE_FOLDER, null);
+ }
+ if(folder==null) {
+ SeamProjectsSet set = new SeamProjectsSet(project);
+ IFolder f = set.getModelFolder();
+ folder = f!=null?f.getFullPath().toString():"";
+ }
+ return folder;
+ }
+
+ private String getViewFolder() {
+ String folder = null;
+ if(preferences!=null) {
+ folder = preferences.get(ISeamFacetDataModelProperties.WEB_CONTENTS_FOLDER, null);
+ }
+ if(folder==null) {
+ SeamProjectsSet set = new SeamProjectsSet(project);
+ IFolder f = set.getViewsFolder();
+ folder = f!=null?f.getFullPath().toString():"";
+ }
+ return folder;
+ }
+
+ private List<String> getProfileNameList() {
+ IConnectionProfile[] profiles = ProfileManager.getInstance()
+ .getProfilesByCategory("org.eclipse.datatools.connectivity.db.category"); //$NON-NLS-1$
+ List<String> names = new ArrayList<String>();
+ for (IConnectionProfile connectionProfile : profiles) {
+ names.add(connectionProfile.getName());
+ }
+ return names;
+ }
+
+ private String getConnectionProfile() {
+ String defaultDs = SeamProjectPreferences.getStringPreference(
+ SeamProjectPreferences.SEAM_DEFAULT_CONNECTION_PROFILE);
+ return getProfileNameList().contains(defaultDs)?defaultDs:""; //$NON-NLS-1$
+ }
+
+ private String getEjbProjectName() {
+ if(preferences!=null) {
+ return preferences.get(ISeamFacetDataModelProperties.SEAM_EJB_PROJECT, project.getName());
+ }
+ return project.getName();
+ }
+
+ private Object getDeployAsValue() {
+ if(preferences!=null) {
+ return preferences.get(ISeamFacetDataModelProperties.JBOSS_AS_DEPLOY_AS, ISeamFacetDataModelProperties.DEPLOY_AS_WAR);
+ }
+ return ISeamFacetDataModelProperties.DEPLOY_AS_WAR;
+ }
+
+ private void validate() {
+// if(getSeamSupport() && (runtime.getValue()== null || "".equals(runtime.getValue()))) { //$NON-NLS-1$
+//// setValid(false);
+// setMessage(SeamPreferencesMessages.SEAM_SETTINGS_PREFERENCE_PAGE_SEAM_RUNTIME_IS_NOT_SELECTED, IMessageProvider.WARNING);
+//// setErrorMessage(SeamPreferencesMessages.SEAM_SETTINGS_PREFERENCE_PAGE_SEAM_RUNTIME_IS_NOT_SELECTED);
+// } else {
+// setValid(true);
+// String value = runtime.getValueAsString();
+// if(Boolean.TRUE.equals(seamEnablement.getValue()) && SeamRuntimeManager.getInstance().findRuntimeByName(value) == null) {
+// setErrorMessage("Runtime " + value + " does not exist.");
+// } else {
+// setErrorMessage(null);
+// setMessage(null, IMessageProvider.WARNING);
+// }
+// }
+ }
+
private String getSeamRuntimeName() {
if(preferences!=null) {
return preferences.get(ISeamFacetDataModelProperties.SEAM_RUNTIME_NAME, "");
@@ -109,15 +295,9 @@
public void propertyChange(PropertyChangeEvent evt) {
}
- /**
- *
- * @param id
- * @param editor
- */
- public void addEditor(IFieldEditor editor) {
+ private void registerEditor(IFieldEditor editor, Composite parent) {
editorRegistry.put(editor.getName(), editor);
- editorOrder.add(editor);
- editor.addPropertyChangeListener(this);
+ editor.doFillIntoGrid(parent);
}
/*
@@ -146,10 +326,38 @@
}
private boolean isSeamSupported() {
- //TODO
- return true;
+ return suportSeam;
}
+ private void setEnabledSeamSuport(boolean enabled) {
+ suportSeam = enabled;
+ for (String key : editorRegistry.keySet()) {
+ if(key!=SeamPreferencesMessages.SEAM_SETTINGS_PREFERENCE_PAGE_SEAM_SUPPORT) {
+ editorRegistry.get(key).setEnabled(enabled && runtimeIsSelected);
+ }
+ if(key==ISeamFacetDataModelProperties.SEAM_RUNTIME_NAME) {
+ editorRegistry.get(key).setEnabled(enabled);
+ }
+ }
+ setEnabledGroups(enabled && runtimeIsSelected);
+ }
+
+ private void setEnabledGroups(boolean enabled) {
+ for (Group group : groups) {
+ group.setEnabled(enabled);
+ }
+ }
+
+ private void setRuntimeIsSelected(boolean selected) {
+ runtimeIsSelected = selected;
+ for (String key : editorRegistry.keySet()) {
+ if(key!=SeamPreferencesMessages.SEAM_SETTINGS_PREFERENCE_PAGE_SEAM_SUPPORT && key!=ISeamFacetDataModelProperties.SEAM_RUNTIME_NAME) {
+ editorRegistry.get(key).setEnabled(selected);
+ }
+ }
+ setEnabledGroups(selected);
+ }
+
private void removeSeamSupport() {
try {
EclipseResourceUtil.removeNatureFromProject(project,
@@ -185,7 +393,7 @@
// }
return SeamVersion.ALL_VERSIONS;
}
-
+/*
private SeamVersion findMatchingVersion(String vs) {
if(vs == null) return null;
if(vs.matches(SeamVersion.SEAM_1_2.toString().replace(".", "\\.") + ".*")) {
@@ -217,29 +425,5 @@
}
return null;
}
-
- public class GridLayoutComposite extends Composite {
-
- public GridLayoutComposite(Composite parent, int style) {
- super(parent, style);
- int columnNumber = 1;
- for (IFieldEditor fieldEditor : editorOrder) {
- if(fieldEditor.getNumberOfControls()>columnNumber)
- columnNumber=fieldEditor.getNumberOfControls();
- }
- GridLayout gl = new GridLayout(columnNumber, false);
- gl.verticalSpacing = 5;
- gl.marginTop = 3;
- gl.marginLeft = 3;
- gl.marginRight = 3;
- setLayout(gl);
- for (IFieldEditor fieldEditor : editorOrder) {
- fieldEditor.doFillIntoGrid(this);
- }
- }
-
- public GridLayoutComposite(Composite parent) {
- this(parent, SWT.NONE);
- }
- }
+*/
}
\ No newline at end of file
Modified: trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/widget/editor/BaseFieldEditor.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/widget/editor/BaseFieldEditor.java 2008-03-07 20:58:26 UTC (rev 6791)
+++ trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/widget/editor/BaseFieldEditor.java 2008-03-07 21:10:15 UTC (rev 6792)
@@ -170,9 +170,23 @@
for(int i=0;i<controls.length;i++) {
Control control = controls[i];
control.setEnabled(enabled);
+ if(control instanceof Composite) {
+ setEnabled((Composite)control, enabled);
+ }
}
}
+ private void setEnabled(Composite composite, boolean enabled) {
+ Control[] controls = composite.getChildren();
+ for(int i=0;i<controls.length;i++) {
+ Control control = controls[i];
+ control.setEnabled(enabled);
+ if(control instanceof Composite) {
+ setEnabled((Composite)control, enabled);
+ }
+ }
+ }
+
/**
*
*/
Modified: trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/widget/editor/ComboFieldEditor.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/widget/editor/ComboFieldEditor.java 2008-03-07 20:58:26 UTC (rev 6791)
+++ trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/widget/editor/ComboFieldEditor.java 2008-03-07 21:10:15 UTC (rev 6792)
@@ -55,7 +55,7 @@
@Override
public Object[] getEditorControls() {
- return null;
+ return new Control[]{comboField.getControl()};
}
public void save(Object object) {
Modified: trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/widget/editor/CompositeEditor.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/widget/editor/CompositeEditor.java 2008-03-07 20:58:26 UTC (rev 6791)
+++ trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/widget/editor/CompositeEditor.java 2008-03-07 21:10:15 UTC (rev 6792)
@@ -15,7 +15,6 @@
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
-import java.util.HashMap;
import java.util.List;
import org.eclipse.core.runtime.Assert;
Modified: trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/widget/editor/IFieldEditorFactory.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/widget/editor/IFieldEditorFactory.java 2008-03-07 20:58:26 UTC (rev 6791)
+++ trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/widget/editor/IFieldEditorFactory.java 2008-03-07 21:10:15 UTC (rev 6792)
@@ -83,8 +83,7 @@
* @param defaultValue
* @return
*/
- IFieldEditor createBrowseFolderEditor(String name, String label,
- String defaultValue);
+ IFieldEditor createBrowseFolderEditor(String name, String label, String defaultValue);
/**
*
@@ -93,6 +92,24 @@
* @param defaultValue
* @return
*/
+ IFieldEditor createBrowseWorkspaceFolderEditor(String name, String label, String defaultValue);
+
+ /**
+ *
+ * @param name
+ * @param label
+ * @param defaultValue
+ * @return
+ */
+ IFieldEditor createBrowseSourceFolderEditor(String name, String label, String defaultValue);
+
+ /**
+ *
+ * @param name
+ * @param label
+ * @param defaultValue
+ * @return
+ */
IFieldEditor createBrowseFileEditor(String name, String label,
String defaultValue);
Modified: trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/widget/editor/RadioFieldEditor.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/widget/editor/RadioFieldEditor.java 2008-03-07 20:58:26 UTC (rev 6791)
+++ trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/widget/editor/RadioFieldEditor.java 2008-03-07 21:10:15 UTC (rev 6792)
@@ -57,7 +57,7 @@
@Override
public Object[] getEditorControls() {
- return null;
+ return new Control[]{radioField.getControl()};
}
public void save(Object object) {
Modified: trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/widget/editor/SwtFieldEditorFactory.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/widget/editor/SwtFieldEditorFactory.java 2008-03-07 20:58:26 UTC (rev 6791)
+++ trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/widget/editor/SwtFieldEditorFactory.java 2008-03-07 21:10:15 UTC (rev 6792)
@@ -10,12 +10,37 @@
******************************************************************************/
package org.jboss.tools.seam.ui.widget.editor;
+import java.util.ArrayList;
import java.util.List;
+import org.eclipse.core.resources.IFolder;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IWorkspace;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.IPackageFragmentRoot;
+import org.eclipse.jdt.core.JavaModelException;
+import org.eclipse.jdt.ui.JavaElementLabelProvider;
+import org.eclipse.jdt.ui.StandardJavaElementContentProvider;
import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.viewers.ViewerFilter;
+import org.eclipse.jface.window.Window;
import org.eclipse.swt.widgets.DirectoryDialog;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.FileDialog;
+import org.eclipse.ui.dialogs.ElementTreeSelectionDialog;
+import org.eclipse.ui.dialogs.ISelectionStatusValidator;
+import org.eclipse.ui.internal.util.Util;
+import org.eclipse.ui.model.IWorkbenchAdapter;
+import org.eclipse.ui.model.WorkbenchContentProvider;
+import org.eclipse.ui.model.WorkbenchLabelProvider;
+import org.jboss.tools.common.model.util.EclipseResourceUtil;
+import org.jboss.tools.seam.ui.SeamGuiPlugin;
import org.jboss.tools.seam.ui.SeamUIMessages;
import org.jboss.tools.seam.ui.internal.project.facet.IValidator;
import org.jboss.tools.seam.ui.widget.editor.ButtonFieldEditor.ButtonPressedAction;
@@ -78,7 +103,7 @@
*
*/
public IFieldEditor createUneditableTextEditor(String name, String label, String defaultValue) {
- CompositeEditor editor = new CompositeEditor(name,label, defaultValue);
+ CompositeEditor editor = new CompositeEditor(name, label, defaultValue);
editor.addFieldEditors(new IFieldEditor[]{new LabelFieldEditor(name,label),
new TextFieldEditor(name,label, defaultValue,false)});
return editor;
@@ -88,7 +113,7 @@
*
*/
public IFieldEditor createBrowseFolderEditor(String name, String label, String defaultValue) {
- CompositeEditor editor = new CompositeEditor(name,label, defaultValue);
+ CompositeEditor editor = new CompositeEditor(name, label, defaultValue);
editor.addFieldEditors(new IFieldEditor[]{new LabelFieldEditor(name,label),
new TextFieldEditor(name,label, defaultValue),
new ButtonFieldEditor(name,createSelectFolderAction(SeamUIMessages.SWT_FIELD_EDITOR_FACTORY_BROWS),defaultValue)});
@@ -98,8 +123,178 @@
/**
*
*/
+ public IFieldEditor createBrowseWorkspaceFolderEditor(String name, String label, String defaultValue) {
+ ButtonFieldEditor.ButtonPressedAction action = createSelectWorkspaceFolderAction(SeamUIMessages.SWT_FIELD_EDITOR_FACTORY_BROWS, defaultValue);
+ CompositeEditor editor = new CompositeEditor(name, label, defaultValue);
+ editor.addFieldEditors(new IFieldEditor[]{new LabelFieldEditor(name,label),
+ new TextFieldEditor(name,label, defaultValue),
+ new ButtonFieldEditor(name, action, defaultValue)});
+ action.setFieldEditor(editor);
+ return editor;
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.tools.seam.ui.widget.editor.IFieldEditorFactory#createBrowseSourceFolderEditor(java.lang.String, java.lang.String, java.lang.String)
+ */
+ public IFieldEditor createBrowseSourceFolderEditor(String name, String label, String defaultValue) {
+ ButtonFieldEditor.ButtonPressedAction action = createSelectSourceFolderAction(SeamUIMessages.SWT_FIELD_EDITOR_FACTORY_BROWS, defaultValue);
+ CompositeEditor editor = new CompositeEditor(name, label, defaultValue);
+ editor.addFieldEditors(new IFieldEditor[]{new LabelFieldEditor(name, label),
+ new TextFieldEditor(name, label, defaultValue),
+ new ButtonFieldEditor(name, action, defaultValue)});
+ action.setFieldEditor(editor);
+ return editor;
+ }
+
+ /**
+ * @param buttonName
+ * @return
+ */
+ public ButtonFieldEditor.ButtonPressedAction createSelectSourceFolderAction(String buttonName, final String initPath) {
+ ButtonFieldEditor.ButtonPressedAction action = new ButtonFieldEditor.ButtonPressedAction(buttonName) {
+ private String inerInitPath;
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.jface.action.Action#run()
+ */
+ @Override
+ public void run() {
+ final ElementTreeSelectionDialog dialog = new ElementTreeSelectionDialog(
+ Display.getCurrent().getActiveShell(),
+ new JavaElementLabelProvider(), new JavaSourceContentProvider());
+ dialog.setInput(ResourcesPlugin.getWorkspace());
+ String path = inerInitPath!=null?inerInitPath:initPath;
+ IResource resource = ResourcesPlugin.getWorkspace().getRoot().findMember(path);
+ if (resource!=null) {
+ IProject project = resource.getProject();
+ if (project.getProject().isOpen()) {
+ IJavaProject javaProject = EclipseResourceUtil.getJavaProject(project);
+ try {
+ IPackageFragmentRoot[] roots = javaProject.getPackageFragmentRoots();
+ for (int i= 0; i < roots.length; i++) {
+ if (roots[i].getKind() == IPackageFragmentRoot.K_SOURCE && roots[i].getResource().equals(resource)) {
+ dialog.setInitialSelection(roots[i]);
+ break;
+ }
+ }
+ } catch (JavaModelException e) {
+ SeamGuiPlugin.getPluginLog().logError(e);
+ }
+ }
+ }
+ dialog.setValidator(new ISelectionStatusValidator(){
+ public IStatus validate(Object[] selection) {
+ if(selection.length>0) {
+ if(selection[0] instanceof IPackageFragmentRoot) {
+ return new Status(IStatus.OK, SeamGuiPlugin.PLUGIN_ID, IStatus.OK, null, null);
+ }
+ }
+ return new Status(IStatus.ERROR, SeamGuiPlugin.PLUGIN_ID, IStatus.ERROR, null, null);
+ }
+ });
+ dialog.setAllowMultiple(false);
+ dialog.setTitle(SeamUIMessages.SELECT_WORKSPACE_FOLDER_DIALOG_TITLE);
+ dialog.setMessage(SeamUIMessages.SELECT_WORKSPACE_FOLDER_DIALOG_MESSAGE);
+ if (dialog.open() == Window.OK) {
+ IPackageFragmentRoot pack = (IPackageFragmentRoot) dialog.getFirstResult();
+ IPath newPath = pack.getResource().getFullPath();
+ String value = newPath.toString();
+ inerInitPath = value;
+ getFieldEditor().setValue(value);
+ }
+ }
+ };
+ return action;
+ }
+
+ /**
+ * @author Alexey Kazakov
+ */
+ private static class JavaSourceContentProvider extends StandardJavaElementContentProvider {
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.jdt.ui.StandardJavaElementContentProvider#hasChildren(java.lang.Object)
+ */
+ @Override
+ public boolean hasChildren(Object element) {
+ if (element instanceof IPackageFragmentRoot) {
+ return false;
+ }
+ return true;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.jdt.ui.StandardJavaElementContentProvider#getChildren(java.lang.Object)
+ */
+ @Override
+ public Object[] getChildren(Object element) {
+ if (!exists(element)) {
+ return NO_CHILDREN;
+ }
+
+ if (element instanceof IWorkspace) {
+ IWorkbenchAdapter adapter = (IWorkbenchAdapter)Util.getAdapter(element, IWorkbenchAdapter.class);
+ if (adapter != null) {
+ Object[] children = adapter.getChildren(element);
+ List<Object> result = new ArrayList<Object>();
+ for (int i = 0; i < children.length; i++) {
+ if(children[i] instanceof IProject) {
+ if(EclipseResourceUtil.getJavaProject((IProject)children[i])!=null) {
+ result.add(children[i]);
+ }
+ }
+ }
+ return result.toArray(new Object[]{});
+ }
+ return new Object[0];
+ }
+
+ if (element instanceof IProject) {
+ element = EclipseResourceUtil.getJavaProject((IProject)element);
+ if(element==null) {
+ return NO_CHILDREN;
+ }
+ }
+
+ if (element instanceof IJavaProject) {
+ try {
+ return getPackageFragmentRoots((IJavaProject)element);
+ } catch (JavaModelException e) {
+ SeamGuiPlugin.getPluginLog().logError(e);
+ return NO_CHILDREN;
+ }
+ }
+ if (element instanceof IPackageFragmentRoot) {
+ return NO_CHILDREN;
+ }
+
+ return super.getChildren(element);
+ }
+
+ protected Object[] getPackageFragmentRoots(IJavaProject project) throws JavaModelException {
+ if (!project.getProject().isOpen()) {
+ return NO_CHILDREN;
+ }
+ IPackageFragmentRoot[] roots= project.getPackageFragmentRoots();
+ List<IPackageFragmentRoot> list= new ArrayList<IPackageFragmentRoot>(roots.length);
+ for (int i= 0; i < roots.length; i++) {
+ IPackageFragmentRoot root = roots[i];
+ if (!isProjectPackageFragmentRoot(root) && root.getKind() == IPackageFragmentRoot.K_SOURCE) {
+ list.add(root);
+ }
+ }
+ return list.toArray();
+ }
+ }
+
+ /**
+ *
+ */
public IFieldEditor createBrowseFileEditor(String name, String label, String defaultValue) {
- CompositeEditor editor = new CompositeEditor(name,label, defaultValue);
+ CompositeEditor editor = new CompositeEditor(name, label, defaultValue);
editor.addFieldEditors(new IFieldEditor[]{new LabelFieldEditor(name,label),
new TextFieldEditor(name,label, defaultValue),
new ButtonFieldEditor(name,createSelectFileAction(SeamUIMessages.SWT_FIELD_EDITOR_FACTORY_BROWS),defaultValue)});
@@ -135,6 +330,53 @@
}
/**
+ * @param buttonName
+ * @return
+ */
+ public ButtonFieldEditor.ButtonPressedAction createSelectWorkspaceFolderAction(String buttonName, final String initPath) {
+ ButtonFieldEditor.ButtonPressedAction action = new ButtonFieldEditor.ButtonPressedAction(buttonName) {
+
+ private String inerInitPath;
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.jface.action.Action#run()
+ */
+ @Override
+ public void run() {
+ ElementTreeSelectionDialog dialog = new ElementTreeSelectionDialog(
+ Display.getCurrent().getActiveShell(),
+ new WorkbenchLabelProvider(), new WorkbenchContentProvider());
+ dialog.setInput(ResourcesPlugin.getWorkspace());
+ String path = inerInitPath!=null?inerInitPath:initPath;
+ IResource resource = ResourcesPlugin.getWorkspace().getRoot().findMember(path);
+ if (resource!=null) {
+ dialog.setInitialSelection(resource);
+ }
+ dialog.addFilter(new ViewerFilter() {
+ public boolean select(Viewer viewer, Object parentElement, Object element) {
+ if (element instanceof IFolder || element instanceof IProject) {
+ return true;
+ }
+ return false;
+ }
+ });
+ dialog.setAllowMultiple(false);
+ dialog.setTitle(SeamUIMessages.SELECT_WORKSPACE_FOLDER_DIALOG_TITLE);
+ dialog.setMessage(SeamUIMessages.SELECT_WORKSPACE_FOLDER_DIALOG_MESSAGE);
+ if (dialog.open() == Window.OK) {
+ IResource res = (IResource) dialog.getFirstResult();
+ IPath newPath = res.getFullPath();
+ String value = newPath.toString();
+ inerInitPath = value;
+ getFieldEditor().setValue(value);
+ }
+ }
+ };
+ return action;
+ }
+
+ /**
*
* @param buttonName
* @return
Modified: trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/widget/field/RadioField.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/widget/field/RadioField.java 2008-03-07 20:58:26 UTC (rev 6791)
+++ trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/widget/field/RadioField.java 2008-03-07 21:10:15 UTC (rev 6792)
@@ -84,7 +84,11 @@
public Object getValue() {
return value;
}
-
+
+ /**
+ *
+ * @param value
+ */
public void setValue(String value) {
this.value = value;
for (int i = 0; i < radios.length; i++) {
@@ -95,5 +99,4 @@
}
}
}
-
-}
+}
\ No newline at end of file
Modified: trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamProjectSelectionDialog.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamProjectSelectionDialog.java 2008-03-07 20:58:26 UTC (rev 6791)
+++ trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamProjectSelectionDialog.java 2008-03-07 21:10:15 UTC (rev 6792)
@@ -28,8 +28,6 @@
import org.eclipse.wst.common.project.facet.core.ProjectFacetsManager;
import org.jboss.tools.seam.core.ISeamProject;
import org.jboss.tools.seam.core.SeamCorePlugin;
-import org.jboss.tools.seam.core.project.facet.SeamProjectPreferences;
-import org.jboss.tools.seam.internal.core.SeamProject;
import org.jboss.tools.seam.internal.core.project.facet.ISeamFacetDataModelProperties;
import org.jboss.tools.seam.ui.SeamUIMessages;
@@ -41,8 +39,9 @@
/**
* @param parent
+ * @param allowAllProjects If "false" show only projects with seam nature.
*/
- public SeamProjectSelectionDialog(Shell parent) {
+ public SeamProjectSelectionDialog(Shell parent, final boolean allowAllProjects) {
super(parent);
setTitle(SeamUIMessages.SEAM_PROJECT_SELECTION_DIALOG_SEAM_WEB_PROJECT);
setMessage(SeamUIMessages.SEAM_PROJECT_SELECTION_DIALOG_SELECT_SEAM_WEB_PROJECT);
@@ -53,11 +52,11 @@
ArrayList<IProject> seamProjects = new ArrayList<IProject>();
for (IProject project : ResourcesPlugin.getWorkspace().getRoot().getProjects()) {
try {
- if(project.hasNature(ISeamProject.NATURE_ID)
+ if(allowAllProjects || (project.hasNature(ISeamProject.NATURE_ID)
&& SeamCorePlugin.getSeamPreferences(project)!=null
&& project.getAdapter(IFacetedProject.class)!=null
&& ((IFacetedProject)project.getAdapter(IFacetedProject.class)).hasProjectFacet(ProjectFacetsManager.getProjectFacet("jst.web"))
- && !"".equals(SeamCorePlugin.getSeamPreferences(project).get(ISeamFacetDataModelProperties.JBOSS_AS_DEPLOY_AS, ""))) { //$NON-NLS-1$
+ && !"".equals(SeamCorePlugin.getSeamPreferences(project).get(ISeamFacetDataModelProperties.JBOSS_AS_DEPLOY_AS, "")))) { //$NON-NLS-1$
seamProjects.add(project);
}
} catch (CoreException e) {
@@ -73,8 +72,15 @@
}
});
}
-
+
/**
+ * @param parent
+ */
+ public SeamProjectSelectionDialog(Shell parent) {
+ this(parent, false);
+ }
+
+ /**
*
*/
@Override
@@ -90,4 +96,4 @@
public void selectionChanged(SelectionChangedEvent event) {
getOkButton().setEnabled(!event.getSelection().isEmpty());
}
-}
+}
\ No newline at end of file
Modified: trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamWizardFactory.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamWizardFactory.java 2008-03-07 20:58:26 UTC (rev 6791)
+++ trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamWizardFactory.java 2008-03-07 21:10:15 UTC (rev 6792)
@@ -15,12 +15,21 @@
import java.util.Arrays;
import java.util.List;
+import org.eclipse.datatools.connectivity.ConnectionProfileException;
+import org.eclipse.datatools.connectivity.IConnectionProfile;
+import org.eclipse.datatools.connectivity.IProfileListener;
+import org.eclipse.datatools.connectivity.ProfileManager;
+import org.eclipse.datatools.connectivity.db.generic.ui.NewConnectionProfileWizard;
+import org.eclipse.datatools.connectivity.internal.ui.wizards.NewCPWizard;
+import org.eclipse.datatools.connectivity.internal.ui.wizards.NewCPWizardCategoryFilter;
import org.eclipse.jface.wizard.Wizard;
import org.eclipse.jface.wizard.WizardDialog;
import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.internal.dialogs.PropertyDialog;
import org.hibernate.console.ConsoleConfiguration;
import org.hibernate.console.KnownConfigurations;
import org.hibernate.eclipse.console.HibernateConsolePlugin;
+import org.jboss.tools.seam.core.SeamCorePlugin;
import org.jboss.tools.seam.core.project.facet.SeamRuntime;
import org.jboss.tools.seam.core.project.facet.SeamRuntimeManager;
import org.jboss.tools.seam.core.project.facet.SeamVersion;
@@ -40,11 +49,25 @@
*
*/
public class SeamWizardFactory {
+
+ /**
+ * @param defaultSelection
+ * @param allowAllProjects If "false" show only projects with seam nature.
+ * @return
+ */
+ public static IFieldEditor createSeamProjectSelectionFieldEditor(String name, String label, String defaultSelection, boolean allowAllProjects) {
+ return IFieldEditorFactory.INSTANCE.createButtonFieldEditor(
+ name, label, defaultSelection,
+ new SelectSeamProjectAction(allowAllProjects), ValidatorFactory.NO_ERRORS_VALIDATOR);
+ }
+
+ /**
+ * @param defaultSelection
+ * @return
+ */
public static IFieldEditor createSeamProjectSelectionFieldEditor(
String defaultSelection) {
- return IFieldEditorFactory.INSTANCE.createButtonFieldEditor(
- IParameter.SEAM_PROJECT_NAME, SeamUIMessages.SEAM_WIZARD_FACTORY_SEAM_PROJECT, defaultSelection,
- new SelectSeamProjectAction(), ValidatorFactory.NO_ERRORS_VALIDATOR);
+ return createSeamProjectSelectionFieldEditor(IParameter.SEAM_PROJECT_NAME, SeamUIMessages.SEAM_WIZARD_FACTORY_SEAM_PROJECT, defaultSelection, false);
}
/**
@@ -86,7 +109,11 @@
return IFieldEditorFactory.INSTANCE.createTextEditor(
IParameter.SEAM_MASTER_PAGE_NAME, SeamUIMessages.SEAM_WIZARD_FACTORY_MASTER_PAGE_NAME, ""); //$NON-NLS-1$
}
-
+
+ /**
+ * @param defaultSelection
+ * @return
+ */
public static final IFieldEditor[] createBaseFormFieldEditors(String defaultSelection) {
return new IFieldEditor[]{
SeamWizardFactory.createSeamProjectSelectionFieldEditor(defaultSelection),
@@ -126,6 +153,179 @@
}
/**
+ * Creates Selection Field of Connection Profiles
+ * @param defaultValue
+ * @return
+ */
+ public static IFieldEditor createConnectionProfileSelectionFieldEditor(Object defaultValue, IValidator validator) {
+ EditConnectionProfileAction editAction = new EditConnectionProfileAction(validator);
+ NewConnectionProfileAction newAction = new NewConnectionProfileAction(validator);
+ IFieldEditor connProfileSelEditor = IFieldEditorFactory.INSTANCE.createComboWithTwoButtons(
+ ISeamFacetDataModelProperties.SEAM_CONNECTION_PROFILE,
+ SeamUIMessages.SEAM_INSTALL_WIZARD_PAGE_CONNECTION_PROFILE,
+ getConnectionProfileNameList(),
+ defaultValue,
+ false, editAction,
+ newAction,
+ ValidatorFactory.NO_ERRORS_VALIDATOR);
+ editAction.setEditor(connProfileSelEditor);
+ newAction.setEditor(connProfileSelEditor);
+ return connProfileSelEditor;
+ }
+
+ private static class EditConnectionProfileAction extends ButtonFieldEditor.ButtonPressedAction {
+
+ private IValidator validator;
+ private IFieldEditor connProfileSelEditor;
+
+ /**
+ * @param validator
+ */
+ public EditConnectionProfileAction(IValidator validator) {
+ super(SeamUIMessages.SEAM_INSTALL_WIZARD_PAGE_EDIT);
+ this.validator = validator;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.jface.action.Action#run()
+ */
+ @Override
+ public void run() {
+ IConnectionProfile selectedProfile = ProfileManager.getInstance()
+ .getProfileByName(getFieldEditor().getValue().toString());
+ String oldName = getFieldEditor().getValue().toString();
+
+ if (selectedProfile == null) {
+ return;
+ }
+ PropertyDialog.createDialogOn(Display.getCurrent().getActiveShell(),
+ "org.eclipse.datatools.connectivity.db.generic.profileProperties", //$NON-NLS-1$
+ selectedProfile).open();
+ if (!oldName.equals(selectedProfile.getName())) {
+ getFieldEditor().setValue(selectedProfile.getName());
+ ((ITaggedFieldEditor) ((CompositeEditor) connProfileSelEditor)
+ .getEditors().get(1)).setTags(getConnectionProfileNameList()
+ .toArray(new String[0]));
+ oldName = selectedProfile.getName();
+ }
+ validator.validate(selectedProfile.getName(), null);
+ }
+
+ public void setEditor(IFieldEditor connProfileSelEditor) {
+ this.connProfileSelEditor = connProfileSelEditor;
+ }
+ };
+
+ /**
+ * Handler for ButtonFieldEditor that shows Property Editor dialog for
+ * selected ConnectionProfile
+ *
+ * @author eskimo
+ */
+ private static class NewConnectionProfileAction extends ButtonFieldEditor.ButtonPressedAction {
+
+ private IValidator validator;
+ private IFieldEditor connProfileSelEditor;
+
+ public NewConnectionProfileAction(IValidator validator) {
+ super(SeamUIMessages.SEAM_INSTALL_WIZARD_PAGE_NEW);
+ this.validator = validator;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.jface.action.Action#run()
+ */
+ @Override
+ public void run() {
+ IProfileListener listener = new ConnectionProfileChangeListener(validator, connProfileSelEditor);
+
+ ProfileManager.getInstance().addProfileListener(listener);
+ NewCPWizardCategoryFilter filter = new NewCPWizardCategoryFilter("org.eclipse.datatools.connectivity.db.category"); //$NON-NLS-1$
+ NewCPWizard wizard = new NewCPWizard(filter, null);
+ new NewConnectionProfileWizard() {
+ public boolean performFinish() {
+ // create profile only
+ try {
+ ProfileManager.getInstance().createProfile(
+ getProfileName() == null ? "" //$NON-NLS-1$
+ : getProfileName(),
+ getProfileDescription() == null ? "" //$NON-NLS-1$
+ : getProfileDescription(),
+ mProviderID,
+ getProfileProperties(),
+ mProfilePage.getRepository() == null ? "" //$NON-NLS-1$
+ : mProfilePage.getRepository()
+ .getName(), false);
+ } catch (ConnectionProfileException e) {
+ SeamCorePlugin.getPluginLog().logError(e);
+ }
+
+ return true;
+ }
+ };
+ WizardDialog wizardDialog = new WizardDialog(Display.getCurrent()
+ .getActiveShell(), wizard);
+ wizardDialog.open();
+ ProfileManager.getInstance().removeProfileListener(listener);
+ }
+
+ public void setEditor(IFieldEditor connProfileSelEditor) {
+ this.connProfileSelEditor = connProfileSelEditor;
+ }
+ }
+
+ private static class ConnectionProfileChangeListener implements IProfileListener {
+
+ private IFieldEditor connProfileSelEditor;
+ private IValidator validator;
+
+ /**
+ * @param validator
+ */
+ public ConnectionProfileChangeListener(IValidator validator, IFieldEditor connProfileSelEditor) {
+ this.validator = validator;
+ this.connProfileSelEditor = connProfileSelEditor;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.datatools.connectivity.IProfileListener#profileAdded(org.eclipse.datatools.connectivity.IConnectionProfile)
+ */
+ public void profileAdded(IConnectionProfile profile) {
+ connProfileSelEditor.setValue(profile.getName());
+ ((ITaggedFieldEditor) ((CompositeEditor) connProfileSelEditor)
+ .getEditors().get(1)).setTags(getConnectionProfileNameList()
+ .toArray(new String[0]));
+ validator.validate(profile.getName(), null);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.datatools.connectivity.IProfileListener#profileChanged(org.eclipse.datatools.connectivity.IConnectionProfile)
+ */
+ public void profileChanged(IConnectionProfile profile) {
+ profileAdded(profile);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.datatools.connectivity.IProfileListener#profileDeleted(org.eclipse.datatools.connectivity.IConnectionProfile)
+ */
+ public void profileDeleted(IConnectionProfile profile) {
+ // this event never happens
+ }
+ }
+
+ private static List<String> getConnectionProfileNameList() {
+ IConnectionProfile[] profiles = ProfileManager.getInstance()
+ .getProfilesByCategory("org.eclipse.datatools.connectivity.db.category"); //$NON-NLS-1$
+ List<String> names = new ArrayList<String>();
+ for (IConnectionProfile connectionProfile : profiles) {
+ names.add(connectionProfile.getName());
+ }
+ return names;
+ }
+
+ /**
* @param seamVersions Array of seam runtime versions. If length == 0 then use all versions
* @param defaultSelection
* @return Editor to select seam runtime
@@ -277,4 +477,16 @@
configurationNames, defaultSelection);
return editor;
}
+
+ /**
+ * @param defaultSelection full path of resource
+ * @return
+ */
+ public static IFieldEditor createViewFolderFieldEditor(String defaultSelection) {
+ IFieldEditor viewDirEditor = IFieldEditorFactory.INSTANCE.createBrowseWorkspaceFolderEditor(
+ ISeamFacetDataModelProperties.WEB_CONTENTS_FOLDER,
+ SeamUIMessages.VIEW_FOLDER_FILED_EDITOR,
+ defaultSelection);
+ return viewDirEditor;
+ }
}
\ No newline at end of file
Modified: trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SelectSeamProjectAction.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SelectSeamProjectAction.java 2008-03-07 20:58:26 UTC (rev 6791)
+++ trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SelectSeamProjectAction.java 2008-03-07 21:10:15 UTC (rev 6792)
@@ -21,17 +21,27 @@
public class SelectSeamProjectAction extends ButtonFieldEditor.ButtonPressedAction {
+ private boolean allowAllProjects;
+
/**
- * @param label
+ * @param allowAllProjects If "false" show only projects with seam nature.
*/
- public SelectSeamProjectAction() {
+ public SelectSeamProjectAction(boolean allowAllProjects) {
super(SeamUIMessages.SELECT_SEAM_PROJECT_ACTION_BROWSE);
+ this.allowAllProjects = allowAllProjects;
}
+ /**
+ *
+ */
+ public SelectSeamProjectAction() {
+ this(false);
+ }
+
@Override
public void run() {
ListDialog dialog = new SeamProjectSelectionDialog(
- Display.getCurrent().getActiveShell());
+ Display.getCurrent().getActiveShell(), allowAllProjects);
if(!"".equals(this.getFieldEditor().getValueAsString())) //$NON-NLS-1$
dialog.setInitialSelections(new Object[] {
ResourcesPlugin.getWorkspace().getRoot().getProject(this.getFieldEditor().getValueAsString())});
18 years, 1 month
JBoss Tools SVN: r6791 - in trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui: text/java and 1 other directories.
by jbosstools-commits@lists.jboss.org
Author: vrubezhny
Date: 2008-03-07 15:58:26 -0500 (Fri, 07 Mar 2008)
New Revision: 6791
Modified:
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/search/SeamSearchQuery.java
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/search/SeamSearchRequestor.java
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/search/SeamSearchResult.java
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/search/SeamSearchVisitor.java
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/text/java/JavaStringHyperlinkDetector.java
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/text/java/scanner/JavaAnnotationScanner.java
Log:
http://jira.jboss.org/jira/browse/JBIDE-509 intelligent navigation support for seam variable names
Modified: trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/search/SeamSearchQuery.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/search/SeamSearchQuery.java 2008-03-07 19:43:55 UTC (rev 6790)
+++ trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/search/SeamSearchQuery.java 2008-03-07 20:58:26 UTC (rev 6791)
@@ -25,7 +25,7 @@
import org.eclipse.search.internal.core.text.PatternConstructor;
import org.eclipse.search.internal.core.text.TextSearchVisitor;
import org.eclipse.search.internal.ui.Messages;
-import org.eclipse.search.internal.ui.SearchMessages;
+//import org.eclipse.search.internal.ui.SearchMessages;
import org.eclipse.search.internal.ui.text.FileMatch;
import org.eclipse.search.internal.ui.text.FileSearchResult;
import org.eclipse.search.internal.ui.text.SearchResultUpdater;
@@ -215,7 +215,9 @@
return Messages.format(SeamUIMessages.SeamSearchQuery_pluralPattern, args);
}
}
- // text search
+/*
+ *
+ // text search
if (isScopeAllFileTypes()) {
// search all file extensions
if (nMatches == 1) {
@@ -232,34 +234,22 @@
}
Object[] args= { searchString, new Integer(nMatches), fScope.getDescription(), fScope.getFilterDescription() };
return Messages.format(SearchMessages.FileSearchQuery_pluralPatternWithFileExt, args);
+*/
}
- // file search
+/*
+ *
+ // file search
if (nMatches == 1) {
Object[] args= { fScope.getFilterDescription(), fScope.getDescription() };
return Messages.format(SearchMessages.FileSearchQuery_singularLabel_fileNameSearch, args);
}
Object[] args= { fScope.getFilterDescription(), new Integer(nMatches), fScope.getDescription() };
return Messages.format(SearchMessages.FileSearchQuery_pluralPattern_fileNameSearch, args);
+*/
+ return "";
}
- /**
- * @param result all result are added to this search result
- * @param monitor the progress monitor to use
- * @param file the file to search in
- * @return returns the status of the operation
- */
-/* public IStatus searchInFile(final AbstractTextSearchResult result, final IProgressMonitor monitor, IFile file) {
- FileTextSearchScope scope= FileTextSearchScope.newSearchScope(new IResource[] { file }, new String[] { "*" }, true); //$NON-NLS-1$
-
- Pattern[] searchPatterns= new Pattern[fVariables == null ? 0 : fVariables.length];
- for (int i = 0; fVariables != null && i < fVariables.length; i++) {
- searchPatterns[i]= getSearchPattern(fVariables[i]);
- }
- SeamSearchResultCollector collector= new SeamSearchResultCollector(result, true);
-
- return SeamSearchEngine.create().search(scope, collector, searchPatterns, monitor);
- }
-*/
+
protected Pattern getSearchPattern(String variableName) {
return PatternConstructor.createPattern(variableName, true, false);
}
Modified: trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/search/SeamSearchRequestor.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/search/SeamSearchRequestor.java 2008-03-07 19:43:55 UTC (rev 6790)
+++ trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/search/SeamSearchRequestor.java 2008-03-07 20:58:26 UTC (rev 6791)
@@ -1,12 +1,8 @@
package org.jboss.tools.seam.ui.search;
-import org.eclipse.core.resources.IFile;
import org.eclipse.core.runtime.CoreException;
-import org.eclipse.jdt.core.IJavaElement;
import org.eclipse.search.core.text.TextSearchRequestor;
-import org.jboss.tools.seam.core.ISeamContextVariable;
import org.jboss.tools.seam.core.ISeamDeclaration;
-import org.jboss.tools.seam.core.ISeamElement;
import org.jboss.tools.seam.core.ISeamJavaSourceReference;
public class SeamSearchRequestor extends TextSearchRequestor {
Modified: trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/search/SeamSearchResult.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/search/SeamSearchResult.java 2008-03-07 19:43:55 UTC (rev 6790)
+++ trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/search/SeamSearchResult.java 2008-03-07 20:58:26 UTC (rev 6791)
@@ -3,13 +3,9 @@
import java.util.Map;
import org.eclipse.core.resources.IFile;
-import org.eclipse.jdt.ui.search.IMatchPresentation;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.search.internal.ui.SearchPluginImages;
-import org.eclipse.search.internal.ui.text.FileSearchQuery;
import org.eclipse.search.ui.ISearchQuery;
-import org.eclipse.search.ui.ISearchResult;
-import org.eclipse.search.ui.ISearchResultListener;
import org.eclipse.search.ui.text.AbstractTextSearchResult;
import org.eclipse.search.ui.text.IEditorMatchAdapter;
import org.eclipse.search.ui.text.IFileMatchAdapter;
@@ -17,7 +13,6 @@
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.IFileEditorInput;
-import org.jboss.tools.seam.ui.SeamGuiPlugin;
public class SeamSearchResult extends AbstractTextSearchResult implements IEditorMatchAdapter, IFileMatchAdapter {
private final Match[] EMPTY_ARR= new Match[0];
Modified: trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/search/SeamSearchVisitor.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/search/SeamSearchVisitor.java 2008-03-07 19:43:55 UTC (rev 6790)
+++ trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/search/SeamSearchVisitor.java 2008-03-07 20:58:26 UTC (rev 6791)
@@ -33,12 +33,19 @@
import org.eclipse.core.runtime.content.IContentType;
import org.eclipse.core.runtime.content.IContentTypeManager;
import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.jdt.core.ICompilationUnit;
import org.eclipse.jdt.core.IJavaElement;
+import org.eclipse.jdt.core.IType;
+import org.eclipse.jdt.core.JavaCore;
+import org.eclipse.jdt.core.dom.ASTNode;
+import org.eclipse.jdt.internal.core.JavaModel;
+import org.eclipse.jdt.internal.ui.javaeditor.EditorUtility;
import org.eclipse.jdt.internal.ui.text.FastJavaPartitionScanner;
import org.eclipse.jdt.ui.text.IJavaPartitions;
import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.Document;
import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.IRegion;
import org.eclipse.jface.text.rules.IToken;
import org.eclipse.jface.text.rules.Token;
import org.eclipse.search.core.text.TextSearchScope;
@@ -103,8 +110,13 @@
import org.jboss.tools.seam.internal.core.el.SeamELStringTokenizer;
import org.jboss.tools.seam.internal.core.el.SeamELTokenizer;
import org.jboss.tools.seam.internal.core.el.ElVarSearcher.Var;
+import org.jboss.tools.seam.internal.core.scanner.ScannerException;
+import org.jboss.tools.seam.internal.core.scanner.java.AnnotatedASTNode;
+import org.jboss.tools.seam.internal.core.scanner.java.ResolvedAnnotation;
+import org.jboss.tools.seam.internal.core.scanner.java.SeamAnnotations;
import org.jboss.tools.seam.ui.SeamGuiPlugin;
import org.jboss.tools.seam.ui.SeamUIMessages;
+import org.jboss.tools.seam.ui.text.java.scanner.JavaAnnotationScanner;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
@@ -361,15 +373,42 @@
String value = document.get(offset, length);
if(value.indexOf('{')>-1) {
locateMatchesInString(file, value, offset, content);
- } else if (false) {
- // TODO: Insert here the check for named Seam annotations
-
- } else if (true) {
-
}
}
token = scaner.nextToken();
}
+
+ // Search in annotations
+ ICompilationUnit compilationUnit = JavaCore.createCompilationUnitFrom(file);
+ if (compilationUnit == null)
+ return;
+
+ JavaAnnotationScanner annotationScanner = new JavaAnnotationScanner();
+ Map<ResolvedAnnotation, AnnotatedASTNode<ASTNode>> loadedAnnotations = null;
+
+ try {
+ annotationScanner.parse((ICompilationUnit)compilationUnit);
+ loadedAnnotations = annotationScanner.getResolvedAnnotations();
+ } catch (ScannerException e) {
+ SeamGuiPlugin.getPluginLog().logError(e);
+ return;
+ }
+ for (ResolvedAnnotation annotation : loadedAnnotations.keySet()) {
+ if (annotationScanner.isAnnotationOfType(annotation, SeamAnnotations.IN_ANNOTATION_TYPE) ||
+ annotationScanner.isAnnotationOfType(annotation, SeamAnnotations.OUT_ANNOTATION_TYPE)) {
+ String value = annotationScanner.getAnnotationValue(annotation);
+ if (value == null || value.length() == 0)
+ continue;
+ IRegion valueRegion = annotationScanner.getAnnotationValueRegion(annotation);
+ if (valueRegion == null)
+ continue;
+
+ int length = valueRegion.getLength();
+ int offset = valueRegion.getOffset();
+ String string = "#{" + value + "}";
+ locateMatchesInString(file, string, offset - 2, content);
+ }
+ }
} catch (BadLocationException e) {
SeamGuiPlugin.getDefault().logError(e);
}
Modified: trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/text/java/JavaStringHyperlinkDetector.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/text/java/JavaStringHyperlinkDetector.java 2008-03-07 19:43:55 UTC (rev 6790)
+++ trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/text/java/JavaStringHyperlinkDetector.java 2008-03-07 20:58:26 UTC (rev 6791)
@@ -105,11 +105,11 @@
return null;
}
- ResolvedAnnotation a = findAnnotationByValueOffset(loadedAnnotations, offset);
- if (!isAnnotationOfType(a, SeamAnnotations.FACTORY_ANNOTATION_TYPE))
+ ResolvedAnnotation a = annotationScanner.findAnnotationByValueOffset(offset);
+ if (!annotationScanner.isAnnotationOfType(a, SeamAnnotations.FACTORY_ANNOTATION_TYPE))
return null;
- String value = getAnnotationValue(a);
+ String value = annotationScanner.getAnnotationValue(a);
// Look at the annotated method:
// If its return type is not void - the Declaration is the factory itself
@@ -199,102 +199,6 @@
return null;
}
- /*
- * Detects if the type of annotation equals to the selected SeamAnnotations' type
- *
- * @param annotation
- * @param typeName
- *
- * @return
- */
- private boolean isAnnotationOfType(ResolvedAnnotation annotation, String typeName) {
- if (annotation == null || typeName == null)
- return false;
-
- return (typeName.equals(annotation.getType()));
- }
-
- /*
- * Returns the annotation's value text
- *
- * @param annotation
- * @return
- */
- private String getAnnotationValue(ResolvedAnnotation annotation) {
- if (annotation.getAnnotation() instanceof SingleMemberAnnotation) {
- SingleMemberAnnotation sma = (SingleMemberAnnotation)annotation.getAnnotation();
- Object vpd = sma.getStructuralProperty(SingleMemberAnnotation.VALUE_PROPERTY);
- if (vpd instanceof StringLiteral) {
- return ((StringLiteral)vpd).getLiteralValue();
- }
- return vpd.toString();
- } else if (annotation.getAnnotation() instanceof NormalAnnotation) {
- NormalAnnotation na = (NormalAnnotation)annotation.getAnnotation();
- Object vpd = na.getStructuralProperty(NormalAnnotation.VALUES_PROPERTY);
- if (vpd instanceof List) {
- for (Object item : (List)vpd) {
- if (item instanceof ASTNode) {
- ASTNode node = (ASTNode)item;
- if (node.getNodeType() != ASTNode.MEMBER_VALUE_PAIR)
- continue;
- MemberValuePair mvp = (MemberValuePair)node;
- SimpleName name = mvp.getName();
- if (!"value".equals(name.getIdentifier())) {
- continue;
- }
- return ((StringLiteral)mvp.getValue()).getLiteralValue();
- }
- }
- }
- }
-
- return null;
- }
-
- private ResolvedAnnotation findAnnotationByValueOffset(Map<ResolvedAnnotation, AnnotatedASTNode<ASTNode>> annotations, int offset) {
- if (annotations == null)
- return null;
-
- for (ResolvedAnnotation a : annotations.keySet()) {
- if (a.getAnnotation() instanceof SingleMemberAnnotation) {
- SingleMemberAnnotation sma = (SingleMemberAnnotation)a.getAnnotation();
- Object vpd = sma.getStructuralProperty(SingleMemberAnnotation.VALUE_PROPERTY);
- if (vpd instanceof ASTNode) {
- ASTNode node = (ASTNode)vpd;
- int start = node.getStartPosition();
- int length = node.getLength();
- if (offset >= start && offset < start + length) {
- return a;
- }
- }
- } else if (a.getAnnotation() instanceof NormalAnnotation) {
- NormalAnnotation na = (NormalAnnotation)a.getAnnotation();
- Object vpd = na.getStructuralProperty(NormalAnnotation.VALUES_PROPERTY);
- if (vpd instanceof List) {
- for (Object item : (List)vpd) {
- if (item instanceof ASTNode) {
- ASTNode node = (ASTNode)item;
- if (node.getNodeType() != ASTNode.MEMBER_VALUE_PAIR)
- continue;
- MemberValuePair mvp = (MemberValuePair)node;
- SimpleName name = mvp.getName();
- if (!"value".equals(name.getIdentifier())) {
- continue;
- }
- int start = node.getStartPosition();
- int length = node.getLength();
- if (offset >= start && offset < start + length) {
- return a;
- }
- }
- }
- }
- }
- }
- return null;
- }
-
-
class JavaMemberHyperlink implements IHyperlink {
private final IRegion fRegion;
Modified: trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/text/java/scanner/JavaAnnotationScanner.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/text/java/scanner/JavaAnnotationScanner.java 2008-03-07 19:43:55 UTC (rev 6790)
+++ trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/text/java/scanner/JavaAnnotationScanner.java 2008-03-07 20:58:26 UTC (rev 6791)
@@ -29,13 +29,17 @@
import org.eclipse.jdt.core.dom.CompilationUnit;
import org.eclipse.jdt.core.dom.FieldDeclaration;
import org.eclipse.jdt.core.dom.MarkerAnnotation;
+import org.eclipse.jdt.core.dom.MemberValuePair;
import org.eclipse.jdt.core.dom.MethodDeclaration;
import org.eclipse.jdt.core.dom.Name;
import org.eclipse.jdt.core.dom.NormalAnnotation;
import org.eclipse.jdt.core.dom.QualifiedName;
import org.eclipse.jdt.core.dom.SimpleName;
import org.eclipse.jdt.core.dom.SingleMemberAnnotation;
+import org.eclipse.jdt.core.dom.StringLiteral;
import org.eclipse.jdt.core.dom.TypeDeclaration;
+import org.eclipse.jface.text.IRegion;
+import org.eclipse.jface.text.Region;
import org.eclipse.osgi.util.NLS;
import org.jboss.tools.common.model.util.EclipseJavaUtil;
import org.jboss.tools.common.model.util.EclipseResourceUtil;
@@ -226,6 +230,152 @@
}
}
+ public ResolvedAnnotation findAnnotationByValueOffset(int offset) {
+ if (resolvedAnnotations == null)
+ return null;
+
+ for (ResolvedAnnotation a : resolvedAnnotations.keySet()) {
+ if (a.getAnnotation() instanceof SingleMemberAnnotation) {
+ SingleMemberAnnotation sma = (SingleMemberAnnotation)a.getAnnotation();
+ Object vpd = sma.getStructuralProperty(SingleMemberAnnotation.VALUE_PROPERTY);
+ if (vpd instanceof ASTNode) {
+ ASTNode node = (ASTNode)vpd;
+ int start = node.getStartPosition();
+ int length = node.getLength();
+ if (offset >= start && offset < start + length) {
+ return a;
+ }
+ }
+ } else if (a.getAnnotation() instanceof NormalAnnotation) {
+ NormalAnnotation na = (NormalAnnotation)a.getAnnotation();
+ Object vpd = na.getStructuralProperty(NormalAnnotation.VALUES_PROPERTY);
+ if (vpd instanceof List) {
+ for (Object item : (List)vpd) {
+ if (item instanceof ASTNode) {
+ ASTNode node = (ASTNode)item;
+ if (node.getNodeType() != ASTNode.MEMBER_VALUE_PAIR)
+ continue;
+ MemberValuePair mvp = (MemberValuePair)node;
+ SimpleName name = mvp.getName();
+ if (!"value".equals(name.getIdentifier())) {
+ continue;
+ }
+ int start = node.getStartPosition();
+ int length = node.getLength();
+ if (offset >= start && offset < start + length) {
+ return a;
+ }
+ }
+ }
+ }
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Returns the annotation's value text
+ *
+ * @param annotation
+ * @return
+ */
+ public String getAnnotationValue(ResolvedAnnotation annotation) {
+ if (annotation.getAnnotation() instanceof SingleMemberAnnotation) {
+ SingleMemberAnnotation sma = (SingleMemberAnnotation)annotation.getAnnotation();
+ Object vpd = sma.getStructuralProperty(SingleMemberAnnotation.VALUE_PROPERTY);
+ if (vpd instanceof StringLiteral) {
+ return ((StringLiteral)vpd).getLiteralValue();
+ }
+ return vpd.toString();
+ } else if (annotation.getAnnotation() instanceof NormalAnnotation) {
+ NormalAnnotation na = (NormalAnnotation)annotation.getAnnotation();
+ Object vpd = na.getStructuralProperty(NormalAnnotation.VALUES_PROPERTY);
+ if (vpd instanceof List) {
+ for (Object item : (List)vpd) {
+ if (item instanceof ASTNode) {
+ ASTNode node = (ASTNode)item;
+ if (node.getNodeType() != ASTNode.MEMBER_VALUE_PAIR)
+ continue;
+ MemberValuePair mvp = (MemberValuePair)node;
+ SimpleName name = mvp.getName();
+ if (!"value".equals(name.getIdentifier())) {
+ continue;
+ }
+ return ((StringLiteral)mvp.getValue()).getLiteralValue();
+ }
+ }
+ }
+ }
+
+ return null;
+ }
+
+ /**
+ * Returns the annotation's value region
+ *
+ * @param annotation
+ * @return
+ */
+ public IRegion getAnnotationValueRegion(ResolvedAnnotation annotation) {
+ if (annotation.getAnnotation() instanceof SingleMemberAnnotation) {
+ SingleMemberAnnotation sma = (SingleMemberAnnotation)annotation.getAnnotation();
+ Object vpd = sma.getStructuralProperty(SingleMemberAnnotation.VALUE_PROPERTY);
+ if (vpd instanceof StringLiteral) {
+ StringLiteral sl = (StringLiteral)vpd;
+ return new Region(sl.getStartPosition() + 1, sl.getLength());
+ }
+ if (vpd instanceof ASTNode) {
+ ASTNode astNode = (ASTNode)vpd;
+ return new Region(astNode.getStartPosition(),astNode.getLength());
+ }
+ return null;
+ } else if (annotation.getAnnotation() instanceof NormalAnnotation) {
+ NormalAnnotation na = (NormalAnnotation)annotation.getAnnotation();
+ Object vpd = na.getStructuralProperty(NormalAnnotation.VALUES_PROPERTY);
+ if (vpd instanceof List) {
+ for (Object item : (List)vpd) {
+ if (item instanceof ASTNode) {
+ ASTNode node = (ASTNode)item;
+ if (node.getNodeType() != ASTNode.MEMBER_VALUE_PAIR)
+ continue;
+ MemberValuePair mvp = (MemberValuePair)node;
+ SimpleName name = mvp.getName();
+ if (!"value".equals(name.getIdentifier())) {
+ continue;
+ }
+ Object sValuesObj = mvp.getStructuralProperty(MemberValuePair.VALUE_PROPERTY);
+ if (sValuesObj instanceof StringLiteral) {
+ StringLiteral sl = (StringLiteral)sValuesObj;
+ return new Region(sl.getStartPosition() + 1, sl.getLength());
+ }
+ if (sValuesObj instanceof ASTNode) {
+ ASTNode astNode = (ASTNode)sValuesObj;
+ return new Region(astNode.getStartPosition(),astNode.getLength());
+ }
+ return null;
+ }
+ }
+ }
+ }
+
+ return null;
+ }
+
+ /**
+ * Detects if the type of annotation equals to the selected SeamAnnotations' type
+ *
+ * @param annotation
+ * @param typeName
+ *
+ * @return
+ */
+ public boolean isAnnotationOfType(ResolvedAnnotation annotation, String typeName) {
+ if (annotation == null || typeName == null)
+ return false;
+
+ return (typeName.equals(annotation.getType()));
+ }
+
static String getResolvedType(IType type, String n) {
String[][] rs;
18 years, 1 month
JBoss Tools SVN: r6790 - in trunk/seam/plugins: org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui and 1 other directories.
by jbosstools-commits@lists.jboss.org
Author: dazarov
Date: 2008-03-07 14:43:55 -0500 (Fri, 07 Mar 2008)
New Revision: 6790
Added:
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/ISeamHelpContextIds.java
Modified:
trunk/seam/plugins/org.jboss.tools.seam.doc.user/plugin.xml
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamActionWizard.java
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamConversationWizard.java
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamEntityWizard.java
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamFormWizard.java
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamGenerateEnitiesWizard.java
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamProjectWizard.java
Log:
http://jira.jboss.com/jira/browse/JBIDE-1692
Modified: trunk/seam/plugins/org.jboss.tools.seam.doc.user/plugin.xml
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.doc.user/plugin.xml 2008-03-07 19:03:33 UTC (rev 6789)
+++ trunk/seam/plugins/org.jboss.tools.seam.doc.user/plugin.xml 2008-03-07 19:43:55 UTC (rev 6790)
@@ -13,7 +13,7 @@
point="org.eclipse.help.contexts">
<contexts
file="SeamContextHelp.xml"
- plugin="org.jboss.tools.seam.doc.user">
+ plugin="org.jboss.tools.seam.ui">
</contexts>
</extension>
Added: trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/ISeamHelpContextIds.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/ISeamHelpContextIds.java (rev 0)
+++ trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/ISeamHelpContextIds.java 2008-03-07 19:43:55 UTC (rev 6790)
@@ -0,0 +1,29 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Exadel, Inc. and Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.seam.ui;
+
+public interface ISeamHelpContextIds {
+ public static final String PREFIX = SeamGuiPlugin.PLUGIN_ID + '.';
+
+ public static final String NEW_SEAM_PROJECT = PREFIX + "new_seam_project";
+
+ public static final String NEW_SEAM_ACTION = PREFIX + "new_seam_action";
+
+ public static final String NEW_SEAM_FORM = PREFIX + "new_seam_form";
+
+ public static final String NEW_SEAM_ENTITY = PREFIX + "new_seam_entity";
+
+ public static final String NEW_SEAM_CONVERSATION = PREFIX
+ + "new_seam_conversation";
+
+ public static final String GENERATE_SEAM_ENTITIES = PREFIX
+ + "generate_seam_entities";
+}
Modified: trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamActionWizard.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamActionWizard.java 2008-03-07 19:03:33 UTC (rev 6789)
+++ trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamActionWizard.java 2008-03-07 19:43:55 UTC (rev 6790)
@@ -21,6 +21,7 @@
import org.eclipse.ui.INewWizard;
import org.eclipse.ui.PlatformUI;
import org.jboss.tools.seam.internal.core.project.facet.ISeamFacetDataModelProperties;
+import org.jboss.tools.seam.ui.ISeamHelpContextIds;
import org.jboss.tools.seam.ui.SeamUIMessages;
import org.jboss.tools.seam.ui.widget.editor.INamedElement;
@@ -33,7 +34,7 @@
public void createPageControls(Composite pageContainer) {
super.createPageControls(pageContainer);
- PlatformUI.getWorkbench().getHelpSystem().setHelp(pageContainer, "org.jboss.tools.seam.doc.user.new_seam_action");
+ PlatformUI.getWorkbench().getHelpSystem().setHelp(pageContainer, ISeamHelpContextIds.NEW_SEAM_ACTION);
}
Modified: trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamConversationWizard.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamConversationWizard.java 2008-03-07 19:03:33 UTC (rev 6789)
+++ trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamConversationWizard.java 2008-03-07 19:43:55 UTC (rev 6790)
@@ -21,6 +21,7 @@
import org.eclipse.ui.INewWizard;
import org.eclipse.ui.PlatformUI;
import org.jboss.tools.seam.internal.core.project.facet.ISeamFacetDataModelProperties;
+import org.jboss.tools.seam.ui.ISeamHelpContextIds;
import org.jboss.tools.seam.ui.SeamUIMessages;
import org.jboss.tools.seam.ui.widget.editor.INamedElement;
@@ -28,7 +29,7 @@
public void createPageControls(Composite pageContainer) {
super.createPageControls(pageContainer);
- PlatformUI.getWorkbench().getHelpSystem().setHelp(pageContainer, "org.jboss.tools.seam.doc.user.new_seam_conversation");
+ PlatformUI.getWorkbench().getHelpSystem().setHelp(pageContainer, ISeamHelpContextIds.NEW_SEAM_CONVERSATION);
}
public SeamConversationWizard() {
Modified: trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamEntityWizard.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamEntityWizard.java 2008-03-07 19:03:33 UTC (rev 6789)
+++ trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamEntityWizard.java 2008-03-07 19:43:55 UTC (rev 6790)
@@ -22,6 +22,7 @@
import org.eclipse.ui.PlatformUI;
import org.jboss.tools.seam.core.SeamProjectsSet;
import org.jboss.tools.seam.internal.core.project.facet.ISeamFacetDataModelProperties;
+import org.jboss.tools.seam.ui.ISeamHelpContextIds;
import org.jboss.tools.seam.ui.SeamUIMessages;
import org.jboss.tools.seam.ui.widget.editor.INamedElement;
@@ -33,7 +34,7 @@
public void createPageControls(Composite pageContainer) {
super.createPageControls(pageContainer);
- PlatformUI.getWorkbench().getHelpSystem().setHelp(pageContainer, "org.jboss.tools.seam.doc.user.new_seam_entity");
+ PlatformUI.getWorkbench().getHelpSystem().setHelp(pageContainer, ISeamHelpContextIds.NEW_SEAM_ENTITY);
}
/**
*
Modified: trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamFormWizard.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamFormWizard.java 2008-03-07 19:03:33 UTC (rev 6789)
+++ trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamFormWizard.java 2008-03-07 19:43:55 UTC (rev 6790)
@@ -22,6 +22,7 @@
import org.eclipse.ui.INewWizard;
import org.eclipse.ui.PlatformUI;
import org.jboss.tools.seam.internal.core.project.facet.ISeamFacetDataModelProperties;
+import org.jboss.tools.seam.ui.ISeamHelpContextIds;
import org.jboss.tools.seam.ui.SeamUIMessages;
import org.jboss.tools.seam.ui.widget.editor.INamedElement;
@@ -34,7 +35,7 @@
public void createPageControls(Composite pageContainer) {
super.createPageControls(pageContainer);
- PlatformUI.getWorkbench().getHelpSystem().setHelp(pageContainer, "org.jboss.tools.seam.doc.user.new_seam_form");
+ PlatformUI.getWorkbench().getHelpSystem().setHelp(pageContainer, ISeamHelpContextIds.NEW_SEAM_FORM);
}
/**
*
Modified: trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamGenerateEnitiesWizard.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamGenerateEnitiesWizard.java 2008-03-07 19:03:33 UTC (rev 6789)
+++ trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamGenerateEnitiesWizard.java 2008-03-07 19:43:55 UTC (rev 6790)
@@ -42,6 +42,7 @@
import org.jboss.tools.seam.core.project.facet.SeamRuntimeManager;
import org.jboss.tools.seam.core.project.facet.SeamVersion;
import org.jboss.tools.seam.internal.core.project.facet.ISeamFacetDataModelProperties;
+import org.jboss.tools.seam.ui.ISeamHelpContextIds;
import org.jboss.tools.seam.ui.SeamUIMessages;
/**
@@ -52,7 +53,7 @@
public void createPageControls(Composite pageContainer) {
super.createPageControls(pageContainer);
- PlatformUI.getWorkbench().getHelpSystem().setHelp(pageContainer, "org.jboss.tools.seam.doc.user.generate_seam_entities");
+ PlatformUI.getWorkbench().getHelpSystem().setHelp(pageContainer, ISeamHelpContextIds.GENERATE_SEAM_ENTITIES);
}
public SeamGenerateEnitiesWizard() {
Modified: trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamProjectWizard.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamProjectWizard.java 2008-03-07 19:03:33 UTC (rev 6789)
+++ trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamProjectWizard.java 2008-03-07 19:43:55 UTC (rev 6790)
@@ -41,6 +41,7 @@
import org.jboss.tools.seam.core.project.facet.SeamProjectPreferences;
import org.jboss.tools.seam.internal.core.project.facet.ISeamFacetDataModelProperties;
import org.jboss.tools.seam.internal.core.project.facet.SeamFacetProjectCreationDataModelProvider;
+import org.jboss.tools.seam.ui.ISeamHelpContextIds;
import org.jboss.tools.seam.ui.SeamUIMessages;
import org.jboss.tools.seam.ui.internal.project.facet.SeamInstallWizardPage;
@@ -81,7 +82,6 @@
@Override
public void createPageControls(Composite container) {
super.createPageControls(container);
- PlatformUI.getWorkbench().getHelpSystem().setHelp(container, "org.jboss.tools.seam.guide.new_seam_project");
Control control = findGroupByText(getShell(), SeamUIMessages.SEAM_PROJECT_WIZARD_EAR_MEMBERSHIP);
if (control != null)
control.setVisible(false);
@@ -134,6 +134,10 @@
}
class SeamWebProjectFirstPage extends WebProjectFirstPage {
+ @Override
+ protected String getInfopopID() {
+ return ISeamHelpContextIds.NEW_SEAM_PROJECT;
+ }
public SeamWebProjectFirstPage(IDataModel model, String pageName ) {
super(model, pageName);
@@ -143,7 +147,6 @@
protected Composite createTopLevelComposite(Composite parent) {
Composite top = new Composite(parent, SWT.NONE);
- PlatformUI.getWorkbench().getHelpSystem().setHelp(top, "org.jboss.tools.seam.guide.new_seam_project");
top.setLayout(new GridLayout());
top.setLayoutData(new GridData(GridData.FILL_BOTH));
createProjectGroup(top);
18 years, 1 month
JBoss Tools SVN: r6789 - in trunk: jsf/plugins/org.jboss.tools.jsf.vpe.jsf/src/org/jboss/tools/jsf/vpe/jsf/template/util and 4 other directories.
by jbosstools-commits@lists.jboss.org
Author: sdzmitrovich
Date: 2008-03-07 14:03:33 -0500 (Fri, 07 Mar 2008)
New Revision: 6789
Added:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mapping/VpeAttributeData.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mapping/VpeElementData.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/ITemplateKeyEventHandler.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/ITemplateNodesManager.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/ITemplateSelectionManager.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/TemplateManagingUtil.java
Removed:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeTemplateKeyEventHandler.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeTemplateNodesManager.java
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jsf/src/org/jboss/tools/jsf/vpe/jsf/template/AbstractJsfTemplate.java
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jsf/src/org/jboss/tools/jsf/vpe/jsf/template/JsfOutputFormatTemplate.java
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jsf/src/org/jboss/tools/jsf/vpe/jsf/template/JsfOutputLabelTemplate.java
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jsf/src/org/jboss/tools/jsf/vpe/jsf/template/JsfOutputTextTemplate.java
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jsf/src/org/jboss/tools/jsf/vpe/jsf/template/util/NodeProxyUtil.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeController.java
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/VpeSourceDomBuilder.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/VpeVisualKeyHandler.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mapping/VpeElementMapping.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/EditableTemplateAdapter.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeAbstractTemplate.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeCreationData.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeTemplate.java
Log:
review editing mechanism
Modified: trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jsf/src/org/jboss/tools/jsf/vpe/jsf/template/AbstractJsfTemplate.java
===================================================================
--- trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jsf/src/org/jboss/tools/jsf/vpe/jsf/template/AbstractJsfTemplate.java 2008-03-07 17:06:05 UTC (rev 6788)
+++ trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jsf/src/org/jboss/tools/jsf/vpe/jsf/template/AbstractJsfTemplate.java 2008-03-07 19:03:33 UTC (rev 6789)
@@ -14,10 +14,19 @@
import java.util.Map;
import java.util.Set;
+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.EditableTemplateAdapter;
import org.jboss.tools.vpe.editor.util.HTML;
+import org.jboss.tools.vpe.editor.util.TemplateManagingUtil;
import org.mozilla.interfaces.nsIDOMElement;
+import org.mozilla.interfaces.nsIDOMKeyEvent;
+import org.mozilla.interfaces.nsIDOMNode;
+import org.mozilla.interfaces.nsISelection;
import org.w3c.dom.Element;
+import org.w3c.dom.Node;
/**
* general class for jsf templates
@@ -72,4 +81,100 @@
}
+ protected boolean handleCharacter(VpePageContext pageContext,
+ nsIDOMKeyEvent keyEvent) {
+
+ // get selection
+ nsISelection selection = getCurrentSelection(pageContext);
+
+ // get visual node which is focused
+ nsIDOMNode visualNode = selection.getFocusNode();
+
+ VpeElementMapping elementMapping = getElmentMapping(pageContext,
+ visualNode);
+ if (elementMapping != null)
+ return super.handleCharacter(pageContext, keyEvent);
+ else
+ return true;
+ }
+
+ protected boolean handleLeftDelete(VpePageContext pageContext,
+ nsIDOMKeyEvent keyEvent) {
+
+ // get selection
+ nsISelection selection = getCurrentSelection(pageContext);
+
+ // get visual node which is focused
+ nsIDOMNode visualNode = selection.getFocusNode();
+
+ VpeElementMapping elementMapping = getElmentMapping(pageContext,
+ visualNode);
+ if (elementMapping != null)
+ return super.handleLeftDelete(pageContext, keyEvent);
+ else
+ return true;
+
+ }
+
+ protected boolean handleRightDelete(VpePageContext pageContext,
+ nsIDOMKeyEvent keyEvent) {
+
+ // get selection
+ nsISelection selection = getCurrentSelection(pageContext);
+
+ // get visual node which is focused
+ nsIDOMNode visualNode = selection.getFocusNode();
+
+ VpeElementMapping elementMapping = getElmentMapping(pageContext,
+ visualNode);
+ if (elementMapping != null)
+ return super.handleRightDelete(pageContext, keyEvent);
+ else
+ return true;
+ }
+
+ @Override
+ public void setSelection(VpePageContext pageContext, nsISelection selection) {
+
+ nsIDOMNode focusedVisualNode = selection.getFocusNode();
+
+ VpeElementMapping elementMapping = pageContext.getDomMapping()
+ .getNearElementMapping(focusedVisualNode);
+
+ if (elementMapping != null)
+ super.setSelection(pageContext, selection);
+ else {
+
+ VpeNodeMapping insertedMapping = pageContext.getDomMapping()
+ .getNearNodeMappingAtVisualNode(focusedVisualNode);
+
+ if (insertedMapping != null) {
+
+ Node insertedNode = insertedMapping.getSourceNode();
+
+ int offset = ((IDOMNode) insertedNode).getStartOffset();
+
+ Node realNode = TemplateManagingUtil.getSourceNodeByPosition(
+ pageContext, offset);
+
+ VpeElementMapping mappingRealNode = pageContext.getDomMapping()
+ .getNearElementMapping(realNode);
+
+ if (mappingRealNode != null) {
+
+ Node focusedNode = getFocusedNode(realNode, mappingRealNode
+ .getElementData(), offset);
+
+ setSourceSelection(pageContext, focusedNode, 0,
+ getLengthNode(focusedNode));
+
+ pageContext.getVisualBuilder().setSelectionRectangle(
+ (nsIDOMElement) mappingRealNode.getVisualElement()
+ .queryInterface(
+ nsIDOMElement.NS_IDOMELEMENT_IID));
+ }
+
+ }
+ }
+ }
}
Modified: trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jsf/src/org/jboss/tools/jsf/vpe/jsf/template/JsfOutputFormatTemplate.java
===================================================================
--- trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jsf/src/org/jboss/tools/jsf/vpe/jsf/template/JsfOutputFormatTemplate.java 2008-03-07 17:06:05 UTC (rev 6788)
+++ trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jsf/src/org/jboss/tools/jsf/vpe/jsf/template/JsfOutputFormatTemplate.java 2008-03-07 19:03:33 UTC (rev 6789)
@@ -18,7 +18,8 @@
import org.eclipse.wst.xml.core.internal.provisional.document.IDOMAttr;
import org.jboss.tools.jsf.vpe.jsf.template.util.NodeProxyUtil;
import org.jboss.tools.vpe.editor.context.VpePageContext;
-import org.jboss.tools.vpe.editor.mapping.VpeNodeMapping;
+import org.jboss.tools.vpe.editor.mapping.VpeAttributeData;
+import org.jboss.tools.vpe.editor.mapping.VpeElementData;
import org.jboss.tools.vpe.editor.template.VpeChildrenInfo;
import org.jboss.tools.vpe.editor.template.VpeCreationData;
import org.jboss.tools.vpe.editor.util.HTML;
@@ -41,32 +42,32 @@
/**
* name of "param" tag
*/
- private static final String PARAM_NAME = "param";
+ private static final String PARAM_NAME = "param"; //$NON-NLS-1$
/**
* name of "choice"
*/
- private static final String CHOICE_NAME = "choice";
+ private static final String CHOICE_NAME = "choice"; //$NON-NLS-1$
/**
* message format elements separator
*/
- private static final String MESSAGE_FORMAT_ELEMENTS_SEPARATOR = ",";
+ private static final String MESSAGE_FORMAT_ELEMENTS_SEPARATOR = ","; //$NON-NLS-1$
/**
* choices separator
*/
- private static final String CHOICES_SEPARATOR = "\\|";
+ private static final String CHOICES_SEPARATOR = "\\|"; //$NON-NLS-1$
/**
* choices separator
*/
- private static final String CHOICE_PAIR_SEPARATOR = "#";
+ private static final String CHOICE_PAIR_SEPARATOR = "#"; //$NON-NLS-1$
/**
* message format elements pattern
*/
- private static final String MESSAGE_FORMAT_ELEMENTS_PATTERN = "\\{(\\d+)(,.*?){0,2}?\\}";
+ private static final String MESSAGE_FORMAT_ELEMENTS_PATTERN = "\\{(\\d+)(,.*?){0,2}?\\}"; //$NON-NLS-1$
/*
* (non-Javadoc)
@@ -79,7 +80,7 @@
Element element = (Element) sourceNode;
- List<VpeNodeMapping> attributesMapping = new ArrayList<VpeNodeMapping>();
+ VpeElementData elementData = new VpeElementData();
// create span element
nsIDOMElement span = visualDocument.createElement(HTML.TAG_SPAN);
@@ -115,16 +116,13 @@
nsIDOMText text;
// if bundleValue differ from value then will be represent
// bundleValue, but text will be not edit
- if (!value.equals(newValue)) {
+ boolean isEditable = value.equals(newValue);
- text = visualDocument.createTextNode(newValue);
+ text = visualDocument.createTextNode(newValue);
+ // add attribute for ability of editing
+ elementData.addAttributeData(new VpeAttributeData(attr, text,
+ isEditable));
- } else {
-
- text = visualDocument.createTextNode(value);
- // add attribute for ability of editing
- attributesMapping.add(new VpeNodeMapping(attr, text));
- }
span.appendChild(text);
}
// then text can be html code
@@ -144,6 +142,8 @@
spanInfo.addSourceChild(child);
}
+ elementData.addAttributeData(new VpeAttributeData(attr, span,
+ false));
creationData.addChildrenInfo(spanInfo);
@@ -151,7 +151,7 @@
}
- creationData.setData(attributesMapping);
+ creationData.setElementData(elementData);
return creationData;
@@ -229,7 +229,8 @@
// get "choice" as value
String choice = getChoice(parametres[2]);
if (choice != null)
- value = choice.replaceAll("[\\{\\}]", "");;
+ value = choice.replaceAll("[\\{\\}]", ""); //$NON-NLS-1$//$NON-NLS-2$
+ ;
}
}
@@ -239,7 +240,7 @@
// get number of param
String paramNumber = parametres[0].trim();
- paramNumber = paramNumber.replaceAll("[\\{\\}]", "");
+ paramNumber = paramNumber.replaceAll("[\\{\\}]", ""); //$NON-NLS-1$//$NON-NLS-2$
try {
// decode
Modified: trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jsf/src/org/jboss/tools/jsf/vpe/jsf/template/JsfOutputLabelTemplate.java
===================================================================
--- trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jsf/src/org/jboss/tools/jsf/vpe/jsf/template/JsfOutputLabelTemplate.java 2008-03-07 17:06:05 UTC (rev 6788)
+++ trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jsf/src/org/jboss/tools/jsf/vpe/jsf/template/JsfOutputLabelTemplate.java 2008-03-07 19:03:33 UTC (rev 6789)
@@ -10,12 +10,10 @@
******************************************************************************/
package org.jboss.tools.jsf.vpe.jsf.template;
-import java.util.ArrayList;
-import java.util.List;
-
import org.jboss.tools.jsf.vpe.jsf.template.util.NodeProxyUtil;
import org.jboss.tools.vpe.editor.context.VpePageContext;
-import org.jboss.tools.vpe.editor.mapping.VpeNodeMapping;
+import org.jboss.tools.vpe.editor.mapping.VpeAttributeData;
+import org.jboss.tools.vpe.editor.mapping.VpeElementData;
import org.jboss.tools.vpe.editor.template.VpeChildrenInfo;
import org.jboss.tools.vpe.editor.template.VpeCreationData;
import org.jboss.tools.vpe.editor.util.HTML;
@@ -38,7 +36,7 @@
/**
* name of "for" attribute
*/
- protected static final String FOR_ATTR_NAME = "for";
+ protected static final String FOR_ATTR_NAME = "for"; //$NON-NLS-1$
/*
* (non-Javadoc)
@@ -51,7 +49,7 @@
Element element = (Element) sourceNode;
- List<VpeNodeMapping> attributesMapping = new ArrayList<VpeNodeMapping>();
+ VpeElementData elementData = new VpeElementData();
// create label element
nsIDOMElement label = visualDocument.createElement(HTML.TAG_LABEL);
@@ -71,7 +69,7 @@
// if escape then contents of value (or other attribute) is only
// text
if (!element.hasAttribute(ESCAPE_ATTR_NAME)
- || ("true".equalsIgnoreCase(element
+ || ("true".equalsIgnoreCase(element //$NON-NLS-1$
.getAttribute(ESCAPE_ATTR_NAME)))) {
String value = attr.getNodeValue();
@@ -82,23 +80,20 @@
nsIDOMText text;
// if bundleValue differ from value then will be represent
// bundleValue, but text will be not edit
- if (!value.equals(bundleValue)) {
+ boolean isEditable = value.equals(bundleValue);
- text = visualDocument.createTextNode(bundleValue);
+ text = visualDocument.createTextNode(bundleValue);
+ // add attribute for ability of editing
+ elementData.addAttributeData(new VpeAttributeData(attr, text,
+ isEditable));
- } else {
-
- text = visualDocument.createTextNode(value);
- // add attribute for ability of editing
- attributesMapping.add(new VpeNodeMapping(attr, text));
- }
label.appendChild(text);
}
// then text can be html code
else {
// create info
- VpeChildrenInfo spanInfo = new VpeChildrenInfo(label);
+ VpeChildrenInfo labelInfo = new VpeChildrenInfo(label);
// reparse attribute's value
NodeList list = NodeProxyUtil.reparseAttributeValue(attr);
@@ -108,17 +103,20 @@
Node child = list.item(i);
- spanInfo.addSourceChild(child);
+ labelInfo.addSourceChild(child);
}
+ elementData.addAttributeData(new VpeAttributeData(attr, label,
+ false));
+
// add info to creation data
- creationData.addChildrenInfo(spanInfo);
+ creationData.addChildrenInfo(labelInfo);
}
}
- creationData.setData(attributesMapping);
+ creationData.setElementData(elementData);
return creationData;
Modified: trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jsf/src/org/jboss/tools/jsf/vpe/jsf/template/JsfOutputTextTemplate.java
===================================================================
--- trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jsf/src/org/jboss/tools/jsf/vpe/jsf/template/JsfOutputTextTemplate.java 2008-03-07 17:06:05 UTC (rev 6788)
+++ trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jsf/src/org/jboss/tools/jsf/vpe/jsf/template/JsfOutputTextTemplate.java 2008-03-07 19:03:33 UTC (rev 6789)
@@ -10,12 +10,10 @@
******************************************************************************/
package org.jboss.tools.jsf.vpe.jsf.template;
-import java.util.ArrayList;
-import java.util.List;
-
import org.jboss.tools.jsf.vpe.jsf.template.util.NodeProxyUtil;
import org.jboss.tools.vpe.editor.context.VpePageContext;
-import org.jboss.tools.vpe.editor.mapping.VpeNodeMapping;
+import org.jboss.tools.vpe.editor.mapping.VpeAttributeData;
+import org.jboss.tools.vpe.editor.mapping.VpeElementData;
import org.jboss.tools.vpe.editor.template.VpeChildrenInfo;
import org.jboss.tools.vpe.editor.template.VpeCreationData;
import org.jboss.tools.vpe.editor.util.HTML;
@@ -46,7 +44,7 @@
Element element = (Element) sourceNode;
- List<VpeNodeMapping> attributesMapping = new ArrayList<VpeNodeMapping>();
+ VpeElementData elementData = new VpeElementData();
// create span element
nsIDOMElement span = visualDocument.createElement(HTML.TAG_SPAN);
@@ -64,7 +62,7 @@
// if escape then contents of value (or other attribute) is only
// text
if (!element.hasAttribute(ESCAPE_ATTR_NAME)
- || "true".equalsIgnoreCase(element
+ || "true".equalsIgnoreCase(element //$NON-NLS-1$
.getAttribute(ESCAPE_ATTR_NAME))) {
String value = attr.getNodeValue();
@@ -75,16 +73,13 @@
nsIDOMText text;
// if bundleValue differ from value then will be represent
// bundleValue, but text will be not edit
- if (!value.equals(bundleValue)) {
+ boolean isEditable = value.equals(bundleValue);
- text = visualDocument.createTextNode(bundleValue);
+ text = visualDocument.createTextNode(bundleValue);
+ // add attribute for ability of editing
- } else {
-
- text = visualDocument.createTextNode(value);
- // add attribute for ability of editing
- attributesMapping.add(new VpeNodeMapping(attr, text));
- }
+ elementData.addAttributeData(new VpeAttributeData(attr, text,
+ isEditable));
span.appendChild(text);
}
// then text can be html code
@@ -104,14 +99,15 @@
// add info to creation data
spanInfo.addSourceChild(child);
}
-
+ elementData.addAttributeData(new VpeAttributeData(attr, span,
+ false));
creationData.addChildrenInfo(spanInfo);
}
}
- creationData.setData(attributesMapping);
+ creationData.setElementData(elementData);
return creationData;
Modified: trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jsf/src/org/jboss/tools/jsf/vpe/jsf/template/util/NodeProxyUtil.java
===================================================================
--- trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jsf/src/org/jboss/tools/jsf/vpe/jsf/template/util/NodeProxyUtil.java 2008-03-07 17:06:05 UTC (rev 6788)
+++ trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jsf/src/org/jboss/tools/jsf/vpe/jsf/template/util/NodeProxyUtil.java 2008-03-07 19:03:33 UTC (rev 6789)
@@ -20,8 +20,8 @@
import org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel;
import org.eclipse.wst.xml.core.internal.provisional.document.IDOMText;
import org.jboss.tools.jsf.vpe.jsf.template.util.model.ElementProxy;
+import org.jboss.tools.jsf.vpe.jsf.template.util.model.NodeListImpl;
import org.jboss.tools.jsf.vpe.jsf.template.util.model.NodeProxy;
-import org.jboss.tools.jsf.vpe.jsf.template.util.model.NodeListImpl;
import org.jboss.tools.jsf.vpe.jsf.template.util.model.TextProxy;
import org.w3c.dom.Attr;
import org.w3c.dom.Node;
Modified: trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeController.java
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeController.java 2008-03-07 17:06:05 UTC (rev 6788)
+++ trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeController.java 2008-03-07 19:03:33 UTC (rev 6789)
@@ -126,6 +126,7 @@
import org.jboss.tools.vpe.editor.mozilla.MozillaEditor;
import org.jboss.tools.vpe.editor.selection.VpeSelectionController;
import org.jboss.tools.vpe.editor.selection.VpeSelectionHelper;
+import org.jboss.tools.vpe.editor.template.ITemplateSelectionManager;
import org.jboss.tools.vpe.editor.template.VpeAnyData;
import org.jboss.tools.vpe.editor.template.VpeEditAnyDialog;
import org.jboss.tools.vpe.editor.template.VpeHtmlTemplate;
@@ -133,9 +134,9 @@
import org.jboss.tools.vpe.editor.template.VpeTemplate;
import org.jboss.tools.vpe.editor.template.VpeTemplateListener;
import org.jboss.tools.vpe.editor.template.VpeTemplateManager;
-import org.jboss.tools.vpe.editor.template.VpeTemplateNodesManager;
import org.jboss.tools.vpe.editor.toolbar.format.FormatControllerManager;
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.editor.util.VisualDomUtil;
import org.jboss.tools.vpe.editor.util.VpeDndUtil;
@@ -539,12 +540,25 @@
Point range = sourceEditor.getTextViewer().getSelectedRange();
int anchorPosition = range.x;
int focusPosition = range.x + range.y;
+
boolean extendFlag = range.y != 0;
boolean reversionFlag = extendFlag && anchorPosition == VpeSelectionHelper.getCaretOffset(sourceEditor);
if (reversionFlag) {
anchorPosition = focusPosition;
focusPosition = range.x;
}
+
+ VpeTemplate template = TemplateManagingUtil
+ .getTemplateBySourceSelection(pageContext, focusPosition,
+ anchorPosition);
+
+ if (template instanceof ITemplateSelectionManager) {
+ ((ITemplateSelectionManager) template).setVisualSelectionBySource(
+ pageContext, visualSelectionController, focusPosition,
+ anchorPosition);
+ return;
+ }
+
Node focusNode = getSourceNodeAt(focusPosition);
if (focusNode == null) {
return;
@@ -1369,14 +1383,6 @@
if (elementMapping != null) {
- // if template implements VpeTemplateNodesManager interface
- if (elementMapping.getTemplate() instanceof VpeTemplateNodesManager) {
- Node focusedAttr = ((VpeTemplateNodesManager) elementMapping
- .getTemplate()).getFocusedNode((IDOMNode) node,
- offset, elementMapping.getData());
- if (node != null)
- return focusedAttr;
- }
if (node instanceof IDOMElement) {
IDOMElement element = (IDOMElement) node;
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-03-07 17:06:05 UTC (rev 6788)
+++ trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeSelectionBuilder.java 2008-03-07 19:03:33 UTC (rev 6789)
@@ -21,8 +21,11 @@
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.ITemplateSelectionManager;
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.TextUtil;
import org.jboss.tools.vpe.editor.util.VisualDomUtil;
import org.jboss.tools.vpe.xulrunner.editor.XulRunnerEditor;
@@ -69,6 +72,15 @@
}
public void setSelection(nsISelection selection) {
+
+ VpeTemplate vpeTemplate = TemplateManagingUtil
+ .getTemplateByVisualSelection(visualBuilder.getPageContext());
+ if (vpeTemplate instanceof ITemplateSelectionManager) {
+ ((ITemplateSelectionManager) vpeTemplate).setSelection(
+ visualBuilder.getPageContext(), selection);
+ return;
+ }
+
if (selection.getIsCollapsed()) {
VisualSelectionInfo info = getVisualFocusSelectedInfo(selection);
if (info != null) {
Modified: trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeSourceDomBuilder.java
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeSourceDomBuilder.java 2008-03-07 17:06:05 UTC (rev 6788)
+++ trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeSourceDomBuilder.java 2008-03-07 19:03:33 UTC (rev 6789)
@@ -35,9 +35,9 @@
import org.jboss.tools.vpe.editor.mapping.VpeElementMapping;
import org.jboss.tools.vpe.editor.mapping.VpeNodeMapping;
import org.jboss.tools.vpe.editor.selection.VpeSelectionHelper;
+import org.jboss.tools.vpe.editor.template.ITemplateNodesManager;
import org.jboss.tools.vpe.editor.template.VpeTemplate;
import org.jboss.tools.vpe.editor.template.VpeTemplateManager;
-import org.jboss.tools.vpe.editor.template.VpeTemplateNodesManager;
import org.jboss.tools.vpe.editor.util.TextUtil;
import org.mozilla.interfaces.nsIDOMElement;
import org.mozilla.interfaces.nsIDOMNode;
@@ -260,9 +260,9 @@
VpeTemplate template = elementMapping.getTemplate();
// if template implements VpeTemplateNodesManager interface
- if (template instanceof VpeTemplateNodesManager) {
- return ((VpeTemplateNodesManager) template).openBundle(
- pageContext, visualNode, elementMapping.getData());
+ if (template instanceof ITemplateNodesManager) {
+ return ((ITemplateNodesManager) template).openBundle(
+ pageContext, visualNode, elementMapping.getElementData());
} else {
template.openBundleEditors(pageContext,
(Element) sourceNode, elementMapping.getData());
@@ -325,29 +325,12 @@
.getNodeMapping(sourceParent);
if (elementMapping != null) {
-
+
VpeTemplate template = elementMapping.getTemplate();
- // if template implements VpeTemplateAttributesManager
- // functions
- if (template instanceof VpeTemplateNodesManager) {
- // get attribute
- Node node = ((VpeTemplateNodesManager) template)
- .getSourceNode(pageContext,
- visualText, elementMapping.getData());
- // set selection
- if (node != null)
- ((VpeTemplateNodesManager) template)
- .setSourceNodeSelection(pageContext,
- node, offset, length);
- else
- setSelection(sourceParent, offset, length);
- } else {
-
- template.setSourceAttributeSelection(pageContext,
- (Element) sourceParent, offset, length,
- elementMapping.getData());
- }
+ template.setSourceAttributeSelection(pageContext,
+ (Element) sourceParent, offset, length,
+ elementMapping.getData());
}
} else if (sourceParent.getNodeType() == Node.COMMENT_NODE) {
// VpeVisualElementInfo info = domMapping.getVisualElementInfo(sourceParent);
@@ -430,7 +413,7 @@
return structuredTextViewer;
}
- Document getSourceDocument() {
+ public Document getSourceDocument() {
return sourceDocument;
}
}
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 2008-03-07 17:06:05 UTC (rev 6788)
+++ trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeVisualDomBuilder.java 2008-03-07 19:03:33 UTC (rev 6789)
@@ -57,6 +57,7 @@
import org.jboss.tools.vpe.editor.mapping.VpeElementMapping;
import org.jboss.tools.vpe.editor.mapping.VpeNodeMapping;
import org.jboss.tools.vpe.editor.mozilla.MozillaEditor;
+import org.jboss.tools.vpe.editor.template.ITemplateNodesManager;
import org.jboss.tools.vpe.editor.template.VpeChildrenInfo;
import org.jboss.tools.vpe.editor.template.VpeCreationData;
import org.jboss.tools.vpe.editor.template.VpeCreatorUtil;
@@ -64,7 +65,6 @@
import org.jboss.tools.vpe.editor.template.VpeTagDescription;
import org.jboss.tools.vpe.editor.template.VpeTemplate;
import org.jboss.tools.vpe.editor.template.VpeTemplateManager;
-import org.jboss.tools.vpe.editor.template.VpeTemplateNodesManager;
import org.jboss.tools.vpe.editor.template.VpeToggableTemplate;
import org.jboss.tools.vpe.editor.template.dnd.VpeDnd;
import org.jboss.tools.vpe.editor.util.HTML;
@@ -205,6 +205,7 @@
pageContext.installIncludeElements();
addChildren(null, sourceDocument, visualContentArea);
registerNodes(new VpeNodeMapping(sourceDocument, visualContentArea));
+
}
public void rebuildDom(Document sourceDocument) {
@@ -433,12 +434,13 @@
setReadOnlyElement(visualNewElement);
}
if (registerFlag) {
- VpeElementMapping elementMapping = new VpeElementMapping(
- (Element) sourceNode, visualNewElement, border,
- template, ifDependencySet, creationData.getData());
- // elementMapping.setXmlnsMap(xmlnsMap);
- registerNodes(elementMapping);
- }
+ VpeElementMapping elementMapping = new VpeElementMapping(
+ (Element) sourceNode, visualNewElement, border,
+ template, ifDependencySet, creationData.getData(),
+ creationData.getElementData());
+ // elementMapping.setXmlnsMap(xmlnsMap);
+ registerNodes(elementMapping);
+ }
if (template.isChildren()) {
List<?> childrenInfoList = creationData.getChildrenInfoList();
if (childrenInfoList == null) {
@@ -1140,7 +1142,7 @@
return visualContentArea;
}
- void setSelectionRectangle(nsIDOMElement visualElement) {
+ public void setSelectionRectangle(nsIDOMElement visualElement) {
setSelectionRectangle(visualElement, true);
}
@@ -1574,10 +1576,10 @@
VpeTemplate template = ((VpeElementMapping) nodeMapping)
.getTemplate();
// if template implements VpeTemplateAttributesManager
- if (template instanceof VpeTemplateNodesManager)
- return ((VpeTemplateNodesManager) template).isNodeEditable(
+ if (template instanceof ITemplateNodesManager)
+ return ((ITemplateNodesManager) template).isNodeEditable(
pageContext, visualNode,
- ((VpeElementMapping) nodeMapping).getData());
+ ((VpeElementMapping) nodeMapping).getElementData());
}
@@ -1938,16 +1940,10 @@
VpeElementMapping elementMapping = domMapping
.getNearElementMapping(sourceElement);
if (elementMapping != null) {
-
- if (elementMapping.getTemplate() instanceof VpeTemplateNodesManager) {
- return (nsIDOMText) ((VpeTemplateNodesManager) elementMapping
- .getTemplate()).getVisualNode(pageContext, attr,
- elementMapping.getData());
- }
-
- return elementMapping.getTemplate().getOutputTextNode(pageContext,
- sourceElement, elementMapping.getData());
- }
+
+ return elementMapping.getTemplate().getOutputTextNode(pageContext,
+ sourceElement, elementMapping.getData());
+ }
return null;
}
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-03-07 17:06:05 UTC (rev 6788)
+++ trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeVisualKeyHandler.java 2008-03-07 19:03:33 UTC (rev 6789)
@@ -42,11 +42,12 @@
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.ITemplateKeyEventHandler;
import org.jboss.tools.vpe.editor.template.VpeHtmlTemplate;
import org.jboss.tools.vpe.editor.template.VpeTemplate;
-import org.jboss.tools.vpe.editor.template.VpeTemplateKeyEventHandler;
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;
@@ -168,12 +169,13 @@
boolean shiftKey = keyEvent.getShiftKey();
// get template of selected element
- VpeTemplate template = getCurrentSelectionTemplate();
+ VpeTemplate template = TemplateManagingUtil
+ .getTemplateByVisualSelection(pageContext);
// if template сan handle keyEvent than pass control to him. And if
// template handled event return true
- if ((template instanceof VpeTemplateKeyEventHandler)
- && ((VpeTemplateKeyEventHandler) template).handleKeyPress(
+ if ((template instanceof ITemplateKeyEventHandler)
+ && ((ITemplateKeyEventHandler) template).handleKeyPress(
pageContext, keyEvent)) {
return true;
}
@@ -1825,19 +1827,4 @@
return pageContext.getEditPart().getController().getXulRunnerEditor().getLastSelectedElement();
}
-
- /**
- * get {@link VpeTemplate} from selection
- *
- * @return
- */
- private VpeTemplate getCurrentSelectionTemplate() {
- VpeElementMapping elementMapping = domMapping
- .getNearElementMapping(getSelectedNode());
-
- if (elementMapping != null)
- return elementMapping.getTemplate();
-
- return null;
- }
}
\ No newline at end of file
Added: trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mapping/VpeAttributeData.java
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mapping/VpeAttributeData.java (rev 0)
+++ trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mapping/VpeAttributeData.java 2008-03-07 19:03:33 UTC (rev 6789)
@@ -0,0 +1,111 @@
+/*******************************************************************************
+ * 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.mapping;
+
+import org.mozilla.interfaces.nsIDOMNode;
+import org.w3c.dom.Attr;
+
+/**
+ *
+ * @author Sergey Dzmitrovich
+ *
+ * Keep information about output attribute. Set up a correspondence source node
+ * and visual node
+ *
+ *
+ */
+public class VpeAttributeData {
+
+ /**
+ * source presentation of attribute
+ */
+ private Attr sourceAttr;
+
+ /**
+ * visual presentation of attribute
+ */
+ private nsIDOMNode visualAttr;
+
+ /**
+ * mark if editable
+ */
+ private boolean isEditable;
+
+ public VpeAttributeData(Attr sourceAttr, nsIDOMNode visualAttr,
+ boolean isEditable) {
+ this.sourceAttr = sourceAttr;
+ this.visualAttr = visualAttr;
+ this.isEditable = isEditable;
+
+ }
+
+ public VpeAttributeData(Attr sourceAttr, nsIDOMNode visualAttr) {
+ this.sourceAttr = sourceAttr;
+ this.visualAttr = visualAttr;
+ this.isEditable = true;
+
+ }
+
+ /**
+ * get source
+ *
+ * @return
+ */
+ public Attr getSourceAttr() {
+ return sourceAttr;
+ }
+
+ /**
+ * set source
+ *
+ * @param sourceAttr
+ */
+ public void setSourceAttr(Attr sourceAttr) {
+ this.sourceAttr = sourceAttr;
+ }
+
+ /**
+ * get visual
+ *
+ * @return
+ */
+ public nsIDOMNode getVisualAttr() {
+ return visualAttr;
+ }
+
+ /**
+ * set visual
+ *
+ * @param visualAttr
+ */
+ public void setVisualAttr(nsIDOMNode visualAttr) {
+ this.visualAttr = visualAttr;
+ }
+
+ /**
+ * is editable
+ *
+ * @return
+ */
+ public boolean isEditable() {
+ return isEditable;
+ }
+
+ /**
+ * set editable
+ *
+ * @param isEditable
+ */
+ public void setEditable(boolean isEditable) {
+ this.isEditable = isEditable;
+ }
+
+}
Added: trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mapping/VpeElementData.java
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mapping/VpeElementData.java (rev 0)
+++ trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mapping/VpeElementData.java 2008-03-07 19:03:33 UTC (rev 6789)
@@ -0,0 +1,62 @@
+/*******************************************************************************
+ * 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.mapping;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ *
+ * @author Sergey Dzmitrovich
+ *
+ * keep information about element
+ */
+public class VpeElementData {
+
+ /**
+ * list of attribute data
+ *
+ * keep information about output attributes
+ */
+ private List<VpeAttributeData> attributesData;
+
+ /**
+ * get attributes data
+ *
+ * @return
+ */
+ public List<VpeAttributeData> getAttributesData() {
+ return attributesData;
+ }
+
+ /**
+ * set attributes data
+ *
+ * @param attributesData
+ */
+ public void setAttributesData(List<VpeAttributeData> attributesData) {
+ this.attributesData = attributesData;
+ }
+
+ /**
+ * add <code>VpeAttributeData</code>
+ * @param attributeData
+ */
+ public void addAttributeData(VpeAttributeData attributeData) {
+
+ if (attributesData == null)
+ attributesData = new ArrayList<VpeAttributeData>();
+
+ attributesData.add(attributeData);
+
+ }
+
+}
Modified: trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mapping/VpeElementMapping.java
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mapping/VpeElementMapping.java 2008-03-07 17:06:05 UTC (rev 6788)
+++ trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mapping/VpeElementMapping.java 2008-03-07 19:03:33 UTC (rev 6789)
@@ -11,6 +11,7 @@
package org.jboss.tools.vpe.editor.mapping;
import java.util.Set;
+
import org.jboss.tools.vpe.editor.template.VpeTemplate;
import org.jboss.tools.vpe.editor.template.expression.VpeExpressionBuilder;
import org.mozilla.interfaces.nsIDOMElement;
@@ -21,19 +22,40 @@
private VpeTemplate template;
private Set ifDependencySet;
// private Map xmlnsMap;
+ /**
+ * @deprecated - You must use elementData. If VpeElementData has not
+ * necessary functionality you must extend its
+ */
private Object data;
+ private VpeElementData elementData;
private nsIDOMElement border;
- public VpeElementMapping(Element sourceElement, nsIDOMElement visualElement, nsIDOMElement border, VpeTemplate template, Set ifDependencySet, Object data) {
+ public VpeElementMapping(Element sourceElement,
+ nsIDOMElement visualElement, nsIDOMElement border,
+ VpeTemplate template, Set ifDependencySet, Object data, VpeElementData elementData) {
super(sourceElement, visualElement);
this.template = template;
if (ifDependencySet != null && ifDependencySet.size() > 0) {
this.ifDependencySet = ifDependencySet;
}
this.data = data;
+ this.elementData = elementData;
this.border = border;
}
+ public VpeElementMapping(Element sourceElement,
+ nsIDOMElement visualElement, nsIDOMElement border,
+ VpeTemplate template, Set ifDependencySet,
+ VpeElementData elementData) {
+ super(sourceElement, visualElement);
+ this.template = template;
+ if (ifDependencySet != null && ifDependencySet.size() > 0) {
+ this.ifDependencySet = ifDependencySet;
+ }
+ this.elementData = elementData;
+ this.border = border;
+ }
+
public nsIDOMElement getVisualElement() {
return (nsIDOMElement) getVisualNode();
}
@@ -50,6 +72,10 @@
// this.xmlnsMap = xmlnsMap;
// }
+ /**
+ * @deprecated - You must use elementData. If VpeElementData has not
+ * necessary functionality you must extend its
+ */
public Object getData() {
return data;
}
@@ -84,4 +110,20 @@
}
return false;
}
+
+ /**
+ * get element data
+ * @return
+ */
+ public VpeElementData getElementData() {
+ return elementData;
+ }
+
+ /**
+ * get element data
+ * @param elementData
+ */
+ public void setElementData(VpeElementData elementData) {
+ this.elementData = elementData;
+ }
}
Modified: trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/EditableTemplateAdapter.java
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/EditableTemplateAdapter.java 2008-03-07 17:06:05 UTC (rev 6788)
+++ trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/EditableTemplateAdapter.java 2008-03-07 19:03:33 UTC (rev 6789)
@@ -15,32 +15,37 @@
import org.eclipse.wst.sse.core.internal.provisional.IndexedRegion;
import org.eclipse.wst.xml.core.internal.provisional.document.IDOMAttr;
import org.jboss.tools.vpe.editor.context.VpePageContext;
+import org.jboss.tools.vpe.editor.mapping.VpeAttributeData;
+import org.jboss.tools.vpe.editor.mapping.VpeElementData;
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.util.TemplateManagingUtil;
import org.jboss.tools.vpe.editor.util.TextUtil;
+import org.mozilla.interfaces.nsIDOMElement;
import org.mozilla.interfaces.nsIDOMKeyEvent;
import org.mozilla.interfaces.nsIDOMNode;
-import org.mozilla.interfaces.nsIDOMText;
import org.mozilla.interfaces.nsISelection;
+import org.mozilla.interfaces.nsISelectionController;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
/**
* Abstract class to handle keyEvent.
*
- * Default implementation of {@link VpeTemplateKeyEventHandler}. In result of
- * work handleKeyPress() call one from handle* methods.
+ * Default implementation of ITemplateKeyEventHandler. In result of work
+ * handleKeyPress() call one from handle* methods.
*
* You must override some handle* methods if you want change work of your
* handler *
*
- * Default implementation of {@link VpeTemplateNodesManager}.
+ * Default implementation of ITemplateNodesManager.
*
* @author Sergey Dzmitrovich
*
*/
public abstract class EditableTemplateAdapter extends VpeAbstractTemplate
- implements VpeTemplateKeyEventHandler, VpeTemplateNodesManager {
+ implements ITemplateKeyEventHandler, ITemplateNodesManager,
+ ITemplateSelectionManager {
/**
* name of "view" tag
@@ -141,8 +146,7 @@
nsIDOMKeyEvent keyEvent) {
// get selection
- nsISelection selection = pageContext.getEditPart().getController()
- .getXulRunnerEditor().getSelection();
+ nsISelection selection = getCurrentSelection(pageContext);
// get visual node which is focused
nsIDOMNode visualNode = selection.getFocusNode();
@@ -150,17 +154,17 @@
VpeElementMapping elementMapping = getElmentMapping(pageContext,
visualNode);
- if (elementMapping == null || elementMapping.getData() == null) {
+ if (elementMapping == null || elementMapping.getElementData() == null) {
return false;
}
- Object data = elementMapping.getData();
+ VpeElementData elementData = elementMapping.getElementData();
// if node editable
- if (isNodeEditable(pageContext, visualNode, data)) {
+ if (isNodeEditable(pageContext, visualNode, elementData)) {
// get source node
- Node node = getSourceNode(pageContext, visualNode, data);
+ Node node = getSourceNode(pageContext, visualNode, elementData);
if (node == null)
return false;
@@ -201,7 +205,7 @@
node.setNodeValue(newValue);
// set selection
- setSourceNodeSelection(pageContext, node, startOffset + 1, 0);
+ setSourceSelection(pageContext, node, startOffset + 1, 0);
}
return true;
@@ -237,8 +241,7 @@
protected boolean handleRightDelete(VpePageContext pageContext,
nsIDOMKeyEvent keyEvent) {
// get selection
- nsISelection selection = pageContext.getEditPart().getController()
- .getXulRunnerEditor().getSelection();
+ nsISelection selection = getCurrentSelection(pageContext);
// get visual node which is focused
nsIDOMNode visualNode = selection.getFocusNode();
@@ -246,17 +249,17 @@
VpeElementMapping elementMapping = getElmentMapping(pageContext,
visualNode);
- if (elementMapping == null || elementMapping.getData() == null) {
+ if (elementMapping == null || elementMapping.getElementData() == null) {
return false;
}
- Object data = elementMapping.getData();
+ VpeElementData elementData = elementMapping.getElementData();
// if node editable
- if (isNodeEditable(pageContext, visualNode, data)) {
+ if (isNodeEditable(pageContext, visualNode, elementData)) {
// get source node
- Node node = getSourceNode(pageContext, visualNode, data);
+ Node node = getSourceNode(pageContext, visualNode, elementData);
if (node == null)
return false;
@@ -301,7 +304,7 @@
node.setNodeValue(newValue);
// set new selection
- setSourceNodeSelection(pageContext, node, startOffset, 0);
+ setSourceSelection(pageContext, node, startOffset, 0);
}
@@ -323,8 +326,7 @@
nsIDOMKeyEvent keyEvent) {
// get selection
- nsISelection selection = pageContext.getEditPart().getController()
- .getXulRunnerEditor().getSelection();
+ nsISelection selection = getCurrentSelection(pageContext);
// get visual node which is focused
nsIDOMNode visualNode = selection.getFocusNode();
@@ -333,17 +335,17 @@
VpeElementMapping elementMapping = getElmentMapping(pageContext,
visualNode);
- if (elementMapping == null || elementMapping.getData() == null) {
+ if (elementMapping == null || elementMapping.getElementData() == null) {
return false;
}
- Object data = elementMapping.getData();
+ VpeElementData elementData = elementMapping.getElementData();
// if node editable
- if (isNodeEditable(pageContext, visualNode, data)) {
+ if (isNodeEditable(pageContext, visualNode, elementData)) {
// get source node
- Node node = getSourceNode(pageContext, visualNode, data);
+ Node node = getSourceNode(pageContext, visualNode, elementData);
if (node == null)
return false;
@@ -386,7 +388,7 @@
node.setNodeValue(newValue);
// set new selection
- setSourceNodeSelection(pageContext, node, startOffset, 0);
+ setSourceSelection(pageContext, node, startOffset, 0);
}
@@ -456,8 +458,7 @@
nsIDOMKeyEvent keyEvent) {
// get selection
- nsISelection selection = pageContext.getEditPart().getController()
- .getXulRunnerEditor().getSelection();
+ nsISelection selection = getCurrentSelection(pageContext);
// get visual node which is focused
nsIDOMNode visualNode = selection.getFocusNode();
@@ -465,27 +466,28 @@
VpeElementMapping elementMapping = getElmentMapping(pageContext,
visualNode);
- if (elementMapping == null || elementMapping.getData() == null) {
+ if (elementMapping == null || elementMapping.getElementData() == null) {
return false;
}
- Object data = elementMapping.getData();
+ VpeElementData elementData = elementMapping.getElementData();
- // if node editable
- if (isNodeEditable(pageContext, visualNode, data)) {
+ // get source node
+ Node node = getSourceNode(pageContext, visualNode, elementData);
- // get source node
- Node node = getSourceNode(pageContext, visualNode, data);
+ if (node == null)
+ return false;
- if (node == null)
- return false;
+ // get focus and anchor offsets
+ int focusOffset = selection.getFocusOffset();
- // get focus and anchor offsets
- int focusOffset = selection.getFocusOffset();
+ // if node editable
+ if (isNodeEditable(pageContext, visualNode, elementData)) {
if (focusOffset != node.getNodeValue().length()) {
- setSourceNodeSelection(pageContext, node, focusOffset + 1, 0);
- }
+ setSourceSelection(pageContext, node, focusOffset + 1, 0);
+ } else
+ setSourceSelection(pageContext, node, focusOffset, 0);
}
return true;
@@ -522,8 +524,7 @@
nsIDOMKeyEvent keyEvent) {
// get selection
- nsISelection selection = pageContext.getEditPart().getController()
- .getXulRunnerEditor().getSelection();
+ nsISelection selection = getCurrentSelection(pageContext);
// get visual node which is focused
nsIDOMNode visualNode = selection.getFocusNode();
@@ -531,17 +532,17 @@
VpeElementMapping elementMapping = getElmentMapping(pageContext,
visualNode);
- if (elementMapping == null || elementMapping.getData() == null) {
+ if (elementMapping == null || elementMapping.getElementData() == null) {
return false;
}
- Object data = elementMapping.getData();
+ VpeElementData elementData = elementMapping.getElementData();
// if node editable
- if (isNodeEditable(pageContext, visualNode, data)) {
+ if (isNodeEditable(pageContext, visualNode, elementData)) {
// get source node
- Node node = getSourceNode(pageContext, visualNode, data);
+ Node node = getSourceNode(pageContext, visualNode, elementData);
if (node == null)
return false;
@@ -550,7 +551,7 @@
int focusOffset = selection.getFocusOffset();
if (focusOffset != 0) {
- setSourceNodeSelection(pageContext, node, focusOffset - 1, 0);
+ setSourceSelection(pageContext, node, focusOffset - 1, 0);
}
}
return true;
@@ -569,7 +570,7 @@
*/
protected boolean handleEnter(VpePageContext pageContext,
nsIDOMKeyEvent keyEvent) {
- return false;
+ return true;
}
/*
@@ -577,63 +578,98 @@
*
* @see org.jboss.tools.vpe.editor.template.VpeTemplateNodesManager#getSourceNode(org.jboss.tools.vpe.editor.context.VpePageContext,
* org.mozilla.interfaces.nsIDOMNode)
- */public Node getSourceNode(VpePageContext pageContext,
- nsIDOMNode visualNode, Object data) {
+ */
+ public Node getSourceNode(VpePageContext pageContext,
+ nsIDOMNode visualNode, VpeElementData elementData) {
- if ((data != null) && (data instanceof List)) {
+ if ((elementData != null) && (elementData.getAttributesData() != null)) {
- List<VpeNodeMapping> attributesMapping = (List<VpeNodeMapping>) data;
+ List<VpeAttributeData> attributesMapping = elementData
+ .getAttributesData();
- for (VpeNodeMapping mapping : attributesMapping) {
+ for (VpeAttributeData attributeData : attributesMapping) {
- if (mapping.getVisualNode().equals(visualNode))
- return mapping.getSourceNode();
-
+ if (attributeData.getVisualAttr().equals(visualNode))
+ return attributeData.getSourceAttr();
}
-
}
return null;
}
+ /**
+ *
+ * @param pageContext
+ * @param node
+ * @param elementData
+ * @return
+ */
public nsIDOMNode getVisualNode(VpePageContext pageContext, Node node,
- Object data) {
- if ((data != null) && (data instanceof List)) {
+ VpeElementData elementData) {
- List<VpeNodeMapping> attributesMapping = (List<VpeNodeMapping>) data;
- for (VpeNodeMapping mapping : attributesMapping) {
- if (mapping.getSourceNode().equals(node))
- return (nsIDOMText) mapping.getVisualNode();
+ if ((elementData != null) && (elementData.getAttributesData() != null)) {
+
+ List<VpeAttributeData> attributesMapping = elementData
+ .getAttributesData();
+
+ for (VpeAttributeData attributeData : attributesMapping) {
+ if (attributeData.getSourceAttr().equals(node))
+ return attributeData.getVisualAttr();
}
}
return null;
}
+ /**
+ *
+ * @param pageContext
+ * @param visualNode
+ * @param elementData
+ * @return
+ */
public boolean isNodeEditable(VpePageContext pageContext,
- nsIDOMNode visualNode, Object data) {
+ nsIDOMNode visualNode, VpeElementData elementData) {
- if ((data != null) && (data instanceof List)) {
+ if ((elementData != null) && (elementData.getAttributesData() != null)) {
- List<VpeNodeMapping> attributesMapping = (List<VpeNodeMapping>) data;
+ List<VpeAttributeData> attributesMapping = elementData
+ .getAttributesData();
- for (VpeNodeMapping mapping : attributesMapping) {
+ for (VpeAttributeData attributeData : attributesMapping) {
- if (mapping.getVisualNode().equals(visualNode))
- return true;
+ if (attributeData.getVisualAttr().equals(visualNode))
+ return attributeData.isEditable();
}
}
return false;
}
- /*
- * (non-Javadoc)
+ public boolean isNodeEditable(VpePageContext pageContext, Node node,
+ VpeElementData elementData) {
+ if ((elementData != null) && (elementData.getAttributesData() != null)) {
+
+ List<VpeAttributeData> attributesMapping = elementData
+ .getAttributesData();
+
+ for (VpeAttributeData attributeData : attributesMapping) {
+
+ if (attributeData.getSourceAttr().equals(node))
+ return attributeData.isEditable();
+ }
+ }
+ return false;
+ }
+
+ /**
*
- * @see org.jboss.tools.vpe.editor.template.VpeTemplateNodesManager#setSourceNodeSelection(org.jboss.tools.vpe.editor.context.VpePageContext,
- * org.w3c.dom.Node, int, int)
+ * @param pageContext
+ * @param node
+ * @param offset
+ * @param length
*/
- public void setSourceNodeSelection(VpePageContext pageContext, Node node,
+ protected void setSourceSelection(VpePageContext pageContext, Node node,
int offset, int length) {
- int start = getStartOffsetNode(node) + 1;
+ int start = getStartOffsetNode(node) ;
pageContext.getSourceBuilder().getStructuredTextViewer()
.setSelectedRange(start + offset, length);
@@ -645,20 +681,122 @@
/*
* (non-Javadoc)
*
+ * @see org.jboss.tools.vpe.editor.template.ITemplateSelectionManager#setSelection(org.jboss.tools.vpe.editor.context.VpePageContext,
+ * org.mozilla.interfaces.nsISelection)
+ */
+ public void setSelection(VpePageContext pageContext, nsISelection selection) {
+
+ nsIDOMNode focusedVisualNode = selection.getFocusNode();
+
+ VpeElementMapping elementMapping = pageContext.getDomMapping()
+ .getNearElementMapping(focusedVisualNode);
+
+ int focusOffset = selection.getFocusOffset();
+ int anchorOffset = selection.getAnchorOffset();
+
+ boolean isEditable = isNodeEditable(pageContext, focusedVisualNode,
+ elementMapping.getElementData());
+
+ Node focusedSourceNode = getSourceNode(pageContext, focusedVisualNode,
+ elementMapping.getElementData());
+
+ if (focusedSourceNode == null)
+ focusedSourceNode = elementMapping.getSourceNode();
+ if (isEditable)
+ setSourceSelection(pageContext, focusedSourceNode, focusOffset,
+ anchorOffset - focusOffset);
+ else
+ setSourceSelection(pageContext, focusedSourceNode, 0,
+ getLengthNode(focusedSourceNode));
+
+ if (focusedVisualNode.getNodeType() != nsIDOMNode.ELEMENT_NODE)
+ focusedVisualNode = focusedVisualNode.getParentNode();
+
+ pageContext.getVisualBuilder().setSelectionRectangle(
+ (nsIDOMElement) focusedVisualNode
+ .queryInterface(nsIDOMElement.NS_IDOMELEMENT_IID));
+
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.jboss.tools.vpe.editor.template.ITemplateSelectionManager#setVisualSelectionBySource(org.jboss.tools.vpe.editor.context.VpePageContext,
+ * int, int)
+ */
+ public void setVisualSelectionBySource(VpePageContext pageContext,
+ VpeSelectionController selectionController, int focus, int anchor) {
+
+ // get source node
+ Node sourceNode = TemplateManagingUtil.getSourceNodeByPosition(
+ pageContext, focus);
+
+ // get element mapping
+ VpeElementMapping elementMapping = pageContext.getDomMapping()
+ .getNearElementMapping(sourceNode);
+
+ // get focused attribute
+ Node focusNode = getFocusedNode(sourceNode, elementMapping
+ .getElementData(), focus);
+
+ Node anchorNode = getFocusedNode(sourceNode, elementMapping
+ .getElementData(), anchor);
+
+ int visualFocus = 0;
+ int visualAnchor = 0;
+ nsIDOMNode visualNode = null;
+ nsIDOMNode visualParent = null;
+ if (focusNode == anchorNode) {
+
+ visualNode = getVisualNode(pageContext, focusNode, elementMapping
+ .getElementData());
+ if (visualNode != null) {
+ visualParent = (nsIDOMNode) visualNode.getParentNode()
+ .queryInterface(nsIDOMElement.NS_IDOMELEMENT_IID);
+ String text = focusNode.getNodeValue();
+ int start = getStartOffsetNode(focusNode);
+ focus = focus - start;
+ anchor = anchor - start;
+ visualFocus = TextUtil.visualInnerPosition(text, focus);
+ visualAnchor = TextUtil.visualInnerPosition(text, anchor);
+ }
+
+ }
+
+ if (visualNode == null) {
+ visualParent = visualNode = elementMapping.getVisualNode();
+
+ }
+ nsISelection selection = selectionController
+ .getSelection(nsISelectionController.SELECTION_NORMAL);
+
+ selection.collapse(visualNode, visualFocus);
+
+ // selection.extend(visualNode, visualAnchor - visualFocus);
+ pageContext.getVisualBuilder().setSelectionRectangle(
+ (nsIDOMElement) visualParent);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
* @see org.jboss.tools.vpe.editor.template.VpeTemplateNodesManager#getFocusedNode(org.w3c.dom.Node,
* int)
*/
- public Node getFocusedNode(Node sourceNode, int offset, Object data) {
+ public Node getFocusedNode(Node sourceNode, VpeElementData elementData,
+ int offset) {
- if ((data != null) && (data instanceof List)) {
+ if ((elementData != null) && (elementData.getAttributesData() != null)) {
- List<VpeNodeMapping> attributesMapping = (List<VpeNodeMapping>) data;
+ List<VpeAttributeData> attributesMapping = elementData
+ .getAttributesData();
- for (VpeNodeMapping mapping : attributesMapping) {
+ for (VpeAttributeData attributeData : attributesMapping) {
- if ((offset > (getStartOffsetNode(mapping.getSourceNode()) + 1))
- && (offset < (getEndOffsetNode(mapping.getSourceNode()) - 1)))
- return mapping.getSourceNode();
+ if ((offset > (getStartOffsetNode(attributeData.getSourceAttr())))
+ && (offset < (getEndOffsetNode(attributeData
+ .getSourceAttr()))))
+ return attributeData.getSourceAttr();
}
}
@@ -671,10 +809,10 @@
* @param node
* @return
*/
- private int getStartOffsetNode(Node node) {
+ protected int getStartOffsetNode(Node node) {
if (node instanceof IDOMAttr) {
- return ((IDOMAttr) node).getValueRegionStartOffset();
+ return ((IDOMAttr) node).getValueRegionStartOffset()+1;
} else if (node instanceof IndexedRegion) {
return ((IndexedRegion) node).getStartOffset();
}
@@ -682,12 +820,28 @@
}
/**
+ *
+ * @param node
+ * @return
+ */
+ protected int getLengthNode(Node node) {
+
+ if (node instanceof IDOMAttr) {
+ return ((IDOMAttr) node).getValueSource().length();
+ } else if (node instanceof IndexedRegion) {
+ return ((IndexedRegion) node).getStartOffset()
+ - ((IndexedRegion) node).getEndOffset();
+ }
+ return 0;
+ }
+
+ /**
* get end offset of node
*
* @param node
* @return
*/
- private int getEndOffsetNode(Node node) {
+ protected int getEndOffsetNode(Node node) {
if (node instanceof IndexedRegion) {
return ((IndexedRegion) node).getEndOffset();
@@ -695,10 +849,13 @@
return 0;
}
+ /**
+ *
+ */
public boolean openBundle(VpePageContext pageContext,
- nsIDOMNode visualNode, Object data) {
+ nsIDOMNode visualNode, VpeElementData elementData) {
- Node node = getSourceNode(pageContext, visualNode, data);
+ Node node = getSourceNode(pageContext, visualNode, elementData);
// so as nsIDOMMouseEvent doesn't give simple selected nsIDOMText as
// target, but nsiSelection can give simple "text"
@@ -712,7 +869,7 @@
// get visual node which is focused
nsIDOMNode tempNode = selection.getFocusNode();
- node = getSourceNode(pageContext, tempNode, data);
+ node = getSourceNode(pageContext, tempNode, elementData);
}
@@ -750,10 +907,21 @@
}
- private VpeElementMapping getElmentMapping(VpePageContext pageContext,
+ /**
+ *
+ * @param pageContext
+ * @param node
+ * @return
+ */
+ protected VpeElementMapping getElmentMapping(VpePageContext pageContext,
nsIDOMNode node) {
return pageContext.getDomMapping().getNearElementMapping(node);
}
+
+ protected nsISelection getCurrentSelection(VpePageContext pageContext) {
+ return pageContext.getEditPart().getController().getXulRunnerEditor()
+ .getSelection();
+ }
}
Added: trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/ITemplateKeyEventHandler.java
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/ITemplateKeyEventHandler.java (rev 0)
+++ trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/ITemplateKeyEventHandler.java 2008-03-07 19:03:33 UTC (rev 6789)
@@ -0,0 +1,35 @@
+/*******************************************************************************
+ * 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.template;
+
+import org.jboss.tools.vpe.editor.context.VpePageContext;
+import org.mozilla.interfaces.nsIDOMKeyEvent;
+
+/**
+ * interface for handling of keyEvent by himself template
+ *
+ * @author Sergey Dzmitrovich
+ *
+ */
+public interface ITemplateKeyEventHandler {
+
+ /**
+ * handle keyEvent
+ *
+ * @param pageContext
+ * @param keyEvent -
+ * happens when element of current template is selected and
+ * is pressed key
+ * @return
+ */
+ boolean handleKeyPress(VpePageContext pageContext, nsIDOMKeyEvent keyEvent);
+
+}
Copied: trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/ITemplateNodesManager.java (from rev 6668, trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeTemplateNodesManager.java)
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/ITemplateNodesManager.java (rev 0)
+++ trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/ITemplateNodesManager.java 2008-03-07 19:03:33 UTC (rev 6789)
@@ -0,0 +1,88 @@
+/*******************************************************************************
+ * 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.template;
+
+import org.jboss.tools.vpe.editor.context.VpePageContext;
+import org.jboss.tools.vpe.editor.mapping.VpeElementData;
+import org.mozilla.interfaces.nsIDOMNode;
+import org.w3c.dom.Node;
+
+/**
+ * Interface for editing of attributes of a template
+ *
+ * @author Sergey Dzmitrovich
+ *
+ */
+public interface ITemplateNodesManager {
+
+ /**
+ * @param pageContext -
+ * context of vpe
+ * @param visualNode -
+ * selected visual node
+ *
+ * @return true if selected attribute is editable
+ */
+ public boolean isNodeEditable(VpePageContext pageContext,
+ nsIDOMNode visualNode, VpeElementData elementData);
+
+ /**
+ *
+ * @param pageContext
+ * @param node
+ * @param elementData
+ * @return
+ */
+ public boolean isNodeEditable(VpePageContext pageContext, Node node,
+ VpeElementData elementData);
+
+ /**
+ * get visual element of attribute from source element
+ *
+ * @param pageContext
+ * @param attr
+ * @param data
+ * @return
+ */
+ public nsIDOMNode getVisualNode(VpePageContext pageContext, Node node,
+ VpeElementData elementData);
+
+ /**
+ * get source element of attribute from visual element
+ *
+ * @param pageContext
+ * @param visualNode
+ * @param data
+ * @return
+ */
+ public Node getSourceNode(VpePageContext pageContext,
+ nsIDOMNode visualNode, VpeElementData elementData);
+
+ /**
+ * get sourceNode by offset
+ *
+ * @param sourceNode
+ * @param offset
+ * @return
+ */
+ public Node getFocusedNode(Node sourceNode, VpeElementData elementData,
+ int offset);
+
+ /**
+ * open bundle
+ *
+ * @param pageContext
+ * @param visualNod
+ * @return
+ */
+ boolean openBundle(VpePageContext pageContext, nsIDOMNode visualNode,
+ VpeElementData elementData);
+}
Added: trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/ITemplateSelectionManager.java
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/ITemplateSelectionManager.java (rev 0)
+++ trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/ITemplateSelectionManager.java 2008-03-07 19:03:33 UTC (rev 6789)
@@ -0,0 +1,42 @@
+/*******************************************************************************
+ * 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.template;
+
+import org.jboss.tools.vpe.editor.context.VpePageContext;
+import org.jboss.tools.vpe.editor.selection.VpeSelectionController;
+import org.mozilla.interfaces.nsISelection;
+
+/**
+ *
+ * interface for template selection
+ *
+ * @author Sergey Dzmitrovich
+ */
+public interface ITemplateSelectionManager {
+
+ /**
+ * selection
+ *
+ * @param pageContext
+ * @param selection
+ */
+ public void setSelection(VpePageContext pageContext, nsISelection selection);
+
+ /**
+ * select visual element by source selection
+ *
+ * @param pageContext
+ * @return true if visual element was selected
+ */
+ public void setVisualSelectionBySource(VpePageContext pageContext,
+ VpeSelectionController selectionController, int focus, int anchor);
+
+}
Modified: trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeAbstractTemplate.java
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeAbstractTemplate.java 2008-03-07 17:06:05 UTC (rev 6788)
+++ trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeAbstractTemplate.java 2008-03-07 19:03:33 UTC (rev 6789)
@@ -738,10 +738,14 @@
return children;
}
- boolean isModify() {
+ public boolean isModify() {
return modify;
}
+ public void setModify(boolean modify) {
+ this.modify = modify;
+ }
+
/**
* @return <code>true</code> if the element is case sensitive
*/
Modified: trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeCreationData.java
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeCreationData.java 2008-03-07 17:06:05 UTC (rev 6788)
+++ trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeCreationData.java 2008-03-07 19:03:33 UTC (rev 6789)
@@ -14,6 +14,7 @@
import java.util.List;
import org.jboss.tools.common.model.util.XMLUtil;
+import org.jboss.tools.vpe.editor.mapping.VpeElementData;
import org.jboss.tools.vpe.editor.util.VpeDebugUtil;
import org.jboss.tools.vpe.editor.util.XmlUtil;
import org.mozilla.interfaces.nsIDOMNode;
@@ -23,7 +24,13 @@
private nsIDOMNode node;
private List<VpeChildrenInfo> childrenInfoList;
private List<Node> illegalChildren;
+
+ /**
+ * @deprecated - You must use elementData. If VpeElementData has not
+ * necessary functionality you must extend its
+ */
private Object data;
+ private VpeElementData elementData;
public VpeCreationData(nsIDOMNode node) {
this.node = node;
@@ -55,15 +62,41 @@
return illegalChildren;
}
+ /**
+ * @deprecated - You must use elementData. If VpeElementData has not
+ * necessary functionality you must extend its
+ * @param data
+ */
public void setData(Object data) {
this.data = data;
}
-
+
+ /**
+ * @deprecated - You must use elementData. If VpeElementData has not
+ * necessary functionality you must extend its
+ * @return
+ */
public Object getData() {
return data;
}
/**
+ * get element data
+ * @return
+ */
+ public VpeElementData getElementData() {
+ return elementData;
+ }
+
+ /**
+ * set element data
+ * @param elementData
+ */
+ public void setElementData(VpeElementData elementData) {
+ this.elementData = elementData;
+ }
+
+ /**
* Added method for creation copy which will
* placed in cash to improve perfomance of VPE
* Added by Max Areshkau JBIDE-675.
@@ -90,6 +123,8 @@
}
data.illegalChildren =this.illegalChildren;
data.data = this.data;
+ data.elementData = this.elementData;
return data;
}
+
}
Modified: trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeTemplate.java
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeTemplate.java 2008-03-07 17:06:05 UTC (rev 6788)
+++ trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeTemplate.java 2008-03-07 19:03:33 UTC (rev 6789)
@@ -464,4 +464,9 @@
nsIDOMNode visualContainer, nsIDOMDocument visualDocument);
boolean containsText();
+
+ public boolean isModify();
+
+ public void setModify(boolean modify);
+
}
\ No newline at end of file
Deleted: trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeTemplateKeyEventHandler.java
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeTemplateKeyEventHandler.java 2008-03-07 17:06:05 UTC (rev 6788)
+++ trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeTemplateKeyEventHandler.java 2008-03-07 19:03:33 UTC (rev 6789)
@@ -1,35 +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.template;
-
-import org.jboss.tools.vpe.editor.context.VpePageContext;
-import org.mozilla.interfaces.nsIDOMKeyEvent;
-
-/**
- * interface for handling of keyEvent by himself template
- *
- * @author Sergey Dzmitrovich
- *
- */
-public interface VpeTemplateKeyEventHandler {
-
- /**
- * handle keyEvent
- *
- * @param pageContext
- * @param keyEvent -
- * happens when element of current template is selected and
- * is pressed key
- * @return
- */
- boolean handleKeyPress(VpePageContext pageContext, nsIDOMKeyEvent keyEvent);
-
-}
Deleted: trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeTemplateNodesManager.java
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeTemplateNodesManager.java 2008-03-07 17:06:05 UTC (rev 6788)
+++ trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeTemplateNodesManager.java 2008-03-07 19:03:33 UTC (rev 6789)
@@ -1,91 +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.template;
-
-import org.jboss.tools.vpe.editor.context.VpePageContext;
-import org.mozilla.interfaces.nsIDOMNode;
-import org.w3c.dom.Node;
-
-/**
- * Interface for editing of attributes of a template
- *
- * @author Sergey Dzmitrovich
- *
- */
-public interface VpeTemplateNodesManager {
-
- /**
- * @param pageContext -
- * context of vpe
- * @param visualNode -
- * selected visual node
- *
- * @return true if selected attribute is editable
- */
- public boolean isNodeEditable(VpePageContext pageContext,
- nsIDOMNode visualNode, Object data);
-
- /**
- * set attribute in sourceEditor
- *
- * @param pageContext -
- * context of vpe
- * @param attr -
- * attribute
- * @param focusOffset -
- * focus offset
- * @param length -
- * length of selection
- *
- */
- public void setSourceNodeSelection(VpePageContext pageContext, Node node,
- int focusOffset, int length);
-
- /**
- * get visual element of attribute from source element
- *
- * @param pageContext
- * @param attr
- * @param data
- * @return
- */
- public nsIDOMNode getVisualNode(VpePageContext pageContext, Node node,
- Object data);
-
- /**
- * get source element of attribute from visual element
- *
- * @param pageContext
- * @param visualNode
- * @param data
- * @return
- */
- public Node getSourceNode(VpePageContext pageContext,
- nsIDOMNode visualNode, Object data);
-
- /**
- * get sourceNode by offset
- *
- * @param sourceNode
- * @param offset
- * @return
- */
- public Node getFocusedNode(Node sourceNode, int offset, Object data);
-
- /**
- * open bundle
- *
- * @param pageContext
- * @param visualNod
- * @return
- */
- boolean openBundle(VpePageContext pageContext, nsIDOMNode visualNode, Object data);
-}
Added: 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 (rev 0)
+++ trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/TemplateManagingUtil.java 2008-03-07 19:03:33 UTC (rev 6789)
@@ -0,0 +1,130 @@
+/*******************************************************************************
+ * 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.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.w3c.dom.Node;
+
+public class TemplateManagingUtil {
+
+ /**
+ * get template of selected element
+ *
+ * @param pageContext
+ * @return
+ */
+ public static VpeTemplate getTemplateByVisualSelection(
+ VpePageContext pageContext) {
+ // get element mapping
+ VpeElementMapping elementMapping = pageContext.getDomMapping()
+ .getNearElementMapping(getVisualSelectedNode(pageContext));
+
+ if (elementMapping != null)
+ return elementMapping.getTemplate();
+
+ // 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(getVisualSelectedNode(pageContext));
+
+ 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 source node by ofsset
+ Node sourceNode = getSourceNodeByPosition(pageContext, mappingNode
+ .getStartOffset());
+ // find elementMapping by source node
+ if (sourceNode != null) {
+ VpeElementMapping mapping = pageContext.getDomMapping()
+ .getNearElementMapping(sourceNode);
+ if (mapping != null)
+ return mapping.getTemplate();
+ }
+
+ }
+
+ return null;
+ }
+
+ /**
+ *
+ * @param pageContext
+ * @param focus
+ * @param anchor
+ * @return
+ */
+ public static VpeTemplate getTemplateBySourceSelection(
+ VpePageContext pageContext, int focus, int anchor) {
+
+ // get source node by ofsset
+ Node focusNode = getSourceNodeByPosition(pageContext, focus);
+ // if focus node also contain anchor point (selected only 1 element)
+ if ((anchor <= ((IDOMNode) focusNode).getEndOffset())
+ && (anchor >= ((IDOMNode) focusNode).getStartOffset())) {
+
+ VpeElementMapping elementMapping = pageContext.getDomMapping()
+ .getNearElementMapping(focusNode);
+
+ if (elementMapping != null)
+ return elementMapping.getTemplate();
+
+ }
+ return null;
+
+ }
+
+ /**
+ * get source node by position
+ *
+ * @param pageContext
+ * @param position
+ * @return
+ */
+ public static Node getSourceNodeByPosition(VpePageContext pageContext,
+ int position) {
+
+ // get document
+ IDOMDocument document = (IDOMDocument) pageContext.getSourceBuilder()
+ .getSourceDocument();
+
+ // get source node by position
+ return (Node) document.getModel().getIndexedRegion(position);
+
+ }
+
+ /**
+ * get selected element
+ *
+ * @param pageContext
+ * @return
+ */
+ private static nsIDOMElement getVisualSelectedNode(
+ VpePageContext pageContext) {
+
+ return pageContext.getEditPart().getController().getXulRunnerEditor()
+ .getLastSelectedElement();
+ }
+
+}
18 years, 1 month
JBoss Tools SVN: r6788 - trunk/hibernatetools/docs/resources/styles/en.
by jbosstools-commits@lists.jboss.org
Author: smukhina
Date: 2008-03-07 12:06:05 -0500 (Fri, 07 Mar 2008)
New Revision: 6788
Removed:
trunk/hibernatetools/docs/resources/styles/en/highlight.xsl
Log:
http://jira.jboss.com/jira/browse/JBIDE-1703
now the highlighter is taken from online resource
Deleted: trunk/hibernatetools/docs/resources/styles/en/highlight.xsl
===================================================================
--- trunk/hibernatetools/docs/resources/styles/en/highlight.xsl 2008-03-07 16:55:45 UTC (rev 6787)
+++ trunk/hibernatetools/docs/resources/styles/en/highlight.xsl 2008-03-07 17:06:05 UTC (rev 6788)
@@ -1,18 +0,0 @@
-<!DOCTYPE xsl:stylesheet>
-<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
- version="1.0" xmlns="http://www.w3.org/TR/xhtml1/transitional"
- exclude-result-prefixes="#default">
-
- <xsl:template match="programlisting[@role='XML']|programlisting[@role='JAVA']|programlisting[@role='XHTML']|programlisting[@role='JSP']">
- <xsl:variable name="kidz">
- <xsl:apply-templates></xsl:apply-templates>
- </xsl:variable>
- <pre class="{@role}">
- <xsl:value-of
- select="javahl:highlight(string($kidz), attribute::role)"
- xmlns:javahl="java:com.exadel.docbook.colorer.HighLighter"
- disable-output-escaping="yes"/>
- </pre>
- </xsl:template>
-
-</xsl:stylesheet>
18 years, 1 month