JBoss Tools SVN: r3842 - trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/modules.
by jbosstools-commits@lists.jboss.org
Author: rob.stryker(a)jboss.com
Date: 2007-09-27 00:34:36 -0400 (Thu, 27 Sep 2007)
New Revision: 3842
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/modules/PackageModuleFactory.java
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/modules/SingleDeployableFactory.java
Log:
unused single-file modules are automatically removed as modules, keeping the UI clean!
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/modules/PackageModuleFactory.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/modules/PackageModuleFactory.java 2007-09-27 03:03:22 UTC (rev 3841)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/modules/PackageModuleFactory.java 2007-09-27 04:34:36 UTC (rev 3842)
@@ -161,8 +161,10 @@
protected IModuleContributor[] moduleContributors;
public PackageModuleFactory() {
super();
+ }
+
+ public void initialize() {
moduleContributors = new IModuleContributor[] { ArchivesModelModuleContributor.getInstance() };
-
}
protected IModule createModule2(IArchive pack, IProject project) {
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/modules/SingleDeployableFactory.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/modules/SingleDeployableFactory.java 2007-09-27 03:03:22 UTC (rev 3841)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/modules/SingleDeployableFactory.java 2007-09-27 04:34:36 UTC (rev 3842)
@@ -13,6 +13,8 @@
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Status;
import org.eclipse.wst.server.core.IModule;
+import org.eclipse.wst.server.core.IServer;
+import org.eclipse.wst.server.core.ServerCore;
import org.eclipse.wst.server.core.internal.ModuleFactory;
import org.eclipse.wst.server.core.internal.ModuleFile;
import org.eclipse.wst.server.core.internal.ServerPlugin;
@@ -20,6 +22,8 @@
import org.eclipse.wst.server.core.model.ModuleDelegate;
import org.eclipse.wst.server.core.model.ModuleFactoryDelegate;
import org.jboss.ide.eclipse.as.core.JBossServerCorePlugin;
+import org.jboss.ide.eclipse.as.core.server.UnitedServerListener;
+import org.jboss.ide.eclipse.as.core.server.UnitedServerListenerManager;
public class SingleDeployableFactory extends ModuleFactoryDelegate {
public static final String FACTORY_ID = "org.jboss.ide.eclipse.as.core.singledeployablefactory";
@@ -79,8 +83,12 @@
private HashMap<IPath, IModule> moduleIdToModule;
private HashMap<IModule, SingleDeployableModuleDelegate> moduleToDelegate;
public SingleDeployableFactory() {
+ }
+
+ public void initialize() {
moduleIdToModule = new HashMap<IPath, IModule>();
moduleToDelegate = new HashMap<IModule, SingleDeployableModuleDelegate>();
+ registerListener();
String files = JBossServerCorePlugin.getDefault().getPluginPreferences().getString(PREFERENCE_KEY);
if( files.equals("")) return;
String[] files2 = files.split(DELIM);
@@ -89,6 +97,34 @@
}
}
+ protected void registerListener() {
+ UnitedServerListenerManager.getDefault().addListener(new UnitedServerListener() {
+ public void publishFinished(IServer server, IStatus status) {
+ cleanUnusedModules();
+ }
+ });
+ }
+
+ protected void cleanUnusedModules() {
+ IModule[] mods = getModules();
+ IServer[] servers = ServerCore.getServers();
+ for( int i = 0; i < mods.length; i++ ) {
+ boolean used = false;
+ for( int j = 0; j < servers.length && !used; j++ ) {
+ IModule[] modsInner = servers[i].getModules();
+ for( int k = 0; k < modsInner.length && !used; k++ ) {
+ if( mods[i].equals(modsInner[k]))
+ used = true;
+ }
+ }
+ if( !used ) {
+ SingleDeployableModuleDelegate delegate = (SingleDeployableModuleDelegate)
+ mods[i].loadAdapter(SingleDeployableModuleDelegate.class, new NullProgressMonitor());
+ unmakeDeployable(delegate.getWorkspaceRelativePath());
+ }
+ }
+ }
+
public IModule getModule(IPath path) {
return moduleIdToModule.get(path);
}
@@ -131,7 +167,9 @@
public class SingleDeployableModuleDelegate extends ModuleDelegate {
private IPath global;
+ private IPath workspaceRelative;
public SingleDeployableModuleDelegate(IPath workspaceRelative) {
+ this.workspaceRelative = workspaceRelative;
global = ResourcesPlugin.getWorkspace().getRoot().getLocation().append(workspaceRelative);
}
public IModule[] getChildModules() {
@@ -152,5 +190,9 @@
public IPath getGlobalSourcePath() {
return this.global;
}
+
+ public IPath getWorkspaceRelativePath() {
+ return workspaceRelative;
+ }
}
}
17 years, 3 months
JBoss Tools SVN: r3841 - in trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/server: providers and 1 other directories.
by jbosstools-commits@lists.jboss.org
Author: rob.stryker(a)jboss.com
Date: 2007-09-26 23:03:22 -0400 (Wed, 26 Sep 2007)
New Revision: 3841
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/server/ExtensionTableViewer.java
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/server/providers/ModuleViewProvider.java
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/server/providers/jmx/JMXViewProvider.java
Log:
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/server/ExtensionTableViewer.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/server/ExtensionTableViewer.java 2007-09-27 03:03:19 UTC (rev 3840)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/server/ExtensionTableViewer.java 2007-09-27 03:03:22 UTC (rev 3841)
@@ -28,6 +28,8 @@
import org.eclipse.wst.server.core.IServerLifecycleListener;
import org.eclipse.wst.server.core.ServerCore;
import org.eclipse.wst.server.ui.ServerUICore;
+import org.jboss.ide.eclipse.as.core.server.UnitedServerListener;
+import org.jboss.ide.eclipse.as.core.server.UnitedServerListenerManager;
import org.jboss.ide.eclipse.as.core.server.internal.JBossServer;
import org.jboss.ide.eclipse.as.ui.JBossServerUIPlugin;
import org.jboss.ide.eclipse.as.ui.Messages;
@@ -47,14 +49,8 @@
setLabelProvider(new LabelProviderDelegator());
propertySheet = new TableViewerPropertySheet();
createActions();
- ServerCore.addServerLifecycleListener(new IServerLifecycleListener() {
-
- public void serverAdded(IServer server) {
- }
-
- public void serverChanged(IServer server) {
- }
-
+
+ UnitedServerListenerManager.getDefault().addListener(new UnitedServerListener() {
public void serverRemoved(IServer server) {
final IServer server2 = server;
Display.getDefault().asyncExec(new Runnable() {
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/server/providers/ModuleViewProvider.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/server/providers/ModuleViewProvider.java 2007-09-27 03:03:19 UTC (rev 3840)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/server/providers/ModuleViewProvider.java 2007-09-27 03:03:22 UTC (rev 3841)
@@ -42,14 +42,14 @@
import org.eclipse.wst.server.core.IServerLifecycleListener;
import org.eclipse.wst.server.core.IServerListener;
import org.eclipse.wst.server.core.IServerWorkingCopy;
-import org.eclipse.wst.server.core.ServerCore;
import org.eclipse.wst.server.core.ServerEvent;
import org.eclipse.wst.server.core.ServerUtil;
import org.eclipse.wst.server.core.internal.PublishServerJob;
import org.eclipse.wst.server.core.model.ServerBehaviourDelegate;
import org.eclipse.wst.server.ui.ServerUICore;
import org.eclipse.wst.server.ui.internal.view.servers.ModuleServer;
-import org.jboss.ide.eclipse.as.core.server.internal.JBossServer;
+import org.jboss.ide.eclipse.as.core.server.UnitedServerListener;
+import org.jboss.ide.eclipse.as.core.server.UnitedServerListenerManager;
import org.jboss.ide.eclipse.as.core.util.ServerConverter;
import org.jboss.ide.eclipse.as.ui.JBossServerUISharedImages;
import org.jboss.ide.eclipse.as.ui.Messages;
@@ -275,21 +275,7 @@
}
private void addListeners() {
- serverResourceListener = new IServerLifecycleListener() {
- public void serverAdded(IServer server) {
- if( ServerConverter.getJBossServer(server) != null )
- server.addServerListener(serverListener);
- }
- public void serverChanged(IServer server) {
- }
- public void serverRemoved(IServer server) {
- if( ServerConverter.getJBossServer(server) != null )
- server.removeServerListener(serverListener);
- }
- };
- ServerCore.addServerLifecycleListener(serverResourceListener);
-
- serverListener = new IServerListener() {
+ UnitedServerListenerManager.getDefault().addListener(new UnitedServerListener() {
public void serverChanged(ServerEvent event) {
int eventKind = event.getKind();
if ((eventKind & ServerEvent.MODULE_CHANGE) != 0) {
@@ -298,15 +284,7 @@
refreshViewer();
}
}
- }
- };
- // add listeners to servers
- JBossServer[] servers = ServerConverter.getAllJBossServers();
- if (servers != null) {
- int size = servers.length;
- for (int i = 0; i < size; i++) {
- servers[i].getServer().addServerListener(serverListener);
- }
- }
+ }
+ });
}
}
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/server/providers/jmx/JMXViewProvider.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/server/providers/jmx/JMXViewProvider.java 2007-09-27 03:03:19 UTC (rev 3840)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/server/providers/jmx/JMXViewProvider.java 2007-09-27 03:03:22 UTC (rev 3841)
@@ -9,17 +9,15 @@
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Group;
-import org.eclipse.ui.ISelectionListener;
import org.eclipse.ui.views.properties.IPropertySheetPage;
import org.eclipse.wst.server.core.IServer;
-import org.eclipse.wst.server.core.IServerLifecycleListener;
-import org.eclipse.wst.server.core.IServerListener;
-import org.eclipse.wst.server.core.ServerCore;
import org.eclipse.wst.server.core.ServerEvent;
import org.jboss.ide.eclipse.as.core.extensions.jmx.JMXClassLoaderRepository;
import org.jboss.ide.eclipse.as.core.extensions.jmx.JMXModel;
import org.jboss.ide.eclipse.as.core.extensions.jmx.JMXModel.JMXBean;
import org.jboss.ide.eclipse.as.core.extensions.jmx.JMXModel.JMXDomain;
+import org.jboss.ide.eclipse.as.core.server.UnitedServerListener;
+import org.jboss.ide.eclipse.as.core.server.UnitedServerListenerManager;
import org.jboss.ide.eclipse.as.ui.views.server.JBossServerView;
import org.jboss.ide.eclipse.as.ui.views.server.ExtensionTableViewer.ContentWrapper;
import org.jboss.ide.eclipse.as.ui.views.server.extensions.JBossServerViewExtension;
@@ -34,7 +32,6 @@
public static final Object CLASSLOADING_TOKEN = new Object();
protected JMXPropertySheetPage propertyPage;
- protected JMXServerLifecycleListener lcListener;
protected JMXServerListener serverListener;
protected ISelectionChangedListener jbossServerViewSelectionListener;
protected JMXTreeContentProvider contentProvider;
@@ -78,45 +75,25 @@
// make sure we know about server events
serverListener = new JMXServerListener();
- lcListener = new JMXServerLifecycleListener();
- ServerCore.addServerLifecycleListener(lcListener);
- IServer[] servers = ServerCore.getServers();
- for (int i = 0; i < servers.length; i++) {
- servers[i].addServerListener(serverListener);
- if( servers[i].getServerState() == IServer.STATE_STARTED )
- JMXClassLoaderRepository.getDefault().addConcerned(
- servers[i], CLASSLOADING_TOKEN);
- }
+ UnitedServerListenerManager.getDefault().addListener(serverListener);
}
protected void removeListeners() {
- ServerCore.removeServerLifecycleListener(lcListener);
- IServer[] servers = ServerCore.getServers();
- for (int i = 0; i < servers.length; i++) {
- servers[i].removeServerListener(serverListener);
- JMXClassLoaderRepository.getDefault().removeConcerned(
- servers[i], CLASSLOADING_TOKEN);
- }
+ UnitedServerListenerManager.getDefault().removeListener(serverListener);
JBossServerView.removeExtensionFrameListener(jbossServerViewSelectionListener);
}
- protected class JMXServerLifecycleListener implements
- IServerLifecycleListener {
- public void serverAdded(IServer server) {
- server.addServerListener(serverListener);
+ protected class JMXServerListener extends UnitedServerListener {
+ public void init(IServer server) {
+ if( server.getServerState() == IServer.STATE_STARTED )
+ JMXClassLoaderRepository.getDefault().addConcerned(
+ server, CLASSLOADING_TOKEN);
+
}
-
- public void serverChanged(IServer server) {
- }
-
public void serverRemoved(IServer server) {
- server.removeServerListener(serverListener);
JMXClassLoaderRepository.getDefault()
.removeConcerned(server, JMXModel.getDefault());
}
- }
-
- protected class JMXServerListener implements IServerListener {
public void serverChanged(ServerEvent event) {
if ((event.getKind() & ServerEvent.SERVER_CHANGE) != 0) {
if ((event.getKind() & ServerEvent.STATE_CHANGE) != 0) {
@@ -130,6 +107,10 @@
}
}
}
+ public void cleanUp(IServer server) {
+ JMXClassLoaderRepository.getDefault().removeConcerned(
+ server, CLASSLOADING_TOKEN);
+ }
}
public IPropertySheetPage getPropertySheetPage() {
17 years, 3 months
JBoss Tools SVN: r3840 - in trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core: server and 1 other directory.
by jbosstools-commits@lists.jboss.org
Author: rob.stryker(a)jboss.com
Date: 2007-09-26 23:03:19 -0400 (Wed, 26 Sep 2007)
New Revision: 3840
Added:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/UnitedServerListener.java
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/UnitedServerListenerManager.java
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/ExtensionManager.java
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/JBossServerCorePlugin.java
Log:
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/ExtensionManager.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/ExtensionManager.java 2007-09-27 01:58:32 UTC (rev 3839)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/ExtensionManager.java 2007-09-27 03:03:19 UTC (rev 3840)
@@ -42,9 +42,9 @@
return instance;
}
- private HashMap pollers;
+ private HashMap<String, ServerStatePollerType> pollers;
public void loadPollers() {
- pollers = new HashMap();
+ pollers = new HashMap<String, ServerStatePollerType>();
IExtensionRegistry registry = Platform.getExtensionRegistry();
IConfigurationElement[] cf = registry.getConfigurationElementsFor(JBossServerCorePlugin.PLUGIN_ID, "pollers");
for( int i = 0; i < cf.length; i++ ) {
@@ -54,33 +54,33 @@
public ServerStatePollerType getPollerType(String id) {
if( pollers == null )
loadPollers();
- return (ServerStatePollerType)pollers.get(id);
+ return pollers.get(id);
}
public ServerStatePollerType[] getStartupPollers() {
if( pollers == null )
loadPollers();
- ArrayList list = new ArrayList();
- Iterator i = pollers.values().iterator();
+ ArrayList<ServerStatePollerType> list = new ArrayList<ServerStatePollerType>();
+ Iterator<ServerStatePollerType> i = pollers.values().iterator();
ServerStatePollerType type;
while(i.hasNext()) {
- type = (ServerStatePollerType)i.next();
+ type = i.next();
if( type.supportsStartup())
list.add(type);
}
- return (ServerStatePollerType[]) list.toArray(new ServerStatePollerType[list.size()]);
+ return list.toArray(new ServerStatePollerType[list.size()]);
}
public ServerStatePollerType[] getShutdownPollers() {
if( pollers == null )
loadPollers();
- ArrayList list = new ArrayList();
- Iterator i = pollers.values().iterator();
+ ArrayList<ServerStatePollerType> list = new ArrayList<ServerStatePollerType>();
+ Iterator<ServerStatePollerType> i = pollers.values().iterator();
ServerStatePollerType type;
while(i.hasNext()) {
- type = (ServerStatePollerType)i.next();
+ type = i.next();
if( type.supportsShutdown() )
list.add(type);
}
- return (ServerStatePollerType[]) list.toArray(new ServerStatePollerType[list.size()]);
+ return list.toArray(new ServerStatePollerType[list.size()]);
}
}
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/JBossServerCorePlugin.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/JBossServerCorePlugin.java 2007-09-27 01:58:32 UTC (rev 3839)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/JBossServerCorePlugin.java 2007-09-27 03:03:19 UTC (rev 3840)
@@ -31,6 +31,7 @@
import org.eclipse.core.runtime.Plugin;
import org.jboss.ide.eclipse.as.core.extensions.descriptors.XPathModel;
import org.jboss.ide.eclipse.as.core.modules.ArchivesBuildListener;
+import org.jboss.ide.eclipse.as.core.server.UnitedServerListenerManager;
import org.osgi.framework.BundleContext;
/**
@@ -72,6 +73,7 @@
super.start(context);
ArchivesBuildListener.getInstance();
XPathModel.getDefault();
+ UnitedServerListenerManager.getDefault();
}
/**
Added: trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/UnitedServerListener.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/UnitedServerListener.java (rev 0)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/UnitedServerListener.java 2007-09-27 03:03:19 UTC (rev 3840)
@@ -0,0 +1,17 @@
+package org.jboss.ide.eclipse.as.core.server;
+
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.wst.server.core.IServer;
+import org.eclipse.wst.server.core.ServerEvent;
+
+public class UnitedServerListener {
+
+ public void init(IServer server) {}
+ public void serverAdded(IServer server) {}
+ public void serverChanged(IServer server) {}
+ public void serverRemoved(IServer server) {}
+ public void serverChanged(ServerEvent event) {}
+ public void publishStarted(IServer server){}
+ public void publishFinished(IServer server, IStatus status){}
+ public void cleanUp(IServer server) {}
+}
Added: trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/UnitedServerListenerManager.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/UnitedServerListenerManager.java (rev 0)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/UnitedServerListenerManager.java 2007-09-27 03:03:19 UTC (rev 3840)
@@ -0,0 +1,86 @@
+package org.jboss.ide.eclipse.as.core.server;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.wst.server.core.IPublishListener;
+import org.eclipse.wst.server.core.IServer;
+import org.eclipse.wst.server.core.IServerLifecycleListener;
+import org.eclipse.wst.server.core.IServerListener;
+import org.eclipse.wst.server.core.ServerCore;
+import org.eclipse.wst.server.core.ServerEvent;
+
+public class UnitedServerListenerManager implements
+ IServerLifecycleListener, IServerListener, IPublishListener {
+ protected static UnitedServerListenerManager instance;
+ public static UnitedServerListenerManager getDefault() {
+ if( instance == null )
+ instance = new UnitedServerListenerManager();
+ return instance;
+ }
+
+ protected ArrayList<UnitedServerListener> list;
+ protected UnitedServerListenerManager() {
+ list = new ArrayList<UnitedServerListener>();
+ ServerCore.addServerLifecycleListener(this);
+ IServer[] allServers = ServerCore.getServers();
+ for( int i = 0; i < allServers.length; i++ ) {
+ allServers[i].addServerListener(this);
+ allServers[i].addPublishListener(this);
+ }
+ }
+
+
+ public void addListener(UnitedServerListener listener) {
+ if( !list.contains(listener)) {
+ list.add(listener);
+ IServer[] allServers = ServerCore.getServers();
+ for( int i = 0; i < allServers.length; i++ )
+ listener.init(allServers[i]);
+ }
+ }
+ public void removeListener(UnitedServerListener listener) {
+ list.remove(listener);
+ IServer[] allServers = ServerCore.getServers();
+ for( int i = 0; i < allServers.length; i++ )
+ listener.cleanUp(allServers[i]);
+ }
+
+ public void serverAdded(IServer server) {
+ server.addServerListener(this);
+ server.addPublishListener(this);
+ for( Iterator<UnitedServerListener> i = list.iterator(); i.hasNext(); ) {
+ i.next().serverAdded(server);
+ }
+ }
+ public void serverChanged(IServer server) {
+ for( Iterator<UnitedServerListener> i = list.iterator(); i.hasNext(); ) {
+ i.next().serverChanged(server);
+ }
+ }
+ public void serverRemoved(IServer server) {
+ server.removeServerListener(this);
+ server.removePublishListener(this);
+ for( Iterator<UnitedServerListener> i = list.iterator(); i.hasNext(); ) {
+ i.next().serverRemoved(server);
+ }
+ }
+
+ public void serverChanged(ServerEvent event) {
+ for( Iterator<UnitedServerListener> i = list.iterator(); i.hasNext(); ) {
+ i.next().serverChanged(event);
+ }
+ }
+
+ public void publishStarted(IServer server) {
+ for( Iterator<UnitedServerListener> i = list.iterator(); i.hasNext(); )
+ i.next().publishStarted(server);
+ }
+
+ public void publishFinished(IServer server, IStatus status) {
+ for( Iterator<UnitedServerListener> i = list.iterator(); i.hasNext(); )
+ i.next().publishFinished(server, status);
+ }
+
+}
17 years, 3 months
JBoss Tools SVN: r3839 - trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/extensions/events.
by jbosstools-commits@lists.jboss.org
Author: rob.stryker(a)jboss.com
Date: 2007-09-26 21:58:32 -0400 (Wed, 26 Sep 2007)
New Revision: 3839
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/extensions/events/EventLogModel.java
Log:
ability to disable logging added
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/extensions/events/EventLogModel.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/extensions/events/EventLogModel.java 2007-09-27 01:58:05 UTC (rev 3838)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/extensions/events/EventLogModel.java 2007-09-27 01:58:32 UTC (rev 3839)
@@ -41,13 +41,15 @@
*/
public class EventLogModel {
public static final String ENABLE_LOGGING_PREFERENCE = "org.jboss.ide.eclipse.as.core.extensions.events.enableLogging";
- public static boolean loggingEnabled = true;
-
-
+ public static void enableLogging(boolean enabled) {
+ if( enabled )
+ enableLogging();
+ else
+ disableLogging();
+ }
public static void enableLogging() {
- loggingEnabled = true;
IEclipsePreferences prefs = new DefaultScope().getNode(JBossServerCorePlugin.PLUGIN_ID);
prefs.putBoolean(ENABLE_LOGGING_PREFERENCE, true);
try {
@@ -58,7 +60,6 @@
}
public static void disableLogging() {
- loggingEnabled = false;
IEclipsePreferences prefs = new DefaultScope().getNode(JBossServerCorePlugin.PLUGIN_ID);
prefs.putBoolean(ENABLE_LOGGING_PREFERENCE, false);
try {
@@ -72,6 +73,11 @@
}
}
+ public static boolean isLoggingEnabled() {
+ IEclipsePreferences prefs = new DefaultScope().getNode(JBossServerCorePlugin.PLUGIN_ID);
+ return prefs.getBoolean(ENABLE_LOGGING_PREFERENCE, false);
+ }
+
public static final String JBOSS_EVENT_ROOT_TYPE = "jboss.event.root";
private static EventLogModel instance;
public static EventLogModel getDefault() {
@@ -193,17 +199,17 @@
}
public void addChild(SimpleTreeItem item) {
- if( loggingEnabled )
+ if( isLoggingEnabled() )
super.addChild(item);
}
public void addChild(int loc, SimpleTreeItem item) {
- if( loggingEnabled )
+ if( isLoggingEnabled() )
super.addChild(loc, item);
}
public void addChildren(SimpleTreeItem[] kids) {
- if( loggingEnabled )
+ if( isLoggingEnabled() )
super.addChildren(kids);
}
17 years, 3 months
JBoss Tools SVN: r3838 - trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/server/providers.
by jbosstools-commits@lists.jboss.org
Author: rob.stryker(a)jboss.com
Date: 2007-09-26 21:58:05 -0400 (Wed, 26 Sep 2007)
New Revision: 3838
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/server/providers/EventLogViewProvider.java
Log:
disabling the view addition should disable logging. it does now.
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/server/providers/EventLogViewProvider.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/server/providers/EventLogViewProvider.java 2007-09-27 01:21:19 UTC (rev 3837)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/server/providers/EventLogViewProvider.java 2007-09-27 01:58:05 UTC (rev 3838)
@@ -422,4 +422,13 @@
}
return "";
}
+
+ public void enable() {
+ EventLogModel.enableLogging();
+ }
+ public void disable() {
+ EventLogModel.disableLogging();
+ }
+
+
}
17 years, 3 months
JBoss Tools SVN: r3837 - in trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core: modules and 1 other directories.
by jbosstools-commits@lists.jboss.org
Author: rob.stryker(a)jboss.com
Date: 2007-09-26 21:21:19 -0400 (Wed, 26 Sep 2007)
New Revision: 3837
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/extensions/events/EventLogModel.java
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/modules/SingleDeployableFactory.java
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/util/SimpleTreeItem.java
Log:
allowing event log to turn off and no longer log
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/extensions/events/EventLogModel.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/extensions/events/EventLogModel.java 2007-09-27 01:01:44 UTC (rev 3836)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/extensions/events/EventLogModel.java 2007-09-27 01:21:19 UTC (rev 3837)
@@ -22,17 +22,56 @@
package org.jboss.ide.eclipse.as.core.extensions.events;
import java.util.ArrayList;
+import java.util.Collection;
import java.util.Date;
import java.util.HashMap;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.preferences.DefaultScope;
+import org.eclipse.core.runtime.preferences.IEclipsePreferences;
import org.eclipse.wst.server.core.IServer;
+import org.jboss.ide.eclipse.as.core.JBossServerCorePlugin;
import org.jboss.ide.eclipse.as.core.util.SimpleTreeItem;
+import org.osgi.service.prefs.BackingStoreException;
/**
*
* @author rob.stryker(a)jboss.com
*/
public class EventLogModel {
+ public static final String ENABLE_LOGGING_PREFERENCE = "org.jboss.ide.eclipse.as.core.extensions.events.enableLogging";
+ public static boolean loggingEnabled = true;
+
+
+
+
+ public static void enableLogging() {
+ loggingEnabled = true;
+ IEclipsePreferences prefs = new DefaultScope().getNode(JBossServerCorePlugin.PLUGIN_ID);
+ prefs.putBoolean(ENABLE_LOGGING_PREFERENCE, true);
+ try {
+ prefs.flush();
+ } catch (BackingStoreException e) {
+ JBossServerCorePlugin.getDefault().getLog().log(new Status(IStatus.ERROR, JBossServerCorePlugin.PLUGIN_ID, "Saving preferences failed", e));
+ }
+ }
+
+ public static void disableLogging() {
+ loggingEnabled = false;
+ IEclipsePreferences prefs = new DefaultScope().getNode(JBossServerCorePlugin.PLUGIN_ID);
+ prefs.putBoolean(ENABLE_LOGGING_PREFERENCE, false);
+ try {
+ prefs.flush();
+ } catch (BackingStoreException e) {
+ JBossServerCorePlugin.getDefault().getLog().log(new Status(IStatus.ERROR, JBossServerCorePlugin.PLUGIN_ID, "Saving preferences failed", e));
+ }
+ ServerEventModel[] models = getModels();
+ for( int i = 0; i < models.length; i++ ) {
+ models[i].clearEvents();
+ }
+ }
+
public static final String JBOSS_EVENT_ROOT_TYPE = "jboss.event.root";
private static EventLogModel instance;
public static EventLogModel getDefault() {
@@ -49,6 +88,10 @@
return getDefault().getEventModel(serverId);
}
+ public static ServerEventModel[] getModels() {
+ return getDefault().getEventModels();
+ }
+
public static void markChanged(EventLogTreeItem item) {
SimpleTreeItem root = item.getRoot();
if( root != null && root instanceof EventLogRoot ) {
@@ -89,6 +132,10 @@
return m;
}
+ public ServerEventModel[] getEventModels() {
+ Collection c = serverToModel.values();
+ return (ServerEventModel[]) c.toArray(new ServerEventModel[c.size()]);
+ }
public static class ServerEventModel {
private String id;
@@ -144,5 +191,21 @@
public String getServerId() {
return model.getId();
}
+
+ public void addChild(SimpleTreeItem item) {
+ if( loggingEnabled )
+ super.addChild(item);
+ }
+
+ public void addChild(int loc, SimpleTreeItem item) {
+ if( loggingEnabled )
+ super.addChild(loc, item);
+ }
+
+ public void addChildren(SimpleTreeItem[] kids) {
+ if( loggingEnabled )
+ super.addChildren(kids);
+ }
+
}
}
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/modules/SingleDeployableFactory.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/modules/SingleDeployableFactory.java 2007-09-27 01:01:44 UTC (rev 3836)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/modules/SingleDeployableFactory.java 2007-09-27 01:21:19 UTC (rev 3837)
@@ -111,7 +111,7 @@
return true;
} else {
return false;
- }
+ }
}
protected void removeModule(IPath path) {
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/util/SimpleTreeItem.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/util/SimpleTreeItem.java 2007-09-27 01:01:44 UTC (rev 3836)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/util/SimpleTreeItem.java 2007-09-27 01:21:19 UTC (rev 3837)
@@ -61,6 +61,12 @@
children.add(loc, item);
}
+ public void addChildren(SimpleTreeItem[] kids) {
+ for( int i = 0; i < kids.length; i++ ) {
+ addChild(kids[i]);
+ }
+ }
+
public void deleteChildren() {
children.clear();
}
@@ -93,13 +99,7 @@
public void setData(Object data) {
this.data = data;
}
-
- public void addChildren(SimpleTreeItem[] kids) {
- for( int i = 0; i < kids.length; i++ ) {
- addChild(kids[i]);
- }
- }
-
+
public SimpleTreeItem getRoot() {
SimpleTreeItem item = this;
while(item.getParent() != null)
17 years, 3 months
JBoss Tools SVN: r3836 - in trunk/as/plugins/org.jboss.ide.eclipse.as.ui: jbossui/org/jboss/ide/eclipse/as/ui and 1 other directories.
by jbosstools-commits@lists.jboss.org
Author: rob.stryker(a)jboss.com
Date: 2007-09-26 21:01:44 -0400 (Wed, 26 Sep 2007)
New Revision: 3836
Added:
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/actions/
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/actions/DeployAction.java
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/plugin.xml
Log:
Added a deploy option for generic files
Added: trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/actions/DeployAction.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/actions/DeployAction.java (rev 0)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/actions/DeployAction.java 2007-09-27 01:01:44 UTC (rev 3836)
@@ -0,0 +1,164 @@
+package org.jboss.ide.eclipse.as.ui.actions;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.viewers.BaseLabelProvider;
+import org.eclipse.jface.viewers.ILabelProvider;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Image;
+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.MessageBox;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Tree;
+import org.eclipse.ui.IObjectActionDelegate;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.wst.server.core.IModule;
+import org.eclipse.wst.server.core.IServer;
+import org.eclipse.wst.server.core.model.ServerBehaviourDelegate;
+import org.eclipse.wst.server.ui.internal.ImageResource;
+import org.jboss.ide.eclipse.as.core.modules.SingleDeployableFactory;
+import org.jboss.ide.eclipse.as.core.server.internal.DeployableServerBehavior;
+import org.jboss.ide.eclipse.as.core.util.ServerConverter;
+import org.jboss.ide.eclipse.as.ui.JBossServerUISharedImages;
+import org.jboss.ide.eclipse.as.ui.Messages;
+
+public class DeployAction implements IObjectActionDelegate {
+
+ protected ISelection selection;
+ public DeployAction() {
+ }
+
+ public void setActivePart(IAction action, IWorkbenchPart targetPart) {
+ }
+
+ public void run(IAction action) {
+ IServer server = getServer();
+ if( selection instanceof IStructuredSelection ) {
+ Object element = ((IStructuredSelection)selection).getFirstElement();
+ if( server == null ) {
+ MessageBox messageBox = new MessageBox (new Shell(), SWT.OK );
+ messageBox.setText ("Cannot Publish To Server");
+ messageBox.setMessage ("No deployable servers located.");
+ messageBox.open();
+ } else if( element != null && element instanceof IFile ) {
+ IFile tmp = (IFile)element;
+ SingleDeployableFactory factory = SingleDeployableFactory.getFactory();
+ factory.makeDeployable(tmp.getFullPath());
+ IModule module = factory.findModule(tmp.getFullPath());
+ DeployableServerBehavior behavior = (DeployableServerBehavior)
+ server.loadAdapter(DeployableServerBehavior.class, new NullProgressMonitor());
+ if( module != null && behavior != null ) {
+ behavior.publishOneModule(new IModule[]{module}, IServer.PUBLISH_FULL, ServerBehaviourDelegate.CHANGED, false, new NullProgressMonitor());
+ }
+ }
+ }
+ }
+
+
+ protected IServer getServer() {
+
+ IServer[] servers = ServerConverter.getDeployableServersAsIServers();
+ if( servers.length == 0 ) return null;
+ if( servers.length == 1 ) return servers[0];
+
+ // Throw up a dialog
+ SelectServerDialog d = new SelectServerDialog(null);
+ int result = d.open();
+ if( result == Dialog.OK ) {
+ return d.getSelectedServer();
+ }
+ return null;
+ }
+
+ public void selectionChanged(IAction action, ISelection selection) {
+ this.selection = selection;
+ }
+
+
+ public class SelectServerDialog extends Dialog {
+ private Object selected;
+ private final class LabelProviderExtension extends BaseLabelProvider implements ILabelProvider {
+ public Image getImage(Object element) {
+ if( element instanceof IServer )
+ return ImageResource.getImage(((IServer)element).getServerType().getId());
+ return null;
+ }
+
+ public String getText(Object element) {
+ if( element instanceof IServer )
+ return ((IServer)element).getName();
+ return "unknown object type";
+ }
+ }
+
+ protected SelectServerDialog(Shell parentShell) {
+ super(parentShell);
+ }
+
+ protected void configureShell(Shell newShell) {
+ super.configureShell(newShell);
+ newShell.setText("Select a server to publish to");
+ }
+
+ public IServer getSelectedServer() {
+ if( selected instanceof IServer )
+ return ((IServer)selected);
+ return null;
+ }
+
+ protected Control createDialogArea(Composite parent) {
+ Composite c = (Composite)super.createDialogArea(parent);
+ Tree tree = new Tree(c, SWT.SINGLE | SWT.FULL_SELECTION | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
+ tree.setLayoutData(new GridData(GridData.FILL_BOTH));
+ final TreeViewer viewer = new TreeViewer(tree);
+ viewer.setContentProvider(new ITreeContentProvider() {
+
+ public Object[] getChildren(Object parentElement) {
+ return null;
+ }
+ public Object getParent(Object element) {
+ return null;
+ }
+ public boolean hasChildren(Object element) {
+ return false;
+ }
+ public Object[] getElements(Object inputElement) {
+ return ServerConverter.getDeployableServersAsIServers();
+ }
+ public void dispose() {
+ }
+ public void inputChanged(Viewer viewer, Object oldInput,
+ Object newInput) {
+ }
+ });
+
+ viewer.setLabelProvider(new LabelProviderExtension());
+
+ viewer.addSelectionChangedListener(new ISelectionChangedListener() {
+ public void selectionChanged(SelectionChangedEvent event) {
+ ISelection sel = viewer.getSelection();
+ if( sel instanceof IStructuredSelection ) {
+ selected = ((IStructuredSelection)sel).getFirstElement();
+ }
+ }
+ });
+
+ viewer.setInput(new Boolean(true));
+ return c;
+ }
+ }
+
+
+}
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.ui/plugin.xml
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.ui/plugin.xml 2007-09-27 01:01:03 UTC (rev 3835)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.ui/plugin.xml 2007-09-27 01:01:44 UTC (rev 3836)
@@ -294,5 +294,23 @@
file="InlineDocs/Twiddle/twiddleContext.xml">
</contexts>
</extension>
+
+
+ <extension point="org.eclipse.ui.popupMenus">
+ <objectContribution
+ adaptable="true"
+ id="org.jboss.ide.eclipse.as.ui.popups.makeDeployable.contrib"
+ nameFilter="*"
+ objectClass="org.eclipse.core.resources.IFile">
+ <action
+ id="org.jboss.ide.eclipse.as.ui.popups.makeDeployable.action"
+ label="Deploy To Server"
+ icon="icons/publish.gif"
+ menubarPath="additions"
+ class="org.jboss.ide.eclipse.as.ui.actions.DeployAction">
+ </action>
+ </objectContribution>
+</extension>
+
</plugin>
17 years, 3 months
JBoss Tools SVN: r3835 - in trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core: server/internal and 1 other directory.
by jbosstools-commits@lists.jboss.org
Author: rob.stryker(a)jboss.com
Date: 2007-09-26 21:01:03 -0400 (Wed, 26 Sep 2007)
New Revision: 3835
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/publishers/PublisherEventLogger.java
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/DeployableServerBehavior.java
Log:
Event maneuvering
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/publishers/PublisherEventLogger.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/publishers/PublisherEventLogger.java 2007-09-27 00:59:20 UTC (rev 3834)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/publishers/PublisherEventLogger.java 2007-09-27 01:01:03 UTC (rev 3835)
@@ -39,6 +39,7 @@
for( int i = 0; i < module.length; i++ ) {
name += module[i].getName() + Path.SEPARATOR;
}
+ name = name.substring(0, name.length()-1);
event.setProperty(MODULE_KIND, new Integer(kind));
event.setProperty(DELTA_KIND, new Integer(deltaKind));
event.setProperty(MODULE_NAME, name);
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/DeployableServerBehavior.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/DeployableServerBehavior.java 2007-09-27 00:59:20 UTC (rev 3834)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/DeployableServerBehavior.java 2007-09-27 01:01:03 UTC (rev 3835)
@@ -158,6 +158,7 @@
// Basically stolen from RunOnServerActionDelegate
+ @Deprecated
public IStatus publishOneModule(int kind, IModule[] module, int deltaKind, IProgressMonitor monitor) {
return publishOneModule(module, kind, deltaKind, true, monitor);
}
17 years, 3 months
JBoss Tools SVN: r3834 - trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/dialogs.
by jbosstools-commits@lists.jboss.org
Author: rob.stryker(a)jboss.com
Date: 2007-09-26 20:59:20 -0400 (Wed, 26 Sep 2007)
New Revision: 3834
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/dialogs/TwiddleDialog.java
Log:
dialog missing icon
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/dialogs/TwiddleDialog.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/dialogs/TwiddleDialog.java 2007-09-27 00:53:13 UTC (rev 3833)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/dialogs/TwiddleDialog.java 2007-09-27 00:59:20 UTC (rev 3834)
@@ -21,6 +21,7 @@
import org.jboss.ide.eclipse.as.core.server.internal.launch.TwiddleLaunchConfiguration;
import org.jboss.ide.eclipse.as.core.server.internal.launch.TwiddleLauncher;
import org.jboss.ide.eclipse.as.core.server.internal.launch.TwiddleLauncher.ProcessData;
+import org.jboss.ide.eclipse.as.ui.JBossServerUISharedImages;
import org.jboss.ide.eclipse.as.ui.Messages;
public class TwiddleDialog extends TrayDialog {
@@ -40,10 +41,11 @@
}
}
+
protected void configureShell(Shell newShell) {
super.configureShell(newShell);
newShell.setText(Messages.TwiddleDialog);
- //newShell.setImage(JBossServerUISharedImages.getImage(JBossServerUISharedImages.TWIDDLE_IMAGE));
+ newShell.setImage(JBossServerUISharedImages.getImage(JBossServerUISharedImages.TWIDDLE_IMAGE));
}
protected Point getInitialSize() {
17 years, 3 months
JBoss Tools SVN: r3833 - in branches/jbosstools_xulrunner/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces: src/org/jboss/tools/jsf/vpe/richfaces/template and 1 other directories.
by jbosstools-commits@lists.jboss.org
Author: dsakovich
Date: 2007-09-26 20:53:13 -0400 (Wed, 26 Sep 2007)
New Revision: 3833
Added:
branches/jbosstools_xulrunner/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/resources/tree/iconClosedNode.gif
branches/jbosstools_xulrunner/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/resources/tree/iconClosedNodeWithLines.gif
branches/jbosstools_xulrunner/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/resources/tree/iconNodeWithLine.gif
branches/jbosstools_xulrunner/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/resources/tree/iconNotCollapsed.gif
branches/jbosstools_xulrunner/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/resources/tree/iconNotCollapsedWithLines.gif
branches/jbosstools_xulrunner/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/resources/tree/leftLine.gif
branches/jbosstools_xulrunner/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/resources/tree/line.gif
branches/jbosstools_xulrunner/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/resources/tree/rightLine.gif
branches/jbosstools_xulrunner/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesRecursiveTreeNodesAdaptorTemplate.java
branches/jbosstools_xulrunner/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesTreeNodesAdaptorTemplate.java
Removed:
branches/jbosstools_xulrunner/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesTreeNodesTemplate.java
Modified:
branches/jbosstools_xulrunner/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/resources/tree/iconLeaf.gif
branches/jbosstools_xulrunner/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/resources/tree/iconLeafWithLines.gif
branches/jbosstools_xulrunner/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/resources/tree/iconNodeWithLines.gif
branches/jbosstools_xulrunner/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/resources/tree/tree.css
branches/jbosstools_xulrunner/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesTreeNodeTemplate.java
branches/jbosstools_xulrunner/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesTreeTemplate.java
branches/jbosstools_xulrunner/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/templates/vpe-templates-richfaces.xml
Log:
http://jira.jboss.com/jira/browse/JBIDE-847 Add templates for rich:treeNodesAdaptor and rich:recursiveTreeNodesAdaptor
Added: branches/jbosstools_xulrunner/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/resources/tree/iconClosedNode.gif
===================================================================
(Binary files differ)
Property changes on: branches/jbosstools_xulrunner/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/resources/tree/iconClosedNode.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: branches/jbosstools_xulrunner/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/resources/tree/iconClosedNodeWithLines.gif
===================================================================
(Binary files differ)
Property changes on: branches/jbosstools_xulrunner/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/resources/tree/iconClosedNodeWithLines.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Modified: branches/jbosstools_xulrunner/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/resources/tree/iconLeaf.gif
===================================================================
(Binary files differ)
Modified: branches/jbosstools_xulrunner/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/resources/tree/iconLeafWithLines.gif
===================================================================
(Binary files differ)
Added: branches/jbosstools_xulrunner/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/resources/tree/iconNodeWithLine.gif
===================================================================
(Binary files differ)
Property changes on: branches/jbosstools_xulrunner/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/resources/tree/iconNodeWithLine.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Modified: branches/jbosstools_xulrunner/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/resources/tree/iconNodeWithLines.gif
===================================================================
(Binary files differ)
Added: branches/jbosstools_xulrunner/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/resources/tree/iconNotCollapsed.gif
===================================================================
(Binary files differ)
Property changes on: branches/jbosstools_xulrunner/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/resources/tree/iconNotCollapsed.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: branches/jbosstools_xulrunner/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/resources/tree/iconNotCollapsedWithLines.gif
===================================================================
(Binary files differ)
Property changes on: branches/jbosstools_xulrunner/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/resources/tree/iconNotCollapsedWithLines.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: branches/jbosstools_xulrunner/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/resources/tree/leftLine.gif
===================================================================
(Binary files differ)
Property changes on: branches/jbosstools_xulrunner/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/resources/tree/leftLine.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: branches/jbosstools_xulrunner/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/resources/tree/line.gif
===================================================================
(Binary files differ)
Property changes on: branches/jbosstools_xulrunner/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/resources/tree/line.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: branches/jbosstools_xulrunner/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/resources/tree/rightLine.gif
===================================================================
(Binary files differ)
Property changes on: branches/jbosstools_xulrunner/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/resources/tree/rightLine.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Modified: branches/jbosstools_xulrunner/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/resources/tree/tree.css
===================================================================
--- branches/jbosstools_xulrunner/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/resources/tree/tree.css 2007-09-27 00:50:58 UTC (rev 3832)
+++ branches/jbosstools_xulrunner/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/resources/tree/tree.css 2007-09-27 00:53:13 UTC (rev 3833)
@@ -1,10 +1,24 @@
.treePictureStyle {
width: 22px;
- height: 100%;
+ height: 22px;
}
-.treeNodeNameStyle{
- width : 100%;
- vertical-align : middle;
- text-align : left;
+.treeNodeNameStyle {
+ width: 100%;
+ vertical-align: middle;
+ text-align: left;
}
+
+.dr-tree-h-ic-div {
+ margin-left: 8px;
+ padding-left: 14px;
+}
+
+.dr-tree-full-width {
+ width: 100%;
+}
+
+.dr-tree-h-ic-line-position {
+ background-position: center;
+ background-repeat: repeat-y;
+}
Added: branches/jbosstools_xulrunner/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesRecursiveTreeNodesAdaptorTemplate.java
===================================================================
--- branches/jbosstools_xulrunner/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesRecursiveTreeNodesAdaptorTemplate.java (rev 0)
+++ branches/jbosstools_xulrunner/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesRecursiveTreeNodesAdaptorTemplate.java 2007-09-27 00:53:13 UTC (rev 3833)
@@ -0,0 +1,106 @@
+/*******************************************************************************
+ * 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.jsf.vpe.richfaces.template;
+
+import org.jboss.tools.jsf.vpe.richfaces.HtmlComponentUtil;
+import org.jboss.tools.vpe.editor.context.VpePageContext;
+import org.jboss.tools.vpe.editor.template.VpeAbstractTemplate;
+import org.jboss.tools.vpe.editor.template.VpeChildrenInfo;
+import org.jboss.tools.vpe.editor.template.VpeCreationData;
+import org.mozilla.interfaces.nsIDOMDocument;
+import org.mozilla.interfaces.nsIDOMElement;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+/**
+ * Create template for rich:recursiveTreeNodesAdaptor element
+ *
+ * @author dsakovich(a)exadel.com
+ *
+ */
+public class RichFacesRecursiveTreeNodesAdaptorTemplate extends
+ VpeAbstractTemplate {
+ private final static String TREE_NODE_NAME = "treeNode";
+
+ private static final String TREE_TABLE_ATR_CELLSPACING_VALUE = "0px";
+
+ private static final String TREE_TABLE_ATR_CELLPADDING_VALUE = "0px";
+
+ private static final String TREE_TABLE_ATR_BORDER_VALUE = "0px";
+
+ public VpeCreationData create(VpePageContext pageContext, Node sourceNode,
+ nsIDOMDocument visualDocument) {
+ nsIDOMElement visualElement = visualDocument
+ .createElement(HtmlComponentUtil.HTML_TAG_TABLE);
+ addBasicTreeNodeAttributes(visualElement);
+ VpeCreationData vpeCreationData = new VpeCreationData(visualElement);
+ parseTree(pageContext, sourceNode, visualDocument, vpeCreationData,
+ visualElement);
+ return vpeCreationData;
+ }
+
+ /**
+ *
+ * Function for parsing tree by tree nodes;
+ *
+ * @param pageContext
+ * @param sourceNode
+ * @param visualDocument
+ * @return
+ */
+ public void parseTree(VpePageContext pageContext, Node sourceNode,
+ nsIDOMDocument visualDocument, VpeCreationData vpeCreationData,
+ nsIDOMElement parentElement) {
+ NodeList nodeList = sourceNode.getChildNodes();
+ Element element = null;
+ int lenght = nodeList.getLength();
+ String treeNodeName = sourceNode.getPrefix() + ":" + TREE_NODE_NAME;
+ VpeChildrenInfo vpeChildrenInfo = null;
+ for (int i = 0; i < lenght; i++) {
+ if (!(nodeList.item(i) instanceof Element)) {
+ continue;
+ }
+ element = (Element) nodeList.item(i);
+ if (element.getNodeName().equals(treeNodeName)) {
+ nsIDOMElement tr = visualDocument
+ .createElement(HtmlComponentUtil.HTML_TAG_TR);
+ nsIDOMElement td = visualDocument
+ .createElement(HtmlComponentUtil.HTML_TAG_TD);
+ tr.appendChild(td);
+ vpeChildrenInfo = new VpeChildrenInfo(td);
+ vpeCreationData.addChildrenInfo(vpeChildrenInfo);
+ vpeChildrenInfo.addSourceChild(element);
+ parentElement.appendChild(tr);
+ }
+ }
+ }
+
+ /**
+ * Set attributes for treeNode
+ *
+ * @param table
+ */
+ private void addBasicTreeNodeAttributes(nsIDOMElement table) {
+ if (table == null) {
+ return;
+ }
+ table.setAttribute(HtmlComponentUtil.HTML_CELLPADDING_ATTR,
+ TREE_TABLE_ATR_CELLPADDING_VALUE);
+ table.setAttribute(HtmlComponentUtil.HTML_CELLSPACING_ATTR,
+ TREE_TABLE_ATR_CELLSPACING_VALUE);
+ table.setAttribute(HtmlComponentUtil.HTML_BORDER_ATTR,
+ TREE_TABLE_ATR_BORDER_VALUE);
+ table.setAttribute(HtmlComponentUtil.HTML_CLASS_ATTR,
+ "dr-tree-full-width");
+ }
+
+}
Modified: branches/jbosstools_xulrunner/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesTreeNodeTemplate.java
===================================================================
--- branches/jbosstools_xulrunner/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesTreeNodeTemplate.java 2007-09-27 00:50:58 UTC (rev 3832)
+++ branches/jbosstools_xulrunner/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesTreeNodeTemplate.java 2007-09-27 00:53:13 UTC (rev 3833)
@@ -7,13 +7,14 @@
*
* Contributors:
* Exadel, Inc. and Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
+ ******************************************************************************/
package org.jboss.tools.jsf.vpe.richfaces.template;
import java.util.List;
import org.jboss.tools.jsf.vpe.richfaces.ComponentUtil;
import org.jboss.tools.jsf.vpe.richfaces.HtmlComponentUtil;
+import org.jboss.tools.jsf.vpe.richfaces.RichFacesTemplatesActivator;
import org.jboss.tools.vpe.editor.context.VpePageContext;
import org.jboss.tools.vpe.editor.template.VpeAbstractTemplate;
import org.jboss.tools.vpe.editor.template.VpeChildrenInfo;
@@ -27,373 +28,554 @@
import org.w3c.dom.NodeList;
/**
- * Creates VPE content for rich:treeNode
+ * Create template for rich:treeNodes element
*
- * @author Max Areshkau
+ * @author dsakovich(a)exadel.com
*
*/
public class RichFacesTreeNodeTemplate extends VpeAbstractTemplate {
- public static final String DEFAULT_ICON_PARAM_VALUE = "DEFAULT_ICON_PARAM";
+ public static final String DEFAULT_ICON_PARAM_VALUE = "DEFAULT_ICON_PARAM";
- public static final String ICON_PARAM_NAME = "richFacesTreeNodeParam";
+ public static final String ICON_PARAM_NAME = "richFacesTreeNodeParam";
- public static final String DEFAULT_ICON_EXPANDED_PARAM_VALUE = "DEFAULT_ICON_EXPANDED_PARAM";
+ public static final String DEFAULT_ICON_EXPANDED_PARAM_VALUE = "DEFAULT_ICON_EXPANDED_PARAM";
- public static final String UNDEFINED_ICON = "/tree/unresolved.gif";
+ public static final String UNDEFINED_ICON = "/tree/unresolved.gif";
- public static final String NODE_ICON_LEAF_ATTR_NAME = "iconLeaf";
+ public static final String NODE_ICON_LEAF_ATTR_NAME = "iconLeaf";
- public static final String ICON_NODE_WITH_LINES = "/tree/iconNodeWithLines.gif";
+ public static final String ICON_NODE_WITH_LINES = "/tree/iconNodeWithLines.gif";
- public static final String ICON_EXPANDED_WITH_LINES = "/tree/iconCollapsedWithLines.gif";
+ public static final String ICON_NODE_WITH_LINE = "/tree/iconNodeWithLine.gif";
- public static final String ICON_NODE_WITHOUT_LINES = "/tree/iconNode.gif";
+ public static final String ICON_EXPANDED_WITH_LINES = "/tree/iconCollapsedWithLines.gif";
- public static final String ICON_EXPANDED_WITHOUT_LINES = "/tree/iconCollapsed.gif";
+ public static final String ICON_NODE_WITHOUT_LINES = "/tree/iconNode.gif";
- public static final String ICON_LEAF_WITH_LINES = "/tree/iconLeaf.gif";
+ public static final String ICON_EXPANDED_WITHOUT_LINES = "/tree/iconCollapsed.gif";
- public static final String ICON_LEAF_WITHOUT_LINES = "/tree/iconLeafWithLines.gif";
+ public static final String ICON_NOT_EXPANDED_WITH_LINES = "/tree/iconNotCollapsedWithLines.gif";
- private static final String TREE_TABLE_PICTURE_STYLE_CLASS_NAME = "treePictureStyle";
+ public static final String ICON_NOT_EXPANDED_WITHOUT_LINES = "/tree/iconNotCollapsed.gif";
- private static final String STYLE_CLASS_FOR_NODE_TITLE = "treeNodeNameStyle";
+ public static final String ICON_EXPANDED_ADAPTER_WITH_LINES = "/tree/iconClosedNodeWithLines.gif";
- private static final String NODE_TITLE_STYLE_CLASS_ATTR_NAME = "nodeClass";
+ public static final String ICON_EXPANDED_ADAPTER_WITHOUT_LINES = "/tree/iconClosedNode.gif";
- private static final String NODE_ICON_EXPANDED_ATTR_NAME = "iconExpanded";
+ public static final String ICON_LEAF_WITH_LINES = "/tree/iconLeafWithLines.gif";
- private static final String NODE_ICON_ATTR_NAME = "icon";
+ public static final String ICON_RIGHT_LINE = "/tree/rightLine.gif";
- /**
- * Creates a node of the visual tree on the node of the source tree. This
- * visual node should not have the parent node This visual node can have
- * child nodes.
- *
- * @param pageContext
- * Contains the information on edited page.
- * @param sourceNode
- * The current node of the source tree.
- * @param visualDocument
- * The document of the visual tree.
- * @return The information on the created node of the visual tree.
- */
- public VpeCreationData create(VpePageContext pageContext, Node sourceNode,
- nsIDOMDocument visualDocument) {
- nsIDOMElement tableRow = visualDocument
- .createElement(HtmlComponentUtil.HTML_TAG_TR);
- addAttributeToTableNode((Element) sourceNode, tableRow);
-
- VpeCreationData vpeCreationData = new VpeCreationData(tableRow);
- createBasicTree(pageContext, visualDocument, tableRow, sourceNode,
- vpeCreationData);
- return vpeCreationData;
+ public static final String ICON_LEFT_LINE = "/tree/leftLine.gif";
+
+ public static final String ICON_LINE = "/tree/line.gif";
+
+ public static final String ICON_LEAF_WITHOUT_LINES = "/tree/iconLeaf.gif";
+
+ private static final String TREE_TABLE_PICTURE_STYLE_CLASS_NAME = "treePictureStyle";
+
+ private static final String STYLE_CLASS_FOR_NODE_TITLE = "treeNodeNameStyle";
+
+ private static final String NODE_TITLE_STYLE_CLASS_ATTR_NAME = "nodeClass";
+
+ private static final String NODE_ICON_EXPANDED_ATTR_NAME = "iconExpanded";
+
+ private static final String NODE_ICON_ATTR_NAME = "icon";
+
+ private static final String TREE_TABLE_ATR_CELLSPACING_VALUE = "0px";
+
+ private static final String TREE_TABLE_ATR_CELLPADDING_VALUE = "0px";
+
+ private static final String TREE_TABLE_ATR_BORDER_VALUE = "0px";
+
+ private static final String TREE_NAME = "tree";
+
+ private static final String NODE_LINES_STYLE = "background-position: center; background-repeat: repeat-y;";
+
+ /**
+ * Creates a node of the visual tree on the node of the source tree. This
+ * visual node should not have the parent node This visual node can have
+ * child nodes.
+ *
+ * @param pageContext
+ * Contains the information on edited page.
+ * @param sourceNode
+ * The current node of the source tree.
+ * @param visualDocument
+ * The document of the visual tree.
+ * @return The information on the created node of the visual tree.
+ */
+ public VpeCreationData create(VpePageContext pageContext, Node sourceNode,
+ nsIDOMDocument visualDocument) {
+
+ nsIDOMElement visualElement = visualDocument
+ .createElement(HtmlComponentUtil.HTML_TAG_TABLE);
+ addBasicTreeNodeAttributes(visualElement);
+
+ nsIDOMElement tbody = visualDocument
+ .createElement(HtmlComponentUtil.HTML_TAG_TBODY);
+
+ nsIDOMElement tableRow = visualDocument
+ .createElement(HtmlComponentUtil.HTML_TAG_TR);
+ addAttributeToTableNode((Element) sourceNode, tableRow);
+ visualElement.appendChild(tbody);
+ tbody.appendChild(tableRow);
+
+ VpeCreationData vpeCreationData = new VpeCreationData(visualElement);
+ createBasicTree(pageContext, visualDocument, tableRow, sourceNode,
+ vpeCreationData);
+ return vpeCreationData;
+ }
+
+ /**
+ * Checks for attributes for node and if such exist convert it's to html
+ * atributes.
+ *
+ * @param sourceNode
+ * @param tableRow
+ */
+ private void addAttributeToTableNode(Element sourceNode,
+ nsIDOMElement tableRow) {
+
+ String attrValue = sourceNode
+ .getAttribute(NODE_TITLE_STYLE_CLASS_ATTR_NAME);
+ if ((attrValue != null) && (attrValue.length() > 0)) {
+ tableRow.setAttribute(HtmlComponentUtil.HTML_CLASS_ATTR, attrValue);
}
+ }
- /**
- * Checks for attributes for node and if such exist convert it's to html
- * atributes.
- *
- * @param sourceNode
- * @param tableRow
- */
- private void addAttributeToTableNode(Element sourceNode, nsIDOMElement tableRow) {
+ /**
+ * Used for setting images into tree nodes
+ *
+ * @param pageContext
+ * page context
+ * @param visualDocument
+ * visual document
+ * @param sourceNode
+ * treeNode element
+ * @param iconCell
+ * cell were image should be setted
+ * @param nodeAttrName
+ * image attr name( icon, iconExpanded, ...)
+ * @param defaultImage
+ * (image by default)
+ */
+ private void setAttributeForPictureNode(VpePageContext pageContext,
+ nsIDOMDocument visualDocument, Element sourceNode,
+ nsIDOMElement iconCell, String nodeAttrName, String defaultImage) {
+ if (RichFacesTemplatesActivator.getDefault().isDebugging()) {
+ System.out.println("call setAttributeForPictureNode");
+ }
+ nsIDOMElement img = visualDocument
+ .createElement(HtmlComponentUtil.HTML_TAG_IMG);
+ addBasicAttributesToPicture(img);
+ iconCell.appendChild(img);
+ // get image from treeNode
+ String imgName = sourceNode.getAttribute(nodeAttrName);
+ // if in tree node image doesn't exist we get image attr from tree
+ if (imgName == null || imgName.length() == 0) {
+ Node parentElement = sourceNode.getParentNode();
+ if (parentElement instanceof Element) {
+ imgName = ((Element) parentElement).getAttribute(nodeAttrName);
+ }
+ } else {
+ img.setAttribute(ICON_PARAM_NAME, "");
+ }
+ // if we can't get attribute from parent we use default attribute
+ addBasicAttributesToPicture(img);
+ iconCell.appendChild(img);
+ if (imgName == null || imgName.length() == 0) {
+ ComponentUtil.setImg(img, defaultImage);
+ } else {
+ ComponentUtil.setImgFromResources(pageContext, img, imgName,
+ UNDEFINED_ICON);
+ }
+ if (nodeAttrName.equals(NODE_ICON_EXPANDED_ATTR_NAME)) {
+ img
+ .setAttribute(ICON_PARAM_NAME,
+ DEFAULT_ICON_EXPANDED_PARAM_VALUE);
+ } else if (nodeAttrName.equals(NODE_ICON_ATTR_NAME)) {
+ img.setAttribute(ICON_PARAM_NAME, DEFAULT_ICON_PARAM_VALUE);
+ } else if (nodeAttrName.equals(NODE_ICON_LEAF_ATTR_NAME)) {
+ img.setAttribute(ICON_PARAM_NAME, NODE_ICON_LEAF_ATTR_NAME);
+ }
+ }
- String attrValue = sourceNode
- .getAttribute(NODE_TITLE_STYLE_CLASS_ATTR_NAME);
- if ((attrValue != null) && (attrValue.length() > 0)) {
- tableRow.setAttribute(HtmlComponentUtil.HTML_CLASS_ATTR,
- attrValue);
- }
+ /**
+ * Create simple tree node attribute.Used for creating more complex trees.
+ *
+ * @param treeNodeTitle
+ * @param visualDocument
+ * @return tree
+ */
+ private void createBasicTree(VpePageContext pageContext,
+ nsIDOMDocument visualDocument, nsIDOMElement treeRow,
+ Node sourceNode, VpeCreationData vpeCreationData) {
+ // creates icon node
+ String backgroundLinePath = null;
+ if (RichFacesTemplatesActivator.getDefault().isDebugging()) {
+ System.out.println("call createBasicTree");
}
+ boolean showLinesValue = getShowLinesAttr((Element) sourceNode);
- /**
- * Used for setting images into tree nodes
- *
- * @param pageContext
- * page context
- * @param visualDocument
- * visual document
- * @param sourceNode
- * treeNode element
- * @param iconCell
- * cell were image should be setted
- * @param nodeAttrName
- * image attr name( icon, iconExpanded, ...)
- * @param defaultImage
- * (image by default)
- */
- private void setAttributeForPictureNode(VpePageContext pageContext,
- nsIDOMDocument visualDocument, Element sourceNode, nsIDOMElement iconCell,
- String nodeAttrName, String defaultImage) {
- nsIDOMElement img = visualDocument
- .createElement(HtmlComponentUtil.HTML_TAG_IMG);
- addBasicAttributesToPicture(img);
- iconCell.appendChild(img);
- // get image from treeNode
- String imgName = sourceNode.getAttribute(nodeAttrName);
- // if in tree node image doesn't exist we get image attr from tree
- if (imgName == null || imgName.length() == 0) {
- imgName = ((Element) sourceNode.getParentNode())
- .getAttribute(nodeAttrName);
- } else {
- img.setAttribute(ICON_PARAM_NAME, "");
- }
- // if we can't get attribute from parent we use default attribute
- addBasicAttributesToPicture(img);
- iconCell.appendChild(img);
- if (imgName == null || imgName.length() == 0) {
- ComponentUtil.setImg(img, defaultImage);
- } else {
- ComponentUtil.setImgFromResources(pageContext, img, imgName,
- UNDEFINED_ICON);
- }
- if (nodeAttrName.equals(NODE_ICON_EXPANDED_ATTR_NAME)) {
- img
- .setAttribute(ICON_PARAM_NAME,
- DEFAULT_ICON_EXPANDED_PARAM_VALUE);
- } else if (nodeAttrName.equals(NODE_ICON_ATTR_NAME)) {
- img.setAttribute(ICON_PARAM_NAME, DEFAULT_ICON_PARAM_VALUE);
- } else if (nodeAttrName.equals(NODE_ICON_LEAF_ATTR_NAME)) {
- img.setAttribute(ICON_PARAM_NAME, NODE_ICON_LEAF_ATTR_NAME);
- }
+ nsIDOMElement iconNode = visualDocument
+ .createElement(HtmlComponentUtil.HTML_TAG_TD);
+ // creates icon with status of node(collapsed or not) node
+ nsIDOMElement td1 = visualDocument
+ .createElement(HtmlComponentUtil.HTML_TAG_TD);
+
+ // sets icon node
+ if (!isLastElement(sourceNode) && isAdaptorChild(sourceNode)) {
+ backgroundLinePath = RichFacesTemplatesActivator
+ .getPluginResourcePath()
+ + ICON_LINE;
+ setAttributeForPictureNode(pageContext, visualDocument,
+ (Element) sourceNode, td1, NODE_ICON_EXPANDED_ATTR_NAME,
+ showLinesValue == true ? ICON_EXPANDED_ADAPTER_WITH_LINES
+ : ICON_EXPANDED_ADAPTER_WITHOUT_LINES);
+ setAttributeForPictureNode(pageContext, visualDocument,
+ (Element) sourceNode, iconNode, NODE_ICON_ATTR_NAME,
+ showLinesValue == true ? ICON_NODE_WITH_LINE
+ : ICON_NODE_WITHOUT_LINES);
+ } else if ((isAdaptorChild(sourceNode) && isLastElement(sourceNode) && isLastElementAfterAdaptor(sourceNode))
+ || (!isAdaptorChild(sourceNode) && isLastElement(sourceNode))) {
+ backgroundLinePath = RichFacesTemplatesActivator
+ .getPluginResourcePath()
+ + ICON_RIGHT_LINE;
+ setAttributeForPictureNode(pageContext, visualDocument,
+ (Element) sourceNode, td1, NODE_ICON_EXPANDED_ATTR_NAME,
+ showLinesValue == true ? ICON_NOT_EXPANDED_WITH_LINES
+ : ICON_NOT_EXPANDED_WITHOUT_LINES);
+ setAttributeForPictureNode(pageContext, visualDocument,
+ (Element) sourceNode, iconNode, NODE_ICON_LEAF_ATTR_NAME,
+ showLinesValue == true ? ICON_LEAF_WITH_LINES
+ : ICON_LEAF_WITHOUT_LINES);
+ } else {
+ backgroundLinePath = RichFacesTemplatesActivator
+ .getPluginResourcePath()
+ + ICON_RIGHT_LINE;
+ setAttributeForPictureNode(pageContext, visualDocument,
+ (Element) sourceNode, td1, NODE_ICON_EXPANDED_ATTR_NAME,
+ showLinesValue == true ? ICON_EXPANDED_WITH_LINES
+ : ICON_EXPANDED_WITHOUT_LINES);
+
+ if (showLinesValue) {
+ String path = RichFacesTemplatesActivator
+ .getPluginResourcePath()
+ + ICON_LEFT_LINE;
+ iconNode.setAttribute(HtmlComponentUtil.HTML_STYLE_ATTR,
+ "background-image: url(file://" + path + "); "
+ + NODE_LINES_STYLE);
+ }
+
+ setAttributeForPictureNode(pageContext, visualDocument,
+ (Element) sourceNode, iconNode, NODE_ICON_ATTR_NAME,
+ showLinesValue == true ? ICON_NODE_WITH_LINES
+ : ICON_NODE_WITHOUT_LINES);
}
- /**
- * Create simple tree node attribute.Used for creating more complex trees.
- *
- * @param treeNodeTitle
- * @param visualDocument
- * @return tree
+ if (showLinesValue) {
+ td1.setAttribute(HtmlComponentUtil.HTML_STYLE_ATTR,
+ "background-image: url(file://" + backgroundLinePath
+ + "); " + NODE_LINES_STYLE);
+ }
+ treeRow.appendChild(td1);
+ treeRow.appendChild(iconNode);
+ // creates Tree Node Name Message
+ nsIDOMElement nodeTitle = visualDocument
+ .createElement(HtmlComponentUtil.HTML_TAG_TD);
+ addBasicNodeTitleAttributes(nodeTitle);
+ // Create mapping to Encode body
+ VpeChildrenInfo tdInfo = new VpeChildrenInfo(nodeTitle);
+
+ // Create mapping to Encode body
+ List<Node> children = ComponentUtil.getChildren((Element) sourceNode,
+ false);
+ for (Node child : children) {
+ tdInfo.addSourceChild(child);
+ }
+ vpeCreationData.addChildrenInfo(tdInfo);
+ treeRow.appendChild(nodeTitle);
+
+ }
+
+ /**
+ * Sets attributes for no node title name
+ *
+ * @param nodeTitle
+ */
+ private void addBasicNodeTitleAttributes(nsIDOMElement nodeTitle) {
+ nodeTitle.setAttribute(HtmlComponentUtil.HTML_CLASS_ATTR,
+ STYLE_CLASS_FOR_NODE_TITLE);
+ }
+
+ @Override
+ public void setAttribute(VpePageContext pageContext, Element sourceElement,
+ nsIDOMDocument visualDocument, nsIDOMNode visualNode, Object data,
+ String name, String value) {
+ /*
+ * processed only next attributes iconExpanded and icon, becouse tree
+ * allways shows as expanded and information is it leaf or not contains
+ * in model
*/
- private void createBasicTree(VpePageContext pageContext,
- nsIDOMDocument visualDocument, nsIDOMElement treeRow, Node sourceNode,
- VpeCreationData vpeCreationData) {
- // creates icon node
- nsIDOMElement iconNode = visualDocument
- .createElement(HtmlComponentUtil.HTML_TAG_TD);
- String showLinesParam = ((Element) sourceNode.getParentNode())
- .getAttribute(RichFacesTreeTemplate.SHOW_LINES_ATTR_NAME);
- boolean showLinesValue = true;
- if (showLinesParam != null && showLinesParam.equalsIgnoreCase("false")) {
- showLinesValue = false;
- }
- // creates icon with status of node(collapsed or not) node
- nsIDOMElement td1 = visualDocument
- .createElement(HtmlComponentUtil.HTML_TAG_TD);
+ if (NODE_ICON_EXPANDED_ATTR_NAME.equalsIgnoreCase(name)) {
+ nsIDOMElement expandedIconCell = (nsIDOMElement) visualNode
+ .getChildNodes().item(0).queryInterface(
+ nsIDOMElement.NS_IDOMELEMENT_IID);
+ nsIDOMElement img = (nsIDOMElement) expandedIconCell
+ .getChildNodes().item(0).queryInterface(
+ nsIDOMElement.NS_IDOMELEMENT_IID);
- // sets attribute for icon expanded picture or not
- setAttributeForPictureNode(pageContext, visualDocument,
- (Element) sourceNode, td1, NODE_ICON_EXPANDED_ATTR_NAME,
- showLinesValue == true ? ICON_EXPANDED_WITH_LINES
- : ICON_EXPANDED_WITHOUT_LINES);
- // sets icon node
- if (!isLastElement(sourceNode.getParentNode(), sourceNode)) {
- setAttributeForPictureNode(pageContext, visualDocument,
- (Element) sourceNode, iconNode, NODE_ICON_ATTR_NAME,
- showLinesValue == true ? ICON_NODE_WITH_LINES
- : ICON_NODE_WITHOUT_LINES);
- } else {
- setAttributeForPictureNode(pageContext, visualDocument,
- (Element) sourceNode, iconNode, NODE_ICON_LEAF_ATTR_NAME,
- showLinesValue == true ? ICON_LEAF_WITH_LINES
- : ICON_LEAF_WITHOUT_LINES);
- }
+ ComponentUtil.setImgFromResources(pageContext, img, value,
+ UNDEFINED_ICON);
+ img.setAttribute(ICON_PARAM_NAME, "");
+ } else if (NODE_ICON_ATTR_NAME.equals(name)
+ && !isLastElement(visualNode)) {
+ nsIDOMElement iconCell = (nsIDOMElement) visualNode.getChildNodes()
+ .item(1).queryInterface(nsIDOMElement.NS_IDOMELEMENT_IID);
+ nsIDOMElement img = (nsIDOMElement) iconCell.getChildNodes()
+ .item(0).queryInterface(nsIDOMElement.NS_IDOMELEMENT_IID);
- treeRow.appendChild(td1);
- treeRow.appendChild(iconNode);
- // creates Tree Node Name Message
- nsIDOMElement nodeTitle = visualDocument
- .createElement(HtmlComponentUtil.HTML_TAG_TD);
- addBasicNadeTitleAttributes(nodeTitle);
- // Create mapping to Encode body
- VpeChildrenInfo tdInfo = new VpeChildrenInfo(nodeTitle);
+ ComponentUtil.setImgFromResources(pageContext, img, value,
+ UNDEFINED_ICON);
+ img.setAttribute(ICON_PARAM_NAME, "");
+ } else if (NODE_ICON_LEAF_ATTR_NAME.equals(name)
+ && isLastElement(sourceElement)) {
+ nsIDOMElement iconCell = (nsIDOMElement) visualNode.getChildNodes()
+ .item(1).queryInterface(nsIDOMElement.NS_IDOMELEMENT_IID);
+ nsIDOMElement img = (nsIDOMElement) iconCell.getChildNodes()
+ .item(0).queryInterface(nsIDOMElement.NS_IDOMELEMENT_IID);
- // Create mapping to Encode body
- List<Node> children = ComponentUtil.getChildren((Element) sourceNode,
- false);
- for (Node child : children) {
- tdInfo.addSourceChild(child);
- }
- vpeCreationData.addChildrenInfo(tdInfo);
- treeRow.appendChild(nodeTitle);
+ ComponentUtil.setImgFromResources(pageContext, img, value,
+ UNDEFINED_ICON);
+ img.setAttribute(ICON_PARAM_NAME, "");
}
+ }
- /**
- * Sets attributes for no node title name
- *
- * @param nodeTitle
+ @Override
+ public void removeAttribute(VpePageContext pageContext,
+ Element sourceElement, nsIDOMDocument visualDocument,
+ nsIDOMNode visualNode, Object data, String name) {
+ /*
+ * processed only next attributes iconExpanded and icon, becouse tree
+ * allways shows as expanded and information is it leaf or not contains
+ * in model
*/
- private void addBasicNadeTitleAttributes(nsIDOMElement nodeTitle) {
- nodeTitle.setAttribute(HtmlComponentUtil.HTML_CLASS_ATTR,
- STYLE_CLASS_FOR_NODE_TITLE);
+
+ boolean showLinesValue = getShowLinesAttr(sourceElement);
+ if (NODE_ICON_EXPANDED_ATTR_NAME.equalsIgnoreCase(name)) {
+ nsIDOMElement expandedIconCell = (nsIDOMElement) visualNode
+ .getChildNodes().item(0).queryInterface(
+ nsIDOMElement.NS_IDOMELEMENT_IID);
+ nsIDOMElement img = (nsIDOMElement) expandedIconCell
+ .getChildNodes().item(0).queryInterface(
+ nsIDOMElement.NS_IDOMELEMENT_IID);
+
+ String parentAttrName = ((Element) sourceElement.getParentNode())
+ .getAttribute(NODE_ICON_EXPANDED_ATTR_NAME);
+ if (parentAttrName == null || parentAttrName.length() == 0) {
+ ComponentUtil.setImg(img,
+ showLinesValue == true ? ICON_EXPANDED_WITH_LINES
+ : ICON_EXPANDED_WITHOUT_LINES);
+ } else {
+ ComponentUtil.setImgFromResources(pageContext, img,
+ parentAttrName, UNDEFINED_ICON);
+ }
+ img
+ .setAttribute(ICON_PARAM_NAME,
+ DEFAULT_ICON_EXPANDED_PARAM_VALUE);
+ } else if (NODE_ICON_ATTR_NAME.equalsIgnoreCase(name)
+ && !isLastElement(sourceElement)) {
+ nsIDOMElement iconCell = (nsIDOMElement) visualNode.getChildNodes()
+ .item(1).queryInterface(nsIDOMElement.NS_IDOMELEMENT_IID);
+
+ nsIDOMElement img = (nsIDOMElement) iconCell.getChildNodes()
+ .item(0).queryInterface(nsIDOMElement.NS_IDOMELEMENT_IID);
+
+ String parentAttrName = ((Element) sourceElement.getParentNode())
+ .getAttribute(NODE_ICON_ATTR_NAME);
+ if (parentAttrName == null || parentAttrName.length() == 0) {
+ ComponentUtil.setImg(img,
+ showLinesValue == true ? ICON_NODE_WITH_LINES
+ : ICON_NODE_WITHOUT_LINES);
+ } else {
+ ComponentUtil.setImgFromResources(pageContext, img,
+ parentAttrName, UNDEFINED_ICON);
+ }
+ img.setAttribute(ICON_PARAM_NAME, DEFAULT_ICON_PARAM_VALUE);
+
+ } else if (NODE_ICON_LEAF_ATTR_NAME.equalsIgnoreCase(name)
+ && isLastElement(sourceElement)) {
+ nsIDOMElement iconCell = (nsIDOMElement) visualNode.getChildNodes()
+ .item(1).queryInterface(nsIDOMElement.NS_IDOMELEMENT_IID);
+ nsIDOMElement img = (nsIDOMElement) iconCell.getChildNodes()
+ .item(0).queryInterface(nsIDOMElement.NS_IDOMELEMENT_IID);
+
+ String parentAttrName = ((Element) sourceElement.getParentNode())
+ .getAttribute(NODE_ICON_LEAF_ATTR_NAME);
+ if (parentAttrName == null || parentAttrName.length() == 0) {
+ ComponentUtil.setImg(img,
+ showLinesValue == true ? ICON_LEAF_WITH_LINES
+ : ICON_LEAF_WITHOUT_LINES);
+ } else {
+ ComponentUtil.setImgFromResources(pageContext, img,
+ parentAttrName, UNDEFINED_ICON);
+ }
+ img.setAttribute(ICON_PARAM_NAME, NODE_ICON_LEAF_ATTR_NAME);
}
+ }
-
-
- @Override
- public void setAttribute(VpePageContext pageContext, Element sourceElement,
- nsIDOMDocument visualDocument, nsIDOMNode visualNode, Object data, String name,
- String value) {
- //
- // processed only next attributes iconExpanded and icon, becouse tree
- // allways shows as expanded and information is it leaf or not contains
- // in model
- //
- if (NODE_ICON_EXPANDED_ATTR_NAME.equalsIgnoreCase(name)) {
- nsIDOMElement expandedIconCell = (nsIDOMElement) visualNode.getChildNodes()
- . item(0).queryInterface(nsIDOMElement.NS_IDOMELEMENT_IID);
- nsIDOMElement img = (nsIDOMElement) expandedIconCell.getChildNodes()
- .item(0).queryInterface(nsIDOMElement.NS_IDOMELEMENT_IID);
- ComponentUtil.setImgFromResources(pageContext, img, value,
- UNDEFINED_ICON);
- img.setAttribute(ICON_PARAM_NAME, "");
- } else if (NODE_ICON_ATTR_NAME.equals(name)
- && !isLastElement(visualNode.getParentNode(), visualNode)) {
- nsIDOMElement iconCell = (nsIDOMElement) visualNode.getChildNodes().item(1)
- .queryInterface(nsIDOMElement.NS_IDOMELEMENT_IID);
- nsIDOMElement img = (nsIDOMElement) iconCell.getChildNodes().item(0)
- .queryInterface(nsIDOMElement.NS_IDOMELEMENT_IID);
- ComponentUtil.setImgFromResources(pageContext, img, value,
- UNDEFINED_ICON);
- img.setAttribute(ICON_PARAM_NAME, "");
- } else if (NODE_ICON_LEAF_ATTR_NAME.equals(name)
- && isLastElement(sourceElement.getParentNode(), sourceElement)) {
- nsIDOMElement iconCell = (nsIDOMElement) visualNode.getChildNodes().item(1)
- .queryInterface(nsIDOMElement.NS_IDOMELEMENT_IID);
- nsIDOMElement img = (nsIDOMElement) iconCell.getChildNodes().item(0)
- .queryInterface(nsIDOMElement.NS_IDOMELEMENT_IID);
- ComponentUtil.setImgFromResources(pageContext, img, value,
- UNDEFINED_ICON);
- img.setAttribute(ICON_PARAM_NAME, "");
- }
+ /**
+ *
+ * @param sourceNode
+ * @return
+ */
+ private boolean isAdaptorChild(Node sourceNode) {
+ Node parentNode = sourceNode.getParentNode();
+ if (!(parentNode instanceof Element)) {
+ return true;
}
- @Override
- public void removeAttribute(VpePageContext pageContext,
- Element sourceElement, nsIDOMDocument visualDocument, nsIDOMNode visualNode,
- Object data, String name) {
- //
- // processed only next attributes iconExpanded and icon, becouse tree
- // allways shows as expanded and information is it leaf or not contains
- // in model
- //
- String showLinesParam = ((Element) sourceElement.getParentNode())
- .getAttribute(RichFacesTreeTemplate.SHOW_LINES_ATTR_NAME);
- boolean showLinesValue = true;
- if (showLinesParam != null && showLinesParam.equalsIgnoreCase("false")) {
- showLinesValue = false;
- }
- if (NODE_ICON_EXPANDED_ATTR_NAME.equalsIgnoreCase(name)) {
- nsIDOMElement expandedIconCell = (nsIDOMElement) visualNode.getChildNodes()
- .item(0).queryInterface(nsIDOMElement.NS_IDOMELEMENT_IID);
- nsIDOMElement img = (nsIDOMElement) expandedIconCell.getChildNodes().item(0)
- .queryInterface(nsIDOMElement.NS_IDOMELEMENT_IID);
-
- String parentAttrName = ((Element) sourceElement.getParentNode())
- .getAttribute(NODE_ICON_EXPANDED_ATTR_NAME);
- if (parentAttrName == null || parentAttrName.length() == 0) {
- ComponentUtil.setImg(img,
- showLinesValue == true ? ICON_EXPANDED_WITH_LINES
- : ICON_EXPANDED_WITHOUT_LINES);
- } else {
- ComponentUtil.setImgFromResources(pageContext, img,
- parentAttrName, UNDEFINED_ICON);
- }
- img
- .setAttribute(ICON_PARAM_NAME,
- DEFAULT_ICON_EXPANDED_PARAM_VALUE);
- } else if (NODE_ICON_ATTR_NAME.equalsIgnoreCase(name)
- && !isLastElement(sourceElement.getParentNode(), sourceElement)) {
- nsIDOMElement iconCell = (nsIDOMElement) visualNode.getChildNodes().item(1)
- .queryInterface(nsIDOMElement.NS_IDOMELEMENT_IID);
-
- nsIDOMElement img = (nsIDOMElement) iconCell.getChildNodes().item(0)
- .queryInterface(nsIDOMElement.NS_IDOMELEMENT_IID);
- String parentAttrName = ((Element) sourceElement.getParentNode())
- .getAttribute(NODE_ICON_ATTR_NAME);
- if (parentAttrName == null || parentAttrName.length() == 0) {
- ComponentUtil.setImg(img,
- showLinesValue == true ? ICON_NODE_WITH_LINES
- : ICON_NODE_WITHOUT_LINES);
- } else {
- ComponentUtil.setImgFromResources(pageContext, img,
- parentAttrName, UNDEFINED_ICON);
- }
- img.setAttribute(ICON_PARAM_NAME, DEFAULT_ICON_PARAM_VALUE);
+ String treeNodesAdaptorName = sourceNode.getPrefix() + ":"
+ + RichFacesTreeTemplate.TREE_NODES_ADAPTOR;
+ String treeRecursiveNodesAdaptorName = sourceNode.getPrefix() + ":"
+ + RichFacesTreeTemplate.TREE_RECURSIVE_NODES_ADAPTOR;
+ if (parentNode.getNodeName().equals(treeNodesAdaptorName)
+ || parentNode.getNodeName().equals(
+ treeRecursiveNodesAdaptorName)) {
+ return true;
+ }
+ return false;
+ }
- } else if (NODE_ICON_LEAF_ATTR_NAME.equalsIgnoreCase(name)
- && isLastElement(sourceElement.getParentNode(), sourceElement)) {
- nsIDOMElement iconCell = (nsIDOMElement) visualNode.getChildNodes().item(1)
- .queryInterface(nsIDOMElement.NS_IDOMELEMENT_IID);
- nsIDOMElement img = (nsIDOMElement) iconCell.getChildNodes().item(0)
- .queryInterface(nsIDOMElement.NS_IDOMELEMENT_IID);
- String parentAttrName = ((Element) sourceElement.getParentNode())
- .getAttribute(NODE_ICON_LEAF_ATTR_NAME);
- if (parentAttrName == null || parentAttrName.length() == 0) {
- ComponentUtil.setImg(img,
- showLinesValue == true ? ICON_LEAF_WITH_LINES
- : ICON_LEAF_WITHOUT_LINES);
- } else {
- ComponentUtil.setImgFromResources(pageContext, img,
- parentAttrName, UNDEFINED_ICON);
- }
- img.setAttribute(ICON_PARAM_NAME, NODE_ICON_LEAF_ATTR_NAME);
- }
+ /**
+ *
+ * @param parentTree
+ * @param sourceNode
+ * @return
+ */
+ private boolean isLastElement(Node sourceNode) {
+ Node parentTree = sourceNode.getParentNode();
+ if (!(parentTree instanceof Element)) {
+ return true;
}
-
+ NodeList childs = parentTree.getChildNodes();
+ String treeNodeName = parentTree.getPrefix() + ":"
+ + RichFacesTreeTemplate.TREE_NODE_NAME;
+ String treeNodesAdaptorName = parentTree.getPrefix() + ":"
+ + RichFacesTreeTemplate.TREE_NODES_ADAPTOR;
+ String treeRecursiveNodesAdaptorName = parentTree.getPrefix() + ":"
+ + RichFacesTreeTemplate.TREE_RECURSIVE_NODES_ADAPTOR;
+ Node lastElement = null;
+ Node el = null;
+ for (int i = 0; i < childs.getLength(); i++) {
+ el = childs.item(i);
+ if (el.getNodeName().equals(treeNodeName)
+ || el.getNodeName().equals(treeNodesAdaptorName)
+ || el.getNodeName().equals(treeRecursiveNodesAdaptorName)) {
+ lastElement = el;
+ }
+ }
+ return sourceNode.equals(lastElement);
+ }
- /**
- *
- * @param parentTree
- * @param currentNode
- * @return
- */
- private boolean isLastElement(Node parentTree, Node currentNode) {
- NodeList childs = parentTree.getChildNodes();
- String treeNodeName = parentTree.getPrefix() + ":"
- + RichFacesTreeTemplate.TREE_NODE_NAME;
- Node lastElement = null;
- Node el = null;
- for (int i = 0; i < childs.getLength(); i++) {
- el = childs.item(i);
- if (el.getNodeName().equals(treeNodeName)) {
- lastElement = el;
- }
- }
- return currentNode.equals(lastElement);
+ /**
+ *
+ * @param parentTree
+ * @param sourceNode
+ * @return
+ */
+ private boolean isLastElement(nsIDOMNode sourceNode) {
+ nsIDOMNode parentTree = sourceNode.getParentNode();
+ if (!(parentTree instanceof Element)) {
+ return true;
}
-
- /**
- *
- * @param parentTree
- * @param currentNode
- * @return
- */
- private boolean isLastElement(nsIDOMNode parentTree, nsIDOMNode currentNode) {
- nsIDOMNodeList childs = parentTree.getChildNodes();
- String treeNodeName = parentTree.getPrefix() + ":"
- + RichFacesTreeTemplate.TREE_NODE_NAME;
- nsIDOMNode lastElement = null;
- nsIDOMNode el = null;
- for (int i = 0; i < childs.getLength(); i++) {
- el = childs.item(i);
- if (el.getNodeName().equals(treeNodeName)) {
- lastElement = el;
- }
- }
- return currentNode.equals(lastElement);
+ nsIDOMNodeList childs = parentTree.getChildNodes();
+ String treeNodeName = parentTree.getPrefix() + ":"
+ + RichFacesTreeTemplate.TREE_NODE_NAME;
+ String treeNodesAdaptorName = parentTree.getPrefix() + ":"
+ + RichFacesTreeTemplate.TREE_NODES_ADAPTOR;
+ String treeRecursiveNodesAdaptorName = parentTree.getPrefix() + ":"
+ + RichFacesTreeTemplate.TREE_RECURSIVE_NODES_ADAPTOR;
+ nsIDOMNode lastElement = null;
+ nsIDOMNode el = null;
+ for (int i = 0; i < childs.getLength(); i++) {
+ el = childs.item(i);
+ if (el.getNodeName().equals(treeNodeName)
+ || el.getNodeName().equals(treeNodesAdaptorName)
+ || el.getNodeName().equals(treeRecursiveNodesAdaptorName)) {
+ lastElement = el;
+ }
}
+ return sourceNode.equals(lastElement);
+ }
- /**
- * Adds basic attributes to tree
- *
- * @param img
- */
+ /**
+ * Adds basic attributes to tree
+ *
+ * @param img
+ */
- private void addBasicAttributesToPicture(nsIDOMElement img) {
- img.setAttribute(HtmlComponentUtil.HTML_CLASS_ATTR,
- TREE_TABLE_PICTURE_STYLE_CLASS_NAME);
+ private void addBasicAttributesToPicture(nsIDOMElement img) {
+ img.setAttribute(HtmlComponentUtil.HTML_CLASS_ATTR,
+ TREE_TABLE_PICTURE_STYLE_CLASS_NAME);
+ }
+
+ /**
+ * Set attributes for treeNode
+ *
+ * @param table
+ */
+ private void addBasicTreeNodeAttributes(nsIDOMElement table) {
+ if (table == null) {
+ return;
}
+ table.setAttribute(HtmlComponentUtil.HTML_CELLPADDING_ATTR,
+ TREE_TABLE_ATR_CELLPADDING_VALUE);
+ table.setAttribute(HtmlComponentUtil.HTML_CELLSPACING_ATTR,
+ TREE_TABLE_ATR_CELLSPACING_VALUE);
+ table.setAttribute(HtmlComponentUtil.HTML_BORDER_ATTR,
+ TREE_TABLE_ATR_BORDER_VALUE);
+ table.setAttribute(HtmlComponentUtil.HTML_CLASS_ATTR,
+ "dr-tree-full-width");
+ }
+
+ /**
+ * Get showConnectingLines attribute
+ *
+ * @param sourceNode
+ * @return
+ */
+ private boolean getShowLinesAttr(Node sourceNode) {
+ String treeName = sourceNode.getPrefix() + ":" + TREE_NAME;
+ do {
+ sourceNode = sourceNode.getParentNode();
+ if (!(sourceNode instanceof Element)) {
+ return true;
+ }
+ } while (!sourceNode.getNodeName().equals(treeName));
+
+ String showLinesParam = ((Element) sourceNode)
+ .getAttribute(RichFacesTreeTemplate.SHOW_LINES_ATTR_NAME);
+
+ boolean showLinesValue = true;
+ if (showLinesParam != null && showLinesParam.equalsIgnoreCase("false")) {
+ showLinesValue = false;
+ }
+ return showLinesValue;
+ }
+
+ /**
+ *
+ * @param sourceNode
+ * @return
+ */
+ private boolean isLastElementAfterAdaptor(Node sourceNode) {
+ Node nodeAdaptor = sourceNode.getParentNode();
+ if (!(nodeAdaptor instanceof Element)) {
+ return true;
+ }
+ return isLastElement(nodeAdaptor);
+ }
}
Copied: branches/jbosstools_xulrunner/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesTreeNodesAdaptorTemplate.java (from rev 3575, branches/jbosstools_xulrunner/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesTreeNodesTemplate.java)
===================================================================
--- branches/jbosstools_xulrunner/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesTreeNodesAdaptorTemplate.java (rev 0)
+++ branches/jbosstools_xulrunner/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesTreeNodesAdaptorTemplate.java 2007-09-27 00:53:13 UTC (rev 3833)
@@ -0,0 +1,105 @@
+/*******************************************************************************
+ * 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.jsf.vpe.richfaces.template;
+
+import org.jboss.tools.jsf.vpe.richfaces.HtmlComponentUtil;
+import org.jboss.tools.vpe.editor.context.VpePageContext;
+import org.jboss.tools.vpe.editor.template.VpeAbstractTemplate;
+import org.jboss.tools.vpe.editor.template.VpeChildrenInfo;
+import org.jboss.tools.vpe.editor.template.VpeCreationData;
+import org.mozilla.interfaces.nsIDOMDocument;
+import org.mozilla.interfaces.nsIDOMElement;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+/**
+ * Create template for rich:treeNodesAdaptor element
+ *
+ * @author dsakovich(a)exadel.com
+ *
+ */
+public class RichFacesTreeNodesAdaptorTemplate extends VpeAbstractTemplate {
+
+ private final static String TREE_NODE_NAME = "treeNode";
+
+ private static final String TREE_TABLE_ATR_CELLSPACING_VALUE = "0px";
+
+ private static final String TREE_TABLE_ATR_CELLPADDING_VALUE = "0px";
+
+ private static final String TREE_TABLE_ATR_BORDER_VALUE = "0px";
+
+ public VpeCreationData create(VpePageContext pageContext, Node sourceNode,
+ nsIDOMDocument visualDocument) {
+ nsIDOMElement visualElement = visualDocument
+ .createElement(HtmlComponentUtil.HTML_TAG_TABLE);
+ addBasicTreeNodeAttributes(visualElement);
+ VpeCreationData vpeCreationData = new VpeCreationData(visualElement);
+ parseTree(pageContext, sourceNode, visualDocument, vpeCreationData,
+ visualElement);
+ return vpeCreationData;
+ }
+
+ /**
+ *
+ * Function for parsing tree by tree nodes;
+ *
+ * @param pageContext
+ * @param sourceNode
+ * @param visualDocument
+ * @return
+ */
+ public void parseTree(VpePageContext pageContext, Node sourceNode,
+ nsIDOMDocument visualDocument, VpeCreationData vpeCreationData,
+ nsIDOMElement parentElement) {
+ NodeList nodeList = sourceNode.getChildNodes();
+ Element element = null;
+ int lenght = nodeList.getLength();
+ String treeNodeName = sourceNode.getPrefix() + ":" + TREE_NODE_NAME;
+ VpeChildrenInfo vpeChildrenInfo = null;
+ for (int i = 0; i < lenght; i++) {
+ if (!(nodeList.item(i) instanceof Element)) {
+ continue;
+ }
+ element = (Element) nodeList.item(i);
+ if (element.getNodeName().equals(treeNodeName)) {
+ nsIDOMElement tr = visualDocument
+ .createElement(HtmlComponentUtil.HTML_TAG_TR);
+ nsIDOMElement td = visualDocument
+ .createElement(HtmlComponentUtil.HTML_TAG_TD);
+ tr.appendChild(td);
+ vpeChildrenInfo = new VpeChildrenInfo(td);
+ vpeCreationData.addChildrenInfo(vpeChildrenInfo);
+ vpeChildrenInfo.addSourceChild(element);
+ parentElement.appendChild(tr);
+ }
+ }
+ }
+
+ /**
+ * Set attributes for treeNode
+ *
+ * @param table
+ */
+ private void addBasicTreeNodeAttributes(nsIDOMElement table) {
+ if (table == null) {
+ return;
+ }
+ table.setAttribute(HtmlComponentUtil.HTML_CELLPADDING_ATTR,
+ TREE_TABLE_ATR_CELLPADDING_VALUE);
+ table.setAttribute(HtmlComponentUtil.HTML_CELLSPACING_ATTR,
+ TREE_TABLE_ATR_CELLSPACING_VALUE);
+ table.setAttribute(HtmlComponentUtil.HTML_BORDER_ATTR,
+ TREE_TABLE_ATR_BORDER_VALUE);
+ table.setAttribute(HtmlComponentUtil.HTML_CLASS_ATTR,
+ "dr-tree-full-width");
+ }
+}
Deleted: branches/jbosstools_xulrunner/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesTreeNodesTemplate.java
===================================================================
--- branches/jbosstools_xulrunner/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesTreeNodesTemplate.java 2007-09-27 00:50:58 UTC (rev 3832)
+++ branches/jbosstools_xulrunner/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesTreeNodesTemplate.java 2007-09-27 00:53:13 UTC (rev 3833)
@@ -1,16 +0,0 @@
-package org.jboss.tools.jsf.vpe.richfaces.template;
-
-import org.jboss.tools.vpe.editor.context.VpePageContext;
-import org.jboss.tools.vpe.editor.template.VpeAbstractTemplate;
-import org.jboss.tools.vpe.editor.template.VpeCreationData;
-import org.mozilla.interfaces.nsIDOMDocument;
-import org.w3c.dom.Node;
-
-public class RichFacesTreeNodesTemplate extends VpeAbstractTemplate {
-
- public VpeCreationData create(VpePageContext pageContext, Node sourceNode,
- nsIDOMDocument visualDocument) {
- return null;
- }
-
-}
Modified: branches/jbosstools_xulrunner/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesTreeTemplate.java
===================================================================
--- branches/jbosstools_xulrunner/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesTreeTemplate.java 2007-09-27 00:50:58 UTC (rev 3832)
+++ branches/jbosstools_xulrunner/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesTreeTemplate.java 2007-09-27 00:53:13 UTC (rev 3833)
@@ -7,7 +7,7 @@
*
* Contributors:
* Exadel, Inc. and Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
+ ******************************************************************************/
package org.jboss.tools.jsf.vpe.richfaces.template;
import org.jboss.tools.jsf.vpe.richfaces.ComponentUtil;
@@ -23,391 +23,292 @@
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
+
/**
* Create template for rich:tree element.
*
- * @author Max Areshkau
+ * @author dsakovich(a)exadel.com
*
*/
public class RichFacesTreeTemplate extends VpeAbstractTemplate {
- /** Resurces */
+ /** Resurces */
- public static final String TREE_NODE_NAME = "treeNode";
+ public static final String TREE_NODE_NAME = "treeNode";
- public static final String SHOW_LINES_ATTR_NAME = "showConnectingLines";
+ public static final String TREE_NODES_ADAPTOR = "treeNodesAdaptor";
- private static final String STYLE_PATH = "/tree/tree.css";
+ public static final String TREE_RECURSIVE_NODES_ADAPTOR = "recursiveTreeNodesAdaptor";
- private static final String ICON_ATTR = "icon";
+ public static final String SHOW_LINES_ATTR_NAME = "showConnectingLines";
- private static final String TREE_TABLE_ATR_CELLSPACING_VALUE = "0px";
+ private static final String STYLE_PATH = "/tree/tree.css";
- private static final String TREE_TABLE_ATR_CELLPADDING_VALUE = "0px";
+ private static final String ICON_ATTR = "icon";
- private static final String TREE_TABLE_ATR_BORDER_VALUE = "0px";
+ private static final String TREE_STYLE_CLASS_ATR_NAME = "styleClass";
- private static final String TREE_STYLE_CLASS_ATR_NAME = "styleClass";
+ private static final String ICON_COLLAPSED_ATTR_NAME = "iconExpanded";
- private static final String ICON_COLLAPSED_ATTR_NAME = "iconExpanded";
-
- /**
- * Creates a node of the visual tree on the node of the source tree. This
- * visual node should not have the parent node This visual node can have
- * child nodes.
- *
- * @param pageContext
- * Contains the information on edited page.
- * @param sourceNode
- * The current node of the source tree.
- * @param visualDocument
- * The document of the visual tree.
- * @return The information on the created node of the visual tree.
- */
- public VpeCreationData create(VpePageContext pageContext, Node sourceNode,
- nsIDOMDocument visualDocument) {
- // sets css for tree on page
- ComponentUtil.setCSSLink(pageContext, STYLE_PATH, "tree");
- nsIDOMElement visualElement = visualDocument
- .createElement(HtmlComponentUtil.HTML_TAG_TABLE);
- nsIDOMElement treeRow = visualDocument
- .createElement(HtmlComponentUtil.HTML_TAG_TR);
- nsIDOMElement treeCell = visualDocument
- .createElement(HtmlComponentUtil.HTML_TAG_TD);
- addBasicTreeAttributes(visualElement);
- treeRow.appendChild(treeCell);
- visualElement.appendChild(treeRow);
-
- VpeCreationData vpeCreationData = new VpeCreationData(visualElement);
-
- parseTree(pageContext, sourceNode, visualDocument, vpeCreationData,
- treeCell);
- setStylesAttributesToTree(visualElement, (Element) sourceNode);
- return vpeCreationData;
+ /**
+ * Creates a node of the visual tree on the node of the source tree. This
+ * visual node should not have the parent node This visual node can have
+ * child nodes.
+ *
+ * @param pageContext
+ * Contains the information on edited page.
+ * @param sourceNode
+ * The current node of the source tree.
+ * @param visualDocument
+ * The document of the visual tree.
+ * @return The information on the created node of the visual tree.
+ */
+ public VpeCreationData create(VpePageContext pageContext, Node sourceNode,
+ nsIDOMDocument visualDocument) {
+ // sets css for tree on page
+ ComponentUtil.setCSSLink(pageContext, STYLE_PATH, "tree");
+ nsIDOMElement visualElement = visualDocument
+ .createElement(HtmlComponentUtil.HTML_TAG_DIV);
+ Element sourceElement = (Element) sourceNode;
+ String style = sourceElement
+ .getAttribute(HtmlComponentUtil.HTML_STYLE_ATTR);
+ if (style != null) {
+ visualElement
+ .setAttribute(HtmlComponentUtil.HTML_STYLE_ATTR, style);
}
-
- /**
- * Sets to tree basic style attributes
- *
- * @param tree
- * @param sourceNode
- */
- private void setStylesAttributesToTree(nsIDOMElement treeTable, Element sourceNode) {
- String styleAttr = sourceNode
- .getAttribute(HtmlComponentUtil.HTML_STYLE_ATTR);
- if (styleAttr != null && styleAttr.length() != 0) {
- setAttributeToTree(treeTable, HtmlComponentUtil.HTML_STYLE_ATTR,
- removeFromStyleWithAndHeight(styleAttr));
- treeTable
- .setAttribute(HtmlComponentUtil.HTML_STYLE_ATTR, styleAttr);
- }
- String styleClassAttr = sourceNode
- .getAttribute(TREE_STYLE_CLASS_ATR_NAME);
- if ((styleClassAttr != null) && (styleClassAttr.length() != 0)) {
- setAttributeToTree(treeTable, HtmlComponentUtil.HTML_CLASS_ATTR,
- styleClassAttr);
- }
+ String styleClass = sourceElement
+ .getAttribute(HtmlComponentUtil.HTML_CLASS_ATTR);
+ if (styleClass != null) {
+ visualElement.setAttribute(HtmlComponentUtil.HTML_CLASS_ATTR,
+ styleClass);
}
+ VpeCreationData vpeCreationData = new VpeCreationData(visualElement);
+ parseTree(pageContext, sourceNode, visualDocument, vpeCreationData,
+ visualElement);
+ setStylesAttributesToTree(visualElement, (Element) sourceNode);
+ return vpeCreationData;
+ }
- /**
- *
- * @param styleArgs
- * @return
- */
- private String removeFromStyleWithAndHeight(String styleArgs) {
- StringBuffer result = new StringBuffer();
- String[] mas = styleArgs.split(";");
- for (String styleAttr : mas) {
- if ((styleAttr.indexOf(HtmlComponentUtil.HTML_ATR_WIDTH) != -1)
- || (styleAttr.indexOf(HtmlComponentUtil.HTML_ATR_HEIGHT) != -1)) {
- continue;
- }
- result.append(styleAttr + ";");
- }
- return result.toString();
+ /**
+ * Sets to tree basic style attributes
+ *
+ * @param tree
+ * @param sourceNode
+ */
+ private void setStylesAttributesToTree(nsIDOMElement treeTable,
+ Element sourceNode) {
+ String styleAttr = sourceNode
+ .getAttribute(HtmlComponentUtil.HTML_STYLE_ATTR);
+ if (styleAttr != null && styleAttr.length() != 0) {
+ setAttributeToTree(treeTable, HtmlComponentUtil.HTML_STYLE_ATTR,
+ removeFromStyleWithAndHeight(styleAttr));
+ treeTable
+ .setAttribute(HtmlComponentUtil.HTML_STYLE_ATTR, styleAttr);
}
-
- /**
- * Sets to tree tables attributes
- *
- * @param node
- * @param sourceNode
- * @param attrValue
- */
- private void setAttributeToTree(nsIDOMNode node, String attrName, String attrValue) {
- if (!(node instanceof nsIDOMElement)) {
- return;
- }
- if (node.getNodeName().equalsIgnoreCase(
- HtmlComponentUtil.HTML_TAG_TABLE)) {
- ((nsIDOMElement)node.queryInterface(nsIDOMElement.NS_IDOMELEMENT_IID)).setAttribute(attrName, attrValue);
- }
- nsIDOMNodeList list2 = node.getChildNodes();
- for (int i = 0; i < list2.getLength(); i++) {
- setAttributeToTree(list2.item(i), attrName, attrValue);
- }
+ String styleClassAttr = sourceNode
+ .getAttribute(TREE_STYLE_CLASS_ATR_NAME);
+ if ((styleClassAttr != null) && (styleClassAttr.length() != 0)) {
+ setAttributeToTree(treeTable, HtmlComponentUtil.HTML_CLASS_ATTR,
+ styleClassAttr);
}
+ }
- /**
- * Is invoked after construction of all child nodes of the current visual
- * node.
- *
- * @param pageContext
- * Contains the information on edited page.
- * @param sourceNode
- * The current node of the source tree.
- * @param visualDocument
- * The document of the visual tree.
- * @param data
- * Object <code>VpeCreationData</code>, built by a method
- * <code>create</code>
- */
- public void validate(VpePageContext pageContext, Node sourceNode,
- nsIDOMDocument visualDocument, VpeCreationData data) {
- super.validate(pageContext, sourceNode, visualDocument, data);
- data.getChildrenInfoList().get(0);
- revertTableRows(data.getNode());
+ /**
+ *
+ * @param styleArgs
+ * @return
+ */
+ private String removeFromStyleWithAndHeight(String styleArgs) {
+ StringBuffer result = new StringBuffer();
+ String[] mas = styleArgs.split(";");
+ for (String styleAttr : mas) {
+ if ((styleAttr.indexOf(HtmlComponentUtil.HTML_ATR_WIDTH) != -1)
+ || (styleAttr.indexOf(HtmlComponentUtil.HTML_ATR_HEIGHT) != -1)) {
+ continue;
+ }
+ result.append(styleAttr + ";");
}
+ return result.toString();
+ }
- /**
- * Recursive go throw three and checks if icon was seted for node or not
- *
- * @param node
- */
- private void correctImage(VpePageContext pageContex, Element sourceNode,
- nsIDOMNode node) {
- if (!(node instanceof nsIDOMElement)) {
- return;
- }
- if (node.getNodeName().equalsIgnoreCase(HtmlComponentUtil.HTML_TAG_IMG)) {
- String srcAttr = ((nsIDOMElement) node
- .queryInterface(nsIDOMElement.NS_IDOMELEMENT_IID))
- .getAttribute(RichFacesTreeNodeTemplate.ICON_PARAM_NAME);
- if (RichFacesTreeNodeTemplate.DEFAULT_ICON_EXPANDED_PARAM_VALUE
- .equals(srcAttr)) {
- setImgForNode(pageContex, sourceNode, (nsIDOMElement) node.queryInterface(nsIDOMElement.NS_IDOMELEMENT_IID),
- ICON_COLLAPSED_ATTR_NAME,
- RichFacesTreeNodeTemplate.ICON_EXPANDED_WITH_LINES,
- RichFacesTreeNodeTemplate.ICON_EXPANDED_WITHOUT_LINES);
- } else if (RichFacesTreeNodeTemplate.DEFAULT_ICON_PARAM_VALUE
- .equals(srcAttr)) {
- setImgForNode(pageContex, sourceNode, (nsIDOMElement) node.queryInterface(nsIDOMElement.NS_IDOMELEMENT_IID),
- ICON_ATTR,
- RichFacesTreeNodeTemplate.ICON_NODE_WITH_LINES,
- RichFacesTreeNodeTemplate.ICON_NODE_WITHOUT_LINES);
- } else if (RichFacesTreeNodeTemplate.NODE_ICON_LEAF_ATTR_NAME
- .equals(srcAttr)) {
- setImgForNode(pageContex, sourceNode, (nsIDOMElement) node.queryInterface(nsIDOMElement.NS_IDOMELEMENT_IID),
- RichFacesTreeNodeTemplate.NODE_ICON_LEAF_ATTR_NAME,
- RichFacesTreeNodeTemplate.ICON_LEAF_WITH_LINES,
- RichFacesTreeNodeTemplate.ICON_LEAF_WITHOUT_LINES);
- }
- }
- nsIDOMNodeList list2 = node.getChildNodes();
- for (int i = 0; i < list2.getLength(); i++) {
- correctImage(pageContex, sourceNode, list2.item(i));
- }
+ /**
+ * Sets to tree tables attributes
+ *
+ * @param node
+ * @param sourceNode
+ * @param attrValue
+ */
+ private void setAttributeToTree(nsIDOMNode node, String attrName,
+ String attrValue) {
+ if (!(node instanceof nsIDOMElement)) {
+ return;
}
-
- /**
- * Sets icon fro node
- *
- * @param img
- * @param sourceNode
- */
- private void setImgForNode(VpePageContext pageContext, Element sourceNode,
- nsIDOMElement img, String attrName, String iconWithLines,
- String iconWithoutLines) {
- String treeIconAttr = sourceNode.getAttribute(attrName);
- if (treeIconAttr != null && treeIconAttr.length() > 0) {
- ComponentUtil.setImgFromResources(pageContext, img, treeIconAttr,
- RichFacesTreeNodeTemplate.UNDEFINED_ICON);
- return;
- }
- String showConnectingLinesAttr = sourceNode
- .getAttribute(SHOW_LINES_ATTR_NAME);
- if (showConnectingLinesAttr != null
- && showConnectingLinesAttr.length() > 0
- && showConnectingLinesAttr.equalsIgnoreCase("false")) {
- ComponentUtil.setImg(img, iconWithoutLines);
- } else {
- ComponentUtil.setImg(img, iconWithLines);
- }
+ if (node.getNodeName().equalsIgnoreCase(
+ HtmlComponentUtil.HTML_TAG_TABLE)) {
+ ((nsIDOMElement) node
+ .queryInterface(nsIDOMElement.NS_IDOMELEMENT_IID))
+ .setAttribute(attrName, attrValue);
}
-
- /**
- * Revert tree elements in right order.
- *
- * @param node
- */
- private void revertTableRows(nsIDOMNode node) {
-
- //if (!(node instanceof nsIDOMElement)) {
- // return;
- //}
-
- nsIDOMNodeList list = node.getChildNodes();
- if (node.getNodeName().equalsIgnoreCase(
- HtmlComponentUtil.HTML_TAG_TABLE)
- && list.getLength() == 2) {
- nsIDOMNode tr1 = list.item(0);
- nsIDOMNode tr2 = list.item(1);
- node.removeChild(tr1);
- node.removeChild(tr2);
- node.appendChild(tr2);
- node.appendChild(tr1);
- }
- nsIDOMNodeList list2 = node.getChildNodes();
- for (int i = 0; i < list2.getLength(); i++) {
- revertTableRows(list2.item(i));
- }
+ nsIDOMNodeList list2 = node.getChildNodes();
+ for (int i = 0; i < list2.getLength(); i++) {
+ setAttributeToTree(list2.item(i), attrName, attrValue);
}
+ }
- /**
- *
- * Function for parsing tree by tree nodes;
- *
- * @param pageContext
- * @param sourceNode
- * @param visualDocument
- * @return
- */
- public void parseTree(VpePageContext pageContext, Node sourceNode,
- nsIDOMDocument visualDocument, VpeCreationData vpeCreationData,
- nsIDOMElement cell) {
- // work arroud, becouse getChielsByName returns always null;
- NodeList nodeList = sourceNode.getChildNodes();
- Element element = null;
- nsIDOMElement tree = null;
- nsIDOMElement childTree = null;
- nsIDOMElement childLast = null;
- int lenght = nodeList.getLength();
- String treeNodeName = sourceNode.getPrefix() + ":" + TREE_NODE_NAME;
- VpeChildrenInfo vpeChildrenInfo = null;
- for (int i = 0; i < lenght; i++) {
- if (!(nodeList.item(i) instanceof Element)) {
- continue;
- }
- element = (Element) nodeList.item(i);
- childTree = null;
- if (element.getNodeName().equals(treeNodeName)) {
- if (tree == null) {
+ /**
+ * Is invoked after construction of all child nodes of the current visual
+ * node.
+ *
+ * @param pageContext
+ * Contains the information on edited page.
+ * @param sourceNode
+ * The current node of the source tree.
+ * @param visualDocument
+ * The document of the visual tree.
+ * @param data
+ * Object <code>VpeCreationData</code>, built by a method
+ * <code>create</code>
+ */
+ public void validate(VpePageContext pageContext, Node sourceNode,
+ nsIDOMDocument visualDocument, VpeCreationData data) {
+ super.validate(pageContext, sourceNode, visualDocument, data);
+ revertTableRows(data.getNode());
+ }
- tree = createBasicTree(visualDocument);
- vpeChildrenInfo = new VpeChildrenInfo(tree);
- vpeCreationData.addChildrenInfo(vpeChildrenInfo);
- vpeChildrenInfo.addSourceChild(element);
- childLast = tree;
- continue;
- } else if (childTree == null) {
+ /**
+ * Revert tree elements in right order.
+ *
+ * @param node
+ */
+ private void revertTableRows(nsIDOMNode node) {
- childTree = createBasicTree(visualDocument);
- appendChildTree(childLast, childTree, visualDocument);
- vpeChildrenInfo = new VpeChildrenInfo(childTree);
- vpeCreationData.addChildrenInfo(vpeChildrenInfo);
- vpeChildrenInfo.addSourceChild(element);
- childLast = childTree;
- continue;
- }
- }
- }
- if (tree != null) {
- cell.appendChild(tree);
- }
+ nsIDOMNodeList list = node.getChildNodes();
+ if (node.getNodeName().equalsIgnoreCase(HtmlComponentUtil.HTML_TAG_DIV)
+ && list.getLength() == 2) {
+ nsIDOMNode table1 = list.item(0);
+ nsIDOMNode table2 = list.item(1);
+ node.removeChild(table1);
+ node.removeChild(table2);
+ node.appendChild(table2);
+ node.appendChild(table1);
}
-
- /**
- * Appends child node to tree
- *
- * @param parentNode
- * @param childNode
- * @param visualDocument
- */
- private void appendChildTree(nsIDOMElement parentNode, nsIDOMElement childNode,
- nsIDOMDocument visualDocument) {
- nsIDOMElement tr = visualDocument
- .createElement(HtmlComponentUtil.HTML_TAG_TR);
- nsIDOMElement emptyCell = visualDocument
- .createElement(HtmlComponentUtil.HTML_TAG_TD);
- nsIDOMElement treeCell = visualDocument
- .createElement(HtmlComponentUtil.HTML_TAG_TD);
- treeCell.setAttribute(HtmlComponentUtil.HTML_TABLE_COLSPAN, "2");
- tr.appendChild(emptyCell);
- tr.appendChild(treeCell);
- treeCell.appendChild(childNode);
- parentNode.appendChild(tr);
+ nsIDOMNodeList list2 = node.getChildNodes();
+ for (int i = 0; i < list2.getLength(); i++) {
+ revertTableRows(list2.item(i));
}
+ }
+ /**
+ *
+ * Function for parsing tree by tree nodes;
+ *
+ * @param pageContext
+ * @param sourceNode
+ * @param visualDocument
+ * @return
+ */
+ public void parseTree(VpePageContext pageContext, Node sourceNode,
+ nsIDOMDocument visualDocument, VpeCreationData vpeCreationData,
+ nsIDOMElement parentDiv) {
+ NodeList nodeList = sourceNode.getChildNodes();
+ Element element = null;
+ nsIDOMElement div = null;
+ nsIDOMElement childTree = null;
+ nsIDOMElement childLast = null;
+ int lenght = nodeList.getLength();
+ String treeNodeName = sourceNode.getPrefix() + ":" + TREE_NODE_NAME;
+ String treeNodesAdaptorName = sourceNode.getPrefix() + ":"
+ + TREE_NODES_ADAPTOR;
+ String recursiveTreeNodesAdaptorName = sourceNode.getPrefix() + ":"
+ + TREE_RECURSIVE_NODES_ADAPTOR;
+ VpeChildrenInfo vpeChildrenInfo = null;
+ for (int i = 0; i < lenght; i++) {
+ if (!(nodeList.item(i) instanceof Element)) {
+ continue;
+ }
+ element = (Element) nodeList.item(i);
+ childTree = null;
+ if (element.getNodeName().equals(treeNodeName)
+ || element.getNodeName().equals(treeNodesAdaptorName)
+ || element.getNodeName().equals(
+ recursiveTreeNodesAdaptorName)) {
+ if (div == null) {
- @Override
- public void setAttribute(VpePageContext pageContext, Element sourceElement,
- nsIDOMDocument visualDocument, nsIDOMNode visualNode, Object data, String name,
- String value) {
- if (TREE_STYLE_CLASS_ATR_NAME.equalsIgnoreCase(name)) {
- setAttributeToTree(visualNode, HtmlComponentUtil.HTML_CLASS_ATTR,
- value);
- } else if (HtmlComponentUtil.HTML_STYLE_ATTR.equalsIgnoreCase(name)) {
- setAttributeToTree(visualNode, HtmlComponentUtil.HTML_STYLE_ATTR,
- removeFromStyleWithAndHeight(value));
- ((nsIDOMElement) visualNode.queryInterface(nsIDOMElement.NS_IDOMELEMENT_IID)).setAttribute(
- HtmlComponentUtil.HTML_STYLE_ATTR, value);
- } else if (ICON_COLLAPSED_ATTR_NAME.equals(name)
- || SHOW_LINES_ATTR_NAME.equals(name)
- || ICON_ATTR.equals(name)
- || RichFacesTreeNodeTemplate.NODE_ICON_LEAF_ATTR_NAME
- .equals(name)) {
- correctImage(pageContext, sourceElement, visualNode);
+ vpeChildrenInfo = new VpeChildrenInfo(parentDiv);
+ vpeCreationData.addChildrenInfo(vpeChildrenInfo);
+ vpeChildrenInfo.addSourceChild(element);
+ div = createBasicTree(visualDocument);
+ childLast = parentDiv;
+ continue;
+ } else if (childTree == null) {
+
+ vpeChildrenInfo = new VpeChildrenInfo(div);
+ vpeCreationData.addChildrenInfo(vpeChildrenInfo);
+ vpeChildrenInfo.addSourceChild(element);
+ childLast.appendChild(div);
+ childLast = div;
+ div = createBasicTree(visualDocument);
+ continue;
}
- }
-
- @Override
- public void removeAttribute(VpePageContext pageContext,
- Element sourceElement, nsIDOMDocument visualDocument, nsIDOMNode visualNode,
- Object data, String name) {
- if (TREE_STYLE_CLASS_ATR_NAME.equalsIgnoreCase(name)) {
- setAttributeToTree(visualNode, HtmlComponentUtil.HTML_CLASS_ATTR,
- "");
- } else if (HtmlComponentUtil.HTML_STYLE_ATTR.equalsIgnoreCase(name)) {
- setAttributeToTree(visualNode, HtmlComponentUtil.HTML_STYLE_ATTR,
- "");
- } else if (ICON_COLLAPSED_ATTR_NAME.equals(name)
- || SHOW_LINES_ATTR_NAME.equals(name)
- || ICON_ATTR.equals(name)
- || RichFacesTreeNodeTemplate.NODE_ICON_LEAF_ATTR_NAME
- .equals(name)) {
- correctImage(pageContext, sourceElement, visualNode);
- }
+ }
}
-
- /**
- * Create simple tree node attribute.Used for creating more complex trees.
- *
- * @param treeNodeTitle
- * @param visualDocument
- * @return tree
- */
- private nsIDOMElement createBasicTree(nsIDOMDocument visualDocument) {
- // create table
- nsIDOMElement tree = visualDocument
- .createElement(HtmlComponentUtil.HTML_TAG_TABLE);
- addBasicTreeAttributes(tree);
- return tree;
+ }
+
+ @Override
+ public boolean isRecreateAtAttrChange(VpePageContext pageContext,
+ Element sourceElement, nsIDOMDocument visualDocument,
+ nsIDOMElement visualNode, Object data, String name, String value) {
+ if (ICON_COLLAPSED_ATTR_NAME.equals(name)
+ || SHOW_LINES_ATTR_NAME.equals(name)
+ || ICON_ATTR.equals(name)
+ || RichFacesTreeNodeTemplate.NODE_ICON_LEAF_ATTR_NAME
+ .equals(name)) {
+ return true;
}
+ return false;
+ }
- /**
- * Sets some attributes which necessary for displaying table as tree
- *
- * @param tree
- */
- private void addBasicTreeAttributes(nsIDOMElement tree) {
- if (tree == null) {
- return;
- }
- tree.setAttribute(HtmlComponentUtil.HTML_CELLSPACING_ATTR,
- TREE_TABLE_ATR_CELLSPACING_VALUE);
- tree.setAttribute(HtmlComponentUtil.HTML_CELLPADDING_ATTR,
- TREE_TABLE_ATR_CELLPADDING_VALUE);
- tree.setAttribute(HtmlComponentUtil.HTML_BORDER_ATTR,
- TREE_TABLE_ATR_BORDER_VALUE);
+ @Override
+ public void setAttribute(VpePageContext pageContext, Element sourceElement,
+ nsIDOMDocument visualDocument, nsIDOMNode visualNode, Object data,
+ String name, String value) {
+ if (TREE_STYLE_CLASS_ATR_NAME.equalsIgnoreCase(name)) {
+ setAttributeToTree(visualNode, HtmlComponentUtil.HTML_CLASS_ATTR,
+ value);
+ } else if (HtmlComponentUtil.HTML_STYLE_ATTR.equalsIgnoreCase(name)) {
+ setAttributeToTree(visualNode, HtmlComponentUtil.HTML_STYLE_ATTR,
+ removeFromStyleWithAndHeight(value));
+ ((Element) visualNode).setAttribute(
+ HtmlComponentUtil.HTML_STYLE_ATTR, value);
}
+ }
+
+ @Override
+ public void removeAttribute(VpePageContext pageContext,
+ Element sourceElement, nsIDOMDocument visualDocument,
+ nsIDOMNode visualNode, Object data, String name) {
+ if (TREE_STYLE_CLASS_ATR_NAME.equalsIgnoreCase(name)) {
+ setAttributeToTree(visualNode, HtmlComponentUtil.HTML_CLASS_ATTR,
+ "");
+ } else if (HtmlComponentUtil.HTML_STYLE_ATTR.equalsIgnoreCase(name)) {
+ setAttributeToTree(visualNode, HtmlComponentUtil.HTML_STYLE_ATTR,
+ "");
+ }
+ }
+
+ /**
+ * Create simple tree node attribute.Used for creating more complex trees.
+ *
+ * @param treeNodeTitle
+ * @param visualDocument
+ * @return tree
+ */
+ private nsIDOMElement createBasicTree(nsIDOMDocument visualDocument) {
+
+ nsIDOMElement div = visualDocument
+ .createElement(HtmlComponentUtil.HTML_TAG_DIV);
+ div.setAttribute(HtmlComponentUtil.HTML_CLASS_ATTR, "dr-tree-h-ic-div");
+ return div;
+ }
+
}
Modified: branches/jbosstools_xulrunner/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/templates/vpe-templates-richfaces.xml
===================================================================
--- branches/jbosstools_xulrunner/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/templates/vpe-templates-richfaces.xml 2007-09-27 00:50:58 UTC (rev 3832)
+++ branches/jbosstools_xulrunner/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/templates/vpe-templates-richfaces.xml 2007-09-27 00:53:13 UTC (rev 3833)
@@ -43,6 +43,8 @@
<vpe:drag start-enable="yes" />
<vpe:drop container="yes">
<vpe:container-child tag-name="treeNode" />
+ <vpe:container-child tag-name="treeNodesAdaptor" />
+ <vpe:container-child tag-name="recursiveTreeNodesAdaptor" />
</vpe:drop>
</vpe:dnd>
<vpe:textFormating>
@@ -72,8 +74,33 @@
<vpe:pseudoContent defaultText="yes" />
</vpe:template>
</vpe:tag>
+
+ <vpe:tag name="rich:treeNodesAdaptor" case-sensitive="yes">
+ <vpe:template children="yes" modify="no"
+ class="org.jboss.tools.jsf.vpe.richfaces.template.RichFacesTreeNodesAdaptorTemplate">
+ <vpe:dnd>
+ <vpe:drag start-enable="yes" />
+ <vpe:drop container="yes">
+ <vpe:container-child tag-name="treeNode" />
+ </vpe:drop>
+ </vpe:dnd>
+ </vpe:template>
+ </vpe:tag>
+
+ <vpe:tag name="rich:recursiveTreeNodesAdaptor" case-sensitive="yes">
+ <vpe:template children="yes" modify="no"
+ class="org.jboss.tools.jsf.vpe.richfaces.template.RichFacesRecursiveTreeNodesAdaptorTemplate">
+ <vpe:dnd>
+ <vpe:drag start-enable="yes" />
+ <vpe:drop container="yes">
+ <vpe:container-child tag-name="treeNode" />
+ </vpe:drop>
+ </vpe:dnd>
+ </vpe:template>
+ </vpe:tag>
+
<vpe:tag name="rich:treeNode" case-sensitive="yes">
<vpe:template children="yes" modify="yes"
class="org.jboss.tools.jsf.vpe.richfaces.template.RichFacesTreeNodeTemplate">
@@ -592,6 +619,23 @@
<span style="display:none">
</span>
</vpe:template>
+ </vpe:tag>
+
+ <vpe:tag name="rich:treeNodesAdaptor" case-sensitive="yes">
+ <vpe:template children="yes" modify="no"
+ class="org.jboss.tools.jsf.vpe.richfaces.template.RichFacesTreeNodesAdaptorTemplate">
+ <vpe:resize>
+ <vpe:width width-attr="style.width" />
+ <vpe:height height-attr="style.height" />
+ </vpe:resize>
+ <vpe:dnd>
+ <vpe:drag start-enable="yes" />
+ <vpe:drop container="yes">
+ <vpe:container-child tag-name="treeNode" />
+ </vpe:drop>
+ </vpe:dnd>
+ <vpe:pseudoContent defaultText="yes" />
+ </vpe:template>
</vpe:tag>
</vpe:templates>
\ No newline at end of file
17 years, 3 months