JBoss Tools SVN: r11853 - in trunk/as/plugins: org.jboss.ide.eclipse.archives.webtools/src/org/jboss/ide/eclipse/archives/webtools/modules and 13 other directories.
by jbosstools-commits@lists.jboss.org
Author: rob.stryker(a)jboss.com
Date: 2008-11-17 14:06:38 -0500 (Mon, 17 Nov 2008)
New Revision: 11853
Added:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/extensions/events/IServerLogListener.java
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/extensions/events/ServerLog.java
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/extensions/events/ServerLogger.java
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/ServerLogView.java
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/server/extensions/ServerLogActionProvider.java
Removed:
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/publishers/PublisherEventLogger.java
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.ui/jbossui/org/jboss/ide/eclipse/as/ui/dialogs/ShowStackTraceDialog.java
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/server/extensions/EventLogActionProvider.java
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/server/extensions/EventLogContentProvider.java
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/server/extensions/EventLogLabelProvider.java
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/server/extensions/IEventLogLabelProvider.java
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/server/providers/events/ComplexEventLogLabelProvider.java
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/server/providers/events/PackagesPublishLabelProvider.java
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/server/providers/events/PollingLabelProvider.java
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.archives.webtools/src/org/jboss/ide/eclipse/archives/webtools/Messages.java
trunk/as/plugins/org.jboss.ide.eclipse.archives.webtools/src/org/jboss/ide/eclipse/archives/webtools/Messages.properties
trunk/as/plugins/org.jboss.ide.eclipse.archives.webtools/src/org/jboss/ide/eclipse/archives/webtools/modules/PackagesPublisher.java
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/extensions/polling/JMXPoller.java
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/publishers/JstPublisher.java
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/publishers/NullPublisher.java
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/publishers/SingleFilePublisher.java
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/IJBossServerPublisher.java
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/IServerStatePoller.java
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/DeployableServer.java
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/JBossServerBehavior.java
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/PollThread.java
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/util/FileUtil.java
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/util/ModuleUtil.java
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/META-INF/MANIFEST.MF
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/tools/as/wst/server/ui/ServerActionProvider.java
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/plugin.xml
Log:
JBIDE-3078
Modified: trunk/as/plugins/org.jboss.ide.eclipse.archives.webtools/src/org/jboss/ide/eclipse/archives/webtools/Messages.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.archives.webtools/src/org/jboss/ide/eclipse/archives/webtools/Messages.java 2008-11-17 18:42:45 UTC (rev 11852)
+++ trunk/as/plugins/org.jboss.ide.eclipse.archives.webtools/src/org/jboss/ide/eclipse/archives/webtools/Messages.java 2008-11-17 19:06:38 UTC (rev 11853)
@@ -8,6 +8,7 @@
public static String ExceptionUnexpectedException;
public static String ExceptionCannotDeployFile;
public static String ErrorDuringPublish;
+ public static String PublishSuccessful;
public static String ArchivePublishSettings;
public static String SelectServerWizard;
public static String SelectServerWizardDescription;
Modified: trunk/as/plugins/org.jboss.ide.eclipse.archives.webtools/src/org/jboss/ide/eclipse/archives/webtools/Messages.properties
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.archives.webtools/src/org/jboss/ide/eclipse/archives/webtools/Messages.properties 2008-11-17 18:42:45 UTC (rev 11852)
+++ trunk/as/plugins/org.jboss.ide.eclipse.archives.webtools/src/org/jboss/ide/eclipse/archives/webtools/Messages.properties 2008-11-17 19:06:38 UTC (rev 11853)
@@ -1,7 +1,8 @@
ExceptionCannotScanDirectory=Cannot scan directory
ExceptionUnexpectedException=Unexpected exception
-ExceptionCannotDeployFile=Cannot deploy file {0}
-ErrorDuringPublish=Error during publish
+ExceptionCannotDeployFile=Cannot publish file {0}
+ErrorDuringPublish=Error publishing module {0}
+PublishSuccessful=Module {0} published.
ArchivePublishSettings=Archive Publish Settings
SelectServerWizard=Select Server Wizard
SelectServerWizardDescription=Select the server to publish the archive to.
Modified: trunk/as/plugins/org.jboss.ide.eclipse.archives.webtools/src/org/jboss/ide/eclipse/archives/webtools/modules/PackagesPublisher.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.archives.webtools/src/org/jboss/ide/eclipse/archives/webtools/modules/PackagesPublisher.java 2008-11-17 18:42:45 UTC (rev 11852)
+++ trunk/as/plugins/org.jboss.ide.eclipse.archives.webtools/src/org/jboss/ide/eclipse/archives/webtools/modules/PackagesPublisher.java 2008-11-17 19:06:38 UTC (rev 11853)
@@ -27,9 +27,11 @@
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.MultiStatus;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Status;
+import org.eclipse.osgi.util.NLS;
import org.eclipse.wst.server.core.IModule;
import org.eclipse.wst.server.core.IServer;
import org.eclipse.wst.server.core.model.IModuleFile;
@@ -43,13 +45,11 @@
import org.jboss.ide.eclipse.archives.webtools.modules.PackageModuleFactory.ExtendedModuleFile;
import org.jboss.ide.eclipse.archives.webtools.modules.PackageModuleFactory.IExtendedModuleResource;
import org.jboss.ide.eclipse.archives.webtools.modules.PackageModuleFactory.PackagedModuleDelegate;
-import org.jboss.ide.eclipse.as.core.extensions.events.EventLogModel.EventLogTreeItem;
-import org.jboss.ide.eclipse.as.core.publishers.PublisherEventLogger;
-import org.jboss.ide.eclipse.as.core.publishers.PublisherEventLogger.PublisherFileUtilListener;
import org.jboss.ide.eclipse.as.core.server.IDeployableServer;
import org.jboss.ide.eclipse.as.core.server.IJBossServerPublisher;
import org.jboss.ide.eclipse.as.core.util.FileUtil;
import org.jboss.ide.eclipse.as.core.util.ServerConverter;
+import org.jboss.ide.eclipse.as.core.util.FileUtil.FileUtilListener;
/**
*
@@ -59,8 +59,7 @@
protected IDeployableServer server;
protected IModuleResourceDelta[] delta;
- protected EventLogTreeItem eventRoot;
-
+ protected FileUtilListener listener = new FileUtilListener();
public PackagesPublisher() {
}
@@ -76,14 +75,13 @@
}
public IStatus publishModule(IServer server, IModule[] module,
int publishType, IModuleResourceDelta[] delta,
- EventLogTreeItem log, IProgressMonitor monitor)
+ IProgressMonitor monitor)
throws CoreException {
this.server = ServerConverter.getDeployableServer(server);
- eventRoot = log;
this.delta = delta;
+ IModule module2 = module[0];
try {
- IModule module2 = module[0];
// if it's being removed
if( publishType == REMOVE_PUBLISH ) {
removeModule(module2, monitor);
@@ -93,10 +91,23 @@
publishModule(module2, true, monitor);
}
}catch(Exception e) {
- IStatus status = new Status(IStatus.ERROR, IntegrationPlugin.PLUGIN_ID, Messages.ErrorDuringPublish, e);
- IntegrationPlugin.getDefault().getLog().log(status);
+ IStatus status = new Status(IStatus.ERROR, IntegrationPlugin.PLUGIN_ID,
+ NLS.bind(Messages.ErrorDuringPublish, module2.getName()), e);
+ return status;
}
- return null;
+
+ if( listener.getStatuses().length > 0 ) {
+ MultiStatus ms = new MultiStatus(IntegrationPlugin.PLUGIN_ID, IStatus.ERROR,
+ NLS.bind(Messages.ErrorDuringPublish, module2.getName()), null);
+ for( int i = 0; i < listener.getStatuses().length; i++ ) {
+ ms.add(listener.getStatuses()[i]);
+ }
+ return ms;
+ }
+
+ IStatus ret = new Status(IStatus.OK, IntegrationPlugin.PLUGIN_ID,
+ NLS.bind(Messages.PublishSuccessful, module2.getName()));
+ return ret;
}
protected void removeModule(IModule module, IProgressMonitor monitor) {
@@ -106,7 +117,6 @@
IPath sourcePath = pack.getArchiveFilePath();
IPath destPath = new Path(server.getDeployFolder()).append(sourcePath.lastSegment());
// remove the entire file or folder
- PublisherFileUtilListener listener = new PublisherFileUtilListener(eventRoot);
FileUtil.safeDelete(destPath.toFile(), listener);
}
}
@@ -124,10 +134,8 @@
return;
}
- PublisherFileUtilListener listener = new PublisherFileUtilListener(eventRoot);
- eventRoot.setProperty(PublisherEventLogger.CHANGED_RESOURCE_COUNT, countChanges(delta));
if( incremental ) {
- publishFromDelta(module, destPathRoot, sourcePath.removeLastSegments(1), delta, listener);
+ publishFromDelta(module, destPathRoot, sourcePath.removeLastSegments(1), delta);
} else {
// full publish, copy whole folder or file
FileUtil.fileSafeCopy(sourcePath.toFile(), destPathRoot.append(sourcePath.lastSegment()).toFile(), listener);
@@ -135,10 +143,10 @@
}
protected void publishFromDelta(IModule module, IPath destPathRoot, IPath sourcePrefix,
- IModuleResourceDelta[] delta, PublisherFileUtilListener listener) {
+ IModuleResourceDelta[] delta) {
ArrayList<IPath> changedFiles = new ArrayList<IPath>();
for( int i = 0; i < delta.length; i++ ) {
- publishFromDeltaHandle(delta[i], destPathRoot, sourcePrefix, changedFiles, listener);
+ publishFromDeltaHandle(delta[i], destPathRoot, sourcePrefix, changedFiles);
}
}
@@ -183,7 +191,7 @@
}
protected void publishFromDeltaHandle(IModuleResourceDelta delta, IPath destRoot,
- IPath sourcePrefix, ArrayList<IPath> changedFiles, PublisherFileUtilListener listener) {
+ IPath sourcePrefix, ArrayList<IPath> changedFiles) {
switch( delta.getKind()) {
case IModuleResourceDelta.REMOVED:
// removed might not be IExtendedModuleResource
@@ -244,7 +252,7 @@
IModuleResourceDelta[] children = delta.getAffectedChildren();
if( children != null ) {
for( int i = 0; i < children.length; i++ ) {
- publishFromDeltaHandle(children[i], destRoot, sourcePrefix, changedFiles, listener);
+ publishFromDeltaHandle(children[i], destRoot, sourcePrefix, changedFiles);
}
}
}
@@ -253,5 +261,4 @@
PackagedModuleDelegate delegate = (PackagedModuleDelegate)module.loadAdapter(PackagedModuleDelegate.class, new NullProgressMonitor());
return delegate == null ? null : delegate.getPackage();
}
-
}
Deleted: 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 2008-11-17 18:42:45 UTC (rev 11852)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/extensions/events/EventLogModel.java 2008-11-17 19:06:38 UTC (rev 11853)
@@ -1,215 +0,0 @@
-/**
- * JBoss, a Division of Red Hat
- * Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
-* This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-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 final String EVENT_TYPE_EXCEPTION = "org.jboss.ide.eclipse.as.core.extensions.events.EXCEPTION";
- public static final String EXCEPTION_PROPERTY = "org.jboss.ide.eclipse.as.core.extensions.events.EXCEPTION_PROPERTY";
-
- public static void enableLogging(boolean enabled) {
- if( enabled )
- enableLogging();
- else
- disableLogging();
- }
-
- public static void enableLogging() {
- 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() {
- 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 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() {
- if( instance == null )
- instance = new EventLogModel();
- return instance;
- }
-
- public static ServerEventModel getModel(IServer server) {
- return getModel(server.getId());
- }
-
- public static ServerEventModel getModel(String serverId) {
- return getDefault().getEventModel(serverId);
- }
-
- public static ServerEventModel[] getModels() {
- return getDefault().getEventModels();
- }
-
- public static void markChanged(EventLogTreeItem item) {
- if( item == null ) return;
- SimpleTreeItem root = item.getRoot();
- if( root != null && root instanceof EventLogRoot ) {
- String serverId = ((EventLogRoot)root).getServerId();
- getDefault().fireItemChanged(serverId, item);
- }
- }
-
- public static interface IEventLogListener {
- public void eventModelChanged(String serverId, EventLogTreeItem changed);
- }
-
- private HashMap serverToModel;
- private ArrayList listeners;
- public EventLogModel() {
- serverToModel = new HashMap();
- listeners = new ArrayList();
- }
-
- public void addListener(IEventLogListener listener) {
- if( !listeners.contains(listener)) listeners.add(listener);
- }
- public void removeListener(IEventLogListener listener) {
- listeners.remove(listener);
- }
- public void fireItemChanged(String serverId, EventLogTreeItem changed) {
- IEventLogListener[] listenerArray = (IEventLogListener[]) listeners.toArray(new IEventLogListener[listeners.size()]);
- for( int i = 0; i < listenerArray.length; i++ ) {
- listenerArray[i].eventModelChanged(serverId, changed);
- }
- }
-
- public ServerEventModel getEventModel(String serverId) {
- if( serverToModel.get(serverId) != null )
- return (ServerEventModel)serverToModel.get(serverId);
- ServerEventModel m = new ServerEventModel(serverId);
- serverToModel.put(serverId, m);
- return m;
- }
-
- public ServerEventModel[] getEventModels() {
- Collection c = serverToModel.values();
- return (ServerEventModel[]) c.toArray(new ServerEventModel[c.size()]);
- }
-
- public static class ServerEventModel {
- private String id;
- private EventLogRoot root;
- protected ServerEventModel(String serverId) {
- this.id = serverId;
- root = new EventLogRoot(this);
- }
- public String getId() {
- return id;
- }
- public EventLogRoot getRoot() {
- return root;
- }
- public void clearEvents() {
- root.deleteChildren();
- }
- }
-
- public static class EventLogTreeItem extends SimpleTreeItem {
- public static final String DATE = "org.jboss.ide.eclipse.as.core.model.EventLogTreeItem.Date";
- protected String specificType, majorType;
- public EventLogTreeItem(SimpleTreeItem parent, String majorType, String specificType) {
- super(parent, null);
- this.specificType = specificType;
- this.majorType = majorType;
- setProperty(DATE, new Long(new Date().getTime()));
- }
- public String getEventClass() {
- return majorType;
- }
- public String getSpecificType() {
- return specificType;
- }
- public EventLogTreeItem getEventRoot() {
- SimpleTreeItem item = this;
- while(item.getParent() != null && item.getParent() instanceof EventLogTreeItem)
- item = item.getParent();
- return (EventLogTreeItem)item;
- }
-
- }
-
- public static class EventLogRoot extends EventLogTreeItem {
- protected ServerEventModel model;
- public EventLogRoot(ServerEventModel model) {
- super(null, null, JBOSS_EVENT_ROOT_TYPE);
- this.model = model;
- }
- public ServerEventModel getModel() {
- return model;
- }
- public String getServerId() {
- return model.getId();
- }
-
- public void addChild(SimpleTreeItem item) {
- if( isLoggingEnabled() )
- super.addChild(item);
- }
-
- public void addChildren(SimpleTreeItem[] kids) {
- if( isLoggingEnabled() )
- super.addChildren(kids);
- }
-
- }
-}
Added: trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/extensions/events/IServerLogListener.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/extensions/events/IServerLogListener.java (rev 0)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/extensions/events/IServerLogListener.java 2008-11-17 19:06:38 UTC (rev 11853)
@@ -0,0 +1,8 @@
+package org.jboss.ide.eclipse.as.core.extensions.events;
+
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.wst.server.core.IServer;
+
+public interface IServerLogListener {
+ public void logging(IStatus status, IServer server);
+}
Added: trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/extensions/events/ServerLog.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/extensions/events/ServerLog.java (rev 0)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/extensions/events/ServerLog.java 2008-11-17 19:06:38 UTC (rev 11853)
@@ -0,0 +1,46 @@
+package org.jboss.ide.eclipse.as.core.extensions.events;
+
+import java.io.File;
+import java.util.ArrayList;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.adaptor.EclipseLog;
+import org.eclipse.osgi.framework.log.FrameworkLogEntry;
+
+public class ServerLog extends EclipseLog {
+ public ServerLog(File file) {
+ super(file);
+ }
+
+ public void log(IStatus status) {
+ log(getLog(status));
+ }
+
+ // Hard Coppied from PlatformLogWriter. You'd think
+ // they'd make that method static or some shit.
+ protected FrameworkLogEntry getLog(IStatus status) {
+ Throwable t = status.getException();
+ ArrayList<FrameworkLogEntry> childlist = new ArrayList<FrameworkLogEntry>();
+
+ int stackCode = t instanceof CoreException ? 1 : 0;
+ // ensure a substatus inside a CoreException is properly logged
+ if (stackCode == 1) {
+ IStatus coreStatus = ((CoreException) t).getStatus();
+ if (coreStatus != null) {
+ childlist.add(getLog(coreStatus));
+ }
+ }
+
+ if (status.isMultiStatus()) {
+ IStatus[] children = status.getChildren();
+ for (int i = 0; i < children.length; i++) {
+ childlist.add(getLog(children[i]));
+ }
+ }
+
+ FrameworkLogEntry[] children = (FrameworkLogEntry[]) (childlist.size() == 0 ? null : childlist.toArray(new FrameworkLogEntry[childlist.size()]));
+
+ return new FrameworkLogEntry(status.getPlugin(), status.getSeverity(), status.getCode(), status.getMessage(), stackCode, t, children);
+ }
+}
Added: trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/extensions/events/ServerLogger.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/extensions/events/ServerLogger.java (rev 0)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/extensions/events/ServerLogger.java 2008-11-17 19:06:38 UTC (rev 11853)
@@ -0,0 +1,86 @@
+/**
+ * JBoss, a Division of Red Hat
+ * Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+* This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ide.eclipse.as.core.extensions.events;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.HashMap;
+
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.wst.server.core.IServer;
+import org.jboss.ide.eclipse.as.core.JBossServerCorePlugin;
+
+public class ServerLogger {
+ private static final IPath LOG_LOCATION = JBossServerCorePlugin.getDefault().getStateLocation().append("logs");
+
+ private static ServerLogger instance;
+ public static ServerLogger getDefault() {
+ if( instance == null ) {
+ instance = new ServerLogger();
+ if( !LOG_LOCATION.toFile().exists())
+ LOG_LOCATION.toFile().mkdirs();
+ }
+ return instance;
+ }
+
+ private HashMap<String, ServerLog> map = new HashMap<String, ServerLog>();
+ private HashMap<String, ArrayList<IServerLogListener>> listeners =
+ new HashMap<String, ArrayList<IServerLogListener>>();
+
+ public void addListener(IServer server, IServerLogListener listener) {
+ ArrayList<IServerLogListener> list = listeners.get(server.getId());
+ if( list == null ) {
+ list = new ArrayList<IServerLogListener>();
+ listeners.put(server.getId(), list);
+ }
+ list.add(listener);
+ }
+
+ public void removeListener(IServer server, IServerLogListener listener) {
+ ArrayList<IServerLogListener> list = listeners.get(server.getId());
+ if( list != null ) {
+ list.remove(listener);
+ }
+ }
+
+ public void log(IServer server, IStatus status) {
+ ServerLog log = map.get(server.getId());
+ if( log == null ) {
+ log = new ServerLog(getServerLogFile(server));
+ map.put(server.getId(), log);
+ }
+ log.log(status);
+
+ ArrayList<IServerLogListener> list = listeners.get(server.getId());
+ if( list != null ) {
+ IServerLogListener[] listeners =
+ list.toArray(new IServerLogListener[list.size()]);
+ for( int i = 0; i < listeners.length;i++)
+ listeners[i].logging(status, server);
+ }
+ }
+
+ public File getServerLogFile(IServer server) {
+ return server == null ? LOG_LOCATION.toFile() : LOG_LOCATION.append(server.getId()).toFile();
+ }
+}
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/extensions/polling/JMXPoller.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/extensions/polling/JMXPoller.java 2008-11-17 18:42:45 UTC (rev 11852)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/extensions/polling/JMXPoller.java 2008-11-17 19:06:38 UTC (rev 11853)
@@ -35,16 +35,17 @@
import javax.naming.InitialContext;
import javax.naming.NamingException;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
import org.eclipse.wst.server.core.IServer;
-import org.jboss.ide.eclipse.as.core.extensions.events.EventLogModel;
-import org.jboss.ide.eclipse.as.core.extensions.events.EventLogModel.EventLogTreeItem;
+import org.jboss.ide.eclipse.as.core.JBossServerCorePlugin;
+import org.jboss.ide.eclipse.as.core.extensions.events.ServerLogger;
import org.jboss.ide.eclipse.as.core.extensions.jmx.JMXClassLoaderRepository;
import org.jboss.ide.eclipse.as.core.extensions.jmx.JMXUtil;
import org.jboss.ide.eclipse.as.core.extensions.jmx.JMXUtil.CredentialException;
import org.jboss.ide.eclipse.as.core.server.IServerStatePoller;
import org.jboss.ide.eclipse.as.core.server.internal.PollThread;
import org.jboss.ide.eclipse.as.core.server.internal.ServerStatePollerType;
-import org.jboss.ide.eclipse.as.core.util.SimpleTreeItem;
/**
* A poller dedicated to server startup, checks via JMX
@@ -54,35 +55,33 @@
public class JMXPoller implements IServerStatePoller {
public static final String POLLER_ID = "org.jboss.ide.eclipse.as.core.runtime.server.JMXPoller";
+
+ public static final int CODE = 2 << 16;
+ public static final int JMXPOLLER_CODE = POLLING_CODE | CODE;
- public static final String STARTED_PROPERTY = "org.jboss.ide.eclipse.as.core.extensions.polling.jmx.STARTED_PROPERTY";
- public static final String EVENT_TYPE_STARTING = "org.jboss.ide.eclipse.as.core.extensions.polling.jmx.eventTypes.STARTING";
-
public static final String REQUIRED_USER = "org.jboss.ide.eclipse.as.core.extensions.polling.jmx.REQUIRED_USER";
public static final String REQUIRED_PASS = "org.jboss.ide.eclipse.as.core.extensions.polling.jmx.REQUIRED_PASS";
public static final int STATE_STARTED = 1;
public static final int STATE_STOPPED = 0;
- public static final int STATE_TRANSITION = -1;
+ public static final int STATE_TRANSITION = 2;
private int started;
- private boolean canceled;
- private boolean done;
+ private boolean canceled, done;
private boolean waitingForCredentials = false;
+ private boolean ceFound,nnfeFound,startingFound;
+
+
private IServer server;
private ServerStatePollerType type;
private PollingException pollingException = null;
private RequiresInfoException requiresInfoException = null;
private Properties requiredPropertiesReturned = null;
- private EventLogTreeItem event;
-
public void beginPolling(IServer server, boolean expectedState,
PollThread pt) {
- this.canceled = false;
- this.done = false;
+ ceFound = nnfeFound = startingFound = canceled = done = false;
this.server = server;
- event = pt.getActiveEvent();
launchJMXPoller();
}
@@ -114,7 +113,11 @@
boolean b = ((Boolean) attInfo).booleanValue();
started = b ? STATE_STARTED : STATE_TRANSITION;
done = b;
- new JMXEvent(event, b);
+ if( !startingFound ) {
+ startingFound = true;
+ IStatus s = new Status(IStatus.INFO, JBossServerCorePlugin.PLUGIN_ID, CODE|started, "Server is starting", null);
+ log(s);
+ }
}
} catch (SecurityException se) {
synchronized(this) {
@@ -137,10 +140,18 @@
}
} catch (CommunicationException ce) {
started = STATE_STOPPED;
- new JMXEvent(event, ce);
+ if( !ceFound ) {
+ ceFound = true;
+ IStatus s = new Status(IStatus.WARNING, JBossServerCorePlugin.PLUGIN_ID, CODE|started, ce.getMessage(), ce);
+ log(s);
+ }
} catch (NamingException nnfe) {
started = STATE_STOPPED;
- new JMXEvent(event, nnfe);
+ if( !nnfeFound ) {
+ nnfeFound = true;
+ IStatus s = new Status(IStatus.WARNING, JBossServerCorePlugin.PLUGIN_ID, CODE|started, nnfe.getMessage(), nnfe);
+ log(s);
+ }
} catch( OperationsException e ) {
failingException = e;
} catch (MBeanException e) {
@@ -232,20 +243,7 @@
throw requiresInfoException;
return done;
}
-
- public class JMXEvent extends EventLogTreeItem {
- public JMXEvent(SimpleTreeItem parent, boolean started) {
- super(parent, PollThread.SERVER_STATE_MAJOR_TYPE, EVENT_TYPE_STARTING );
- setProperty(STARTED_PROPERTY, new Boolean(started));
- }
-
- public JMXEvent(SimpleTreeItem parent, Exception e) {
- super(parent, PollThread.SERVER_STATE_MAJOR_TYPE, EventLogModel.EVENT_TYPE_EXCEPTION );
- setProperty(EventLogModel.EXCEPTION_PROPERTY, e);
- }
- }
-
public void failureHandled(Properties properties) {
if( properties == null ) {
done = true;
@@ -276,4 +274,9 @@
public int getTimeoutBehavior() {
return TIMEOUT_BEHAVIOR_IGNORE;
}
+
+ private void log(IStatus s) {
+ if( !canceled )
+ ServerLogger.getDefault().log(server,s);
+ }
}
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/publishers/JstPublisher.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/publishers/JstPublisher.java 2008-11-17 18:42:45 UTC (rev 11852)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/publishers/JstPublisher.java 2008-11-17 19:06:38 UTC (rev 11853)
@@ -25,6 +25,7 @@
import java.io.FileFilter;
import java.io.IOException;
import java.util.ArrayList;
+import java.util.Arrays;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.runtime.Assert;
@@ -32,6 +33,7 @@
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.MultiStatus;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Status;
@@ -46,15 +48,13 @@
import org.eclipse.wst.server.core.model.ModuleDelegate;
import org.eclipse.wst.server.core.util.ProjectModule;
import org.jboss.ide.eclipse.as.core.JBossServerCorePlugin;
-import org.jboss.ide.eclipse.as.core.extensions.events.EventLogModel;
-import org.jboss.ide.eclipse.as.core.extensions.events.EventLogModel.EventLogTreeItem;
-import org.jboss.ide.eclipse.as.core.publishers.PublisherEventLogger.DeletedEvent;
import org.jboss.ide.eclipse.as.core.server.IDeployableServer;
import org.jboss.ide.eclipse.as.core.server.IJBossServerPublisher;
import org.jboss.ide.eclipse.as.core.server.xpl.ModulePackager;
import org.jboss.ide.eclipse.as.core.server.xpl.PublishUtil;
import org.jboss.ide.eclipse.as.core.util.FileUtil;
import org.jboss.ide.eclipse.as.core.util.ServerConverter;
+import org.jboss.ide.eclipse.as.core.util.FileUtil.FileUtilListener;
import org.jboss.ide.eclipse.as.core.util.FileUtil.IFileUtilListener;
/**
@@ -65,12 +65,9 @@
*/
public class JstPublisher implements IJBossServerPublisher {
- public static final int BUILD_FAILED_CODE = 100;
- public static final int PACKAGE_UNDETERMINED_CODE = 101;
protected IModuleResourceDelta[] delta;
protected IDeployableServer server;
- protected EventLogTreeItem eventRoot;
protected int publishState = IServer.PUBLISH_STATE_NONE;
@@ -87,11 +84,9 @@
}
public IStatus publishModule(IServer server, IModule[] module,
- int publishType, IModuleResourceDelta[] delta,
- EventLogTreeItem log, IProgressMonitor monitor) throws CoreException {
+ int publishType, IModuleResourceDelta[] delta, IProgressMonitor monitor) throws CoreException {
IStatus status = null;
this.server = ServerConverter.getDeployableServer(server);
- this.eventRoot = log;
this.delta = delta;
boolean deleted = false;
@@ -118,27 +113,29 @@
protected IStatus fullPublish(IModule[] moduleTree, IModule module, IProgressMonitor monitor) throws CoreException {
- eventRoot.setProperty(PublisherEventLogger.CHANGED_RESOURCE_COUNT, countChanges(delta));
IPath deployPath = getDeployPath(moduleTree);
ModuleDelegate md = (ModuleDelegate)module.loadAdapter(ModuleDelegate.class, monitor);
IModuleResource[] members = md.members();
+ ArrayList<IStatus> list = new ArrayList<IStatus>();
// if the module we're publishing is a project, not a binary, clean it's folder
if( !(new Path(module.getName()).segmentCount() > 1 ))
- localSafeDelete(deployPath, eventRoot);
+ list.addAll(Arrays.asList(localSafeDelete(deployPath)));
- IStatus[] results;
if( !deployPackaged(moduleTree) && !isBinaryObject(moduleTree))
- results = new PublishUtil(server.getServer()).publishFull(members, deployPath, monitor);
+ list.addAll(Arrays.asList(new PublishUtil(server.getServer()).publishFull(members, deployPath, monitor)));
else if( isBinaryObject(moduleTree))
- results = copyBinaryModule(moduleTree);
+ list.addAll(Arrays.asList(copyBinaryModule(moduleTree)));
else
- results = packModuleIntoJar(moduleTree[moduleTree.length-1], deployPath);
+ list.addAll(Arrays.asList(packModuleIntoJar(moduleTree[moduleTree.length-1], deployPath)));
- int length = results == null ? 0 : results.length;
- for( int i = 0; i < length; i++ ) {
- new PublisherEventLogger.PublishUtilStatusWrapper(eventRoot, results[i]);
+ if( list.size() > 0 ) {
+ MultiStatus ms = new MultiStatus(JBossServerCorePlugin.PLUGIN_ID, IStatus.ERROR, "Full Publish Failed for module " + module.getName(), null);
+ for( int i = 0; i < list.size(); i++ )
+ ms.add(list.get(i));
+ return ms;
}
+
// adjust timestamps
FileFilter filter = new FileFilter() {
@@ -150,11 +147,12 @@
};
FileUtil.touch(filter, deployPath.toFile(), true);
publishState = IServer.PUBLISH_STATE_NONE;
- return null;
+
+ IStatus ret = new Status(IStatus.OK, JBossServerCorePlugin.PLUGIN_ID, countMembers(module) + " files modified in module " + module.getName(), null);
+ return ret;
}
protected IStatus incrementalPublish(IModule[] moduleTree, IModule module, IProgressMonitor monitor) throws CoreException {
- eventRoot.setProperty(PublisherEventLogger.CHANGED_RESOURCE_COUNT, countChanges(delta));
IStatus[] results = new IStatus[] {};
IPath deployPath = getDeployPath(moduleTree);
if( !deployPackaged(moduleTree) && !isBinaryObject(moduleTree))
@@ -165,21 +163,26 @@
else
results = packModuleIntoJar(moduleTree[moduleTree.length-1], deployPath);
}
- int length = results == null ? 0 : results.length;
- for( int i = 0; i < length; i++ ) {
- new PublisherEventLogger.PublishUtilStatusWrapper(eventRoot, results[i]);
+ if( results != null && results.length > 0 ) {
+ MultiStatus ms = new MultiStatus(JBossServerCorePlugin.PLUGIN_ID, IStatus.ERROR, "Incremental Publish Failed for module " + module.getName(), null);
+ for( int i = 0; i < results.length; i++ )
+ ms.add(results[i]);
+ return ms;
}
-
- return null;
+ IStatus ret = new Status(IStatus.OK, JBossServerCorePlugin.PLUGIN_ID, countChanges(delta) + " files modified in module " + module.getName(), null);
+ return ret;
}
protected IStatus unpublish(IDeployableServer jbServer, IModule[] module,
IProgressMonitor monitor) throws CoreException {
- eventRoot.setProperty(PublisherEventLogger.CHANGED_RESOURCE_COUNT, countMembers(module[module.length-1]));
- boolean error = localSafeDelete(getDeployPath(module), eventRoot);
- if( error ) {
+ IStatus[] errors = localSafeDelete(getDeployPath(module));
+ if( errors.length > 0 ) {
+ IModule mod = module[module.length-1];
publishState = IServer.PUBLISH_STATE_FULL;
- throw new CoreException(new Status(IStatus.WARNING, JBossServerCorePlugin.PLUGIN_ID, "Unable to delete module from server. (" + getModulePath(module) + ")", new Exception("Some files were not removed from the server")));
+ MultiStatus ms = new MultiStatus(JBossServerCorePlugin.PLUGIN_ID, IStatus.ERROR, "Unable to delete module " + mod.getName(), new Exception("Some files were not removed from the server"));
+ for( int i = 0; i < errors.length; i++ )
+ ms.addAll(errors[i]);
+ throw new CoreException(ms);
}
return null;
}
@@ -220,28 +223,6 @@
return false;
}
-
- protected class FileUtilListener implements IFileUtilListener {
- protected ArrayList<IStatus> errors = new ArrayList<IStatus>();
- public void fileCoppied(File source, File dest, boolean result,
- Exception e) {
- if(!result)
- errors.add(new Status(IStatus.ERROR, JBossServerCorePlugin.PLUGIN_ID, "Error copying file " + source.toString() + " to " + dest.toString(), e));
- }
- public void fileDeleted(File file, boolean result, Exception e) {
- if(!result)
- errors.add(new Status(IStatus.ERROR, JBossServerCorePlugin.PLUGIN_ID, "Error deleting file " + file.toString(), e));
- }
-
- public void folderDeleted(File file, boolean result, Exception e) {
- if(!result)
- errors.add(new Status(IStatus.ERROR, JBossServerCorePlugin.PLUGIN_ID, "Error deleting folder " + file.toString(), e));
- }
-
- public IStatus[] getStatuses() {
- return (IStatus[]) errors.toArray(new IStatus[errors.size()]);
- }
- }
protected IStatus[] copyBinaryModule(IModule[] moduleTree) {
try {
IPath deployPath = getDeployPath(moduleTree);
@@ -274,30 +255,25 @@
* @param event
* @return returns whether an error was found
*/
- protected boolean localSafeDelete(IPath deployPath, final EventLogTreeItem event) {
+ protected IStatus[] localSafeDelete(IPath deployPath) {
String serverDeployFolder = server.getDeployFolder();
Assert.isTrue(!deployPath.toFile().equals(new Path(serverDeployFolder).toFile()), "An attempt to delete your entire deploy folder has been prevented. This should never happen");
-
- final Boolean[] errorFound = new Boolean[] { new Boolean(false)};
+ final ArrayList<IStatus> status = new ArrayList<IStatus>();
IFileUtilListener listener = new IFileUtilListener() {
public void fileCoppied(File source, File dest, boolean result,Exception e) {}
public void fileDeleted(File file, boolean result, Exception e) {
if( result == false || e != null ) {
- errorFound[0] = new Boolean(true);
- new DeletedEvent(event, file, result, e);
- EventLogModel.markChanged(event);
+ status.add(new Status(IStatus.ERROR, JBossServerCorePlugin.PLUGIN_ID, "Attempt to delete " + file.getAbsolutePath() + " failed",e));
}
}
public void folderDeleted(File file, boolean result, Exception e) {
if( result == false || e != null ) {
- errorFound[0] = new Boolean(true);
- new DeletedEvent(event, file, result, e);
- EventLogModel.markChanged(event);
+ status.add(new Status(IStatus.ERROR, JBossServerCorePlugin.PLUGIN_ID, "Attempt to delete " + file.getAbsolutePath() + " failed",e));
}
}
};
FileUtil.safeDelete(deployPath.toFile(), listener);
- return errorFound[0].booleanValue();
+ return (IStatus[]) status.toArray(new IStatus[status.size()]);
}
protected boolean deployPackaged(IModule[] moduleTree) {
if( moduleTree[moduleTree.length-1].getModuleType().getId().equals("jst.utility")) return true;
@@ -325,7 +301,7 @@
} catch (IOException e) {
IStatus status = new Status(IStatus.ERROR, JBossServerCorePlugin.PLUGIN_ID, 0,
"unable to assemble module", e); //$NON-NLS-1$
- throw new CoreException(status);
+ return new IStatus[]{status};
}
finally{
try{
@@ -334,10 +310,10 @@
catch(IOException e){
IStatus status = new Status(IStatus.ERROR, JBossServerCorePlugin.PLUGIN_ID, 0,
"unable to assemble module", e); //$NON-NLS-1$
- throw new CoreException(status);
+ return new IStatus[]{status};
}
}
- return null;
+ return new IStatus[]{};
}
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/publishers/NullPublisher.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/publishers/NullPublisher.java 2008-11-17 18:42:45 UTC (rev 11852)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/publishers/NullPublisher.java 2008-11-17 19:06:38 UTC (rev 11853)
@@ -27,7 +27,6 @@
import org.eclipse.wst.server.core.IModule;
import org.eclipse.wst.server.core.IServer;
import org.eclipse.wst.server.core.model.IModuleResourceDelta;
-import org.jboss.ide.eclipse.as.core.extensions.events.EventLogModel.EventLogTreeItem;
import org.jboss.ide.eclipse.as.core.server.IJBossServerPublisher;
/**
@@ -44,8 +43,7 @@
}
public IStatus publishModule(IServer server, IModule[] module,
- int publishType, IModuleResourceDelta[] delta,
- EventLogTreeItem log, IProgressMonitor monitor) throws CoreException {
+ int publishType, IModuleResourceDelta[] delta, IProgressMonitor monitor) throws CoreException {
return null;
}
}
Deleted: 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 2008-11-17 18:42:45 UTC (rev 11852)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/publishers/PublisherEventLogger.java 2008-11-17 19:06:38 UTC (rev 11853)
@@ -1,115 +0,0 @@
-package org.jboss.ide.eclipse.as.core.publishers;
-
-import java.io.File;
-
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.wst.server.core.IModule;
-import org.jboss.ide.eclipse.as.core.extensions.events.EventLogModel;
-import org.jboss.ide.eclipse.as.core.extensions.events.EventLogModel.EventLogTreeItem;
-import org.jboss.ide.eclipse.as.core.util.SimpleTreeItem;
-import org.jboss.ide.eclipse.as.core.util.FileUtil.IFileUtilListener;
-
-public class PublisherEventLogger {
- public static final String PUBLISH_MAJOR_TYPE = "org.jboss.ide.eclipse.as.core.publishers.Events.MajorType";
- public static final String MODULE_NAME = "org.jboss.ide.eclipse.as.core.publishers.Events.Properties.ModuleName";
-
- public static class PublishEvent extends EventLogTreeItem {
- public PublishEvent(SimpleTreeItem parent, String specificType) {
- super(parent, PUBLISH_MAJOR_TYPE, specificType);
- }
- public PublishEvent(SimpleTreeItem parent, String specificType, IModule module) {
- super(parent, PUBLISH_MAJOR_TYPE, specificType);
- setProperty(MODULE_NAME, module.getName());
- }
- }
-
- // type
- public static final String ROOT_EVENT = "org.jboss.ide.eclipse.as.core.publishers.PublisherEventLogger.ROOT_EVENT";
- public static final String MODULE_ROOT_EVENT = "org.jboss.ide.eclipse.as.core.publishers.PublisherEventLogger.MODULE_ROOT_EVENT";
- // properties
- public static final String MODULE_KIND = "org.jboss.ide.eclipse.as.core.publishers.PublisherEventLogger.MODULE_KIND";
- public static final String DELTA_KIND = "org.jboss.ide.eclipse.as.core.publishers.PublisherEventLogger.DELTA_KIND";
- public static final String MODULE_PUBLISH_STATE = "org.jboss.ide.eclipse.as.core.publishers.PublisherEventLogger.MODULE_PUBLISH_STATE";
-
- public static PublishEvent createModuleRootEvent(EventLogTreeItem parent, IModule[] module,
- int kind, int deltaKind, int moduleStateKind) {
- PublishEvent event = new PublishEvent(parent, MODULE_ROOT_EVENT);
- String name = "";
- 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_PUBLISH_STATE, new Integer(moduleStateKind));
- event.setProperty(MODULE_NAME, name);
- EventLogModel.markChanged(parent);
- return event;
- }
-
- public static PublishEvent createRemoveResultsEvent() {
- return null;
- }
-
- public static class PublisherFileUtilListener implements IFileUtilListener {
- EventLogTreeItem log;
- public PublisherFileUtilListener(EventLogTreeItem log) {
- this.log = log;
- }
- public void fileCoppied(File source, File dest, boolean result, Exception e) {
- new CoppiedEvent(log, source, dest, result, e);
- EventLogModel.markChanged(log);
- }
- public void fileDeleted(File file, boolean result, Exception e) {
- new DeletedEvent(log, file, result, e);
- EventLogModel.markChanged(log);
- }
- public void folderDeleted(File file, boolean result, Exception e) {
- new DeletedEvent(log, file, result, e);
- EventLogModel.markChanged(log);
- }
- }
- // event types
- public static final String FILE_EVENT_MAJOR_TYPE = "org.jboss.ide.eclipse.as.core.publishers.Events.FILE_EVENT_MAJOR_TYPE";
- public static final String FOLDER_DELETED_EVENT = "org.jboss.ide.eclipse.as.core.publishers.Events.FOLDER_DELETED_EVENT";
- public static final String FILE_DELETED_EVENT = "org.jboss.ide.eclipse.as.core.publishers.Events.FILE_DELETED_EVENT";
- public static final String FILE_COPPIED_EVENT = "org.jboss.ide.eclipse.as.core.publishers.Events.FILE_COPPIED_EVENT";
- // properties
- public static final String SUCCESS_PROPERTY = "org.jboss.ide.eclipse.as.core.publishers.Events.Properties.SUCCESS_PROPERTY";
- public static final String SOURCE_PROPERTY = "org.jboss.ide.eclipse.as.core.publishers.Events.Properties.SOURCE_PROPERTY";
- public static final String DEST_PROPERTY = "org.jboss.ide.eclipse.as.core.publishers.Events.Properties.DEST_PROPERTY";
- public static final String EXCEPTION_MESSAGE = "org.jboss.ide.eclipse.as.core.publishers.Events.Properties.EXCEPTION_PROPERTY";
- public static final String CHANGED_MODULE_COUNT = "org.jboss.ide.eclipse.as.core.publishers.Events.Properties.CHANGED_MODULE_COUNT_PROPERTY";
- public static final String CHANGED_RESOURCE_COUNT = "org.jboss.ide.eclipse.as.core.publishers.Events.Properties.CHANGED_RESOURCE_COUNT_PROPERTY";
-
-
- public static class DeletedEvent extends EventLogTreeItem {
- public DeletedEvent(EventLogTreeItem parent, File file, boolean result, Exception e) {
- super(parent, FILE_EVENT_MAJOR_TYPE, file.isDirectory() ? FOLDER_DELETED_EVENT : FILE_DELETED_EVENT);
- setProperty(SUCCESS_PROPERTY, new Boolean(result));
- setProperty(DEST_PROPERTY, file.getAbsolutePath());
- if( e != null )
- setProperty(EXCEPTION_MESSAGE, e.getMessage());
- }
-
- }
- public static class CoppiedEvent extends EventLogTreeItem {
- public CoppiedEvent(EventLogTreeItem parent, File source, File destination, boolean result, Exception e) {
- super(parent, FILE_EVENT_MAJOR_TYPE, FILE_COPPIED_EVENT);
- setProperty(SOURCE_PROPERTY, source.getAbsolutePath());
- setProperty(DEST_PROPERTY, destination.getAbsolutePath());
- setProperty(SUCCESS_PROPERTY, new Boolean(result));
- if( e != null )
- setProperty(EXCEPTION_MESSAGE, e.getMessage());
- }
- }
-
- public static final String PUBLISH_UTIL_STATUS_WRAPPER_TYPE = "org.jboss.ide.eclipse.as.core.publishers.Events.publishUtilStatusWrapperType";
- public static class PublishUtilStatusWrapper extends EventLogTreeItem {
- public PublishUtilStatusWrapper(EventLogTreeItem parent, IStatus status) {
- super(parent, PUBLISH_MAJOR_TYPE, PUBLISH_UTIL_STATUS_WRAPPER_TYPE);
- setData(status);
- }
- }
-}
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/publishers/SingleFilePublisher.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/publishers/SingleFilePublisher.java 2008-11-17 18:42:45 UTC (rev 11852)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/publishers/SingleFilePublisher.java 2008-11-17 19:06:38 UTC (rev 11853)
@@ -14,11 +14,7 @@
import org.eclipse.wst.server.core.IServer;
import org.eclipse.wst.server.core.model.IModuleResourceDelta;
import org.jboss.ide.eclipse.as.core.JBossServerCorePlugin;
-import org.jboss.ide.eclipse.as.core.extensions.events.EventLogModel;
-import org.jboss.ide.eclipse.as.core.extensions.events.EventLogModel.EventLogTreeItem;
import org.jboss.ide.eclipse.as.core.modules.SingleDeployableFactory.SingleDeployableModuleDelegate;
-import org.jboss.ide.eclipse.as.core.publishers.PublisherEventLogger.CoppiedEvent;
-import org.jboss.ide.eclipse.as.core.publishers.PublisherEventLogger.DeletedEvent;
import org.jboss.ide.eclipse.as.core.server.IDeployableServer;
import org.jboss.ide.eclipse.as.core.server.IJBossServerPublisher;
import org.jboss.ide.eclipse.as.core.util.FileUtil;
@@ -28,7 +24,6 @@
public class SingleFilePublisher implements IJBossServerPublisher {
private IDeployableServer server;
- private EventLogTreeItem root;
private int publishState = IServer.PUBLISH_STATE_NONE;
public SingleFilePublisher() {
}
@@ -46,11 +41,9 @@
}
public IStatus publishModule(IServer server, IModule[] module,
- int publishType, IModuleResourceDelta[] delta,
- EventLogTreeItem log, IProgressMonitor monitor) throws CoreException {
+ int publishType, IModuleResourceDelta[] delta, IProgressMonitor monitor) throws CoreException {
this.server = ServerConverter.getDeployableServer(server);
- this.root = log;
IModule module2 = module[0];
@@ -63,7 +56,6 @@
} else if( publishType == INCREMENTAL_PUBLISH ) {
status = publish(this.server, module2, false, monitor);
}
- root.setProperty(PublisherEventLogger.CHANGED_RESOURCE_COUNT, new Integer(1));
return status;
}
@@ -73,22 +65,28 @@
if( delegate != null ) {
IPath sourcePath = delegate.getGlobalSourcePath();
IPath destFolder = new Path(server.getDeployFolder());
+ IPath tempDestFolder = new Path(server.getTempDeployFolder());
+ File tempDestFile = tempDestFolder.append(sourcePath.lastSegment()).toFile();
File destFile = destFolder.append(sourcePath.lastSegment()).toFile();
- FileUtilListener l = new FileUtilListener(root);
- FileUtil.fileSafeCopy(sourcePath.toFile(), destFile, l);
+ FileUtilListener l = new FileUtilListener();
+ FileUtil.fileSafeCopy(sourcePath.toFile(), tempDestFile, l);
+ boolean success = tempDestFile.renameTo(destFile);
if( updateTimestamp )
destFile.setLastModified(new Date().getTime());
- if( l.errorFound ) {
- publishState = IServer.PUBLISH_STATE_FULL;
+ if( l.errorFound || !success ) {
+ publishState = IServer.PUBLISH_STATE_FULL;
+ Exception e = l.e != null ? l.e : new Exception("Move from " + tempDestFile + " to " + destFile + " failed.");
+ return new Status(IStatus.ERROR, JBossServerCorePlugin.PLUGIN_ID, "The module cannot be published.", e);
}
} else {
// deleted module. o noes. Ignore it. We can't re-publish it, so just ignore it.
publishState = IServer.PUBLISH_STATE_UNKNOWN;
- Status status = new Status(IStatus.WARNING, JBossServerCorePlugin.PLUGIN_ID, "The module cannot be published because it cannot be located. (" + module.getName() + ")");
- throw new CoreException(status);
+ Status status = new Status(IStatus.WARNING, JBossServerCorePlugin.PLUGIN_ID, "The module cannot be published because it cannot be located. (" + module.getName() + ")");
+ return status;
}
- return null;
+ Status status = new Status(IStatus.OK, JBossServerCorePlugin.PLUGIN_ID, "Module " + module.getName() + " coppied.");
+ return status;
}
protected IStatus unpublish(IDeployableServer server, IModule module, IProgressMonitor monitor) throws CoreException {
@@ -97,42 +95,37 @@
if( delegate != null ) {
IPath sourcePath = delegate.getGlobalSourcePath();
IPath destFolder = new Path(server.getDeployFolder());
- FileUtilListener l = new FileUtilListener(root);
- FileUtil.safeDelete(destFolder.append(sourcePath.lastSegment()).toFile(), l);
+ FileUtilListener l = new FileUtilListener();
+ File destFile = destFolder.append(sourcePath.lastSegment()).toFile();
+ FileUtil.safeDelete(destFile, l);
if( l.errorFound ) {
publishState = IServer.PUBLISH_STATE_FULL;
- throw new CoreException(new Status(IStatus.WARNING, JBossServerCorePlugin.PLUGIN_ID, "Unable to delete module from server.", new Exception("Some files were not removed from the server")));
+ return new Status(IStatus.WARNING, JBossServerCorePlugin.PLUGIN_ID, "Unable to delete module " + module.getName() + " from server.", l.e);
}
}
-
- return null;
+ Status status = new Status(IStatus.OK, JBossServerCorePlugin.PLUGIN_ID, "Module " + module.getName() + " removed.");
+ return status;
}
public static class FileUtilListener implements IFileUtilListener {
- protected EventLogTreeItem root;
protected boolean errorFound = false;
- public FileUtilListener(EventLogTreeItem root) {
- this.root = root;
- }
+ protected Exception e;
public void fileCoppied(File source, File dest, boolean result,Exception e) {
if( result == false || e != null ) {
errorFound = true;
- new CoppiedEvent(root, source, dest, result, e);
- EventLogModel.markChanged(root);
+ this.e = e;
}
}
public void fileDeleted(File file, boolean result, Exception e) {
if( result == false || e != null ) {
errorFound = true;
- new DeletedEvent(root, file, result, e);
- EventLogModel.markChanged(root);
+ this.e = e;
}
}
public void folderDeleted(File file, boolean result, Exception e) {
if( result == false || e != null ) {
errorFound = true;
- new DeletedEvent(root, file, result, e);
- EventLogModel.markChanged(root);
+ this.e = e;
}
}
}
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/IJBossServerPublisher.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/IJBossServerPublisher.java 2008-11-17 18:42:45 UTC (rev 11852)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/IJBossServerPublisher.java 2008-11-17 19:06:38 UTC (rev 11853)
@@ -27,7 +27,6 @@
import org.eclipse.wst.server.core.IModule;
import org.eclipse.wst.server.core.IServer;
import org.eclipse.wst.server.core.model.IModuleResourceDelta;
-import org.jboss.ide.eclipse.as.core.extensions.events.EventLogModel.EventLogTreeItem;
/**
*
@@ -39,14 +38,15 @@
public static final int INCREMENTAL_PUBLISH = 1;
public static final int FULL_PUBLISH = 2;
public static final int REMOVE_PUBLISH = 3;
+ public static final int POLLING_CODE = 1 << 24;
+
// pre-publish
public boolean accepts(IServer server, IModule[] module);
public IStatus publishModule(IServer server, IModule[] module,
- int publishType, IModuleResourceDelta[] delta,
- EventLogTreeItem log, IProgressMonitor monitor) throws CoreException;
+ int publishType, IModuleResourceDelta[] delta, IProgressMonitor monitor) throws CoreException;
// post publish
public int getPublishState();
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/IServerStatePoller.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/IServerStatePoller.java 2008-11-17 18:42:45 UTC (rev 11852)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/IServerStatePoller.java 2008-11-17 19:06:38 UTC (rev 11853)
@@ -34,7 +34,8 @@
*
*/
public interface IServerStatePoller {
-
+ public static final int POLLING_CODE = 1 << 24;
+
public static final boolean SERVER_UP = true;
public static final boolean SERVER_DOWN = false;
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/DeployableServer.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/DeployableServer.java 2008-11-17 18:42:45 UTC (rev 11852)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/DeployableServer.java 2008-11-17 19:06:38 UTC (rev 11853)
@@ -31,9 +31,7 @@
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Status;
import org.eclipse.jst.server.core.IEnterpriseApplication;
-import org.eclipse.jst.server.core.IWebModule;
import org.eclipse.wst.server.core.IModule;
-import org.eclipse.wst.server.core.IModuleType;
import org.eclipse.wst.server.core.IRuntime;
import org.eclipse.wst.server.core.IServerWorkingCopy;
import org.eclipse.wst.server.core.ServerPort;
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 2008-11-17 18:42:45 UTC (rev 11852)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/DeployableServerBehavior.java 2008-11-17 19:06:38 UTC (rev 11853)
@@ -23,6 +23,8 @@
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.MultiStatus;
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
import org.eclipse.wst.server.core.IModule;
import org.eclipse.wst.server.core.IServer;
@@ -30,10 +32,8 @@
import org.eclipse.wst.server.core.ServerEvent;
import org.eclipse.wst.server.core.model.ServerBehaviourDelegate;
import org.jboss.ide.eclipse.as.core.ExtensionManager;
-import org.jboss.ide.eclipse.as.core.extensions.events.EventLogModel;
-import org.jboss.ide.eclipse.as.core.extensions.events.EventLogModel.EventLogTreeItem;
-import org.jboss.ide.eclipse.as.core.publishers.PublisherEventLogger;
-import org.jboss.ide.eclipse.as.core.publishers.PublisherEventLogger.PublishEvent;
+import org.jboss.ide.eclipse.as.core.JBossServerCorePlugin;
+import org.jboss.ide.eclipse.as.core.extensions.events.ServerLogger;
import org.jboss.ide.eclipse.as.core.server.IJBossServerPublisher;
import org.jboss.ide.eclipse.as.core.server.internal.launch.DeployableLaunchConfiguration;
@@ -50,9 +50,7 @@
workingCopy.setAttribute(DeployableLaunchConfiguration.ACTION_KEY, DeployableLaunchConfiguration.START);
}
- protected PublishEvent publishRootEvent;
protected void publishStart(IProgressMonitor monitor) throws CoreException {
- publishRootEvent = new PublishEvent(null, PublisherEventLogger.ROOT_EVENT);
}
protected void publishFinish(IProgressMonitor monitor) throws CoreException {
@@ -64,12 +62,6 @@
}
if(allpublished)
setServerPublishState(IServer.PUBLISH_STATE_NONE);
-
- if( publishRootEvent.getChildren().length != 0 ) {
- EventLogTreeItem root = EventLogModel.getModel(getServer()).getRoot();
- root.addChild(publishRootEvent);
- }
- publishRootEvent = null;
}
@@ -90,28 +82,18 @@
IJBossServerPublisher publisher;
if( module.length > 0 && publishType != IJBossServerPublisher.NO_PUBLISH) {
- Integer i,j;
- i = (Integer)publishRootEvent.getProperty(PublisherEventLogger.CHANGED_MODULE_COUNT);
- publishRootEvent.setProperty(PublisherEventLogger.CHANGED_MODULE_COUNT, new Integer(i == null ? 1 : i.intValue()+1));
- PublishEvent modulePublishEvent = PublisherEventLogger.createModuleRootEvent(publishRootEvent, module, kind, deltaKind, modulePublishState);
-
publisher = ExtensionManager.getDefault().getPublisher(getServer(), module);
if( publisher != null ) {
try {
- publisher.publishModule(getServer(), module, publishType,
- getPublishedResourceDelta(module),
- modulePublishEvent, monitor);
+ IStatus result = publisher.publishModule(getServer(), module, publishType,
+ getPublishedResourceDelta(module), monitor);
+ if( result != null )
+ ServerLogger.getDefault().log(getServer(), result);
} catch( CoreException ce ) {
throw ce;
} finally {
setModulePublishState(module, publisher.getPublishState());
}
- // add file changed count to top level element
- i = (Integer)publishRootEvent.getProperty(PublisherEventLogger.CHANGED_RESOURCE_COUNT);
- j = (Integer)modulePublishEvent.getProperty(PublisherEventLogger.CHANGED_RESOURCE_COUNT);
- j = j == null ? new Integer(0) : j;
- int count = (i == null ? 0 : i.intValue()) + j.intValue();
- publishRootEvent.setProperty(PublisherEventLogger.CHANGED_RESOURCE_COUNT, count);
}
}
}
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/JBossServerBehavior.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/JBossServerBehavior.java 2008-11-17 18:42:45 UTC (rev 11852)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/JBossServerBehavior.java 2008-11-17 19:06:38 UTC (rev 11853)
@@ -36,8 +36,7 @@
import org.eclipse.debug.core.model.IProcess;
import org.eclipse.wst.server.core.IServer;
import org.jboss.ide.eclipse.as.core.JBossServerCorePlugin;
-import org.jboss.ide.eclipse.as.core.extensions.events.EventLogModel;
-import org.jboss.ide.eclipse.as.core.extensions.events.EventLogModel.EventLogTreeItem;
+import org.jboss.ide.eclipse.as.core.extensions.events.ServerLogger;
import org.jboss.ide.eclipse.as.core.extensions.jmx.JMXModel.JMXRunnable;
import org.jboss.ide.eclipse.as.core.extensions.jmx.JMXModel.JMXSafeRunner;
import org.jboss.ide.eclipse.as.core.server.IServerStatePoller;
@@ -52,6 +51,10 @@
public class JBossServerBehavior extends DeployableServerBehavior {
private static final String STOP_FAILED_MESSAGE =
"Command to stop server failed. The next attempt will forcefully terminate the process.";
+ private static final String FORCE_TERMINATED = "The server was shutdown forcefully. All processes were terminated.";
+ private static final String TERMINATED = "Server processes have been terminated.";
+ private static final String FORCE_TERMINATE_FAILED = "Killing the server process has failed. The process may still be running.";
+
private PollThread pollThread = null;
protected IProcess process;
protected boolean nextStopRequiresForce = false;
@@ -80,11 +83,6 @@
if( !success ) {
if( process != null && !process.isTerminated() ) {
setServerStarted();
-
- // report it to error log
- IStatus s = new Status(IStatus.ERROR, JBossServerCorePlugin.PLUGIN_ID,
- "", null);
- JBossServerCorePlugin.getDefault().getLog().log(s);
pollThread.cancel(STOP_FAILED_MESSAGE);
nextStopRequiresForce = true;
}
@@ -93,32 +91,39 @@
}
public void forceStop() {
- forceStop(true);
- }
-
- public void forceStop(boolean addEvent) {
// just terminate the process.
- if( process != null )
+ if( process != null && !process.isTerminated()) {
try {
process.terminate();
+ addForceStopEvent();
} catch( DebugException e ) {
- e.printStackTrace();
+ addForceStopFailedEvent(e);
}
+ }
process = null;
setServerStopped();
- if( addEvent ) {
- EventLogTreeItem tpe = new ForceShutdownEvent();
- EventLogModel.markChanged(tpe.getEventRoot());
- }
}
-
- public static final String FORCE_SHUTDOWN_EVENT_KEY = "org.jboss.ide.eclipse.as.core.server.JBossServerBehavior.forceShutdown";
- public class ForceShutdownEvent extends EventLogTreeItem {
- public ForceShutdownEvent() {
- super(EventLogModel.getModel(getServer()).getRoot(), PollThread.SERVER_STATE_MAJOR_TYPE, FORCE_SHUTDOWN_EVENT_KEY);
- }
+
+ protected void addForceStopFailedEvent(DebugException e) {
+ IStatus status = new Status(IStatus.ERROR,
+ JBossServerCorePlugin.PLUGIN_ID, 0,
+ FORCE_TERMINATE_FAILED, e);
+ ServerLogger.getDefault().log(getServer(), status);
}
+ protected void addForceStopEvent() {
+ IStatus status = new Status(IStatus.ERROR,
+ JBossServerCorePlugin.PLUGIN_ID, 0,
+ FORCE_TERMINATED, null);
+ ServerLogger.getDefault().log(getServer(), status);
+ }
+ protected void addProcessTerminatedEvent() {
+ IStatus status = new Status(IStatus.INFO,
+ JBossServerCorePlugin.PLUGIN_ID, 0,
+ TERMINATED, null);
+ ServerLogger.getDefault().log(getServer(), status);
+ }
+
public void setupLaunchConfiguration(ILaunchConfigurationWorkingCopy workingCopy, IProgressMonitor monitor) throws CoreException {
JBossServerStartupLaunchConfiguration.setupLaunchConfiguration(workingCopy, getServer());
}
@@ -126,9 +131,10 @@
protected transient IDebugEventSetListener processListener;
public void setProcess(final IProcess newProcess) {
- if (process != null)
+ if (process != null) {
+ System.out.println(process.isTerminated());
return;
-
+ }
process = newProcess;
if (processListener != null)
DebugPlugin.getDefault().removeDebugEventListener(processListener);
@@ -142,7 +148,8 @@
for (int i = 0; i < size; i++) {
if (process != null && process.equals(events[i].getSource()) && events[i].getKind() == DebugEvent.TERMINATE) {
DebugPlugin.getDefault().removeDebugEventListener(this);
- forceStop(false);
+ forceStop();
+ addProcessTerminatedEvent();
}
}
}
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/PollThread.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/PollThread.java 2008-11-17 18:42:45 UTC (rev 11852)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/PollThread.java 2008-11-17 19:06:38 UTC (rev 11853)
@@ -1,292 +1,313 @@
-/**
- * JBoss, a Division of Red Hat
- * Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
-* This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.ide.eclipse.as.core.server.internal;
-
-import java.util.Date;
-
-import org.eclipse.wst.server.core.IServer;
-import org.jboss.ide.eclipse.as.core.ExtensionManager;
-import org.jboss.ide.eclipse.as.core.extensions.events.EventLogModel;
-import org.jboss.ide.eclipse.as.core.extensions.events.EventLogModel.EventLogRoot;
-import org.jboss.ide.eclipse.as.core.extensions.events.EventLogModel.EventLogTreeItem;
-import org.jboss.ide.eclipse.as.core.server.IJBossServerConstants;
-import org.jboss.ide.eclipse.as.core.server.IPollerFailureHandler;
-import org.jboss.ide.eclipse.as.core.server.IServerStatePoller;
-import org.jboss.ide.eclipse.as.core.server.IServerStatePoller.PollingException;
-import org.jboss.ide.eclipse.as.core.server.IServerStatePoller.RequiresInfoException;
-import org.jboss.ide.eclipse.as.core.util.ServerConverter;
-import org.jboss.ide.eclipse.as.core.util.SimpleTreeItem;
-
-/**
- *
- * @author rob.stryker(a)jboss.com
- */
-public class PollThread extends Thread {
- public static final String SERVER_STATE_MAJOR_TYPE = "org.jboss.ide.eclipse.as.core.runtime.server.polling.MajorType";
-
-
- public static final String SERVER_STARTING = "org.jboss.ide.eclipse.as.core.runtime.server.PollThread.server.starting";
- public static final String SERVER_STOPPING = "org.jboss.ide.eclipse.as.core.runtime.server.PollThread.server.stopping";
- public static final String FAILURE = "org.jboss.ide.eclipse.as.core.runtime.server.PollThread.failure";
- public static final String SUCCESS = "org.jboss.ide.eclipse.as.core.runtime.server.PollThread.success";
- public static final String POLLER_NOT_FOUND = "org.jboss.ide.eclipse.as.core.runtime.server.PollThread.pollerNotFound";
- public static final String POLL_THREAD_ABORTED = "org.jboss.ide.eclipse.as.core.runtime.server.PollThread.aborted";
- public static final String POLL_THREAD_ABORTED_CAUSE = "org.jboss.ide.eclipse.as.core.runtime.server.PollThread.aborted.cause";
- public static final String POLL_THREAD_TIMEOUT = "org.jboss.ide.eclipse.as.core.runtime.server.PollThread.timeout";
- public static final String EXPECTED_STATE = "org.jboss.ide.eclipse.as.core.runtime.server.PollThreadEvent.expectedState";
- public static final String POLL_THREAD_EXCEPTION = "org.jboss.ide.eclipse.as.core.runtime.server.PollThread.exception";
- public static final String POLL_THREAD_EXCEPTION_MESSAGE = "org.jboss.ide.eclipse.as.core.runtime.server.PollThread.exception.message";
-
-
- private boolean expectedState, abort, stateStartedOrStopped;
- private IServerStatePoller poller;
- private String abortMessage;
- private JBossServerBehavior behavior;
- private EventLogRoot eventRoot;
-
- private PollThreadEvent activeEvent;
-
- public PollThread(String name, boolean expectedState, JBossServerBehavior behavior) {
- super(name);
- this.expectedState = expectedState;
- this.abort = false;
- this.abortMessage = null;
- this.behavior = behavior;
- this.eventRoot = EventLogModel.getModel(behavior.getServer()).getRoot();
- this.poller = discoverPoller(behavior, expectedState);
- }
-
- protected IServerStatePoller discoverPoller(JBossServerBehavior behavior, boolean expectedState) {
- JBossServer s = ServerConverter.getJBossServer(behavior.getServer());
- ServerAttributeHelper helper = s.getAttributeHelper();
- String key = expectedState == IServerStatePoller.SERVER_UP ?
- IJBossServerConstants.STARTUP_POLLER_KEY :
- IJBossServerConstants.SHUTDOWN_POLLER_KEY;
- String defaultPoller = expectedState == IServerStatePoller.SERVER_UP ?
- IJBossServerConstants.DEFAULT_STARTUP_POLLER :
- IJBossServerConstants.DEFAULT_SHUTDOWN_POLLER;
- String pollerId = helper.getAttribute(key, defaultPoller);
- ServerStatePollerType type = ExtensionManager.getDefault().getPollerType(pollerId);
- if( type != null ) {
- IServerStatePoller tempPoller = type.createPoller();
- tempPoller.setPollerType(type);
- return tempPoller;
- }
- return null;
- }
-
- public void cancel() {
- cancel(null);
- }
- public void cancel(String message) {
- abort = true;
- abortMessage = message;
- }
-
- public int getTimeout() {
- if( expectedState == IServerStatePoller.SERVER_UP)
- return (getServer().getStartTimeout()-2) * 1000;
- else
- return (getServer().getStopTimeout()-2) * 1000;
- }
-
-
- public void run() {
- // Poller not found
- if( poller == null ) {
- alertEventLogStarting();
- alertPollerNotFound();
- alertBehavior(!expectedState, false);
- return;
- }
-
- int maxWait = getTimeout();
- alertEventLogStarting();
-
- long startTime = new Date().getTime();
- boolean done = false;
- poller.beginPolling(getServer(), expectedState, this);
-
- // begin the loop; ask the poller every so often
- while( !stateStartedOrStopped && !abort && !done &&
- (new Date().getTime() < startTime + maxWait ) || maxWait < 0){
- try {
- Thread.sleep(100);
- } catch( InterruptedException ie ) { }
-
- try {
- done = poller.isComplete();
- } catch( PollingException e ) {
- // abort and put the message in event log
- poller.cancel(IServerStatePoller.CANCEL);
- poller.cleanup();
- alertEventLogPollerException(e);
- alertBehavior(IServerStatePoller.SERVER_DOWN, false);
- return;
- } catch( RequiresInfoException rie ) {
- // This way each request for new info is checked only once.
- if( !rie.getChecked()) {
- rie.setChecked();
- String action = expectedState == IServerStatePoller.SERVER_UP ? SERVER_STARTING : SERVER_STOPPING;
- IPollerFailureHandler handler = ExtensionManager.getDefault().getFirstPollFailureHandler(poller, action, poller.getRequiredProperties());
- handler.handle(poller, action, poller.getRequiredProperties());
- }
- }
- stateStartedOrStopped = checkServerState();
- }
-
- // we stopped. Did we abort?
- if( stateStartedOrStopped ) {
- int state = behavior.getServer().getServerState();
- boolean success = false;
- if( expectedState == IServerStatePoller.SERVER_UP)
- success = state == IServer.STATE_STARTED;
- else
- success = state == IServer.STATE_STOPPED;
-
- poller.cancel(success ? IServerStatePoller.SUCCESS : IServerStatePoller.FAILED);
- poller.cleanup();
- } else if( abort ) {
- poller.cancel(IServerStatePoller.CANCEL);
- poller.cleanup();
- alertEventLogAbort();
- } else {
- boolean currentState = !expectedState;
- boolean finalAlert = true;
- if( done ) {
- // the poller has an answer
- try {
- currentState = poller.getState();
- poller.cleanup();
- alertBehavior(currentState, finalAlert);
- } catch( PollingException pe) {
- // abort and put the message in event log
- poller.cancel(IServerStatePoller.CANCEL);
- poller.cleanup();
- alertEventLogPollerException(pe);
- alertBehavior(IServerStatePoller.SERVER_DOWN, false);
- return;
- } catch( RequiresInfoException rie ) {
- // You don't have an answer... liar!
- }
- } else {
- // we timed out. get response from preferences
- poller.cancel(IServerStatePoller.TIMEOUT_REACHED);
- int behavior = poller.getTimeoutBehavior();
- poller.cleanup();
- alertEventLogTimeout();
- if( behavior != IServerStatePoller.TIMEOUT_BEHAVIOR_IGNORE) {
- // xnor;
- // if behavior is to succeed and we're expected to go up, we're up
- // if behavior is to fail and we're expecting to be down, we're up (failed to shutdown)
- // all other cases, we're down.
- currentState = (expectedState == (behavior == IServerStatePoller.TIMEOUT_BEHAVIOR_SUCCEED));
- finalAlert = false;
- alertBehavior(currentState, finalAlert);
- }
- }
- }
- }
-
- protected boolean checkServerState() {
- int state = behavior.getServer().getServerState();
- if( state == IServer.STATE_STARTED ) return true;
- if( state == IServer.STATE_STOPPED ) return true;
- return false;
- }
-
- protected void alertBehavior(boolean currentState, boolean finalAlert) {
- if( currentState != expectedState ) {
- // it didnt work... cancel all processes! force stop
- behavior.forceStop(false);
- if( finalAlert ) alertEventLogFailure();
- } else {
- if( currentState == IServerStatePoller.SERVER_UP )
- behavior.setServerStarted();
- else {
- behavior.forceStop(false);
- }
- if( finalAlert ) alertEventLogSuccess(currentState);
- }
- }
-
- protected IServer getServer() {
- return behavior.getServer();
- }
-
-
- /*
- * Event Log Stuff here!
- */
- protected void alertEventLogStarting() {
- if( expectedState == IServerStatePoller.SERVER_UP) {
- activeEvent = new PollThreadEvent(eventRoot, SERVER_STARTING, expectedState);
- } else {
- activeEvent = new PollThreadEvent(eventRoot, SERVER_STOPPING, expectedState);
- }
- EventLogModel.markChanged(eventRoot);
- }
-
- public PollThreadEvent getActiveEvent() {
- return activeEvent;
- }
-
- protected void alertEventLogPollerException(PollingException e) {
- PollThreadEvent event = new PollThreadEvent(activeEvent, POLL_THREAD_EXCEPTION, expectedState);
- event.setProperty(POLL_THREAD_EXCEPTION_MESSAGE, e.getMessage());
- EventLogModel.markChanged(activeEvent);
- }
-
- protected void alertEventLogAbort() {
- PollThreadEvent event = new PollThreadEvent(activeEvent, POLL_THREAD_ABORTED, expectedState);
- event.setProperty(POLL_THREAD_ABORTED_CAUSE, abortMessage);
- EventLogModel.markChanged(activeEvent);
- }
- protected void alertEventLogTimeout() {
- PollThreadEvent event = new PollThreadEvent(activeEvent, POLL_THREAD_TIMEOUT, expectedState);
- EventLogModel.markChanged(activeEvent);
- }
- protected void alertEventLogFailure() {
- PollThreadEvent event = new PollThreadEvent(eventRoot, FAILURE, expectedState);
- EventLogModel.markChanged(eventRoot);
- }
- protected void alertEventLogSuccess(boolean currentState) {
- PollThreadEvent event = new PollThreadEvent(activeEvent, SUCCESS, expectedState);
- EventLogModel.markChanged(eventRoot);
- }
- protected void alertPollerNotFound() {
- PollThreadEvent event = new PollThreadEvent(activeEvent, POLLER_NOT_FOUND, expectedState);
- EventLogModel.markChanged(activeEvent);
- }
-
-
- public class PollThreadEvent extends EventLogTreeItem {
- public PollThreadEvent(SimpleTreeItem parent, String type, boolean expectedState) {
- super(parent, SERVER_STATE_MAJOR_TYPE, type);
- setProperty(EXPECTED_STATE, new Boolean(expectedState));
- }
-
- public boolean getExpectedState() {
- return ((Boolean) getProperty(EXPECTED_STATE)).booleanValue();
- }
- }
-}
+/**
+ * JBoss, a Division of Red Hat
+ * Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ide.eclipse.as.core.server.internal;
+
+import java.util.Date;
+
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.wst.server.core.IServer;
+import org.jboss.ide.eclipse.as.core.ExtensionManager;
+import org.jboss.ide.eclipse.as.core.JBossServerCorePlugin;
+import org.jboss.ide.eclipse.as.core.extensions.events.ServerLogger;
+import org.jboss.ide.eclipse.as.core.server.IJBossServerConstants;
+import org.jboss.ide.eclipse.as.core.server.IPollerFailureHandler;
+import org.jboss.ide.eclipse.as.core.server.IServerStatePoller;
+import org.jboss.ide.eclipse.as.core.server.IServerStatePoller.PollingException;
+import org.jboss.ide.eclipse.as.core.server.IServerStatePoller.RequiresInfoException;
+import org.jboss.ide.eclipse.as.core.util.ServerConverter;
+
+/**
+ *
+ * @author rob.stryker(a)jboss.com
+ */
+public class PollThread extends Thread {
+ // PollThread status objects look like this:
+ // 00000001xxxxxxxxaaaaaaaaaaaaaaaa
+ // 00000001000000010000000000xxx00x
+ public static final int POLLING_ROOT_CODE = IServerStatePoller.POLLING_CODE | 1 << 16;
+ public static final int SUCCESS = 0x1;
+ public static final int FAIL = 0;
+ public static final int POLLING_FAIL_CODE = POLLING_ROOT_CODE | FAIL;
+ public static final int STATE_MASK = 0x111000;
+ public static final int STATE_UNKNOWN = IServer.STATE_UNKNOWN << 3;
+ public static final int STATE_STARTING = IServer.STATE_STARTING << 3;
+ public static final int STATE_STARTED = IServer.STATE_STARTED << 3;
+ public static final int STATE_STOPPING = IServer.STATE_STOPPING << 3;
+ public static final int STATE_STOPPED = IServer.STATE_STOPPED << 3;
+
+ public static final String SERVER_STARTING = "org.jboss.ide.eclipse.as.core.runtime.server.PollThread.server.starting";
+ public static final String SERVER_STOPPING = "org.jboss.ide.eclipse.as.core.runtime.server.PollThread.server.stopping";
+
+ private boolean expectedState, abort, stateStartedOrStopped;
+ private IServerStatePoller poller;
+ private String abortMessage;
+ private JBossServerBehavior behavior;
+ private String pollerId;
+
+ public PollThread(String name, boolean expectedState,
+ JBossServerBehavior behavior) {
+ super(name);
+ this.expectedState = expectedState;
+ this.abort = false;
+ this.abortMessage = null;
+ this.behavior = behavior;
+ this.poller = discoverPoller(behavior, expectedState);
+ }
+
+ protected IServerStatePoller discoverPoller(JBossServerBehavior behavior,
+ boolean expectedState) {
+ JBossServer s = ServerConverter.getJBossServer(behavior.getServer());
+ ServerAttributeHelper helper = s.getAttributeHelper();
+ String key = expectedState == IServerStatePoller.SERVER_UP ? IJBossServerConstants.STARTUP_POLLER_KEY
+ : IJBossServerConstants.SHUTDOWN_POLLER_KEY;
+ String defaultPoller = expectedState == IServerStatePoller.SERVER_UP ? IJBossServerConstants.DEFAULT_STARTUP_POLLER
+ : IJBossServerConstants.DEFAULT_SHUTDOWN_POLLER;
+ pollerId = helper.getAttribute(key, defaultPoller);
+ ServerStatePollerType type = ExtensionManager.getDefault()
+ .getPollerType(pollerId);
+ if (type != null) {
+ IServerStatePoller tempPoller = type.createPoller();
+ tempPoller.setPollerType(type);
+ return tempPoller;
+ }
+ return null;
+ }
+
+ public void cancel() {
+ cancel(null);
+ }
+
+ public void cancel(String message) {
+ abort = true;
+ abortMessage = message;
+ poller.cancel(IServerStatePoller.CANCEL);
+ }
+
+ public int getTimeout() {
+ if (expectedState == IServerStatePoller.SERVER_UP)
+ return (getServer().getStartTimeout() - 2) * 1000;
+ else
+ return (getServer().getStopTimeout() - 2) * 1000;
+ }
+
+ public void run() {
+ // Poller not found
+ if (poller == null) {
+ alertEventLogStarting();
+ alertPollerNotFound();
+ alertBehavior(!expectedState, false);
+ return;
+ }
+
+ int maxWait = getTimeout();
+ alertEventLogStarting();
+
+ long startTime = new Date().getTime();
+ boolean done = false;
+ poller.beginPolling(getServer(), expectedState, this);
+
+ // begin the loop; ask the poller every so often
+ while (!stateStartedOrStopped && !abort && !done
+ && (new Date().getTime() < startTime + maxWait) || maxWait < 0) {
+ try {
+ Thread.sleep(100);
+ } catch (InterruptedException ie) {
+ }
+
+ try {
+ done = poller.isComplete();
+ } catch (PollingException e) {
+ // abort and put the message in event log
+ poller.cancel(IServerStatePoller.CANCEL);
+ poller.cleanup();
+ alertEventLogPollerException(e);
+ alertBehavior(!expectedState, false);
+ return;
+ } catch (RequiresInfoException rie) {
+ // This way each request for new info is checked only once.
+ if (!rie.getChecked()) {
+ rie.setChecked();
+ String action = expectedState == IServerStatePoller.SERVER_UP ? SERVER_STARTING
+ : SERVER_STOPPING;
+ IPollerFailureHandler handler = ExtensionManager
+ .getDefault().getFirstPollFailureHandler(poller,
+ action, poller.getRequiredProperties());
+ handler.handle(poller, action, poller
+ .getRequiredProperties());
+ }
+ }
+ stateStartedOrStopped = checkServerState();
+ }
+
+ // we stopped. Did we abort?
+ if (stateStartedOrStopped) {
+ int state = behavior.getServer().getServerState();
+ boolean success = false;
+ if (expectedState == IServerStatePoller.SERVER_UP)
+ success = state == IServer.STATE_STARTED;
+ else
+ success = state == IServer.STATE_STOPPED;
+
+ poller.cancel(success ? IServerStatePoller.SUCCESS
+ : IServerStatePoller.FAILED);
+ poller.cleanup();
+ } else if (abort) {
+ poller.cleanup();
+ alertEventLogAbort();
+ } else {
+ boolean currentState = !expectedState;
+ boolean finalAlert = true;
+ if (done) {
+ // the poller has an answer
+ try {
+ currentState = poller.getState();
+ poller.cleanup();
+ alertBehavior(currentState, finalAlert);
+ } catch (PollingException pe) {
+ // abort and put the message in event log
+ poller.cancel(IServerStatePoller.CANCEL);
+ poller.cleanup();
+ alertEventLogPollerException(pe);
+ alertBehavior(!expectedState, false);
+ return;
+ } catch (RequiresInfoException rie) {
+ // You don't have an answer... liar!
+ }
+ } else {
+ // we timed out. get response from preferences
+ poller.cancel(IServerStatePoller.TIMEOUT_REACHED);
+ int behavior = poller.getTimeoutBehavior();
+ poller.cleanup();
+ alertEventLogTimeout();
+ if (behavior != IServerStatePoller.TIMEOUT_BEHAVIOR_IGNORE) {
+ // xnor;
+ // if behavior is to succeed and we're expected to go up,
+ // we're up
+ // if behavior is to fail and we're expecting to be down,
+ // we're up (failed to shutdown)
+ // all other cases, we're down.
+ currentState = (expectedState == (behavior == IServerStatePoller.TIMEOUT_BEHAVIOR_SUCCEED));
+ finalAlert = false;
+ alertBehavior(currentState, finalAlert);
+ }
+ }
+ }
+ }
+
+ protected boolean checkServerState() {
+ int state = behavior.getServer().getServerState();
+ if (state == IServer.STATE_STARTED)
+ return true;
+ if (state == IServer.STATE_STOPPED)
+ return true;
+ return false;
+ }
+
+ protected void alertBehavior(boolean currentState, boolean finalAlert) {
+ if (currentState != expectedState) {
+ // it didnt work... cancel all processes! force stop
+ behavior.forceStop();
+ if (finalAlert)
+ alertEventLogFailure();
+ } else {
+ if (currentState == IServerStatePoller.SERVER_UP)
+ behavior.setServerStarted();
+ else
+ behavior.forceStop();
+
+ if (finalAlert)
+ alertEventLogSuccess(currentState);
+ }
+ }
+
+ protected IServer getServer() {
+ return behavior.getServer();
+ }
+
+ /*
+ * Event Log Stuff here!
+ */
+ protected void alertEventLogStarting() {
+ String message = expectedState ? "Server Starting" : "Server shutting down";
+ int state = expectedState ? STATE_STARTING : STATE_STOPPING;
+
+ IStatus status = new Status(IStatus.INFO,
+ JBossServerCorePlugin.PLUGIN_ID, POLLING_ROOT_CODE | state, message, null);
+ ServerLogger.getDefault().log(behavior.getServer(), status);
+ }
+
+ protected void alertEventLogPollerException(PollingException e) {
+ IStatus status = new Status(IStatus.ERROR,
+ JBossServerCorePlugin.PLUGIN_ID, POLLING_FAIL_CODE, "Failure in Poll Thread", e);
+ ServerLogger.getDefault().log(behavior.getServer(), status);
+ }
+
+ protected void alertEventLogAbort() {
+ IStatus status = new Status(IStatus.WARNING,
+ JBossServerCorePlugin.PLUGIN_ID, POLLING_FAIL_CODE | getStateMask(expectedState, false), "Poll Thread Aborted: "
+ + abortMessage, null);
+ ServerLogger.getDefault().log(behavior.getServer(), status);
+ }
+
+ protected void alertEventLogTimeout() {
+ IStatus status = new Status(IStatus.ERROR,
+ JBossServerCorePlugin.PLUGIN_ID, POLLING_FAIL_CODE | getStateMask(expectedState, false), "", null);
+ ServerLogger.getDefault().log(behavior.getServer(), status);
+ }
+
+ protected void alertEventLogFailure() {
+ String startupFailed = "Server Startup Failed";
+ String shutdownFailed = "Server Shutdown Failed";
+ IStatus status = new Status(IStatus.ERROR,
+ JBossServerCorePlugin.PLUGIN_ID, POLLING_FAIL_CODE | getStateMask(expectedState, false),
+ expectedState ? startupFailed : shutdownFailed, null);
+ ServerLogger.getDefault().log(behavior.getServer(), status);
+ }
+
+ protected void alertEventLogSuccess(boolean currentState) {
+ String startupSuccess = "Server Startup Succeeded";
+ String shutdownSuccess = "Server Shutdown Succeeded";
+ int state = getStateMask(expectedState, true);
+ IStatus status = new Status(IStatus.INFO,
+ JBossServerCorePlugin.PLUGIN_ID, POLLING_ROOT_CODE | state | SUCCESS,
+ expectedState ? startupSuccess : shutdownSuccess, null);
+ ServerLogger.getDefault().log(behavior.getServer(), status);
+ }
+
+ protected void alertPollerNotFound() {
+ String startupPollerNotFound = "Startup Poller not found: " + pollerId;
+ String shutdownPollerNotFound = "Shutdown Poller not found: "+ pollerId;
+ IStatus status = new Status(IStatus.ERROR, JBossServerCorePlugin.PLUGIN_ID,
+ POLLING_FAIL_CODE | getStateMask(expectedState, false),
+ expectedState ? startupPollerNotFound : shutdownPollerNotFound, null);
+ ServerLogger.getDefault().log(behavior.getServer(), status);
+ }
+
+ protected int getStateMask(boolean expected, boolean success) {
+ if( expected && success )
+ return STATE_STARTED;
+ if( !expected && !success)
+ return STATE_STARTED;
+ return STATE_STOPPED;
+ }
+}
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/util/FileUtil.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/util/FileUtil.java 2008-11-17 18:42:45 UTC (rev 11852)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/util/FileUtil.java 2008-11-17 19:06:38 UTC (rev 11853)
@@ -25,8 +25,13 @@
import java.io.FileFilter;
import java.io.FileInputStream;
import java.io.FileOutputStream;
+import java.util.ArrayList;
import java.util.Date;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.jboss.ide.eclipse.as.core.JBossServerCorePlugin;
+
public class FileUtil {
public static interface IFileUtilListener {
@@ -142,4 +147,27 @@
}
}
}
+
+ public static class FileUtilListener implements IFileUtilListener {
+ protected ArrayList<IStatus> errors = new ArrayList<IStatus>();
+ public void fileCoppied(File source, File dest, boolean result,
+ Exception e) {
+ if(!result)
+ errors.add(new Status(IStatus.ERROR, JBossServerCorePlugin.PLUGIN_ID, "Error copying file " + source.toString() + " to " + dest.toString(), e));
+ }
+ public void fileDeleted(File file, boolean result, Exception e) {
+ if(!result)
+ errors.add(new Status(IStatus.ERROR, JBossServerCorePlugin.PLUGIN_ID, "Error deleting file " + file.toString(), e));
+ }
+
+ public void folderDeleted(File file, boolean result, Exception e) {
+ if(!result)
+ errors.add(new Status(IStatus.ERROR, JBossServerCorePlugin.PLUGIN_ID, "Error deleting folder " + file.toString(), e));
+ }
+
+ public IStatus[] getStatuses() {
+ return (IStatus[]) errors.toArray(new IStatus[errors.size()]);
+ }
+ }
+
}
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/util/ModuleUtil.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/util/ModuleUtil.java 2008-11-17 18:42:45 UTC (rev 11852)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/util/ModuleUtil.java 2008-11-17 19:06:38 UTC (rev 11853)
@@ -9,7 +9,6 @@
import org.eclipse.wst.server.core.IModule;
import org.eclipse.wst.server.core.IModuleType;
import org.eclipse.wst.server.core.IServer;
-import org.eclipse.wst.server.core.model.ModuleDelegate;
public class ModuleUtil {
public static ArrayList<IModule[]> getShallowChildren(IServer server, IModule[] root) {
Deleted: 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 2008-11-17 18:42:45 UTC (rev 11852)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/util/SimpleTreeItem.java 2008-11-17 19:06:38 UTC (rev 11853)
@@ -1,106 +0,0 @@
-/**
- * JBoss, a Division of Red Hat
- * Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
-* This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.ide.eclipse.as.core.util;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-
-public class SimpleTreeItem {
-
- protected ArrayList<SimpleTreeItem> children;
- protected HashMap<Object, Object> properties;
- protected SimpleTreeItem parent;
-
- protected Object data;
-
- public SimpleTreeItem(SimpleTreeItem parent, Object data) {
- children = new ArrayList<SimpleTreeItem>();
- properties = new HashMap<Object, Object>();
- this.data = data;
- this.parent = parent;
- if( parent != null ) parent.addChild(this);
- }
-
- public SimpleTreeItem[] getChildren() {
- SimpleTreeItem[] arr = new SimpleTreeItem[children.size()];
- children.toArray(arr);
- return arr;
- }
-
- public SimpleTreeItem getParent() {
- return parent;
- }
-
- public void addChild(SimpleTreeItem item) {
- if( !children.contains(item)) {
- children.add(item);
- item.setParent(this);
- }
- }
-
- public void addChildren(SimpleTreeItem[] kids) {
- for( int i = 0; i < kids.length; i++ ) {
- addChild(kids[i]);
- }
- }
-
- public void deleteChildren() {
- children.clear();
- }
-
- public void deleteChild(SimpleTreeItem o) {
- children.remove(o);
- }
-
-
- public void setProperty( Object key, Object val ) {
- properties.put(key, val);
- }
-
- public Object getProperty(Object key) {
- return properties.get(key);
- }
-
- public HashMap<Object, Object> getProperties() {
- return properties;
- }
-
- public void setParent(SimpleTreeItem parent) {
- this.parent = parent;
- }
-
- public Object getData() {
- return this.data;
- }
-
- public void setData(Object data) {
- this.data = data;
- }
-
- public SimpleTreeItem getRoot() {
- SimpleTreeItem item = this;
- while(item.getParent() != null)
- item = item.getParent();
- return item;
- }
-
-}
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.ui/META-INF/MANIFEST.MF
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.ui/META-INF/MANIFEST.MF 2008-11-17 18:42:45 UTC (rev 11852)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.ui/META-INF/MANIFEST.MF 2008-11-17 19:06:38 UTC (rev 11853)
@@ -42,7 +42,8 @@
org.eclipse.search,
org.apache.ant,
org.jboss.ide.eclipse.as.core,
- org.eclipse.ui.navigator;bundle-version="3.3.100"
+ org.eclipse.ui.navigator;bundle-version="3.3.100",
+ org.eclipse.ui.views.log;bundle-version="1.0.0"
Eclipse-LazyStart: true
Export-Package: org.jboss.ide.eclipse.as.ui,
org.jboss.ide.eclipse.as.ui.dialogs,
Deleted: trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/dialogs/ShowStackTraceDialog.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/dialogs/ShowStackTraceDialog.java 2008-11-17 18:42:45 UTC (rev 11852)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/dialogs/ShowStackTraceDialog.java 2008-11-17 19:06:38 UTC (rev 11853)
@@ -1,71 +0,0 @@
-package org.jboss.ide.eclipse.as.ui.dialogs;
-
-import java.util.ArrayList;
-
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.window.IShellProvider;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.layout.FillLayout;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.Text;
-import org.jboss.ide.eclipse.as.core.extensions.events.EventLogModel;
-import org.jboss.ide.eclipse.as.core.extensions.events.EventLogModel.EventLogTreeItem;
-
-public class ShowStackTraceDialog extends Dialog {
-
- private EventLogTreeItem selected;
- public ShowStackTraceDialog(IShellProvider parentShell, EventLogTreeItem selected) {
- super(parentShell);
- this.selected = selected;
- }
-
- public ShowStackTraceDialog(Shell shell, EventLogTreeItem selected) {
- super(shell);
- this.selected = selected;
- }
-
- protected void configureShell(Shell newShell) {
- super.configureShell(newShell);
- setShellStyle(SWT.SHELL_TRIM);
- newShell.setText("Exception Stack Trace");
- //newShell.setImage(JBossServerUISharedImages.getImage(JBossServerUISharedImages.TWIDDLE_IMAGE));
- newShell.setBounds(300, 300, 500, 300);
- }
-
- protected Control createDialogArea(Composite parent) {
- Composite c = (Composite)super.createDialogArea(parent);
- c.setLayout(new FillLayout());
- Text t = new Text(c, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
- Object exception = selected.getProperty(EventLogModel.EXCEPTION_PROPERTY);
- if( exception instanceof Throwable) {
- Throwable aThrowable = (Throwable)exception;
- ArrayList<Throwable> seen = new ArrayList<Throwable>();
- final StringBuilder result = new StringBuilder();
- boolean first = true;
- while( aThrowable != null && !seen.contains(aThrowable)) {
- seen.add(aThrowable);
- if( !first ) result.append("nested:" + Text.DELIMITER);
- appendDetails(aThrowable, result);
- aThrowable = aThrowable.getCause();
- first = false;
- }
- t.setText(result.toString());
- }
- return c;
- }
-
- protected void appendDetails(Throwable t, StringBuilder result) {
- result.append(t.toString());
- result.append(Text.DELIMITER);
-
- //add each element of the stack trace
- for (StackTraceElement element : t.getStackTrace() ){
- result.append(" at ");
- result.append( element );
- result.append( Text.DELIMITER );
- }
- result.append(Text.DELIMITER );
- }
-}
Added: trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/ServerLogView.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/ServerLogView.java (rev 0)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/ServerLogView.java 2008-11-17 19:06:38 UTC (rev 11853)
@@ -0,0 +1,58 @@
+package org.jboss.ide.eclipse.as.ui.views;
+
+import java.io.File;
+
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.ui.internal.views.log.LogView;
+import org.eclipse.wst.server.core.IServer;
+import org.jboss.ide.eclipse.as.core.extensions.events.IServerLogListener;
+import org.jboss.ide.eclipse.as.core.extensions.events.ServerLogger;
+
+public class ServerLogView extends LogView implements IServerLogListener {
+ public static final String VIEW_ID = "org.jboss.ide.eclipse.as.ui.view.serverLogView";
+
+ private IServer server;
+ private boolean subclassLogging = false;
+ public ServerLogView() {
+ super();
+ }
+
+ public void createPartControl(Composite parent) {
+ super.createPartControl(parent);
+ setLogFile(ServerLogger.getDefault().getServerLogFile(null));
+ }
+
+ public void setServer(IServer server) {
+ if( this.server != null )
+ ServerLogger.getDefault().removeListener(this.server, this);
+ this.server = server;
+ ServerLogger.getDefault().addListener(server, this);
+ setLogFile(ServerLogger.getDefault().getServerLogFile(server));
+ }
+
+ public void dispose() {
+ setLogFile(null);
+ super.dispose();
+ }
+
+ protected void setLogFile(File f) {
+ super.setLogFile(f);
+ }
+
+ // This must be done because too many fields / classes are private
+ // and the super.logging(IStatus, String) method does nothing
+ // if the platform log is not opened. Which is stupid.
+ public void logging(IStatus status, IServer server) {
+ if( server != null && server.equals(this.server)) {
+ subclassLogging = true;
+ super.logging(status, null);
+ subclassLogging = false;
+ }
+ }
+
+ public boolean isPlatformLogOpen() {
+ return subclassLogging ? true : super.isPlatformLogOpen();
+ }
+}
Deleted: trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/server/extensions/EventLogActionProvider.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/server/extensions/EventLogActionProvider.java 2008-11-17 18:42:45 UTC (rev 11852)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/server/extensions/EventLogActionProvider.java 2008-11-17 19:06:38 UTC (rev 11853)
@@ -1,72 +0,0 @@
-package org.jboss.ide.eclipse.as.ui.views.server.extensions;
-
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.action.IMenuManager;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.navigator.CommonActionProvider;
-import org.eclipse.ui.navigator.ICommonActionExtensionSite;
-import org.eclipse.ui.navigator.ICommonViewerSite;
-import org.eclipse.ui.navigator.ICommonViewerWorkbenchSite;
-import org.jboss.ide.eclipse.as.core.extensions.events.EventLogModel;
-import org.jboss.ide.eclipse.as.core.extensions.events.EventLogModel.EventLogTreeItem;
-import org.jboss.ide.eclipse.as.core.extensions.events.EventLogModel.ServerEventModel;
-import org.jboss.ide.eclipse.as.ui.dialogs.ShowStackTraceDialog;
-
-public class EventLogActionProvider extends CommonActionProvider {
- private Action clearLogAction;
- private Action showStackTraceAction;
- private ICommonActionExtensionSite actionSite;
- public EventLogActionProvider() {
- super();
- }
-
- public void init(ICommonActionExtensionSite aSite) {
- super.init(aSite);
- this.actionSite = aSite;
- createActions();
- }
- public void fillContextMenu(IMenuManager menu) {
- ICommonViewerSite site = actionSite.getViewSite();
- IStructuredSelection selection = null;
- if( site instanceof ICommonViewerWorkbenchSite ) {
- ICommonViewerWorkbenchSite wsSite = (ICommonViewerWorkbenchSite)site;
- selection = (IStructuredSelection) wsSite.getSelectionProvider().getSelection();
- Object first = selection.getFirstElement();
- if( first != null && first instanceof ServerEventModel) {
- menu.add(clearLogAction);
- }
- if( first != null && first instanceof EventLogTreeItem &&
- (((EventLogTreeItem)first).getEventClass().equals(EventLogModel.EVENT_TYPE_EXCEPTION) ||
- ((EventLogTreeItem)first).getSpecificType().equals(EventLogModel.EVENT_TYPE_EXCEPTION))) {
- menu.add(showStackTraceAction);
- }
- }
- }
-
-
- protected void createActions() {
- clearLogAction = new Action() {
- public void run() {
- IStructuredSelection selection = (IStructuredSelection)actionSite.getStructuredViewer().getSelection();
- if(selection.getFirstElement() != null && selection.getFirstElement() instanceof ServerEventModel) {
- ((ServerEventModel)selection.getFirstElement()).clearEvents();
- actionSite.getStructuredViewer().refresh(((ServerEventModel)selection.getFirstElement()));
- }
- }
- };
- clearLogAction.setText("Clear Event Log");
-
- showStackTraceAction = new Action() {
- public void run() {
- IStructuredSelection selection = (IStructuredSelection)actionSite.getStructuredViewer().getSelection();
- if( selection.getFirstElement() != null && selection.getFirstElement() instanceof EventLogTreeItem ) {
- EventLogTreeItem item = (EventLogTreeItem)selection.getFirstElement();
- ShowStackTraceDialog dialog = new ShowStackTraceDialog(new Shell(), item);
- dialog.open();
- }
- }
- };
- showStackTraceAction.setText("See Exception Details");
- }
-}
Deleted: trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/server/extensions/EventLogContentProvider.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/server/extensions/EventLogContentProvider.java 2008-11-17 18:42:45 UTC (rev 11852)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/server/extensions/EventLogContentProvider.java 2008-11-17 19:06:38 UTC (rev 11853)
@@ -1,168 +0,0 @@
-package org.jboss.ide.eclipse.as.ui.views.server.extensions;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.List;
-
-import org.eclipse.core.runtime.Preferences;
-import org.eclipse.jface.viewers.ITreeContentProvider;
-import org.eclipse.jface.viewers.StructuredViewer;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.wst.server.core.IServer;
-import org.jboss.ide.eclipse.as.core.extensions.events.EventLogModel;
-import org.jboss.ide.eclipse.as.core.extensions.events.EventLogModel.EventLogRoot;
-import org.jboss.ide.eclipse.as.core.extensions.events.EventLogModel.EventLogTreeItem;
-import org.jboss.ide.eclipse.as.core.extensions.events.EventLogModel.IEventLogListener;
-import org.jboss.ide.eclipse.as.core.extensions.events.EventLogModel.ServerEventModel;
-import org.jboss.ide.eclipse.as.core.util.SimpleTreeItem;
-import org.jboss.ide.eclipse.as.ui.JBossServerUIPlugin;
-
-public class EventLogContentProvider implements ITreeContentProvider {
- public static final String SHOW_TIMESTAMP = "org.jboss.ide.eclipse.as.ui.views.server.providers.EventLogViewProvider.showTimestamp";
- public static final String GROUP_BY_CATEGORY = "org.jboss.ide.eclipse.as.ui.views.server.providers.EventLogViewProvider.groupByCategory";
- public static final String EVENT_ON_TOP = "org.jboss.ide.eclipse.as.ui.views.server.providers.EventLogViewProvider.eventOnTop";
- public static final int NEWEST_ON_TOP = 1;
- public static final int OLDEST_ON_TOP = 2;
- public static final int _TRUE_ = 1;
- public static final int _FALSE_ = 2;
-
- private Viewer viewer;
- private IEventLogListener listener;
-
- public EventLogContentProvider() {
- EventLogModel.enableLogging();
- listener = new IEventLogListener() {
- public void eventModelChanged(String serverId,
- EventLogTreeItem changed) {
- if( viewer instanceof StructuredViewer ) {
- final Object o = changed.getEventRoot();
- if( o instanceof EventLogRoot) {
- Display.getDefault().asyncExec(new Runnable() {
- public void run() {
- ((StructuredViewer)viewer).refresh(((EventLogRoot)o).getModel());
- }
- });
- }
- }
- }
- };
- EventLogModel.getDefault().addListener(listener);
- }
-
- public Object[] getChildren(Object parentElement) {
- if( parentElement instanceof IServer && parentElement != null ) {
- return new Object[] { EventLogModel.getModel((IServer)parentElement)};
- }
- if( parentElement instanceof ServerEventModel) {
- ServerEventModel s = ((ServerEventModel)parentElement);
- boolean categorize = getCategorize();
- if( categorize )
- return getRootCategories(s);
- Object[] ret = s.getRoot().getChildren();
- if( getSortOrder()) {
- List<Object> l = Arrays.asList(ret);
- Collections.reverse(l);
- return l.toArray();
- }
- return ret;
- }
-
- if( parentElement instanceof MajorEventType ) {
- // get children only of this type
- String serverId = ((MajorEventType)parentElement).getServer();
- SimpleTreeItem[] children = EventLogModel.getModel(serverId).getRoot().getChildren();
- ArrayList<SimpleTreeItem> items = new ArrayList<SimpleTreeItem>();
- for( int i = 0; i < children.length; i++ ) {
- if( children[i] instanceof EventLogTreeItem ) {
- String type = ((EventLogTreeItem)children[i]).getEventClass();
- if( type != null && type.equals(((MajorEventType)parentElement).getId()))
- items.add(children[i]);
- }
- }
-
- if( getSortOrder() ) Collections.reverse(items);
-
- return items.toArray(new Object[items.size()]);
- }
-
- // just return the object's kids
- if( parentElement instanceof EventLogTreeItem ) {
- return ((EventLogTreeItem)parentElement).getChildren();
- }
- return new Object[0];
- }
-
- public static class MajorEventType {
- private String id;
- private String serverId;
- public MajorEventType(String serverId, String id) {
- this.id = id;
- this.serverId = serverId;
- }
- public String getId() {
- return id;
- }
- public String getServer() { return serverId; }
- public String toString() { return id; }
- public boolean equals(Object o) {
- return o instanceof MajorEventType &&
- ((MajorEventType)o).getId().equals(id) &&
- ((MajorEventType)o).getServer().equals(serverId);
- }
- }
-
- protected Object[] getRootCategories(ServerEventModel model) {
- EventLogRoot root = model.getRoot();
- ArrayList<String> list = new ArrayList<String>();
- ArrayList<MajorEventType> majorTypes = new ArrayList<MajorEventType>();
- SimpleTreeItem[] children = root.getChildren();
- for( int i = 0; i < children.length; i++ ) {
- if( children[i] instanceof EventLogTreeItem ) {
- String type = ((EventLogTreeItem)children[i]).getEventClass();
- if( !list.contains(type)) {
- list.add(type);
- majorTypes.add(new MajorEventType(model.getId(), type));
- }
- }
- }
- return majorTypes.toArray(new MajorEventType[majorTypes.size()]);
- }
-
-
- public Object getParent(Object element) {
- return null;
- }
-
- public boolean hasChildren(Object element) {
- return getChildren(element).length > 0 ? true : false;
- }
-
- public Object[] getElements(Object inputElement) {
- return null;
- }
-
- public void dispose() {
- EventLogModel.disableLogging();
- EventLogModel.getDefault().removeListener(listener);
- }
-
- public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
- this.viewer = viewer;
- }
-
- protected boolean getSortOrder() {
- Preferences store = JBossServerUIPlugin.getDefault().getPluginPreferences();
- int showTimestamp = store.getInt(EVENT_ON_TOP);
- if( showTimestamp == OLDEST_ON_TOP) return false;
- return true;
- }
- protected boolean getCategorize() {
- Preferences store = JBossServerUIPlugin.getDefault().getPluginPreferences();
- int showTimestamp = store.getInt(GROUP_BY_CATEGORY);
- if( showTimestamp == _TRUE_ ) return true;
- if( showTimestamp == _FALSE_) return false;
- return false; // default
- }
-}
\ No newline at end of file
Deleted: trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/server/extensions/EventLogLabelProvider.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/server/extensions/EventLogLabelProvider.java 2008-11-17 18:42:45 UTC (rev 11852)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/server/extensions/EventLogLabelProvider.java 2008-11-17 19:06:38 UTC (rev 11853)
@@ -1,142 +0,0 @@
-package org.jboss.ide.eclipse.as.ui.views.server.extensions;
-
-import java.util.Date;
-import java.util.HashMap;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IConfigurationElement;
-import org.eclipse.core.runtime.IExtensionRegistry;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.core.runtime.Preferences;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.jface.viewers.LabelProvider;
-import org.eclipse.swt.graphics.Image;
-import org.jboss.ide.eclipse.as.core.extensions.events.EventLogModel.EventLogTreeItem;
-import org.jboss.ide.eclipse.as.core.extensions.events.EventLogModel.ServerEventModel;
-import org.jboss.ide.eclipse.as.ui.JBossServerUIPlugin;
-import org.jboss.ide.eclipse.as.ui.views.server.extensions.EventLogContentProvider.MajorEventType;
-
-public class EventLogLabelProvider extends LabelProvider {
-
- public static final String SHOW_TIMESTAMP = "org.jboss.ide.eclipse.as.ui.views.server.providers.EventLogViewProvider.showTimestamp";
- public static final int _TRUE_ = 1;
- public static final int _FALSE_ = 2;
- private static HashMap<String, String> majorTypeToName = new HashMap<String, String>();
-
- static {
- IExtensionRegistry registry = Platform.getExtensionRegistry();
- IConfigurationElement[] cf = registry.getConfigurationElementsFor(JBossServerUIPlugin.PLUGIN_ID, "EventLogMajorType");
- for( int i = 0; i < cf.length; i++ ) {
- String type = cf[i].getAttribute("typeId");
- String name = cf[i].getAttribute("name");
- majorTypeToName.put(type, name);
- }
- }
-
- private Image rootImage;
- public EventLogLabelProvider() {
- super();
- ImageDescriptor des = ImageDescriptor.createFromURL(JBossServerUIPlugin.getDefault().getBundle().getEntry("icons/info_obj.gif"));
- rootImage = des.createImage();
- }
- public void dispose() {
- super.dispose();
- rootImage.dispose();
- }
-
- private IEventLogLabelProvider[] labelProviderDelegates = null;
- public Image getImage(Object element) {
- if( labelProviderDelegates == null )
- loadLabelProviderDelegates();
-
- if( element instanceof ServerEventModel ) {
- return rootImage;
- }
-
- if( !(element instanceof EventLogTreeItem))
- return null;
-
- EventLogTreeItem item = (EventLogTreeItem)element;
- for( int i = 0; i < labelProviderDelegates.length; i++ ) {
- if( labelProviderDelegates[i] != null
- && labelProviderDelegates[i].supports(item.getSpecificType())) {
- Image image = labelProviderDelegates[i].getImage((EventLogTreeItem)element);
- if( image != null ) return image;
- }
- }
-
- return null;
- }
-
- public String getText(Object element) {
- if( element == null ) return "ERROR: Unknown String type";
-
- if( element instanceof ServerEventModel ) {
- return "Event Log";
- }
-
-
- String suffix = getShowTimestamp() ? createTimestamp(element) : "";
- if( labelProviderDelegates == null )
- loadLabelProviderDelegates();
-
-
- if( !(element instanceof EventLogTreeItem)) {
- if( element instanceof MajorEventType ) {
- String val = majorTypeToName.get(((MajorEventType)element).getId());
- if( val != null ) return val;
- }
- return element.toString();
- }
- EventLogTreeItem item = (EventLogTreeItem)element;
-
- for( int i = 0; i < labelProviderDelegates.length; i++ ) {
- if( labelProviderDelegates[i] != null
- && labelProviderDelegates[i].supports(item.getSpecificType())) {
- String text = labelProviderDelegates[i].getText((EventLogTreeItem)element);
- if( text != null ) return text + suffix;
- }
- }
-
- return element == null ? "" : element.toString() + suffix;
- }
-
- public void loadLabelProviderDelegates() {
- IExtensionRegistry registry = Platform.getExtensionRegistry();
- IConfigurationElement[] elements = registry.getConfigurationElementsFor(JBossServerUIPlugin.PLUGIN_ID, "EventLogLabelProvider");
- labelProviderDelegates = new IEventLogLabelProvider[elements.length];
- for( int i = 0; i < elements.length; i++ ) {
- try {
- labelProviderDelegates[i] = (IEventLogLabelProvider)elements[i].createExecutableExtension("class");
- } catch( CoreException ce ) {
- JBossServerUIPlugin.log("Error loading Event Log Label Provider Delegate", ce);
- }
- }
- }
- protected boolean getShowTimestamp() {
- Preferences store = JBossServerUIPlugin.getDefault().getPluginPreferences();
- int showTimestamp = store.getInt(SHOW_TIMESTAMP);
- if( showTimestamp == _TRUE_ ) return true;
- if( showTimestamp == _FALSE_) return false;
- return false; // default
- }
-
- protected String createTimestamp(Object element) {
- if( element instanceof EventLogTreeItem ) {
- Long v = (Long) ((EventLogTreeItem)element).getProperty(EventLogTreeItem.DATE);
- if( v == null ) return "";
-
- double date = v.doubleValue();
- double now = new Date().getTime();
- int seconds = (int) (( now - date) / 1000);
- int minutes = seconds / 60;
- int hours = minutes / 60;
- minutes -= (hours * 60);
- String minString = minutes + "m ago";
- if( hours == 0 )
- return " (" + minString + ")";
- return " (" + hours + "h " + minString + ")";
- }
- return "";
- }
-}
\ No newline at end of file
Deleted: trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/server/extensions/IEventLogLabelProvider.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/server/extensions/IEventLogLabelProvider.java 2008-11-17 18:42:45 UTC (rev 11852)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/server/extensions/IEventLogLabelProvider.java 2008-11-17 19:06:38 UTC (rev 11853)
@@ -1,39 +0,0 @@
-/**
- * JBoss, a Division of Red Hat
- * Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
-* This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.ide.eclipse.as.ui.views.server.extensions;
-
-import java.util.Properties;
-
-import org.eclipse.jface.viewers.ILabelProvider;
-import org.eclipse.swt.graphics.Image;
-import org.jboss.ide.eclipse.as.core.extensions.events.EventLogModel.EventLogTreeItem;
-
-/**
- *
- * @author rob.stryker(a)jboss.com
- */
-public interface IEventLogLabelProvider extends ILabelProvider {
- public boolean supports( String type );
- public Image getImage(EventLogTreeItem item);
- public String getText(EventLogTreeItem item);
- public Properties getProperties(EventLogTreeItem item);
-}
Added: trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/server/extensions/ServerLogActionProvider.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/server/extensions/ServerLogActionProvider.java (rev 0)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/server/extensions/ServerLogActionProvider.java 2008-11-17 19:06:38 UTC (rev 11853)
@@ -0,0 +1,113 @@
+package org.jboss.ide.eclipse.as.ui.views.server.extensions;
+
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.jface.action.IContributionItem;
+import org.eclipse.jface.action.IMenuManager;
+import org.eclipse.jface.action.MenuManager;
+import org.eclipse.jface.viewers.ISelectionProvider;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.StructuredViewer;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.navigator.CommonActionProvider;
+import org.eclipse.ui.navigator.CommonViewer;
+import org.eclipse.ui.navigator.ICommonActionExtensionSite;
+import org.eclipse.ui.navigator.ICommonViewerSite;
+import org.eclipse.ui.navigator.ICommonViewerWorkbenchSite;
+import org.eclipse.ui.views.IViewDescriptor;
+import org.eclipse.ui.views.IViewRegistry;
+import org.eclipse.wst.server.core.IServer;
+import org.eclipse.wst.server.ui.internal.view.servers.AbstractServerAction;
+import org.jboss.ide.eclipse.as.core.server.IDeployableServer;
+import org.jboss.ide.eclipse.as.ui.views.ServerLogView;
+
+public class ServerLogActionProvider extends CommonActionProvider {
+ private ICommonActionExtensionSite actionSite;
+ private ShowInServerLogAction showInServerLogAction;
+ public ServerLogActionProvider() {
+ super();
+ }
+
+ public void init(ICommonActionExtensionSite aSite) {
+ super.init(aSite);
+ this.actionSite = aSite;
+ createActions(aSite);
+ }
+
+ protected void createActions(ICommonActionExtensionSite aSite) {
+ ICommonViewerSite site = aSite.getViewSite();
+ if( site instanceof ICommonViewerWorkbenchSite ) {
+ StructuredViewer v = aSite.getStructuredViewer();
+ if( v instanceof CommonViewer ) {
+ CommonViewer cv = (CommonViewer)v;
+ ICommonViewerWorkbenchSite wsSite = (ICommonViewerWorkbenchSite)site;
+ showInServerLogAction = new ShowInServerLogAction(wsSite.getSelectionProvider());
+ }
+ }
+ }
+
+ public void fillContextMenu(IMenuManager menu) {
+ ICommonViewerSite site = actionSite.getViewSite();
+ IStructuredSelection selection = null;
+ if (site instanceof ICommonViewerWorkbenchSite) {
+ ICommonViewerWorkbenchSite wsSite = (ICommonViewerWorkbenchSite) site;
+ selection = (IStructuredSelection) wsSite.getSelectionProvider()
+ .getSelection();
+ }
+ if( selection != null && selection.toArray().length == 1 ) {
+ if( selection.getFirstElement() instanceof IServer ) {
+ if( menu instanceof MenuManager ) {
+ MenuManager mgr = (MenuManager)menu;
+ IContributionItem[] items = mgr.getItems();
+ for( int i = 0; i < items.length; i++ ) {
+ if( "org.eclipse.ui.navigate.showInQuickMenu".equals(items[i].getId())) {
+ ((MenuManager)items[i]).add(showInServerLogAction);
+ }
+ }
+ }
+ }
+ }
+ }
+
+ public class ShowInServerLogAction extends AbstractServerAction {
+ public ShowInServerLogAction(ISelectionProvider sp) {
+ super(sp, "Server Log");
+
+ IViewRegistry reg = PlatformUI.getWorkbench().getViewRegistry();
+ IViewDescriptor desc = reg.find(ServerLogView.VIEW_ID);
+ setText(desc.getLabel());
+ setImageDescriptor(desc.getImageDescriptor());
+ }
+
+ public boolean accept(IServer server) {
+ return (server.getServerType() != null &&
+ server.loadAdapter(IDeployableServer.class, new NullProgressMonitor()) != null);
+ }
+
+ public void perform(IServer server) {
+ IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow() ;
+ if (window != null) {
+ IWorkbenchPage page = window.getActivePage();
+ if (page != null) {
+ IWorkbenchPart part = page.findView(ServerLogView.VIEW_ID);
+ if (part == null) {
+ try {
+ part = page.showView(ServerLogView.VIEW_ID);
+ } catch (PartInitException e) {
+ }
+ }
+ if (part != null) {
+ ServerLogView view = (ServerLogView) part.getAdapter(ServerLogView.class);
+ if (view != null) {
+ view.setFocus();
+ view.setServer(server);
+ }
+ }
+ }
+ }
+ }
+ }
+}
Deleted: trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/server/providers/events/ComplexEventLogLabelProvider.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/server/providers/events/ComplexEventLogLabelProvider.java 2008-11-17 18:42:45 UTC (rev 11852)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/server/providers/events/ComplexEventLogLabelProvider.java 2008-11-17 19:06:38 UTC (rev 11853)
@@ -1,98 +0,0 @@
-/**
- * JBoss, a Division of Red Hat
- * Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
-* This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.ide.eclipse.as.ui.views.server.providers.events;
-
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Properties;
-
-import org.eclipse.jface.viewers.LabelProvider;
-import org.jboss.ide.eclipse.as.core.extensions.events.EventLogModel.EventLogTreeItem;
-import org.jboss.ide.eclipse.as.ui.views.server.extensions.IEventLogLabelProvider;
-
-/**
- *
- * @author rob.stryker(a)jboss.com
- */
-public abstract class ComplexEventLogLabelProvider
- extends LabelProvider implements IEventLogLabelProvider {
- protected static String DELIMITER = "::";
-
- protected ArrayList<String> supported;
- protected HashMap<String, String> propertyToMessageMap;
- public ComplexEventLogLabelProvider() {
- supported = new ArrayList<String>();
- propertyToMessageMap = new HashMap<String, String>();
- addSupportedTypes();
- loadPropertyMap();
- }
- protected abstract void addSupportedTypes();
- protected abstract void loadPropertyMap();
-
- public boolean supports(String type) {
- supported.clear(); addSupportedTypes();
- return supported.contains(type);
- }
-
- public Properties getProperties(EventLogTreeItem item) {
- loadPropertyMap();
- Properties p = new Properties();
- HashMap<Object, Object> map = item.getProperties();
- Object key = null;
- String keyString, valueStringKey, valueString;
- for( Iterator<Object> i = map.keySet().iterator(); i.hasNext();) {
- try {
- key = i.next();
- if( key.equals(EventLogTreeItem.DATE)) {
- keyString = propertyToMessageMap.get(key) == null ? (String)key : propertyToMessageMap.get(key).toString();
- valueString = getDateAsString(((Long)map.get(key)).longValue());
- p.put("Occurred", valueString);
- } else {
- keyString = propertyToMessageMap.get(key) == null ? (String)key : propertyToMessageMap.get(key).toString();
- valueStringKey = key + DELIMITER + toString2(map.get(key));
- valueString = propertyToMessageMap.get(valueStringKey) == null ? toString2(map.get(key)) : toString2(propertyToMessageMap.get(valueStringKey));
- p.put(keyString, valueString);
- }
- } catch( Exception e ) { e.printStackTrace(); }
- }
- return p;
- }
-
- protected String getDateAsString(long date) {
- long now = new Date().getTime();
- long seconds = (now - date) / 1000;
- long minutes = seconds / 60;
- long hours = minutes / 60;
- minutes -= (hours * 60);
- String minString = minutes + "m ago";
- if( hours == 0 )
- return minString;
- return hours + "h " + minString;
- }
-
- private String toString2(Object o) {
- return o == null ? "null" : o.toString();
- }
-
-}
Deleted: trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/server/providers/events/PackagesPublishLabelProvider.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/server/providers/events/PackagesPublishLabelProvider.java 2008-11-17 18:42:45 UTC (rev 11852)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/server/providers/events/PackagesPublishLabelProvider.java 2008-11-17 19:06:38 UTC (rev 11853)
@@ -1,198 +0,0 @@
-/**
- * JBoss, a Division of Red Hat
- * Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
-* This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.ide.eclipse.as.ui.views.server.providers.events;
-
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.ui.ISharedImages;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.wst.server.core.IServer;
-import org.eclipse.wst.server.core.model.ServerBehaviourDelegate;
-import org.jboss.ide.eclipse.as.core.extensions.events.EventLogModel.EventLogTreeItem;
-import org.jboss.ide.eclipse.as.core.publishers.PublisherEventLogger;
-import org.jboss.ide.eclipse.as.core.publishers.PublisherEventLogger.PublishUtilStatusWrapper;
-import org.jboss.ide.eclipse.as.ui.JBossServerUISharedImages;
-import org.jboss.ide.eclipse.as.ui.views.server.extensions.IEventLogLabelProvider;
-
-/**
- *
- * @author Rob Stryker <rob.stryker(a)redhat.com>
- *
- */
-public class PackagesPublishLabelProvider extends ComplexEventLogLabelProvider implements
- IEventLogLabelProvider {
-
- protected void addSupportedTypes() {
- supported.add(PublisherEventLogger.ROOT_EVENT);
- supported.add(PublisherEventLogger.MODULE_ROOT_EVENT);
- supported.add(PublisherEventLogger.FILE_COPPIED_EVENT);
- supported.add(PublisherEventLogger.FILE_DELETED_EVENT);
- supported.add(PublisherEventLogger.FOLDER_DELETED_EVENT);
- supported.add(PublisherEventLogger.PUBLISH_UTIL_STATUS_WRAPPER_TYPE);
- }
- protected void loadPropertyMap() {
- propertyToMessageMap.put(PublisherEventLogger.SOURCE_PROPERTY, "Source");
- propertyToMessageMap.put(PublisherEventLogger.DEST_PROPERTY, "Destination");
- propertyToMessageMap.put(PublisherEventLogger.EXCEPTION_MESSAGE, "Exception");
- propertyToMessageMap.put(PublisherEventLogger.SUCCESS_PROPERTY, "Action Succeeded");
- propertyToMessageMap.put(PublisherEventLogger.MODULE_NAME, "Module Name");
- propertyToMessageMap.put(PublisherEventLogger.DELTA_KIND, "Module's Change Type");
- propertyToMessageMap.put(PublisherEventLogger.MODULE_KIND, "Server's Publish Type");
- propertyToMessageMap.put(PublisherEventLogger.MODULE_PUBLISH_STATE, "Module's Publish Type");
-
- propertyToMessageMap.put(PublisherEventLogger.MODULE_KIND + DELIMITER + IServer.PUBLISH_AUTO, "Auto");
- propertyToMessageMap.put(PublisherEventLogger.MODULE_KIND + DELIMITER + IServer.PUBLISH_CLEAN, "Clean");
- propertyToMessageMap.put(PublisherEventLogger.MODULE_KIND + DELIMITER + IServer.PUBLISH_FULL, "Full");
- propertyToMessageMap.put(PublisherEventLogger.MODULE_KIND + DELIMITER + IServer.PUBLISH_INCREMENTAL, "Incremental");
-
- propertyToMessageMap.put(PublisherEventLogger.MODULE_PUBLISH_STATE + DELIMITER + IServer.PUBLISH_STATE_FULL, "Full");
- propertyToMessageMap.put(PublisherEventLogger.MODULE_PUBLISH_STATE + DELIMITER + IServer.PUBLISH_STATE_INCREMENTAL, "Incremental");
- propertyToMessageMap.put(PublisherEventLogger.MODULE_PUBLISH_STATE + DELIMITER + IServer.PUBLISH_STATE_NONE, "None");
- propertyToMessageMap.put(PublisherEventLogger.MODULE_PUBLISH_STATE + DELIMITER + IServer.PUBLISH_STATE_UNKNOWN, "Unknown");
-
- propertyToMessageMap.put(PublisherEventLogger.DELTA_KIND + DELIMITER + ServerBehaviourDelegate.ADDED, "Added");
- propertyToMessageMap.put(PublisherEventLogger.DELTA_KIND + DELIMITER + ServerBehaviourDelegate.CHANGED, "Changed");
- propertyToMessageMap.put(PublisherEventLogger.DELTA_KIND + DELIMITER + ServerBehaviourDelegate.REMOVED, "Removed");
- propertyToMessageMap.put(PublisherEventLogger.DELTA_KIND + DELIMITER + ServerBehaviourDelegate.NO_CHANGE, "No Change");
-
- propertyToMessageMap.put(PublisherEventLogger.CHANGED_RESOURCE_COUNT, "Changed File(s)");
- propertyToMessageMap.put(PublisherEventLogger.CHANGED_MODULE_COUNT, "Changed Module(s)");
-
-// propertyToMessageMap.put(IJBossServerPublisher.MODULE_NAME, "Module Name");
-// propertyToMessageMap.put(PackagesPublisher.PackagesPublisherRemoveEvent.PACKAGE_NAME, "Package Name");
-// propertyToMessageMap.put(PackagesPublisher.PackagesPublisherRemoveEvent.DESTINATION, "Package File");
-// propertyToMessageMap.put(PackagesPublisher.PackagesPublisherMoveEvent.MOVE_SOURCE, "Source File");
-// propertyToMessageMap.put(PackagesPublisher.PackagesPublisherMoveEvent.MOVE_DESTINATION, "Destination File");
-// propertyToMessageMap.put(PackagesPublisher.PackagesPublisherRemoveEvent.EXCEPTION_MESSAGE, "Exception Message");
- }
-
- public Image getImage(EventLogTreeItem item) {
- String type = item.getSpecificType();
-
- if( type.equals(PublisherEventLogger.ROOT_EVENT)) {
- return JBossServerUISharedImages.getImage(JBossServerUISharedImages.PUBLISH_IMAGE);
- }
- if( type.equals(PublisherEventLogger.MODULE_ROOT_EVENT)) {
- int deltaKind = ((Integer)item.getProperty(PublisherEventLogger.DELTA_KIND)).intValue();
- if( deltaKind == ServerBehaviourDelegate.REMOVED)
- return JBossServerUISharedImages.getImage(JBossServerUISharedImages.UNPUBLISH_IMAGE);
- return JBossServerUISharedImages.getImage(JBossServerUISharedImages.PUBLISH_IMAGE);
- }
-
- if( item.getProperty(PublisherEventLogger.EXCEPTION_MESSAGE) != null )
- return PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJS_ERROR_TSK);
-
- if( type.equals(PublisherEventLogger.FILE_COPPIED_EVENT))
- return PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJ_FILE);
- if( type.equals(PublisherEventLogger.FILE_DELETED_EVENT) || type.equals(PublisherEventLogger.FOLDER_DELETED_EVENT))
- return PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_TOOL_DELETE);
- if( type.equals(PublisherEventLogger.PUBLISH_UTIL_STATUS_WRAPPER_TYPE)) {
- Object data = item.getData();
- if( data != null && data instanceof IStatus ) {
- int sev = ((IStatus)data).getSeverity();
- switch (sev) {
- case IStatus.ERROR: return PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJS_ERROR_TSK);
- case IStatus.WARNING: return PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJS_WARN_TSK);
- }
- }
- }
- return null;
- }
-
- protected String getKindDeltaKind(EventLogTreeItem item) {
- int kind = ((Integer)item.getProperty(PublisherEventLogger.MODULE_KIND)).intValue();
- int deltaKind = ((Integer)item.getProperty(PublisherEventLogger.DELTA_KIND)).intValue();
- int modPublishState = ((Integer)item.getProperty(PublisherEventLogger.MODULE_PUBLISH_STATE)).intValue();
- String r = "[";
- switch(kind) {
- case IServer.PUBLISH_CLEAN: r += "Clean, "; break;
- case IServer.PUBLISH_FULL: r += "Full, "; break;
- case IServer.PUBLISH_AUTO:
- case IServer.PUBLISH_INCREMENTAL:
- if( modPublishState == IServer.PUBLISH_STATE_FULL || modPublishState == IServer.PUBLISH_STATE_UNKNOWN)
- r += "Full, ";
- else
- r += "Incremental, ";
- break;
- default: r += "Unknown, ";
- }
- switch( deltaKind ) {
-
- case ServerBehaviourDelegate.NO_CHANGE: r += "No Change]"; break;
- case ServerBehaviourDelegate.ADDED: r += "Added]"; break;
- case ServerBehaviourDelegate.CHANGED: r += "Changed]"; break;
- case ServerBehaviourDelegate.REMOVED: r += "Removed]"; break;
- default: r += "Unknown]";
- }
- return r;
- }
- public String getText(EventLogTreeItem item) {
- String type = item.getSpecificType();
-
- if( type.equals(PublisherEventLogger.PUBLISH_UTIL_STATUS_WRAPPER_TYPE)) {
- Object o = item.getData();
- if( o == null || !(o instanceof IStatus ))
- return "Unknown Status Event: " + o;
- return ((IStatus)o).getMessage();
- }
-
- if( type.equals(PublisherEventLogger.ROOT_EVENT)) {
- Integer tmp;
- int files, mods;
- tmp = (Integer)item.getProperty(PublisherEventLogger.CHANGED_RESOURCE_COUNT);
- files = tmp == null ? 0 : tmp.intValue();
- tmp = (Integer)item.getProperty(PublisherEventLogger.CHANGED_MODULE_COUNT);
- mods = tmp == null ? 0 : tmp.intValue();
- return "Publishing [" + mods + " modules, " + files + " resources changed]";
- }
-
- if( type.equals(PublisherEventLogger.MODULE_ROOT_EVENT)) {
- return getKindDeltaKind(item) + " " + item.getProperty(PublisherEventLogger.MODULE_NAME);
- }
-
- Boolean b = (Boolean)item.getProperty(PublisherEventLogger.SUCCESS_PROPERTY);
- String fail = "Failed to ";
- if( type.equals(PublisherEventLogger.FILE_COPPIED_EVENT)) {
- return (!b.booleanValue() ? fail : "") +
- "Copy File: " + new Path((String)item.getProperty(PublisherEventLogger.SOURCE_PROPERTY)).lastSegment();
- }
- if( type.equals(PublisherEventLogger.FILE_DELETED_EVENT)) {
- return (!b.booleanValue() ? fail : "") +
- "Delete File: " + new Path((String)item.getProperty(PublisherEventLogger.DEST_PROPERTY)).lastSegment();
- }
- if( type.equals(PublisherEventLogger.FOLDER_DELETED_EVENT)) {
- return (!b.booleanValue() ? fail : "") +
- "Delete Folder: " + new Path((String)item.getProperty(PublisherEventLogger.DEST_PROPERTY)).lastSegment();
- }
- if( type.equals(PublisherEventLogger.PUBLISH_UTIL_STATUS_WRAPPER_TYPE)) {
- Object data = item.getData();
- if( data != null && data instanceof IStatus ) {
- IStatus s = (IStatus)data;
- return s.getMessage();
- }
- return data == null ? "null" : data.toString();
- }
- return item.getSpecificType();
- }
-
-}
Deleted: trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/server/providers/events/PollingLabelProvider.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/server/providers/events/PollingLabelProvider.java 2008-11-17 18:42:45 UTC (rev 11852)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/server/providers/events/PollingLabelProvider.java 2008-11-17 19:06:38 UTC (rev 11853)
@@ -1,168 +0,0 @@
-/**
- * JBoss, a Division of Red Hat
- * Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
-* This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.ide.eclipse.as.ui.views.server.providers.events;
-
-import org.eclipse.debug.core.ILaunchManager;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.ui.ISharedImages;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.wst.server.core.IServer;
-import org.eclipse.wst.server.ui.internal.provisional.UIDecoratorManager;
-import org.jboss.ide.eclipse.as.core.extensions.events.EventLogModel;
-import org.jboss.ide.eclipse.as.core.extensions.events.EventLogModel.EventLogTreeItem;
-import org.jboss.ide.eclipse.as.core.extensions.polling.JMXPoller;
-import org.jboss.ide.eclipse.as.core.server.IServerStatePoller;
-import org.jboss.ide.eclipse.as.core.server.internal.JBossServerBehavior;
-import org.jboss.ide.eclipse.as.core.server.internal.PollThread;
-import org.jboss.ide.eclipse.as.core.server.internal.PollThread.PollThreadEvent;
-import org.jboss.ide.eclipse.as.ui.views.server.extensions.IEventLogLabelProvider;
-
-/**
- *
- * @author rob.stryker(a)jboss.com
- */
-public class PollingLabelProvider extends ComplexEventLogLabelProvider implements IEventLogLabelProvider {
-
-
- protected void addSupportedTypes() {
- supported.add(PollThread.SERVER_STARTING);
- supported.add(PollThread.SERVER_STOPPING);
- supported.add(PollThread.FAILURE);
- supported.add(PollThread.SUCCESS);
- supported.add(PollThread.POLL_THREAD_ABORTED);
- supported.add(PollThread.POLL_THREAD_TIMEOUT);
- supported.add(PollThread.POLL_THREAD_EXCEPTION);
- supported.add(PollThread.POLLER_NOT_FOUND);
-
- supported.add(EventLogModel.EVENT_TYPE_EXCEPTION);
- supported.add(JMXPoller.EVENT_TYPE_STARTING);
-
- supported.add(JBossServerBehavior.FORCE_SHUTDOWN_EVENT_KEY);
- }
-
- public Image getImage(EventLogTreeItem element) {
- if( element.getSpecificType().equals(PollThread.SERVER_STARTING)) return getStartingImage();
- if( element.getSpecificType().equals(PollThread.SERVER_STOPPING)) return getStoppingImage();
-
- if( element instanceof PollThreadEvent ) {
- boolean expected = ((PollThreadEvent)element).getExpectedState();
- //String expectedString = expected == IServerStatePoller.SERVER_UP ? "startup" : "shutdown";
- if( element.getSpecificType().equals(PollThread.POLL_THREAD_ABORTED)) return getErrorImage();
- if( element.getSpecificType().equals(PollThread.POLL_THREAD_TIMEOUT)) return getErrorImage();
- if( element.getSpecificType().equals(PollThread.POLL_THREAD_EXCEPTION)) return getErrorImage();
- if( element.getSpecificType().equals(PollThread.POLLER_NOT_FOUND)) return getErrorImage();
- if( element.getSpecificType().equals(PollThread.SUCCESS)) {
- if( expected == IServerStatePoller.SERVER_UP)
- return getStartedImage();
- return getStoppedImage();
- }
- if( element.getSpecificType().equals(PollThread.FAILURE))
- return getErrorImage();
- }
-
- if( element.getSpecificType().equals(EventLogModel.EVENT_TYPE_EXCEPTION))
- return PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJS_WARN_TSK);
- if( element.getSpecificType().equals(JMXPoller.EVENT_TYPE_STARTING)) {
- boolean started = ((Boolean)element.getProperty(JMXPoller.STARTED_PROPERTY)).booleanValue();
- if( !started )
- return getStartingImage();
- return getStartedImage();
- }
-
-
- if( element.getSpecificType().equals(JBossServerBehavior.FORCE_SHUTDOWN_EVENT_KEY))
- return getErrorImage();
- return null;
- }
-
- public String getText(EventLogTreeItem element) {
- if( element.getSpecificType().equals(PollThread.SERVER_STARTING)) return "Starting the Server";
- if( element.getSpecificType().equals(PollThread.SERVER_STOPPING)) return "Stopping the Server";
-
- if( element instanceof PollThreadEvent ) {
- boolean expected = ((PollThreadEvent)element).getExpectedState();
- String expectedString = expected == IServerStatePoller.SERVER_UP ? "Startup" : "Shutdown";
- if( element.getSpecificType().equals(PollThread.POLL_THREAD_ABORTED)) {
- Object cause = element.getProperty(PollThread.POLL_THREAD_ABORTED_CAUSE);
- return expectedString + " aborted" + (cause != null ? ": " + cause.toString() : "");
- }
- if( element.getSpecificType().equals(PollThread.POLL_THREAD_TIMEOUT)) return expectedString + " timed out";
- if( element.getSpecificType().equals(PollThread.POLL_THREAD_EXCEPTION)) return "Failure: " + element.getProperty(PollThread.POLL_THREAD_EXCEPTION_MESSAGE);
- if( element.getSpecificType().equals(PollThread.SUCCESS)) return expectedString + " succeeded";
- if( element.getSpecificType().equals(PollThread.FAILURE)) return expectedString + " failed";
- if( element.getSpecificType().equals(PollThread.POLLER_NOT_FOUND)) return expectedString + " failed. Poller not found";
- }
-
- if( element.getSpecificType().equals(EventLogModel.EVENT_TYPE_EXCEPTION)) {
- Object o = element.getProperty(EventLogModel.EXCEPTION_PROPERTY);
- return "JMXException: " + ( o == null ? "null" : ((Exception)o).getMessage());
- }
-
- if( element.getSpecificType().equals(JMXPoller.EVENT_TYPE_STARTING)) {
- boolean started = ((Boolean)element.getProperty(JMXPoller.STARTED_PROPERTY)).booleanValue();
- if( !started )
- return "Server is still starting";
- return "Server has completed startup";
- }
-
- if( element.getSpecificType().equals(JBossServerBehavior.FORCE_SHUTDOWN_EVENT_KEY))
- return "The server was shutdown forcefully. All processes terminated.";
- return null;
- }
-
- protected Image getStateImage(int state) {
- return UIDecoratorManager.getUIDecorator(null).getStateImage(state, ILaunchManager.RUN_MODE, 0);
- }
-
- protected Image getErrorImage() {
- return PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJS_ERROR_TSK);
- }
- public Image getStartedImage() {
- return getStateImage(IServer.STATE_STARTED);
- }
- public Image getStartingImage() {
- return getStateImage(IServer.STATE_STARTING);
- }
- public Image getStoppingImage() {
- return getStateImage(IServer.STATE_STOPPING);
- }
- public Image getStoppedImage() {
- return getStateImage(IServer.STATE_STOPPED);
- }
-
-
-
- /*
- * Property Stuff
- */
- protected void loadPropertyMap() {
- // property names and their readable forms
- propertyToMessageMap.put(EventLogTreeItem.DATE, "Time");
- propertyToMessageMap.put(PollThread.EXPECTED_STATE, "Expected State");
- propertyToMessageMap.put(EventLogModel.EXCEPTION_PROPERTY, "Exception");
- propertyToMessageMap.put(JMXPoller.STARTED_PROPERTY, "Server Started");
- propertyToMessageMap.put(PollThread.POLL_THREAD_ABORTED_CAUSE, "Abort Cause");
- // now values and their readable forms
- propertyToMessageMap.put(PollThread.EXPECTED_STATE + DELIMITER + "true", "Up");
- propertyToMessageMap.put(PollThread.EXPECTED_STATE + DELIMITER + "false", "Down");
- }
-}
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/tools/as/wst/server/ui/ServerActionProvider.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/tools/as/wst/server/ui/ServerActionProvider.java 2008-11-17 18:42:45 UTC (rev 11852)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/tools/as/wst/server/ui/ServerActionProvider.java 2008-11-17 19:06:38 UTC (rev 11853)
@@ -215,7 +215,7 @@
text += "\t" + activeBindings[0].format();
}
- MenuManager showInMenu = new MenuManager(text);
+ MenuManager showInMenu = new MenuManager(text, "org.eclipse.ui.navigate.showInQuickMenu");
showInMenu.add(showInConsoleAction);
showInMenu.add(showInDebugAction);
//IActionBars actionBars = getViewSite().getActionBars();
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.ui/plugin.xml
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.ui/plugin.xml 2008-11-17 18:42:45 UTC (rev 11852)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.ui/plugin.xml 2008-11-17 19:06:38 UTC (rev 11853)
@@ -268,6 +268,14 @@
category="org.eclipse.wst.server.ui"
class="org.jboss.tools.as.wst.server.ui.ServersView"
icon="icons/jboss.gif"/>
+ <view
+ category="org.eclipse.wst.server.ui"
+ class="org.jboss.ide.eclipse.as.ui.views.ServerLogView"
+ icon="icons/console.gif"
+ id="org.jboss.ide.eclipse.as.ui.view.serverLogView"
+ name="Server Log"
+ restorable="true">
+ </view>
</extension>
<extension point="org.eclipse.ui.decorators">
@@ -360,34 +368,6 @@
<extension
point="org.eclipse.ui.navigator.navigatorContent">
- <navigatorContent
- id="org.jboss.ide.eclipse.as.ui.extensions.eventLog"
- activeByDefault="true"
- icon="icons/info_obj.gif"
- contentProvider="org.jboss.ide.eclipse.as.ui.views.server.extensions.EventLogContentProvider"
- labelProvider="org.jboss.ide.eclipse.as.ui.views.server.extensions.EventLogLabelProvider"
- name="JBoss Server Event Log"
- priority="normal">
- <triggerPoints>
- <instanceof
- value="org.eclipse.wst.server.core.IServer">
- </instanceof>
- </triggerPoints>
- <possibleChildren>
- <or>
- <instanceof
- value="org.jboss.ide.eclipse.as.core.extensions.events.EventLogModel$EventLogTreeItem">
- </instanceof>
- <instanceof
- value="org.jboss.ide.eclipse.as.core.extensions.events.EventLogModel$ServerEventModel">
- </instanceof>
- </or></possibleChildren>
- <actionProvider
- class="org.jboss.ide.eclipse.as.ui.views.server.extensions.EventLogActionProvider"
- id="org.jboss.ide.eclipse.as.ui.extensions.eventLog.actions"
- priority="highest">
- </actionProvider>
- </navigatorContent>
<navigatorContent
activeByDefault="true"
contentProvider="org.jboss.ide.eclipse.as.ui.views.server.extensions.XPathTreeContentProvider"
@@ -437,6 +417,15 @@
</instanceof>
</enablement>
</actionProvider>
+ <actionProvider
+ class="org.jboss.ide.eclipse.as.ui.views.server.extensions.ServerLogActionProvider"
+ id="org.jboss.ide.eclipse.as.ui.extensions.serverLog">
+ <enablement>
+ <instanceof
+ value="org.eclipse.wst.server.core.IServer">
+ </instanceof>
+ </enablement>
+ </actionProvider>
</extension>
@@ -446,22 +435,19 @@
<viewerContentBinding
viewerId="org.jboss.ide.eclipse.as.ui.views.JBossServerView">
<includes>
- <contentExtension
- isRoot="false"
- pattern="org.jboss.ide.eclipse.as.ui.extensions.eventLog">
- </contentExtension>
- <contentExtension
+ <contentExtension
isRoot="false"
pattern="org.jboss.ide.eclipse.as.ui.extensions.xml">
- </contentExtension>
+ </contentExtension>
</includes>
</viewerContentBinding>
<viewerActionBinding
viewerId="org.jboss.ide.eclipse.as.ui.views.JBossServerView">
<includes>
<actionExtension
- pattern="org.jboss.ide.eclipse.as.ui.extensions.modules">
- </actionExtension>
+ pattern="org.jboss.ide.eclipse.as.ui.extensions.modules"/>
+ <actionExtension
+ pattern="org.jboss.ide.eclipse.as.ui.extensions.serverLog"/>
</includes>
</viewerActionBinding>
</extension>
17 years, 5 months
JBoss Tools SVN: r11852 - in trunk/examples/plugins/org.jboss.tools.project.examples: schema and 3 other directories.
by jbosstools-commits@lists.jboss.org
Author: snjeza
Date: 2008-11-17 13:42:45 -0500 (Mon, 17 Nov 2008)
New Revision: 11852
Added:
trunk/examples/plugins/org.jboss.tools.project.examples/schema/
trunk/examples/plugins/org.jboss.tools.project.examples/schema/projectExamplesXml.exsd
Modified:
trunk/examples/plugins/org.jboss.tools.project.examples/build.properties
trunk/examples/plugins/org.jboss.tools.project.examples/plugin.properties
trunk/examples/plugins/org.jboss.tools.project.examples/plugin.xml
trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/Messages.java
trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/ProjectExamplesActivator.java
trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/messages.properties
trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/model/ProjectUtil.java
trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/wizard/NewProjectExamplesWizard.java
Log:
JBIDE-2966 Add an extension point in order to enable adding a new xml file to the project.examples plugin
Modified: trunk/examples/plugins/org.jboss.tools.project.examples/build.properties
===================================================================
--- trunk/examples/plugins/org.jboss.tools.project.examples/build.properties 2008-11-17 17:36:13 UTC (rev 11851)
+++ trunk/examples/plugins/org.jboss.tools.project.examples/build.properties 2008-11-17 18:42:45 UTC (rev 11852)
@@ -10,4 +10,5 @@
about.ini,\
about.mappings,\
about.properties,\
- rhds_wiz.png
+ rhds_wiz.png,\
+ schema/
Modified: trunk/examples/plugins/org.jboss.tools.project.examples/plugin.properties
===================================================================
--- trunk/examples/plugins/org.jboss.tools.project.examples/plugin.properties 2008-11-17 17:36:13 UTC (rev 11851)
+++ trunk/examples/plugins/org.jboss.tools.project.examples/plugin.properties 2008-11-17 18:42:45 UTC (rev 11852)
@@ -3,4 +3,5 @@
BundleName = Project Examples
JBoss_Tools_category = JBoss Tools
Project_Examples_wizard = Project Examples
-Project_Examples_command = Project Examples
\ No newline at end of file
+Project_Examples_command =Project Examples
+ProjectExamples=Project Examples file
\ No newline at end of file
Modified: trunk/examples/plugins/org.jboss.tools.project.examples/plugin.xml
===================================================================
--- trunk/examples/plugins/org.jboss.tools.project.examples/plugin.xml 2008-11-17 17:36:13 UTC (rev 11851)
+++ trunk/examples/plugins/org.jboss.tools.project.examples/plugin.xml 2008-11-17 18:42:45 UTC (rev 11852)
@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.2"?>
<plugin>
+ <extension-point id="projectExamplesXml" name="%ProjectExamples" schema="schema/projectExamplesXml.exsd"/>
<extension point="org.eclipse.ui.newWizards">
<category
@@ -40,4 +41,9 @@
</menuContribution>
</extension>
+ <extension
+ point="org.jboss.tools.project.examples.projectExamplesXml">
+ <url>http://anonsvn.jboss.org/repos/jbosstools/workspace/examples/projectExamp...</url>
+ </extension>
+
</plugin>
Added: trunk/examples/plugins/org.jboss.tools.project.examples/schema/projectExamplesXml.exsd
===================================================================
--- trunk/examples/plugins/org.jboss.tools.project.examples/schema/projectExamplesXml.exsd (rev 0)
+++ trunk/examples/plugins/org.jboss.tools.project.examples/schema/projectExamplesXml.exsd 2008-11-17 18:42:45 UTC (rev 11852)
@@ -0,0 +1,101 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!-- Schema file written by PDE -->
+<schema targetNamespace="org.jboss.tools.project.examples" xmlns="http://www.w3.org/2001/XMLSchema">
+<annotation>
+ <appinfo>
+ <meta.schema plugin="org.jboss.tools.project.examples" id="projectExamplesXml" name="Project Examples file"/>
+ </appinfo>
+ <documentation>
+ Adds a new Project Examples xml file
+ </documentation>
+ </annotation>
+
+ <element name="extension">
+ <annotation>
+ <appinfo>
+ <meta.element />
+ </appinfo>
+ </annotation>
+ <complexType>
+ <sequence>
+ <element ref="url" minOccurs="1" maxOccurs="unbounded"/>
+ </sequence>
+ <attribute name="point" type="string" use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="id" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="name" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ <appinfo>
+ <meta.attribute translatable="true"/>
+ </appinfo>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <element name="url" type="string">
+ </element>
+
+ <annotation>
+ <appinfo>
+ <meta.section type="since"/>
+ </appinfo>
+ <documentation>
+ 3.0.0
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appinfo>
+ <meta.section type="examples"/>
+ </appinfo>
+ <documentation>
+ <extension
+ point="org.jboss.tools.project.examples.projectExamplesXml">
+ <url>file:/C:/test/projectExamples.xml</url>
+</extension>
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appinfo>
+ <meta.section type="apiinfo"/>
+ </appinfo>
+ <documentation>
+ [Enter API information here.]
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appinfo>
+ <meta.section type="implementation"/>
+ </appinfo>
+ <documentation>
+ [Enter information about supplied implementation of this extension point.]
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appinfo>
+ <meta.section type="copyright"/>
+ </appinfo>
+ <documentation>
+ JBoss, a division of Red Hat
+ </documentation>
+ </annotation>
+
+</schema>
Modified: trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/Messages.java
===================================================================
--- trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/Messages.java 2008-11-17 17:36:13 UTC (rev 11851)
+++ trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/Messages.java 2008-11-17 18:42:45 UTC (rev 11852)
@@ -46,6 +46,7 @@
public static String NewProjectExamplesWizardPage_Show_the_Quick_Fix_dialog;
public static String NewProjectExamplesWizardPage_URL;
public static String ProjectExamplesActivator_Waiting;
+ public static String ProjectUtil_Invalid_URL;
static {
// initialize resource bundle
NLS.initializeMessages(BUNDLE_NAME, Messages.class);
Modified: trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/ProjectExamplesActivator.java
===================================================================
--- trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/ProjectExamplesActivator.java 2008-11-17 17:36:13 UTC (rev 11851)
+++ trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/ProjectExamplesActivator.java 2008-11-17 18:42:45 UTC (rev 11852)
@@ -106,6 +106,11 @@
.getLocalizedMessage(), e);
ProjectExamplesActivator.getDefault().getLog().log(status);
}
+
+ public static void log(String message) {
+ IStatus status = new Status(IStatus.WARNING, PLUGIN_ID,message);
+ ProjectExamplesActivator.getDefault().getLog().log(status);
+ }
public static BundleContext getBundleContext() {
return context;
Modified: trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/messages.properties
===================================================================
--- trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/messages.properties 2008-11-17 17:36:13 UTC (rev 11851)
+++ trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/messages.properties 2008-11-17 18:42:45 UTC (rev 11852)
@@ -30,3 +30,4 @@
NewProjectExamplesWizardPage_Show_the_Quick_Fix_dialog=Show the Quick Fix dialog
NewProjectExamplesWizardPage_URL=URL:
ProjectExamplesActivator_Waiting=Waiting...
+ProjectUtil_Invalid_URL=Invalid URL\: {0}
Modified: trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/model/ProjectUtil.java
===================================================================
--- trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/model/ProjectUtil.java 2008-11-17 17:36:13 UTC (rev 11851)
+++ trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/model/ProjectUtil.java 2008-11-17 18:42:45 UTC (rev 11852)
@@ -25,14 +25,17 @@
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
-import org.eclipse.core.runtime.FileLocator;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IExtension;
+import org.eclipse.core.runtime.IExtensionPoint;
+import org.eclipse.core.runtime.IExtensionRegistry;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Platform;
+import org.eclipse.osgi.util.NLS;
import org.jboss.tools.project.examples.Messages;
import org.jboss.tools.project.examples.ProjectExamplesActivator;
import org.jboss.tools.project.examples.filetransfer.ECFExamplesTransport;
-import org.osgi.framework.Bundle;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
@@ -44,20 +47,67 @@
*/
public class ProjectUtil {
- private final static String PROJECT_EXAMPLES_XML = "http://anonsvn.jboss.org/repos/jbosstools/workspace/examples/projectExamp..."; //$NON-NLS-1$
private static final String PROTOCOL_FILE = "file"; //$NON-NLS-1$
-
+
+ private static final String PROJECT_EXAMPLES_XML_EXTENSION_ID = "org.jboss.tools.project.examples.projectExamplesXml"; //$NON-NLS-1$
+ private static List<URL> URLs;
+
private ProjectUtil() {
+ }
+ private static List<URL> getURLs() {
+ if (URLs == null) {
+ URLs = new ArrayList<URL>();
+ IExtensionRegistry registry = Platform.getExtensionRegistry();
+ IExtensionPoint extensionPoint = registry
+ .getExtensionPoint(PROJECT_EXAMPLES_XML_EXTENSION_ID);
+ IExtension[] extensions = extensionPoint.getExtensions();
+ for (int i = 0; i < extensions.length; i++) {
+ IExtension extension = extensions[i];
+ IConfigurationElement[] configurationElements = extension
+ .getConfigurationElements();
+ for (int j = 0; j < configurationElements.length; j++) {
+ IConfigurationElement configurationElement = configurationElements[j];
+ String urlString = configurationElement.getValue();
+ URL url = getURL(urlString);
+ if (url != null) {
+ URLs.add(url);
+ }
+ }
+ }
+ URL url = getURL(getProjectExamplesXml());
+ if (url != null) {
+ URLs.add(url);
+ }
+ }
+ return URLs;
}
+ private static URL getURL(String urlString) {
+ if (urlString != null && urlString.trim().length() > 0) {
+ urlString = urlString.trim();
+ try {
+ URL url = new URL(urlString);
+ return url;
+ } catch (MalformedURLException e) {
+ ProjectExamplesActivator.log(e);
+ }
+ }
+ return null;
+ }
+
public static List<Category> getProjects() {
+ getURLs();
List<Category> list = new ArrayList<Category>();
Category other = Category.OTHER;
try {
- // TODO add a progress monitor
- File file = getProjectExamplesFile(getProjectExamplesXml(),"projectExamples", ".xml",null); //$NON-NLS-1$ //$NON-NLS-2$
- if (file.exists() && file.isFile()) {
+ for (URL url : URLs) {
+ File file = getProjectExamplesFile(url,
+ "projectExamples", ".xml", null); //$NON-NLS-1$ //$NON-NLS-2$
+ if (file == null || !file.exists() || !file.isFile()) {
+ ProjectExamplesActivator.log(NLS.bind(Messages.ProjectUtil_Invalid_URL,url.toString()));
+ continue;
+ }
DocumentBuilderFactory dbf = DocumentBuilderFactory
.newInstance();
DocumentBuilder db = dbf.newDocumentBuilder();
@@ -80,10 +130,10 @@
if (nodeName.equals("category")) { //$NON-NLS-1$
String value = getContent(child);
boolean found = false;
- for (Category cat:list) {
+ for (Category cat : list) {
if (cat.getName().equals(value)) {
- category=cat;
- found=true;
+ category = cat;
+ found = true;
break;
}
}
@@ -97,7 +147,8 @@
project.setName(getContent(child));
}
if (nodeName.equals("shortDescription")) { //$NON-NLS-1$
- project.setShortDescription(getContent(child));
+ project
+ .setShortDescription(getContent(child));
}
if (nodeName.equals("description")) { //$NON-NLS-1$
project.setDescription(getContent(child));
@@ -116,13 +167,17 @@
if (nodeName.equals("included-projects")) { //$NON-NLS-1$
String includedProjects = getContent(child);
if (includedProjects != null) {
- includedProjects = includedProjects.trim();
- StringTokenizer tokenizer = new StringTokenizer(includedProjects,","); //$NON-NLS-1$
+ includedProjects = includedProjects
+ .trim();
+ StringTokenizer tokenizer = new StringTokenizer(
+ includedProjects, ","); //$NON-NLS-1$
List<String> projectList = new ArrayList<String>();
while (tokenizer.hasMoreTokens()) {
- projectList.add(tokenizer.nextToken());
+ projectList.add(tokenizer
+ .nextToken());
}
- project.setIncludedProjects(projectList);
+ project
+ .setIncludedProjects(projectList);
}
}
}
@@ -139,46 +194,44 @@
}
private static String getProjectExamplesXml() {
- String projectXML = System.getProperty("org.jboss.tools.project.examples.xml"); //$NON-NLS-1$
+ String projectXML = System
+ .getProperty("org.jboss.tools.project.examples.xml"); //$NON-NLS-1$
if (projectXML != null && projectXML.length() > 0) {
return projectXML;
}
- return PROJECT_EXAMPLES_XML;
+ return null;
}
private static String getContent(Element child) {
String value = child.getTextContent();
if (value == null) {
- value=""; //$NON-NLS-1$
+ value = ""; //$NON-NLS-1$
}
return value.trim();
}
-
- public static File getProjectExamplesFile(String urlString,String prefix, String suffix, IProgressMonitor monitor) {
- URL url;
- try {
- url = new URL(urlString);
- } catch (MalformedURLException e) {
- ProjectExamplesActivator.log(e);
- return null;
- }
+
+ public static File getProjectExamplesFile(URL url, String prefix,
+ String suffix, IProgressMonitor monitor) {
File file = null;
if (PROTOCOL_FILE.equals(url.getProtocol())) {
try {
- //assume all illegal characters have been properly encoded, so use URI class to unencode
+ // assume all illegal characters have been properly encoded, so
+ // use URI class to unencode
file = new File(new URI(url.toExternalForm()));
} catch (Exception e) {
- //URL contains unencoded characters
+ // URL contains unencoded characters
file = new File(url.getFile());
}
if (!file.exists())
return null;
} else {
try {
- file = File.createTempFile(prefix,suffix);
+ file = File.createTempFile(prefix, suffix);
file.deleteOnExit();
- BufferedOutputStream destination = new BufferedOutputStream(new FileOutputStream(file));
- IStatus result = getTransport().download(prefix,url.toExternalForm(), destination, monitor);
+ BufferedOutputStream destination = new BufferedOutputStream(
+ new FileOutputStream(file));
+ IStatus result = getTransport().download(prefix,
+ url.toExternalForm(), destination, monitor);
if (!result.isOK()) {
ProjectExamplesActivator.getDefault().getLog().log(result);
return null;
@@ -193,7 +246,7 @@
}
return file;
}
-
+
private static ECFExamplesTransport getTransport() {
return ECFExamplesTransport.getInstance();
}
Modified: trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/wizard/NewProjectExamplesWizard.java
===================================================================
--- trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/wizard/NewProjectExamplesWizard.java 2008-11-17 17:36:13 UTC (rev 11851)
+++ trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/wizard/NewProjectExamplesWizard.java 2008-11-17 18:42:45 UTC (rev 11852)
@@ -17,6 +17,8 @@
import java.io.File;
import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
+import java.net.MalformedURLException;
+import java.net.URL;
import java.util.ArrayList;
import java.util.Enumeration;
import java.util.Iterator;
@@ -113,8 +115,15 @@
Object object = iterator.next();
if (object instanceof Project) {
Project project = (Project) object;
- String url = project.getUrl();
+ String urlString = project.getUrl();
String name = project.getName();
+ URL url = null;
+ try {
+ url = new URL(urlString);
+ } catch (MalformedURLException e) {
+ ProjectExamplesActivator.log(e);
+ continue;
+ }
final File file = ProjectUtil.getProjectExamplesFile(
url, name, ".zip", monitor); //$NON-NLS-1$
if (file == null) {
17 years, 5 months
JBoss Tools SVN: r11849 - in trunk: documentation/guides/GettingStartedGuide/en and 1 other directories.
by jbosstools-commits@lists.jboss.org
Author: smukhina
Date: 2008-11-17 12:29:42 -0500 (Mon, 17 Nov 2008)
New Revision: 11849
Modified:
trunk/birt/docs/en/master.xml
trunk/documentation/guides/GettingStartedGuide/en/master.xml
trunk/documentation/jboss-tools-docs/index/en/master.xml
Log:
https://jira.jboss.org/jira/browse/JBDS-359 added links to pdf from 2 other versions
Modified: trunk/birt/docs/en/master.xml
===================================================================
--- trunk/birt/docs/en/master.xml 2008-11-17 17:07:56 UTC (rev 11848)
+++ trunk/birt/docs/en/master.xml 2008-11-17 17:29:42 UTC (rev 11849)
@@ -26,6 +26,14 @@
Version: 3.0.0.beta1
</releaseinfo>
</bookinfo>
+
+<abstract>
+ <title/>
+ <para>
+ <ulink url="http://download.jboss.org/jbosstools/nightly-docs/en/jboss_birt_plugin_re...">PDF version</ulink>
+ </para>
+</abstract>
+
<toc/>
Modified: trunk/documentation/guides/GettingStartedGuide/en/master.xml
===================================================================
--- trunk/documentation/guides/GettingStartedGuide/en/master.xml 2008-11-17 17:07:56 UTC (rev 11848)
+++ trunk/documentation/guides/GettingStartedGuide/en/master.xml 2008-11-17 17:29:42 UTC (rev 11849)
@@ -39,6 +39,13 @@
</bookinfo>
<toc/>
+<abstract>
+ <title/>
+ <para>
+ <ulink url="http://download.jboss.org/jbosstools/nightly-docs/en/GettingStartedGuide/...">PDF version</ulink>
+ </para>
+</abstract>
+
&getting_started;
&manage;
&first_seam;
Modified: trunk/documentation/jboss-tools-docs/index/en/master.xml
===================================================================
--- trunk/documentation/jboss-tools-docs/index/en/master.xml 2008-11-17 17:07:56 UTC (rev 11848)
+++ trunk/documentation/jboss-tools-docs/index/en/master.xml 2008-11-17 17:29:42 UTC (rev 11849)
@@ -129,7 +129,7 @@
<primaryie>JBoss Birt Plugin Reference Guide <ulink
url="en/jboss_birt_plugin_ref_guide/html/index.html">(html)</ulink>
<ulink url="en/jboss_birt_plugin_ref_guide/html_single/index.html">(html single)</ulink>
- <ulink url="en/jboss_birt_tools_ref_guide/pdf/Birt_Reference_Guide.pdf"
+ <ulink url="en/jboss_birt_plugin_ref_guide/pdf/Birt_Reference_Guide.pdf"
>(pdf)</ulink>
</primaryie>
</indexentry>
17 years, 5 months
JBoss Tools SVN: r11848 - trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/attribute.
by jbosstools-commits@lists.jboss.org
Author: scabanovich
Date: 2008-11-17 12:07:56 -0500 (Mon, 17 Nov 2008)
New Revision: 11848
Modified:
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/attribute/AttributeContentProposalProviderFactory.java
Log:
JBIDE-2575
Modified: trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/attribute/AttributeContentProposalProviderFactory.java
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/attribute/AttributeContentProposalProviderFactory.java 2008-11-17 17:00:26 UTC (rev 11847)
+++ trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/attribute/AttributeContentProposalProviderFactory.java 2008-11-17 17:07:56 UTC (rev 11848)
@@ -22,10 +22,14 @@
import org.eclipse.jface.bindings.keys.ParseException;
import org.eclipse.jface.fieldassist.ComboContentAdapter;
import org.eclipse.jface.fieldassist.ContentProposalAdapter;
+import org.eclipse.jface.fieldassist.ControlDecoration;
+import org.eclipse.jface.fieldassist.FieldDecoration;
+import org.eclipse.jface.fieldassist.FieldDecorationRegistry;
import org.eclipse.jface.fieldassist.IContentProposal;
import org.eclipse.jface.fieldassist.IContentProposalProvider;
import org.eclipse.jface.fieldassist.IControlContentAdapter;
import org.eclipse.jface.fieldassist.TextContentAdapter;
+import org.eclipse.swt.SWT;
import org.eclipse.swt.events.DisposeEvent;
import org.eclipse.swt.events.DisposeListener;
import org.eclipse.swt.widgets.Combo;
@@ -76,6 +80,7 @@
AttributeContentProposalProviderFactory factory = new AttributeContentProposalProviderFactory();
final List<IAttributeContentProposalProvider> ps = factory
.getContentProposalProviders(object, attr);
+ boolean added = false;
for (IAttributeContentProposalProvider p : ps) {
p.init(object, attr);
IContentProposalProvider cpp = p.getContentProposalProvider();
@@ -89,6 +94,7 @@
null);
adapter.setPropagateKeys(true);
adapter.setProposalAcceptanceStyle(p.getProposalAcceptanceStyle());
+ added = true;
}
if (!ps.isEmpty()) {
control.addDisposeListener(new DisposeListener() {
@@ -99,6 +105,21 @@
}
});
}
+ if(added) {
+ int bits = SWT.TOP | SWT.LEFT;
+ ControlDecoration controlDecoration = new ControlDecoration(control, bits);
+ // Configure text widget decoration
+ // No margin
+ controlDecoration.setMarginWidth(0);
+ // Custom hover tip text
+ controlDecoration.setDescriptionText("code assist" /*PDEUIMessages.PDEJavaHelper_msgContentAssistAvailable*/);
+ // Custom hover properties
+ controlDecoration.setShowHover(true);
+ controlDecoration.setShowOnlyOnFocus(true);
+ // Hover image to use
+ FieldDecoration contentProposalImage = FieldDecorationRegistry.getDefault().getFieldDecoration(FieldDecorationRegistry.DEC_CONTENT_PROPOSAL);
+ controlDecoration.setImage(contentProposalImage.getImage());
+ }
}
static String POINT_ID = ModelUIPlugin.PLUGIN_ID + ".attributeContentProposalProviders";
17 years, 5 months
JBoss Tools SVN: r11847 - in trunk/seam/plugins/org.jboss.tools.seam.ui.pages: src/org/jboss/tools/seam/ui/pages/editor/edit and 1 other directory.
by jbosstools-commits@lists.jboss.org
Author: dazarov
Date: 2008-11-17 12:00:26 -0500 (Mon, 17 Nov 2008)
New Revision: 11847
Modified:
trunk/seam/plugins/org.jboss.tools.seam.ui.pages/META-INF/MANIFEST.MF
trunk/seam/plugins/org.jboss.tools.seam.ui.pages/src/org/jboss/tools/seam/ui/pages/editor/edit/ViewIDDirectEditPolicy.java
trunk/seam/plugins/org.jboss.tools.seam.ui.pages/src/org/jboss/tools/seam/ui/pages/editor/edit/ViewIDEditManager.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-2575
Modified: trunk/seam/plugins/org.jboss.tools.seam.ui.pages/META-INF/MANIFEST.MF
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.ui.pages/META-INF/MANIFEST.MF 2008-11-17 15:41:48 UTC (rev 11846)
+++ trunk/seam/plugins/org.jboss.tools.seam.ui.pages/META-INF/MANIFEST.MF 2008-11-17 17:00:26 UTC (rev 11847)
@@ -48,6 +48,7 @@
org.jboss.tools.jst.web.ui,
org.jboss.tools.seam.pages.xml,
org.eclipse.emf;bundle-version="2.4.0",
- org.eclipse.emf.ecore;bundle-version="2.4.0"
+ org.eclipse.emf.ecore;bundle-version="2.4.0",
+ org.eclipse.pde.ui;bundle-version="3.4.0"
Bundle-Version: 2.0.0
Modified: trunk/seam/plugins/org.jboss.tools.seam.ui.pages/src/org/jboss/tools/seam/ui/pages/editor/edit/ViewIDDirectEditPolicy.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.ui.pages/src/org/jboss/tools/seam/ui/pages/editor/edit/ViewIDDirectEditPolicy.java 2008-11-17 15:41:48 UTC (rev 11846)
+++ trunk/seam/plugins/org.jboss.tools.seam.ui.pages/src/org/jboss/tools/seam/ui/pages/editor/edit/ViewIDDirectEditPolicy.java 2008-11-17 17:00:26 UTC (rev 11847)
@@ -12,7 +12,6 @@
import java.util.Properties;
-import org.eclipse.core.runtime.CoreException;
import org.eclipse.gef.commands.Command;
import org.eclipse.gef.editpolicies.DirectEditPolicy;
import org.eclipse.gef.requests.DirectEditRequest;
Modified: trunk/seam/plugins/org.jboss.tools.seam.ui.pages/src/org/jboss/tools/seam/ui/pages/editor/edit/ViewIDEditManager.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.ui.pages/src/org/jboss/tools/seam/ui/pages/editor/edit/ViewIDEditManager.java 2008-11-17 15:41:48 UTC (rev 11846)
+++ trunk/seam/plugins/org.jboss.tools.seam.ui.pages/src/org/jboss/tools/seam/ui/pages/editor/edit/ViewIDEditManager.java 2008-11-17 17:00:26 UTC (rev 11847)
@@ -12,6 +12,7 @@
import java.text.MessageFormat;
+import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.Assert;
import org.eclipse.draw2d.ColorConstants;
import org.eclipse.gef.GraphicalEditPart;
@@ -20,10 +21,12 @@
import org.eclipse.gef.requests.DirectEditRequest;
import org.eclipse.gef.tools.CellEditorLocator;
import org.eclipse.gef.tools.DirectEditManager;
+import org.eclipse.jdt.core.search.IJavaSearchConstants;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.viewers.CellEditor;
import org.eclipse.jface.viewers.ICellEditorValidator;
import org.eclipse.jface.viewers.TextCellEditor;
+import org.eclipse.pde.internal.ui.util.PDEJavaHelperUI;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.graphics.Font;
@@ -37,7 +40,9 @@
import org.eclipse.ui.internal.Workbench;
import org.eclipse.ui.internal.WorkbenchWindow;
import org.eclipse.ui.part.CellEditorActionHandler;
+import org.jboss.tools.common.meta.XAttribute;
import org.jboss.tools.common.model.XModelObject;
+import org.jboss.tools.common.model.ui.attribute.AttributeContentProposalProviderFactory;
import org.jboss.tools.seam.pages.xml.SeamPagesXMLMessages;
import org.jboss.tools.seam.pages.xml.model.handlers.AddViewSupport;
import org.jboss.tools.seam.pages.xml.model.helpers.SeamPagesDiagramHelper;
@@ -190,6 +195,15 @@
actionHandler.addCellEditor(getCellEditor());
actionBars.updateActionBars();
getCellEditor().setValidator(new ViewIDValidator(target));
+ if (figure instanceof PageFigure){
+ XAttribute attr = target.getModel().getMetaData().getEntity("SeamPage21").getAttribute("view id");
+ AttributeContentProposalProviderFactory.registerContentAssist(target, attr, getCellEditor().getControl());
+ }else if(figure instanceof ExceptionFigure){
+ IProject project = (IProject)target.getModel().getProperties().get("project");
+
+ PDEJavaHelperUI.addTypeFieldAssistToText((Text)getCellEditor().getControl(), project, IJavaSearchConstants.CLASS);
+ }
+
}
private void restoreSavedActions(IActionBars actionBars) {
17 years, 5 months
JBoss Tools SVN: r11846 - trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/attribute.
by jbosstools-commits@lists.jboss.org
Author: scabanovich
Date: 2008-11-17 10:41:48 -0500 (Mon, 17 Nov 2008)
New Revision: 11846
Modified:
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/attribute/AttributeContentProposalProviderFactory.java
Log:
JBIDE-2575
Modified: trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/attribute/AttributeContentProposalProviderFactory.java
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/attribute/AttributeContentProposalProviderFactory.java 2008-11-17 15:37:15 UTC (rev 11845)
+++ trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/attribute/AttributeContentProposalProviderFactory.java 2008-11-17 15:41:48 UTC (rev 11846)
@@ -56,6 +56,15 @@
}
public static void registerContentAssist(DefaultValueAdapter valueAdapter, Control control) {
+ XModelObject object = valueAdapter.getModelObject();
+ XAttribute attr = valueAdapter.getAttribute();
+ if (attr == null && valueAdapter.getAttributeData() != null) {
+ attr = valueAdapter.getAttributeData().getAttribute();
+ }
+ registerContentAssist(object, attr, control);
+ }
+
+ public static void registerContentAssist(XModelObject object, XAttribute attr, Control control) {
IControlContentAdapter controlAdapter = control instanceof Text
? new TextContentAdapter()
: control instanceof Combo
@@ -64,11 +73,6 @@
if(controlAdapter == null) {
return;
}
- XModelObject object = valueAdapter.getModelObject();
- XAttribute attr = valueAdapter.getAttribute();
- if (attr == null && valueAdapter.getAttributeData() != null) {
- attr = valueAdapter.getAttributeData().getAttribute();
- }
AttributeContentProposalProviderFactory factory = new AttributeContentProposalProviderFactory();
final List<IAttributeContentProposalProvider> ps = factory
.getContentProposalProviders(object, attr);
17 years, 5 months
JBoss Tools SVN: r11845 - in trunk/esb/plugins/org.jboss.tools.esb.core: resources/meta and 1 other directories.
by jbosstools-commits@lists.jboss.org
Author: scabanovich
Date: 2008-11-17 10:37:15 -0500 (Mon, 17 Nov 2008)
New Revision: 11845
Modified:
trunk/esb/plugins/org.jboss.tools.esb.core/resources/help/keys-esb-attrs.properties
trunk/esb/plugins/org.jboss.tools.esb.core/resources/help/keys-esb.properties
trunk/esb/plugins/org.jboss.tools.esb.core/resources/meta/esb.meta
trunk/esb/plugins/org.jboss.tools.esb.core/src/org/jboss/tools/esb/core/model/handlers/AddProviderSupport.java
Log:
JBIDE-3176
Modified: trunk/esb/plugins/org.jboss.tools.esb.core/resources/help/keys-esb-attrs.properties
===================================================================
--- trunk/esb/plugins/org.jboss.tools.esb.core/resources/help/keys-esb-attrs.properties 2008-11-17 14:54:18 UTC (rev 11844)
+++ trunk/esb/plugins/org.jboss.tools.esb.core/resources/help/keys-esb-attrs.properties 2008-11-17 15:37:15 UTC (rev 11845)
@@ -36,6 +36,7 @@
ESB.service_name=Service Name
ESB.mep=MEP
ESB.id=ID
+ESBBusCreator.id=Channel ID
ESB.cron_expression=Cron Expression
ESB.directory=Directory
ESB.input_suffix=Input Suffix
Modified: trunk/esb/plugins/org.jboss.tools.esb.core/resources/help/keys-esb.properties
===================================================================
--- trunk/esb/plugins/org.jboss.tools.esb.core/resources/help/keys-esb.properties 2008-11-17 14:54:18 UTC (rev 11844)
+++ trunk/esb/plugins/org.jboss.tools.esb.core/resources/help/keys-esb.properties 2008-11-17 15:37:15 UTC (rev 11845)
@@ -16,12 +16,12 @@
ESBProviders101_AddBusProvider_0.WindowTitle=Add Bus Provider
ESBProviders101_AddBusProvider_0.Title=ESB Provider
ESBProviders101_AddBusProvider_1.WindowTitle=Add Bus Provider
-ESBProviders101_AddBusProvider_1.Title=ESB Bus
+ESBProviders101_AddBusProvider_1.Title=ESB Channel
ESBProviders101_AddJBRProvider_0.WindowTitle=Add JBR Provider
ESBProviders101_AddJBRProvider_0.Title=ESB JBR Provider
ESBProviders101_AddJBRProvider_1.WindowTitle=Add JBR Provider
-ESBProviders101_AddJBRProvider_1.Title=ESB JBR Bus
+ESBProviders101_AddJBRProvider_1.Title=ESB Channel
ESBProviders101_AddScheduleProvider.WindowTitle=Add Schedule Provider
ESBProviders101_AddScheduleProvider.Title=ESB Schedule Provider
@@ -31,32 +31,32 @@
ESBProviders101_AddJMSProvider_0.WindowTitle=Add JMS Provider
ESBProviders101_AddJMSProvider_0.Title=ESB JMS Provider
ESBProviders101_AddJMSProvider_1.WindowTitle=Add JMS Provider
-ESBProviders101_AddJMSProvider_1.Title=ESB JMS Bus
+ESBProviders101_AddJMSProvider_1.Title=ESB Channel
ESBProviders101_AddJCAProvider_0.WindowTitle=Add JCA Provider
ESBProviders101_AddJCAProvider_0.Title=ESB JCA Provider
ESBProviders101_AddJCAProvider_1.WindowTitle=Add JCA Provider
-ESBProviders101_AddJCAProvider_1.Title=ESB JMS Bus
+ESBProviders101_AddJCAProvider_1.Title=ESB Channel
ESBProviders101_AddFSProvider_0.WindowTitle=Add FS Provider
ESBProviders101_AddFSProvider_0.Title=ESB FS Provider
ESBProviders101_AddFSProvider_1.WindowTitle=Add FS Provider
-ESBProviders101_AddFSProvider_1.Title=ESB FS Bus
+ESBProviders101_AddFSProvider_1.Title=ESB Channel
ESBProviders101_AddFTPProvider_0.WindowTitle=Add FTP Provider
ESBProviders101_AddFTPProvider_0.Title=ESB FTP Provider
ESBProviders101_AddFTPProvider_1.WindowTitle=Add FTP Provider
-ESBProviders101_AddFTPProvider_1.Title=ESB FTP Bus
+ESBProviders101_AddFTPProvider_1.Title=ESB Channel
ESBProviders101_AddSQLProvider_0.WindowTitle=Add SQL Provider
ESBProviders101_AddSQLProvider_0.Title=ESB SQL Provider
ESBProviders101_AddSQLProvider_1.WindowTitle=Add SQL Provider
-ESBProviders101_AddSQLProvider_1.Title=ESB SQL Bus
+ESBProviders101_AddSQLProvider_1.Title=ESB Channel
ESBProviders101_AddHibernateProvider_0.WindowTitle=Add Hibernate Provider
ESBProviders101_AddHibernateProvider_0.Title=ESB Hibernate Provider
ESBProviders101_AddHibernateProvider_1.WindowTitle=Add Hibernate Provider
-ESBProviders101_AddHibernateProvider_1.Title=ESB Hibernate Bus
+ESBProviders101_AddHibernateProvider_1.Title=ESB Channel
ESBProviders101_Properties.Title=Providers List
Modified: trunk/esb/plugins/org.jboss.tools.esb.core/resources/meta/esb.meta
===================================================================
--- trunk/esb/plugins/org.jboss.tools.esb.core/resources/meta/esb.meta 2008-11-17 14:54:18 UTC (rev 11844)
+++ trunk/esb/plugins/org.jboss.tools.esb.core/resources/meta/esb.meta 2008-11-17 15:37:15 UTC (rev 11845)
@@ -232,6 +232,24 @@
</XActionItem>
<XDependencies/>
</XModelEntity>
+ <XModelEntity name="ESBBusCreator">
+ <XChildrenEntities/>
+ <XEntityRenderer>
+ <ICONS>
+ <ICON info="main.esb.bus" type="main"/>
+ </ICONS>
+ </XEntityRenderer>
+ <XModelAttributes>
+ <XModelAttribute PROPERTIES="category=general;id=true;save=always"
+ name="id" xmlname="busid"/>
+ <XModelAttribute PROPERTIES="category=general;save=always"
+ name="port" xmlname="port">
+ <Constraint loader="%IntEL%"/>
+ </XModelAttribute>
+ </XModelAttributes>
+ <XActionItem kind="list"/>
+ <XDependencies/>
+ </XModelEntity>
<XModelEntity ImplementingClass="%ESB%"
PROPERTIES="formFactory=%Default%;formLayout=org.jboss.tools.esb.ui.editor.form.ESBXMLFormLayoutData;children=%ESBOrdered%"
XMLSUBPATH="bus-provider" name="ESBBusProvider101">
@@ -1596,23 +1614,23 @@
<XActionItem ICON="action.empty" displayName="New" group="1"
kind="list" name="CreateActions">
<XActionItem HandlerClassName="%SpecialWizard%" ICON="action.empty"
- PROPERTIES="validator.add=true;support=org.jboss.tools.esb.core.model.handlers.AddProviderSupport"
+ PROPERTIES="validator.add=true;support=org.jboss.tools.esb.core.model.handlers.AddProviderSupport;busEntity=ESBBus"
displayName="Bus Provider..." kind="action" name="AddBusProvider">
<EntityData EntityName="ESBBusProvider101">
<AttributeData AttributeName="name"/>
</EntityData>
- <EntityData EntityName="ESBBus">
+ <EntityData EntityName="ESBBusCreator">
<AttributeData AttributeName="id"/>
</EntityData>
</XActionItem>
<XActionItem HandlerClassName="%SpecialWizard%" ICON="action.empty"
- PROPERTIES="validator.add=true;support=org.jboss.tools.esb.core.model.handlers.AddProviderSupport"
+ PROPERTIES="validator.add=true;support=org.jboss.tools.esb.core.model.handlers.AddProviderSupport;busEntity=ESBJBRBus101"
displayName="JBR Provider..." kind="action" name="AddJBRProvider">
<EntityData EntityName="ESBJBRProvider101">
<AttributeData AttributeName="name"/>
<AttributeData AttributeName="protocol"/>
</EntityData>
- <EntityData EntityName="ESBJBRBus101">
+ <EntityData EntityName="ESBBusCreator">
<AttributeData AttributeName="id"/>
<AttributeData AttributeName="port"/>
</EntityData>
@@ -1625,66 +1643,66 @@
</EntityData>
</XActionItem>
<XActionItem HandlerClassName="%SpecialWizard%" ICON="action.empty"
- PROPERTIES="validator.add=true;support=org.jboss.tools.esb.core.model.handlers.AddProviderSupport"
+ PROPERTIES="validator.add=true;support=org.jboss.tools.esb.core.model.handlers.AddProviderSupport;busEntity=ESBJMSBus101"
displayName="JMS Provider..." kind="action" name="AddJMSProvider">
<EntityData EntityName="ESBJMSProvider101">
<AttributeData AttributeName="name"/>
<AttributeData AttributeName="connection factory"/>
</EntityData>
- <EntityData EntityName="ESBJMSBus101">
+ <EntityData EntityName="ESBBusCreator">
<AttributeData AttributeName="id"/>
</EntityData>
</XActionItem>
<XActionItem HandlerClassName="%SpecialWizard%" ICON="action.empty"
- PROPERTIES="validator.add=true;support=org.jboss.tools.esb.core.model.handlers.AddProviderSupport"
+ PROPERTIES="validator.add=true;support=org.jboss.tools.esb.core.model.handlers.AddProviderSupport;busEntity=ESBJMSBus101"
displayName="JCA Provider..." kind="action" name="AddJCAProvider">
<EntityData EntityName="ESBJCAProvider101">
<AttributeData AttributeName="name"/>
<AttributeData AttributeName="connection factory"/>
</EntityData>
- <EntityData EntityName="ESBJMSBus101">
+ <EntityData EntityName="ESBBusCreator">
<AttributeData AttributeName="id"/>
</EntityData>
</XActionItem>
<XActionItem HandlerClassName="%SpecialWizard%" ICON="action.empty"
- PROPERTIES="validator.add=true;support=org.jboss.tools.esb.core.model.handlers.AddProviderSupport"
+ PROPERTIES="validator.add=true;support=org.jboss.tools.esb.core.model.handlers.AddProviderSupport;busEntity=ESBFSBus101"
displayName="FS Provider..." kind="action" name="AddFSProvider">
<EntityData EntityName="ESBFSProvider101">
<AttributeData AttributeName="name"/>
</EntityData>
- <EntityData EntityName="ESBFSBus101">
+ <EntityData EntityName="ESBBusCreator">
<AttributeData AttributeName="id"/>
</EntityData>
</XActionItem>
<XActionItem HandlerClassName="%SpecialWizard%" ICON="action.empty"
- PROPERTIES="validator.add=true;support=org.jboss.tools.esb.core.model.handlers.AddProviderSupport"
+ PROPERTIES="validator.add=true;support=org.jboss.tools.esb.core.model.handlers.AddProviderSupport;busEntity=ESBFTPBus101"
displayName="FTP Provider..." kind="action" name="AddFTPProvider">
<EntityData EntityName="ESBFTPProvider101">
<AttributeData AttributeName="name"/>
<AttributeData AttributeName="hostname"/>
</EntityData>
- <EntityData EntityName="ESBFTPBus101">
+ <EntityData EntityName="ESBBusCreator">
<AttributeData AttributeName="id"/>
</EntityData>
</XActionItem>
<XActionItem HandlerClassName="%SpecialWizard%" ICON="action.empty"
- PROPERTIES="validator.add=true;support=org.jboss.tools.esb.core.model.handlers.AddProviderSupport"
+ PROPERTIES="validator.add=true;support=org.jboss.tools.esb.core.model.handlers.AddProviderSupport;busEntity=ESBSQLBus101"
displayName="SQL Provider..." kind="action" name="AddSQLProvider">
<EntityData EntityName="ESBSQLProvider101">
<AttributeData AttributeName="name"/>
</EntityData>
- <EntityData EntityName="ESBSQLBus101">
+ <EntityData EntityName="ESBBusCreator">
<AttributeData AttributeName="id"/>
</EntityData>
</XActionItem>
<XActionItem HandlerClassName="%SpecialWizard%" ICON="action.empty"
- PROPERTIES="validator.add=true;support=org.jboss.tools.esb.core.model.handlers.AddProviderSupport"
+ PROPERTIES="validator.add=true;support=org.jboss.tools.esb.core.model.handlers.AddProviderSupport;busEntity=ESBHibernateBus101"
displayName="Hibernate Provider..." kind="action" name="AddHibernateProvider">
<EntityData EntityName="ESBHibernateProvider101">
<AttributeData AttributeName="name"/>
<AttributeData AttributeName="hibernate cfg file"/>
</EntityData>
- <EntityData EntityName="ESBHibernateBus101">
+ <EntityData EntityName="ESBBusCreator">
<AttributeData AttributeName="id"/>
</EntityData>
</XActionItem>
Modified: trunk/esb/plugins/org.jboss.tools.esb.core/src/org/jboss/tools/esb/core/model/handlers/AddProviderSupport.java
===================================================================
--- trunk/esb/plugins/org.jboss.tools.esb.core/src/org/jboss/tools/esb/core/model/handlers/AddProviderSupport.java 2008-11-17 14:54:18 UTC (rev 11844)
+++ trunk/esb/plugins/org.jboss.tools.esb.core/src/org/jboss/tools/esb/core/model/handlers/AddProviderSupport.java 2008-11-17 15:37:15 UTC (rev 11845)
@@ -17,6 +17,9 @@
protected void reset() {
providerEntity = getEntityData()[0].getModelEntity().getName();
busEntity = getEntityData()[1].getModelEntity().getName();
+ if("ESBBusCreator".equals(busEntity)) {
+ busEntity = action.getProperty("busEntity");
+ }
}
public String[] getActionNames(int stepId) {
17 years, 5 months
JBoss Tools SVN: r11844 - in trunk/documentation/jbosstools-docbook-xslt/src/main/resources/xslt: org/jboss/tools and 1 other directory.
by jbosstools-commits@lists.jboss.org
Author: smukhina
Date: 2008-11-17 09:54:18 -0500 (Mon, 17 Nov 2008)
New Revision: 11844
Modified:
trunk/documentation/jbosstools-docbook-xslt/src/main/resources/xslt/com/jboss/tools/xhtml.xsl
trunk/documentation/jbosstools-docbook-xslt/src/main/resources/xslt/org/jboss/tools/xhtml.xsl
Log:
RF-4644
Possibility to comment each particular page of html docs online, special form is implemented
Modified: trunk/documentation/jbosstools-docbook-xslt/src/main/resources/xslt/com/jboss/tools/xhtml.xsl
===================================================================
--- trunk/documentation/jbosstools-docbook-xslt/src/main/resources/xslt/com/jboss/tools/xhtml.xsl 2008-11-17 14:54:08 UTC (rev 11843)
+++ trunk/documentation/jbosstools-docbook-xslt/src/main/resources/xslt/com/jboss/tools/xhtml.xsl 2008-11-17 14:54:18 UTC (rev 11844)
@@ -34,6 +34,7 @@
<div id="overlay">
<xsl:text> </xsl:text>
</div>
+
<!-- FEEDBACK -->
@@ -49,20 +50,20 @@
<form id="feedback-mailform">
<div class="feedback-textbox-div">
- Subject:<input type="text" id="subject" title="Enter the subject of your message" class="feedback-textbox" />
+ Subject:<input type="text" id="subject" name="subject" title="Enter the subject of your message" class="feedback-textbox" />
</div>
<div class="feedback-textbox-div">
<span style="vertical-align: top;">Message:</span>
- <textarea name="message" title="Type here the text of your message" id="feedback-message"><xsl:text> </xsl:text></textarea>
+ <textarea name="message" title="Type here the text of your message" id="message"><xsl:text> </xsl:text></textarea>
</div>
<div class="feedback-textbox-div">
- Your name:<input type="text" id="name" title="Enter your name" class="feedback-textbox" />
+ Your name:<input type="text" id="name" name="name" title="Enter your name" class="feedback-textbox" />
</div>
<div class="feedback-textbox-div">
- Your email:<input type="text" id="email" title="Enter your email address" class="feedback-textbox" />
+ Your email:<input type="text" id="email" name="email" title="Enter your email address" class="feedback-textbox" />
</div>
<span class="feedback-button-container">
- <input type="submit" value="Send Message" class="feedback-formbutton" title="Send Message" />
+ <input type="submit" value="Send Message" name="submit" class="feedback-formbutton" title="Send Message" />
</span>
<span class="feedback-button-container">
<input type="reset" value="Clear All Fields" class="feedback-formbutton" title="Clear All Fields" />
@@ -78,6 +79,7 @@
<!-- FEEDBACK ENDS -->
+
<p xmlns="http://www.w3.org/1999/xhtml">
<xsl:attribute name="id">
<xsl:text>title</xsl:text>
Modified: trunk/documentation/jbosstools-docbook-xslt/src/main/resources/xslt/org/jboss/tools/xhtml.xsl
===================================================================
--- trunk/documentation/jbosstools-docbook-xslt/src/main/resources/xslt/org/jboss/tools/xhtml.xsl 2008-11-17 14:54:08 UTC (rev 11843)
+++ trunk/documentation/jbosstools-docbook-xslt/src/main/resources/xslt/org/jboss/tools/xhtml.xsl 2008-11-17 14:54:18 UTC (rev 11844)
@@ -33,6 +33,8 @@
<div id="overlay">
<xsl:text> </xsl:text>
</div>
+
+
<!-- FEEDBACK -->
@@ -48,20 +50,20 @@
<form id="feedback-mailform">
<div class="feedback-textbox-div">
- Subject:<input type="text" id="subject" title="Enter the subject of your message" class="feedback-textbox" />
+ Subject:<input type="text" id="subject" name="subject" title="Enter the subject of your message" class="feedback-textbox" />
</div>
<div class="feedback-textbox-div">
<span style="vertical-align: top;">Message:</span>
- <textarea name="message" title="Type here the text of your message" id="feedback-message"><xsl:text> </xsl:text></textarea>
+ <textarea name="message" title="Type here the text of your message" id="message"><xsl:text> </xsl:text></textarea>
</div>
<div class="feedback-textbox-div">
- Your name:<input type="text" id="name" title="Enter your name" class="feedback-textbox" />
+ Your name:<input type="text" id="name" name="name" title="Enter your name" class="feedback-textbox" />
</div>
<div class="feedback-textbox-div">
- Your email:<input type="text" id="email" title="Enter your email address" class="feedback-textbox" />
+ Your email:<input type="text" id="email" name="email" title="Enter your email address" class="feedback-textbox" />
</div>
<span class="feedback-button-container">
- <input type="submit" value="Send Message" class="feedback-formbutton" title="Send Message" />
+ <input type="submit" value="Send Message" name="submit" class="feedback-formbutton" title="Send Message" />
</span>
<span class="feedback-button-container">
<input type="reset" value="Clear All Fields" class="feedback-formbutton" title="Clear All Fields" />
17 years, 5 months
JBoss Tools SVN: r11843 - in trunk/documentation/jbosstools-jdocbook-style/src/main: com/css/images and 7 other directories.
by jbosstools-commits@lists.jboss.org
Author: smukhina
Date: 2008-11-17 09:54:08 -0500 (Mon, 17 Nov 2008)
New Revision: 11843
Added:
trunk/documentation/jbosstools-jdocbook-style/src/main/com/css/images/favicon0.ico
trunk/documentation/jbosstools-jdocbook-style/src/main/com/css/script/swift_lib/
trunk/documentation/jbosstools-jdocbook-style/src/main/com/css/script/swift_lib/EasySwift.php
trunk/documentation/jbosstools-jdocbook-style/src/main/com/css/script/swift_lib/Swift.php
trunk/documentation/jbosstools-jdocbook-style/src/main/com/css/script/swift_lib/Swift/
trunk/documentation/jbosstools-jdocbook-style/src/main/com/css/script/swift_lib/Swift/Address.php
trunk/documentation/jbosstools-jdocbook-style/src/main/com/css/script/swift_lib/Swift/AddressContainer.php
trunk/documentation/jbosstools-jdocbook-style/src/main/com/css/script/swift_lib/Swift/Authenticator.php
trunk/documentation/jbosstools-jdocbook-style/src/main/com/css/script/swift_lib/Swift/Authenticator/
trunk/documentation/jbosstools-jdocbook-style/src/main/com/css/script/swift_lib/Swift/Authenticator/(a)PopB4Smtp.php
trunk/documentation/jbosstools-jdocbook-style/src/main/com/css/script/swift_lib/Swift/Authenticator/CRAMMD5.php
trunk/documentation/jbosstools-jdocbook-style/src/main/com/css/script/swift_lib/Swift/Authenticator/LOGIN.php
trunk/documentation/jbosstools-jdocbook-style/src/main/com/css/script/swift_lib/Swift/Authenticator/PLAIN.php
trunk/documentation/jbosstools-jdocbook-style/src/main/com/css/script/swift_lib/Swift/Authenticator/PopB4Smtp/
trunk/documentation/jbosstools-jdocbook-style/src/main/com/css/script/swift_lib/Swift/Authenticator/PopB4Smtp/Pop3Connection.php
trunk/documentation/jbosstools-jdocbook-style/src/main/com/css/script/swift_lib/Swift/BadResponseException.php
trunk/documentation/jbosstools-jdocbook-style/src/main/com/css/script/swift_lib/Swift/BatchMailer.php
Modified:
trunk/documentation/jbosstools-jdocbook-style/src/main/com/css/css/tools.css
trunk/documentation/jbosstools-jdocbook-style/src/main/com/css/script/send_mail.php
trunk/documentation/jbosstools-jdocbook-style/src/main/com/css/script/toggle.js
trunk/documentation/jbosstools-jdocbook-style/src/main/org/css/css/tools.css
trunk/documentation/jbosstools-jdocbook-style/src/main/org/css/script/send_mail.php
trunk/documentation/jbosstools-jdocbook-style/src/main/org/css/script/toggle.js
Log:
https://jira.jboss.org/jira/browse/RF-4644
Possibility to comment each particular page of html docs online, special form is implemented
Modified: trunk/documentation/jbosstools-jdocbook-style/src/main/com/css/css/tools.css
===================================================================
--- trunk/documentation/jbosstools-jdocbook-style/src/main/com/css/css/tools.css 2008-11-17 13:47:28 UTC (rev 11842)
+++ trunk/documentation/jbosstools-jdocbook-style/src/main/com/css/css/tools.css 2008-11-17 14:54:08 UTC (rev 11843)
@@ -121,8 +121,6 @@
display:block;
}
-
-
/* Feedback styles */
* html div#feedback-wrapper {position: absolute;
@@ -182,7 +180,7 @@
#feedback-state{
font-weight: bold;
height: 20px;
- width: 100%;
+ width: 508px;
line-height: 20px;
overflow: hidden;
}
@@ -217,7 +215,7 @@
color: #415973;
}
-#feedback-message{
+#message{
width: 200px;
height: 150px;
padding: 2px;
@@ -229,7 +227,7 @@
color: #415973;
}
-.feedback-textbox, #feedback-message{
+.feedback-textbox, #message{
background-color:#FFFFFF;
border:1px solid #A5ACB2;
padding:2px 1px 3px 5px;
Added: trunk/documentation/jbosstools-jdocbook-style/src/main/com/css/images/favicon0.ico
===================================================================
(Binary files differ)
Property changes on: trunk/documentation/jbosstools-jdocbook-style/src/main/com/css/images/favicon0.ico
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Modified: trunk/documentation/jbosstools-jdocbook-style/src/main/com/css/script/send_mail.php
===================================================================
--- trunk/documentation/jbosstools-jdocbook-style/src/main/com/css/script/send_mail.php 2008-11-17 13:47:28 UTC (rev 11842)
+++ trunk/documentation/jbosstools-jdocbook-style/src/main/com/css/script/send_mail.php 2008-11-17 14:54:08 UTC (rev 11843)
@@ -6,58 +6,73 @@
$message_not_sent = "Error sending message!";
$message_success = "Message is sent successfully";
-//define pattern
+//get $_REQUEST Array
+$_REQUEST = array_map('trim', $_REQUEST);
+$email = $_REQUEST['email'];
+$name= $_REQUEST['name'];
+$subject = $_REQUEST['subject'];
+$message = $_REQUEST['message'];
+$path = $_REQUEST['path'];
+//define patterns
$email_pat = "/^([A-z0-9|.|-|_]{2,256})(a)(([A-z0-9|.|-]{2,256}).([a-z]{2,4}))*$/";
$general_pat = "/^(\s)+$/";
-// clean up POST data
-$_POST = array_map('trim', $_POST);
-
+
// check if 'subject' field has been filled or not
-if(!$_POST['subject']){
- $subject="(no subject)";
+if(!$subject){
+ $subject="(no subject)";
}else{
- $subject = substr($POST['subject'], 0, 255);
- echo $subject;
+ $subject = substr(htmlentities($subject), 0, 255);
}
// check if 'name' field has been filled or not
-if(!$_POST['name']){
+if(!$name){
$name="(no name)";
}else{
- $name = substr($POST['name'], 0, 255);
+ $name = substr(htmlentities($name), 0, 255);
}
// check if 'message' field has been filled or not
-if(!$_POST['message'] || preg_match($general_pat, $_POST['message'])){
+if(!$message || preg_match($general_pat, $message)){
echo $message_error;
exit();
}else{
- $message = substr($_POST['message'], 0, 3000);
+ $message = "Feedback from ".$path."\n"."Message: ".substr(htmlentities($message), 0, 3000);
}
// check if 'email' field has been filled or not
-if(!$_POST['email']){
+if(!preg_match($email_pat, $email)){
echo $email_error;
exit();
-}elseif(!preg_match($email_pat, $_POST['email'])){
-echo $email_error;
- exit();
-}else{
- $email = substr($POST['email'], 0, 255);
}
-// get neccessary fields
-$to='smukhina(a)exadel.com';
-
// define MIME headers
$headers="MIME-Version 1.0"."\r\n"."Content-Type: text/plain; charset=utf-8"."\r\n"."From: \"".$name."\" "."<".$email.">"."Reply-to: \"".$name."\" "."<".$email.">";
-// send email
-if(!@mail($to, $subject, $message, $headers)){
- echo $message_not_sent;
- exit();
-}else{
- echo $message_success;
- exit();
+ //Load in the files we'll need
+require_once "swift_lib/Swift.php";
+require_once "swift_lib/Swift/Connection/SMTP.php";
+require_once "swift_lib/Swift/Connection/Sendmail.php";
+try{
+//Start Swift
+$sendmail =& new Swift_Connection_Sendmail();
+$sendmail->setTimeout(3); //3 seconds
+
+//$swift =& new Swift(new Swift_Connection_SMTP("localhost"));
+
+$swift =& new Swift($sendmail);
+$sender =& new Swift_Address($email, $name);
+$me =& new Swift_Address("smukhina(a)exadel.com");
+$body =& new Swift_Message($subject, $message);
+ if($swift->send($body, $me, $sender)){
+ echo $message_success;
+ exit();
+ }else{
+ echo $message_not_sent;
+ exit();
+ }
+}catch (Swift_ConnectionException $e) {
+ echo "There was a problem communicating with SMTP: " . $e->getMessage();
+} catch (Swift_Message_MimeException $e) {
+ echo "There was an unexpected problem building the email:" . $e->getMessage();
}
?>
\ No newline at end of file
Added: trunk/documentation/jbosstools-jdocbook-style/src/main/com/css/script/swift_lib/EasySwift.php
===================================================================
--- trunk/documentation/jbosstools-jdocbook-style/src/main/com/css/script/swift_lib/EasySwift.php (rev 0)
+++ trunk/documentation/jbosstools-jdocbook-style/src/main/com/css/script/swift_lib/EasySwift.php 2008-11-17 14:54:08 UTC (rev 11843)
@@ -0,0 +1,949 @@
+<?php
+
+/**
+ * EasySwift: Swift Mailer Facade
+ * Please read the LICENSE file
+ * @author Chris Corbyn <chris(a)w3style.co.uk>
+ * @package EasySwift
+ * @version 1.0.3
+ * @license GNU Lesser General Public License
+ */
+
+require_once dirname(__FILE__) . "/Swift/ClassLoader.php";
+Swift_ClassLoader::load("Swift");
+Swift_ClassLoader::load("Swift_Connection_SMTP");
+Swift_ClassLoader::load("Swift_Connection_Sendmail");
+
+//Some constants for backwards compatibility with v2 code
+if (!defined("SWIFT_TLS")) define("SWIFT_TLS", Swift_Connection_SMTP::ENC_TLS);
+if (!defined("SWIFT_SSL")) define("SWIFT_SSL", Swift_Connection_SMTP::ENC_SSL);
+if (!defined("SWIFT_OPEN")) define("SWIFT_OPEN", Swift_Connection_SMTP::ENC_OFF);
+if (!defined("SWIFT_SECURE_PORT")) define("SWIFT_SECURE_PORT", Swift_Connection_SMTP::PORT_SECURE);
+if (!defined("SWIFT_DEFAULT_PORT")) define("SWIFT_DEFAULT_PORT", Swift_Connection_SMTP::PORT_DEFAULT);
+
+/**
+ * EasySwift: Facade for Swift Mailer Version 3.
+ * Provides (most of) the API from older versions of Swift, wrapped around the new version 3 API.
+ * Due to the popularity of the new API, EasySwift will not be around indefinitely.
+ * @package EasySwift
+ * @author Chris Corbyn <chris(a)w3style.co.uk>
+ * @deprecated
+ */
+class EasySwift
+{
+ /**
+ * The instance of Swift this class wrappers
+ * @var Swift
+ */
+ public $swift = null;
+ /**
+ * This value becomes set to true when Swift fails
+ * @var boolean
+ */
+ public $failed = false;
+ /**
+ * The number of loaded plugins
+ * @var int
+ */
+ protected $pluginCount = 0;
+ /**
+ * An instance of Swift_Message
+ * @var Swift_Message
+ */
+ public $message = null;
+ /**
+ * An address list to send to (Cc, Bcc, To..)
+ * @var Swift_RecipientList
+ */
+ public $recipients = null;
+ /**
+ * If all recipients should get the same copy of the message, including headers
+ * This is already implied if any Cc or Bcc recipients are set
+ * @var boolean
+ */
+ protected $exactCopy = false;
+ /**
+ * If EasySwift should get rid of the message and recipients once it's done sending
+ * @var boolean
+ */
+ protected $autoFlush = true;
+ /**
+ * A list of the IDs of all parts added to the message
+ * @var array
+ */
+ protected $partIds = array();
+ /**
+ * A list of all the IDs of the attachments add to the message
+ * @var array
+ */
+ protected $attachmentIds = array();
+ /**
+ * The last response received from the server
+ * @var string
+ */
+ public $lastResponse = "";
+ /**
+ * The 3 digit code in the last response received from the server
+ * @var int
+ */
+ public $responseCode = 0;
+ /**
+ * The list of errors handled at runtime
+ * @var array
+ */
+ public $errors = array();
+ /**
+ * The last error received
+ * @var string
+ */
+ public $lastError = null;
+
+ /**
+ * Constructor
+ * @param Swift_Connection The connection to use
+ * @param string The domain name of this server (not the SMTP server)
+ */
+ public function __construct(Swift_Connection $connection, $domain=null)
+ {
+ try {
+ $this->swift = new Swift($connection, $domain, Swift::ENABLE_LOGGING);
+ Swift_ClassLoader::load("Swift_Plugin_EasySwiftResponseTracker");
+ $this->swift->attachPlugin(new Swift_Plugin_EasySwiftResponseTracker($this), "_ResponseTracker");
+ } catch (Swift_ConnectionException $e) {
+ $this->failed = true;
+ $this->setError("The connection failed to start. An exception was thrown:<br />" . $e->getMessage());
+ }
+ $this->newMessage();
+ $this->newRecipientList();
+ }
+ /**
+ * Set an error message
+ * @param string Error message
+ */
+ public function setError($msg)
+ {
+ $this->errors[] = ($this->lastError = $msg);
+ }
+ /**
+ * Get the full list of errors
+ * @return array
+ */
+ public function getErrors()
+ {
+ return $this->errors;
+ }
+ /**
+ * Get the last error that occured
+ * @return string
+ */
+ public function getLastError()
+ {
+ return $this->lastError;
+ }
+ /**
+ * Clear the current list of errors
+ */
+ public function flushErrors()
+ {
+ $this->errors = null;
+ $this->errors = array();
+ }
+ /**
+ * Turn automatic flsuhing on or off.
+ * This in ON by deault. It removes the message and all parts after sending.
+ * @param boolean
+ */
+ public function autoFlush($flush=true)
+ {
+ $this->autoFlush = $flush;
+ }
+ /**
+ * Set the maximum size of the log
+ * @param int
+ */
+ public function setMaxLogSize($size)
+ {
+ $log = Swift_LogContainer::getLog();
+ $log->setMaxSize($size);
+ }
+ /**
+ * Turn logging on or off (saves memory)
+ * @param boolean
+ */
+ public function useLogging($use=true)
+ {
+ $log = Swift_LogContainer::getLog();
+ if ($use) $log->setLogLevel(Swift_Log::LOG_NETWORK);
+ else $log->setLogLevel(Swift_Log::LOG_NOTHING);
+ }
+ /**
+ * Enable line resizing (on 1000 by default)
+ * @param int The number of characters allowed on a line
+ */
+ public function useAutoLineResizing($size=1000)
+ {
+ $this->message->setLineWrap($size);
+ }
+ /**
+ * Dump the log contents
+ * @deprecated
+ */
+ public function getTransactions()
+ {
+ return $this->dumpLog();
+ }
+ /**
+ * Dump the contents of the log to the browser
+ * The log contains some < and > characters so you may need to view source
+ * Note that this method dumps data to the browser, it does NOT return anything.
+ */
+ public function dumpLog()
+ {
+ $log = Swift_LogContainer::getLog();
+ $log->dump();
+ }
+ /**
+ * This method should be called if you do not wish to send messages in batch mode (i.e. if all recipients should see each others' addresses)
+ * @param boolean If this mode should be used
+ */
+ public function useExactCopy($bool=true)
+ {
+ $this->exactCopy = $bool;
+ }
+ /**
+ * Reset the current message and start a fresh one
+ */
+ public function newMessage($msg=false)
+ {
+ if (!$msg) $msg = new Swift_Message();
+ $this->message = $msg;
+ $this->partIds = array();
+ $this->attachmentIds = array();
+ }
+ /**
+ * Clear out all message parts
+ * @return boolean
+ */
+ public function flushParts()
+ {
+ $success = true;
+ foreach ($this->partIds as $id)
+ {
+ try {
+ $this->message->detach($id);
+ } catch (Swift_Message_MimeException $e) {
+ $success = false;
+ $this->setError("A MIME part failed to detach due to the error:<br />" . $e->getMessage());
+ }
+ }
+ $this->partIds = array();
+ return $success;
+ }
+ /**
+ * Clear out all attachments
+ * @return boolean
+ */
+ public function flushAttachments()
+ {
+ $success = true;
+ foreach ($this->attachmentIds as $id)
+ {
+ try {
+ $this->message->detach($id);
+ } catch (Swift_Message_MimeException $e) {
+ $success = false;
+ $this->setError("An attachment failed to detach due to the error:<br />" . $e->getMessage());
+ }
+ }
+ $this->attachmentIds = array();
+ return $success;
+ }
+ /**
+ * Clear out all message headers
+ * @deprecated
+ */
+ public function flushHeaders()
+ {
+ $this->newMessage();
+ }
+ /**
+ * Reset the current list of recipients and start a new one
+ */
+ public function newRecipientList($list=false)
+ {
+ if (!$list) $list = new Swift_RecipientList();
+ $this->recipients = $list;
+ }
+ /**
+ * Check if Swift has failed or not
+ * This facade stops processing if so
+ * @return boolean
+ */
+ public function hasFailed()
+ {
+ return $this->failed;
+ }
+ /**
+ * Check if the current connection is open or not
+ * @return boolean
+ */
+ public function isConnected()
+ {
+ return (($this->swift !== null) && $this->swift->connection->isAlive());
+ }
+ /**
+ * Connect to the MTA if not already connected
+ */
+ public function connect()
+ {
+ if (!$this->isConnected())
+ {
+ try {
+ $this->swift->connect();
+ return true;
+ } catch (Swift_ConnectionException $e) {
+ $this->failed = true;
+ $this->setError("Swift failed to run the connection process:<br />" . $e->getMessage());
+ }
+ }
+ return false;
+ }
+ /**
+ * Perform the SMTP greeting process (don't do this unless you understand why you're doing it)
+ */
+ public function handshake()
+ {
+ $this->swift->handshake();
+ }
+ /**
+ * Close the connection to the MTA
+ * @return boolean
+ */
+ public function close()
+ {
+ if ($this->isConnected())
+ {
+ try {
+ $this->swift->disconnect();
+ return true;
+ } catch (Swift_ConnectionException $e) {
+ $this->setError("Disconnect failed:<br />" . $e->getMessage());
+ }
+ }
+ return false;
+ }
+ /**
+ * Send a command to Swift and get a response
+ * @param string The command to send (leave of CRLF)
+ * @return string
+ */
+ public function command($command)
+ {
+ if (substr($command, -2) == "\r\n") $command = substr($command, 0, -2);
+
+ try {
+ $rs = $this->swift->command($command);
+ return $rs->getString();
+ } catch (Swift_ConnectionException $e) {
+ $this->setError("Command failed:<br />" . $e->getMessage());
+ return false;
+ }
+ }
+ /**
+ * Add a new plugin to respond to events
+ * @param Swift_Events_Listener The plugin to load
+ * @param string The ID to identify the plugin by if needed
+ * @return string The ID of the plugin
+ */
+ public function loadPlugin(Swift_Events_Listener $plugin, $name=null)
+ {
+ $this->pluginCount++;
+ if (!$name) $name = "p" . $this->pluginCount;
+ $this->swift->attachPlugin($plugin, $name);
+ return $name;
+ }
+ /**
+ * Get a reference to the plugin identified by $name
+ * @param string the ID of the plugin
+ * @return Swift_Events_Listener
+ */
+ public function getPlugin($name)
+ {
+ try {
+ $plugin = $this->swift->getPlugin($name);
+ return $plugin;
+ } catch (Exception $e) {
+ return null;
+ }
+ }
+ /**
+ * Remove the plugin identified by $name
+ * @param string The ID of the plugin
+ * @return boolean
+ */
+ public function removePlugin($name)
+ {
+ try {
+ $this->swift->removePlugin($name);
+ return true;
+ } catch (Exception $e) {
+ return false;
+ }
+ }
+ /**
+ * Load in a new authentication mechanism for SMTP
+ * This needn't be called since Swift will locate any available in Swift/Authenticator/*.php
+ * @param Swift_Authenticator The authentication mechanism to load
+ * @throws Exception If the wrong connection is used
+ */
+ public function loadAuthenticator(Swift_Authenticator $auth)
+ {
+ if (method_exists($this->swift->connection, "attachAuthenticator"))
+ {
+ $this->swift->connection->attachAuthenticator($auth);
+ }
+ else throw new Exception("SMTP authentication cannot be used with connection class '" . get_class($this->connection) . "'. Swift_Connection_SMTP is needed");
+ }
+ /**
+ * Authenticate with SMTP authentication
+ * @param string The SMTP username
+ * @param string The SMTP password
+ * @return boolean
+ * @throws Exception If the wrong connection is used
+ */
+ public function authenticate($username, $password)
+ {
+ if (method_exists($this->swift->connection, "runAuthenticators"))
+ {
+ try {
+ $this->swift->connection->runAuthenticators($username, $password, $this->swift);
+ return true;
+ } catch (Swift_ConnectionException $e) {
+ $this->setError("Authentication failed:<br />" . $e->getMessage());
+ return false;
+ }
+ }
+ else throw new Exception("SMTP authentication cannot be used with connection class '" . get_class($this->connection) . "'. Swift_Connection_SMTP is needed");
+ }
+ /**
+ * Turn a string representation of an email address into a Swift_Address object
+ * @paramm string The email address
+ * @return Swift_Address
+ */
+ public function stringToAddress($string)
+ {
+ $name = null;
+ $address = null;
+ // Foo Bar <foo@bar>
+ // or: "Foo Bar" <foo@bar>
+ // or: <foo@bar>
+ Swift_ClassLoader::load("Swift_Message_Encoder");
+ if (preg_match("/^\\s*(\"?)(.*?)\\1 *<(" . Swift_Message_Encoder::CHEAP_ADDRESS_RE . ")>\\s*\$/", $string, $matches))
+ {
+ if (!empty($matches[2])) $name = $matches[2];
+ $address = $matches[3];
+ }
+ elseif (preg_match("/^\\s*" . Swift_Message_Encoder::CHEAP_ADDRESS_RE . "\\s*\$/", $string))
+ {
+ $address = trim($string);
+ }
+ else return false;
+
+ $swift_address = new Swift_Address($address, $name);
+ return $swift_address;
+ }
+ /**
+ * Set the encoding used in the message header
+ * The encoding can be one of Q (quoted-printable) or B (base64)
+ * @param string The encoding to use
+ */
+ public function setHeaderEncoding($mode="B")
+ {
+ switch (strtoupper($mode))
+ {
+ case "Q": case "QP": case "QUOTED-PRINTABLE":
+ $this->message->headers->setEncoding("Q");
+ break;
+ default:
+ $this->message->headers->setEncoding("B");
+ }
+ }
+ /**
+ * Set the return path address (where bounces go to)
+ * @param mixed The address as a string or Swift_Address
+ */
+ public function setReturnPath($address)
+ {
+ return $this->message->setReturnPath($address);
+ }
+ /**
+ * Request for a read recipient to be sent to the reply-to address
+ * @param boolean
+ */
+ public function requestReadReceipt($request=true)
+ {
+ //$this->message->requestReadReceipt(true);
+ }
+ /**
+ * Set the message priority
+ * This is an integer between 1 (high) and 5 (low)
+ * @param int The level of priority to use
+ */
+ public function setPriority($priority)
+ {
+ $this->message->setPriority($priority);
+ }
+ /**
+ * Get the return-path address as a string
+ * @return string
+ */
+ public function getReturnPath()
+ {
+ try {
+ return $this->message->getReturnPath();
+ } catch (Swift_Message_MimeException $e) {
+ return false;
+ }
+ }
+ /**
+ * Set the reply-to header
+ * @param mixed The address replies come to. String, or Swift_Address, or an array of either.
+ */
+ public function setReplyTo($address)
+ {
+ return $this->message->setReplyTo($address);
+ }
+ /**
+ * Get the reply-to address(es) as an array of strings
+ * @return array
+ */
+ public function getReplyTo()
+ {
+ try {
+ return $this->message->getReplyTo();
+ } catch (Swift_Message_MimeException $e) {
+ return false;
+ }
+ }
+ /**
+ * Add To: recipients to the email
+ * @param mixed To address(es)
+ * @return boolean
+ */
+ public function addTo($address)
+ {
+ return $this->addRecipients($address, "To");
+ }
+ /**
+ * Get an array of To addresses
+ * This currently returns an array of Swift_Address objects and may be simplified to an array of strings in later versions
+ * @return array
+ */
+ public function getToAddresses()
+ {
+ return $this->recipients->getTo();
+ }
+ /**
+ * Clear out all To: recipients
+ */
+ public function flushTo()
+ {
+ $this->recipients->flushTo();
+ }
+ /**
+ * Add Cc: recipients to the email
+ * @param mixed Cc address(es)
+ * @return boolean
+ */
+ public function addCc($address)
+ {
+ return $this->addRecipients($address, "Cc");
+ }
+ /**
+ * Get an array of Cc addresses
+ * This currently returns an array of Swift_Address objects and may be simplified to an array of strings in later versions
+ * @return array
+ */
+ public function getCcAddresses()
+ {
+ return $this->recipients->getCc();
+ }
+ /**
+ * Clear out all Cc: recipients
+ */
+ public function flushCc()
+ {
+ $this->recipients->flushCc();
+ }
+ /**
+ * Add Bcc: recipients to the email
+ * @param mixed Bcc address(es)
+ * @return boolean
+ */
+ public function addBcc($address)
+ {
+ return $this->addRecipients($address, "Bcc");
+ }
+ /**
+ * Get an array of Bcc addresses
+ * This currently returns an array of Swift_Address objects and may be simplified to an array of strings in later versions
+ * @return array
+ */
+ public function getBccAddresses()
+ {
+ return $this->recipients->getBcc();
+ }
+ /**
+ * Clear out all Bcc: recipients
+ */
+ public function flushBcc()
+ {
+ $this->recipients->flushBcc();
+ }
+ /**
+ * Add recipients to the email
+ * @param mixed Address(es)
+ * @param string Recipient type (To, Cc, Bcc)
+ * @return boolean
+ */
+ protected function addRecipients($address, $type)
+ {
+ if (!in_array($type, array("To", "Cc", "Bcc"))) return false;
+ $method = "add" . $type;
+
+ if ($address instanceof Swift_Address)
+ {
+ $this->recipients->$method($address);
+ return true;
+ }
+ else
+ {
+ $added = 0;
+ foreach ((array)$address as $addr)
+ {
+ if (is_array($addr))
+ {
+ $addr = array_values($addr);
+ if (count($addr) >= 2)
+ {
+ $this->recipients->$method($addr[0], $addr[1]);
+ $added++;
+ continue;
+ }
+ elseif (count($addr) == 1) $addr = $addr[0];
+ else continue;
+ }
+
+ if (is_string($addr))
+ {
+ $addr = $this->stringToAddress($addr);
+ $this->recipients->$method($addr);
+ $added++;
+ }
+ }
+ return ($added > 0);
+ }
+ }
+ /**
+ * Flush message, recipients and headers
+ */
+ public function flush()
+ {
+ $this->newMessage();
+ $this->newRecipientList();
+ }
+ /**
+ * Get a list of any addresses which have failed since instantiation
+ * @return array
+ */
+ public function getFailedRecipients()
+ {
+ $log = Swift_LogContainer::getLog();
+ return $log->getFailedRecipients();
+ }
+ /**
+ * Set the multipart MIME warning message (only seen by old clients)
+ * @param string The message to show
+ */
+ public function setMimeWarning($text)
+ {
+ $this->message->setMimeWarning($text);
+ }
+ /**
+ * Get the currently set MIME warning (seen by old clients)
+ * @return string
+ */
+ public function getMimeWarning()
+ {
+ return $this->message->getMimeWarning();
+ }
+ /**
+ * Set the charset of the charset to use in the message
+ * @param string The charset (e.g. utf-8, iso-8859-1 etc)
+ * @return boolean
+ */
+ public function setCharset($charset)
+ {
+ try {
+ $this->message->setCharset($charset);
+ return true;
+ } catch (Swift_Message_MimeException $e) {
+ $this->setError("Unable to set the message charset:<br />" . $e->getMessage());
+ return false;
+ }
+ }
+ /**
+ * Get the charset of the charset to use in the message
+ * @return string
+ */
+ public function getCharset()
+ {
+ return $this->message->getCharset();
+ }
+ /**
+ * Add a new MIME part to the message
+ * @param mixed The part to add. If this is a string it's used as the body. If it's an instance of Swift_Message_Part it's used as the entire part
+ * @param string Content-type, default text/plain
+ * @param string The encoding used (default is to let Swift decide)
+ * @param string The charset to use (default is to let swift decide)
+ */
+ public function addPart($body, $type="text/plain", $encoding=null, $charset=null)
+ {
+ if ($body instanceof Swift_Message_Mime)
+ {
+ try {
+ $this->partIds[] = $this->message->attach($body);
+ } catch (Swift_Message_MimeException $e) {
+ $this->setError("A MIME part failed to attach:<br />" . $e->getMessage());
+ return false;
+ }
+ }
+ else
+ {
+ try {
+ $this->partIds[] = $this->message->attach(new Swift_Message_Part($body, $type, $encoding, $charset));
+ } catch (Swift_Message_MimeException $e) {
+ $this->setError("A MIME part failed to attach:<br />" . $e->getMessage());
+ return false;
+ }
+ }
+ }
+ /**
+ * Add a new attachment to the message
+ * @param mixed The attachment to add. If this is a string it's used as the file contents. If it's an instance of Swift_Message_Attachment it's used as the entire part. If it's an instance of Swift_File it's used as the contents.
+ * @param string Filename, optional
+ * @param string Content-type. Default application/octet-stream
+ * @param string The encoding used (default is base64)
+ * @return boolean
+ */
+ public function addAttachment($data, $filename=null, $type="application/octet-stream", $encoding=null)
+ {
+ if ($data instanceof Swift_Message_Mime)
+ {
+ try {
+ $this->attachmentIds[] = $this->message->attach($data);
+ } catch (Swift_Message_MimeException $e) {
+ $this->setError("An attachment failed to attach:<br />" . $e->getMessage());
+ return false;
+ }
+ }
+ else
+ {
+ try {
+ $this->attachmentIds[] = $this->message->attach(new Swift_Message_Attachment($data, $filename, $type, $encoding));
+ } catch (Swift_Message_MimeException $e) {
+ $this->setError("An attachment failed to attach<br />" . $e->getMessage());
+ return false;
+ } catch (Swift_FileException $e) {
+ $this->setError("An attachment failed to attach:<br />" . $e->getMessage());
+ return false;
+ }
+ }
+ return true;
+ }
+ /**
+ * Embed an image into the message and get the src attribute for HTML
+ * Returns FALSE on failure
+ * @param mixed The path to the image, a Swift_Message_Image object or a Swift_File object
+ * @return string
+ */
+ public function addImage($input)
+ {
+ $ret = false;
+ if ($input instanceof Swift_Message_Image)
+ {
+ $ret = $this->message->attach($input);
+ $this->attachmentIds[] = $ret;
+ return $ret;
+ }
+ elseif ($input instanceof Swift_File)
+ {
+ try {
+ $ret = $this->message->attach(new Swift_Message_Image($input));
+ $this->attachmentIds[] = $ret;
+ return $ret;
+ } catch (Swift_Message_MimeException $e) {
+ $this->setError("An attachment failed to attach:<br />" . $e->getMessage());
+ return false;
+ } catch (Swift_FileException $e) {
+ $this->setError("An attachment failed to attach:<br />" . $e->getMessage());
+ return false;
+ }
+ }
+ else
+ {
+ try {
+ $ret = $this->message->attach(new Swift_Message_Image(new Swift_File($input)));
+ $this->attachmentIds[] = $ret;
+ return $ret;
+ } catch (Swift_Message_MimeException $e) {
+ $this->setError("An attachment failed to attach:<br />" . $e->getMessage());
+ return false;
+ } catch (Swift_FileException $e) {
+ $this->setError("An attachment failed to attach:<br />" . $e->getMessage());
+ return false;
+ }
+ }
+ }
+ /**
+ * Embed an inline file into the message, such as a Image or MIDI file
+ * @param mixed The file contents, Swift_File object or Swift_Message_EmbeddedFile object
+ * @param string The content-type of the file, optional
+ * @param string The filename to use, optional
+ * @param string the Content-ID to use, optional
+ * @return string
+ */
+ public function embedFile($data, $type="application/octet-stream", $filename=null, $cid=null)
+ {
+ $ret = false;
+ if ($data instanceof Swift_Message_EmbeddedFile)
+ {
+ $ret = $this->message->attach($data);
+ $this->attachmentIds[] = $ret;
+ return $ret;
+ }
+ elseif ($data instanceof Swift_File)
+ {
+ try {
+ $ret = $this->message->attach(new Swift_Message_EmbeddedFile($data, $filename, $type, $cid));
+ $this->attachmentIds[] = $ret;
+ return $ret;
+ } catch (Swift_Message_MimeException $e) {
+ $this->setError("An attachment failed to attach:<br />" . $e->getMessage());
+ return false;
+ } catch (Swift_FileException $e) {
+ $this->setError("An attachment failed to attach:<br />" . $e->getMessage());
+ return false;
+ }
+ }
+ else
+ {
+ try {
+ $ret = $this->message->attach(new Swift_Message_EmbeddedFile($data, $filename, $type, $cid));
+ $this->attachmentIds[] = $ret;
+ return $ret;
+ } catch (Swift_Message_MimeException $e) {
+ $this->setError("An attachment failed to attach:<br />" . $e->getMessage());
+ return false;
+ } catch (Swift_FileException $e) {
+ $this->setError("An attachment failed to attach:<br />" . $e->getMessage());
+ return false;
+ }
+ }
+ }
+ /**
+ * Add headers to the message
+ * @param string The message headers to append, separated by CRLF
+ * @deprecated
+ */
+ public function addHeaders($string)
+ {
+ //Split at the line ending only if it's not followed by LWSP (as in, a full header)
+ $headers = preg_split("~\r?\n(?![ \t])~", $string);
+ foreach ($headers as $header)
+ {
+ if (empty($header)) continue;
+ //Get the bit before the colon
+ $header_name = substr($header, 0, ($c_pos = strpos($header, ": ")));
+ // ... and trim it away
+ $header = substr($header, $c_pos+2);
+ //Try splitting at "; " for attributes
+ $attribute_pairs = preg_split("~\\s*;\\s+~", $header);
+ //The value would always be right after the colon
+ $header_value = $attribute_pairs[0];
+ $this->message->headers->set($header_name, $header_value);
+ unset($attribute_pairs[0]);
+ foreach ($attribute_pairs as $pair)
+ {
+ //Now try finding the attribute name, and it's value (removing quotes)
+ if (preg_match("~^(.*?)=(\"?)(.*?)\\2\\s*\$~", $pair, $matches))
+ {
+ try {
+ $this->message->headers->setAttribute($header_name, $matches[1], $matches[3]);
+ } catch (Swift_Message_MimeException $e) {
+ $this->setError("There was a problem parsing or setting a header attribute:<br />" . $e->getMessage());
+ //Ignored... it's EasySwift... C'mon ;)
+ }
+ }
+ }
+ }
+ }
+ /**
+ * Set a header in the message
+ * @param string The name of the header
+ * @param string The value of the header (without attributes)
+ * @see {addHeaderAttribute}
+ */
+ public function setHeader($name, $value)
+ {
+ $this->message->headers->set($name, $value);
+ }
+ /**
+ * Set an attribute in the message headers
+ * For example charset in Content-Type: text/html; charset=utf-8 set by $swift->setHeaderAttribute("Content-Type", "charset", "utf-8")
+ * @param string The name of the header
+ * @param string The name of the attribute
+ * @param string The value of the attribute
+ */
+ public function setHeaderAttribute($name, $attribute, $value)
+ {
+ if ($this->message->headers->has($name))
+ $this->message->headers->setAttribute($name, $attribute, $value);
+ }
+ /**
+ * Send an email to a number of recipients
+ * Returns the number of successful recipients, or FALSE on failure
+ * @param mixed The recipients to send to. One of string, array, 2-dimensional array or Swift_Address
+ * @param mixed The address to send from. string or Swift_Address
+ * @param string The message subject
+ * @param string The message body, optional
+ * @return int
+ */
+ public function send($recipients, $from, $subject, $body=null)
+ {
+ $this->addTo($recipients);
+
+ $sender = false;
+ if (is_string($from)) $sender = $this->stringToAddress($from);
+ elseif ($from instanceof Swift_Address) $sender = $from;
+ if (!$sender) return false;
+
+ $this->message->setSubject($subject);
+ if ($body) $this->message->setBody($body);
+ try {
+ if (!$this->exactCopy && !$this->recipients->getCc() && !$this->recipients->getBcc())
+ {
+ $sent = $this->swift->batchSend($this->message, $this->recipients, $sender);
+ }
+ else
+ {
+ $sent = $this->swift->send($this->message, $this->recipients, $sender);
+ }
+ if ($this->autoFlush) $this->flush();
+ return $sent;
+ } catch (Swift_ConnectionException $e) {
+ $this->setError("Sending failed:<br />" . $e->getMessage());
+ return false;
+ }
+ }
+}
Added: trunk/documentation/jbosstools-jdocbook-style/src/main/com/css/script/swift_lib/Swift/Address.php
===================================================================
--- trunk/documentation/jbosstools-jdocbook-style/src/main/com/css/script/swift_lib/Swift/Address.php (rev 0)
+++ trunk/documentation/jbosstools-jdocbook-style/src/main/com/css/script/swift_lib/Swift/Address.php 2008-11-17 14:54:08 UTC (rev 11843)
@@ -0,0 +1,104 @@
+<?php
+
+/**
+ * Swift Mailer Address Container (purely for rigid RFC conformance)
+ * Please read the LICENSE file
+ * @copyright Chris Corbyn <chris(a)w3style.co.uk>
+ * @author Chris Corbyn <chris(a)w3style.co.uk>
+ * @package Swift
+ * @license GNU Lesser General Public License
+ */
+
+require_once dirname(__FILE__) . "/ClassLoader.php";
+Swift_ClassLoader::load("Swift_AddressContainer");
+
+/**
+ * Swift_Address is just a lone e-mail address reprsented as an object
+ * @package Swift
+ * @author Chris Corbyn <chris(a)w3style.co.uk>
+ */
+class Swift_Address extends Swift_AddressContainer
+{
+ /**
+ * The e-mail address portion
+ * @var string
+ */
+ protected $address = null;
+ /**
+ * The personal name part
+ * @var string
+ */
+ protected $name = null;
+
+ /**
+ * Constructor
+ * @param string The address portion
+ * @param string The personal name, optional
+ */
+ public function __construct($address, $name=null)
+ {
+ $this->setAddress($address);
+ if ($name !== null) $this->setName($name);
+ }
+ /**
+ * Set the email address
+ * @param string
+ */
+ public function setAddress($address)
+ {
+ $this->address = trim((string)$address);
+ }
+ /**
+ * Get the address portion
+ * @return string
+ */
+ public function getAddress()
+ {
+ return $this->address;
+ }
+ /**
+ * Set the personal name
+ * @param string
+ */
+ public function setName($name)
+ {
+ if ($name !== null) $this->name = (string) $name;
+ else $this->name = null;
+ }
+ /**
+ * Get personal name portion
+ * @return string
+ */
+ public function getName()
+ {
+ return $this->name;
+ }
+ /**
+ * Build the address the way it should be structured
+ * @param boolean If the string will be sent to a SMTP server as an envelope
+ * @return string
+ */
+ public function build($smtp=false)
+ {
+ if ($smtp)
+ {
+ return "<" . $this->address . ">";
+ }
+ else
+ {
+ if (($this->name !== null))
+ {
+ return $this->name . " <" . $this->address . ">";
+ }
+ else return $this->address;
+ }
+ }
+ /**
+ * PHP's casting conversion
+ * @return string
+ */
+ public function __toString()
+ {
+ return $this->build(true);
+ }
+}
Added: trunk/documentation/jbosstools-jdocbook-style/src/main/com/css/script/swift_lib/Swift/AddressContainer.php
===================================================================
--- trunk/documentation/jbosstools-jdocbook-style/src/main/com/css/script/swift_lib/Swift/AddressContainer.php (rev 0)
+++ trunk/documentation/jbosstools-jdocbook-style/src/main/com/css/script/swift_lib/Swift/AddressContainer.php 2008-11-17 14:54:08 UTC (rev 11843)
@@ -0,0 +1,8 @@
+<?php
+
+/**
+ * This is purely here for identify reasons on some subclasses
+ * @package Swift
+ * @author Chris Corbyn <chris(a)w3style.co.uk>
+ */
+abstract class Swift_AddressContainer {}
Added: trunk/documentation/jbosstools-jdocbook-style/src/main/com/css/script/swift_lib/Swift/Authenticator/(a)PopB4Smtp.php
===================================================================
--- trunk/documentation/jbosstools-jdocbook-style/src/main/com/css/script/swift_lib/Swift/Authenticator/(a)PopB4Smtp.php (rev 0)
+++ trunk/documentation/jbosstools-jdocbook-style/src/main/com/css/script/swift_lib/Swift/Authenticator/(a)PopB4Smtp.php 2008-11-17 14:54:08 UTC (rev 11843)
@@ -0,0 +1,86 @@
+<?php
+
+/**
+ * Swift Mailer PopB4Smtp Authenticator Mechanism
+ * Please read the LICENSE file
+ * @author Chris Corbyn <chris(a)w3style.co.uk>
+ * @package Swift_Authenticator
+ * @license GNU Lesser General Public License
+ */
+
+require_once dirname(__FILE__) . "/../ClassLoader.php";
+Swift_ClassLoader::load("Swift_Authenticator");
+Swift_ClassLoader::load("Swift_LogContainer");
+
+/**
+ * Swift PopB4Smtp Authenticator
+ * This form of authentication requires a quick connection to be made with a POP3 server before finally connecting to SMTP
+ * @package Swift_Authenticator
+ * @author Chris Corbyn <chris(a)w3style.co.uk>
+ */
+class Swift_Authenticator_PopB4Smtp implements Swift_Authenticator
+{
+ protected $connection = null;
+ /**
+ * Constructor
+ * @param mixed Swift_Authenticator_PopB4Smtp_Pop3Connection or string FQDN of POP3 server
+ * @param int The remote port number
+ * @param int The level of encryption to use
+ */
+ public function __construct($conn=null, $port=110, $encryption=0)
+ {
+ if (is_object($conn)) $this->connection = $conn;
+ else
+ {
+ Swift_ClassLoader::load("Swift_Authenticator_PopB4Smtp_Pop3Connection");
+ $this->connection = new Swift_Authenticator_PopB4Smtp_Pop3Connection($conn, $port, $encryption);
+ }
+ }
+ /**
+ * Try to authenticate using the username and password
+ * Returns false on failure
+ * @param string The username
+ * @param string The password
+ * @param Swift The instance of Swift this authenticator is used in
+ * @return boolean
+ */
+ public function isAuthenticated($user, $pass, Swift $swift)
+ {
+ $log = Swift_LogContainer::getLog();
+ if ($log->hasLevel(Swift_Log::LOG_EVERYTHING))
+ {
+ $log->add("Trying POP3 Before SMTP authentication. Disconnecting from SMTP first.");
+ }
+ $swift->disconnect();
+ try {
+ $this->connection->start();
+ $this->connection->assertOk($this->connection->read());
+ $this->connection->write("USER " . $user);
+ $this->connection->assertOk($this->connection->read());
+ $this->connection->write("PASS " . $pass);
+ $this->connection->assertOk($this->connection->read());
+ $this->connection->write("QUIT");
+ $this->connection->assertOk($this->connection->read());
+ $this->connection->stop();
+ } catch (Swift_ConnectionException $e) {
+ if ($log->hasLevel(Swift_Log::LOG_ERRORS))
+ {
+ $log->add("POP3 authentication failed.");
+ }
+ return false;
+ }
+ $options = $swift->getOptions();
+ $swift->setOptions($options | Swift::NO_POST_CONNECT);
+ $swift->connect();
+ $swift->setOptions($options);
+ return true;
+ }
+ /**
+ * Return the name of the AUTH extension this is for
+ * @return string
+ */
+ public function getAuthExtensionName()
+ {
+ return "*PopB4Smtp";
+ }
+}
Added: trunk/documentation/jbosstools-jdocbook-style/src/main/com/css/script/swift_lib/Swift/Authenticator/CRAMMD5.php
===================================================================
--- trunk/documentation/jbosstools-jdocbook-style/src/main/com/css/script/swift_lib/Swift/Authenticator/CRAMMD5.php (rev 0)
+++ trunk/documentation/jbosstools-jdocbook-style/src/main/com/css/script/swift_lib/Swift/Authenticator/CRAMMD5.php 2008-11-17 14:54:08 UTC (rev 11843)
@@ -0,0 +1,73 @@
+<?php
+
+/**
+ * Swift Mailer CRAM-MD5 Authenticator Mechanism
+ * Please read the LICENSE file
+ * @author Chris Corbyn <chris(a)w3style.co.uk>
+ * @package Swift_Authenticator
+ * @license GNU Lesser General Public License
+ */
+
+require_once dirname(__FILE__) . "/../ClassLoader.php";
+Swift_ClassLoader::load("Swift_Authenticator");
+
+/**
+ * Swift CRAM-MD5 Authenticator
+ * This form of authentication is a secure challenge-response method
+ * @package Swift_Authenticator
+ * @author Chris Corbyn <chris(a)w3style.co.uk>
+ */
+class Swift_Authenticator_CRAMMD5 implements Swift_Authenticator
+{
+ /**
+ * Try to authenticate using the username and password
+ * Returns false on failure
+ * @param string The username
+ * @param string The password
+ * @param Swift The instance of Swift this authenticator is used in
+ * @return boolean
+ */
+ public function isAuthenticated($user, $pass, Swift $swift)
+ {
+ try {
+ $encoded_challenge = substr($swift->command("AUTH CRAM-MD5", 334)->getString(), 4);
+ $challenge = base64_decode($encoded_challenge);
+ $response = base64_encode($user . " " . self::generateCRAMMD5Hash($pass, $challenge));
+ $swift->command($response, 235);
+ } catch (Swift_ConnectionException $e) {
+ $swift->reset();
+ return false;
+ }
+ return true;
+ }
+ /**
+ * Return the name of the AUTH extension this is for
+ * @return string
+ */
+ public function getAuthExtensionName()
+ {
+ return "CRAM-MD5";
+ }
+ /**
+ * Generate a CRAM-MD5 hash from a challenge
+ * @param string The string to get a hash from
+ * @param string The challenge to use to make the hash
+ * @return string
+ */
+ public static function generateCRAMMD5Hash($password, $challenge)
+ {
+ if (strlen($password) > 64)
+ $password = pack('H32', md5($password));
+
+ if (strlen($password) < 64)
+ $password = str_pad($password, 64, chr(0));
+
+ $k_ipad = substr($password, 0, 64) ^ str_repeat(chr(0x36), 64);
+ $k_opad = substr($password, 0, 64) ^ str_repeat(chr(0x5C), 64);
+
+ $inner = pack('H32', md5($k_ipad.$challenge));
+ $digest = md5($k_opad.$inner);
+
+ return $digest;
+ }
+}
Added: trunk/documentation/jbosstools-jdocbook-style/src/main/com/css/script/swift_lib/Swift/Authenticator/LOGIN.php
===================================================================
--- trunk/documentation/jbosstools-jdocbook-style/src/main/com/css/script/swift_lib/Swift/Authenticator/LOGIN.php (rev 0)
+++ trunk/documentation/jbosstools-jdocbook-style/src/main/com/css/script/swift_lib/Swift/Authenticator/LOGIN.php 2008-11-17 14:54:08 UTC (rev 11843)
@@ -0,0 +1,49 @@
+<?php
+
+/**
+ * Swift Mailer LOGIN Authenticator Mechanism
+ * Please read the LICENSE file
+ * @author Chris Corbyn <chris(a)w3style.co.uk>
+ * @package Swift_Authenticator
+ * @license GNU Lesser General Public License
+ */
+
+require_once dirname(__FILE__) . "/../ClassLoader.php";
+Swift_ClassLoader::load("Swift_Authenticator");
+
+/**
+ * Swift LOGIN Authenticator
+ * @package Swift_Authenticator
+ * @author Chris Corbyn <chris(a)w3style.co.uk>
+ */
+class Swift_Authenticator_LOGIN implements Swift_Authenticator
+{
+ /**
+ * Try to authenticate using the username and password
+ * Returns false on failure
+ * @param string The username
+ * @param string The password
+ * @param Swift The instance of Swift this authenticator is used in
+ * @return boolean
+ */
+ public function isAuthenticated($user, $pass, Swift $swift)
+ {
+ try {
+ $swift->command("AUTH LOGIN", 334);
+ $swift->command(base64_encode($user), 334);
+ $swift->command(base64_encode($pass), 235);
+ } catch (Swift_ConnectionException $e) {
+ $swift->reset();
+ return false;
+ }
+ return true;
+ }
+ /**
+ * Return the name of the AUTH extension this is for
+ * @return string
+ */
+ public function getAuthExtensionName()
+ {
+ return "LOGIN";
+ }
+}
Added: trunk/documentation/jbosstools-jdocbook-style/src/main/com/css/script/swift_lib/Swift/Authenticator/PLAIN.php
===================================================================
--- trunk/documentation/jbosstools-jdocbook-style/src/main/com/css/script/swift_lib/Swift/Authenticator/PLAIN.php (rev 0)
+++ trunk/documentation/jbosstools-jdocbook-style/src/main/com/css/script/swift_lib/Swift/Authenticator/PLAIN.php 2008-11-17 14:54:08 UTC (rev 11843)
@@ -0,0 +1,50 @@
+<?php
+
+/**
+ * Swift Mailer PLAIN Authenticator Mechanism
+ * Please read the LICENSE file
+ * @author Chris Corbyn <chris(a)w3style.co.uk>
+ * @package Swift_Authenticator
+ * @license GNU Lesser General Public License
+ */
+
+require_once dirname(__FILE__) . "/../ClassLoader.php";
+Swift_ClassLoader::load("Swift_Authenticator");
+
+/**
+ * Swift PLAIN Authenticator
+ * This form of authentication is unbelievably insecure since everything is done plain-text
+ * @package Swift_Authenticator
+ * @author Chris Corbyn <chris(a)w3style.co.uk>
+ */
+class Swift_Authenticator_PLAIN implements Swift_Authenticator
+{
+ /**
+ * Try to authenticate using the username and password
+ * Returns false on failure
+ * @param string The username
+ * @param string The password
+ * @param Swift The instance of Swift this authenticator is used in
+ * @return boolean
+ */
+ public function isAuthenticated($user, $pass, Swift $swift)
+ {
+ try {
+ //The authorization string uses ascii null as a separator (See RFC 2554)
+ $credentials = base64_encode($user . chr(0) . $user . chr(0) . $pass);
+ $swift->command("AUTH PLAIN " . $credentials, 235);
+ } catch (Swift_ConnectionException $e) {
+ $swift->reset();
+ return false;
+ }
+ return true;
+ }
+ /**
+ * Return the name of the AUTH extension this is for
+ * @return string
+ */
+ public function getAuthExtensionName()
+ {
+ return "PLAIN";
+ }
+}
Added: trunk/documentation/jbosstools-jdocbook-style/src/main/com/css/script/swift_lib/Swift/Authenticator/PopB4Smtp/Pop3Connection.php
===================================================================
--- trunk/documentation/jbosstools-jdocbook-style/src/main/com/css/script/swift_lib/Swift/Authenticator/PopB4Smtp/Pop3Connection.php (rev 0)
+++ trunk/documentation/jbosstools-jdocbook-style/src/main/com/css/script/swift_lib/Swift/Authenticator/PopB4Smtp/Pop3Connection.php 2008-11-17 14:54:08 UTC (rev 11843)
@@ -0,0 +1,176 @@
+<?php
+
+/**
+ * Swift Mailer PopB4Smtp Pop3 Connection component
+ * Please read the LICENSE file
+ * @author Chris Corbyn <chris(a)w3style.co.uk>
+ * @package Swift_Authenticator
+ * @license GNU Lesser General Public License
+ */
+
+require_once dirname(__FILE__) . "/../../ClassLoader.php";
+
+/**
+ * Swift PopB4Smtp Authenticator Connection Component for the POP3 server
+ * Provides a I/O wrapper for the POP3 connection
+ * @package Swift_Authenticator
+ * @author Chris Corbyn <chris(a)w3style.co.uk>
+ */
+class Swift_Authenticator_PopB4Smtp_Pop3Connection
+{
+ /**
+ * Constant for no encyption
+ */
+ const ENC_OFF = 0;
+ /**
+ * Constant for SSL encryption
+ */
+ const ENC_SSL = 1;
+ /**
+ * The server to connect to (IP or FQDN)
+ * @var string
+ */
+ protected $server = null;
+ /**
+ * The port to connect to
+ * @var int
+ */
+ protected $port = null;
+ /**
+ * The open connection resource from fsockopen()
+ * @var resource
+ */
+ protected $handle = null;
+
+ /**
+ * Constructor
+ * @param string The name of the POP3 server
+ * @param int The port for the POP3 service
+ * @param int The level of encryption to use
+ */
+ public function __construct($server="localhost", $port=110, $encryption=0)
+ {
+ $this->setServer($server);
+ $this->setPort($port);
+ $this->setEncryption($encryption);
+ }
+ /**
+ * Set the server name
+ * @param string The IP or FQDN of the POP3 server
+ */
+ public function setServer($server)
+ {
+ $this->server = (string) $server;
+ }
+ /**
+ * Set the port number for the POP3 server
+ * @param int
+ */
+ public function setPort($port)
+ {
+ $this->port = (int) $port;
+ }
+ /**
+ * Get the server name
+ * @return string
+ */
+ public function getServer()
+ {
+ return $this->server;
+ }
+ /**
+ * Get the remote port number
+ * @return int
+ */
+ public function getPort()
+ {
+ return $this->port;
+ }
+ /**
+ * Set the level of enryption to use (see ENC_OFF or ENC_SSL)
+ * @param int The constant for the encryption level
+ */
+ public function setEncryption($enc)
+ {
+ $this->encryption = (int) $enc;
+ }
+ /**
+ * Get the current encryption level set (corresponds to ENC_SSL or ENC_OFF)
+ * @return int
+ */
+ public function getEncryption()
+ {
+ return $this->encryption;
+ }
+ /**
+ * Check if the response is a +OK response
+ * @throws Swift_ConnectionException Upon bad response
+ */
+ public function assertOk($line)
+ {
+ if (substr($line, 0, 3) != "+OK")
+ {
+ Swift_ClassLoader::load("Swift_ConnectionException");
+ throw new Swift_ConnectionException("The POP3 server did not suitably respond with a +OK response. " .
+ "[" . $line . "]");
+ }
+ }
+ /**
+ * Try to open the connection
+ * @throws Swift_ConnectionException If the connection will not start
+ */
+ public function start()
+ {
+ $url = $this->getServer();
+ if ($this->getEncryption() == self::ENC_SSL) $url = "ssl://" . $url;
+
+ if ((false === $this->handle = fsockopen($url, $this->getPort(), $errno, $errstr, $timeout)))
+ {
+ Swift_ClassLoader::load("Swift_ConnectionException");
+ throw new Swift_ConnectionException("The POP3 connection failed to start. The error string returned from fsockopen() is [" . $errstr . "] #" . $errno);
+ }
+ }
+ /**
+ * Try to close the connection
+ * @throws Swift_ConnectionException If the connection won't close
+ */
+ public function stop()
+ {
+ if ($this->handle !== null)
+ {
+ if (false === fclose($this->handle))
+ {
+ Swift_ClassLoader::load("Swift_ConnectionException");
+ throw new Swift_ConnectionException("The POP3 connection did not close successfully.");
+ }
+ }
+ $this->handle = null;
+ }
+ /**
+ * Return the unread buffer contents
+ * @return string
+ * @throws Swift_ConnectionException If the connection will not allow data to be read
+ */
+ public function read()
+ {
+ if (false === $response = fgets($this->handle))
+ {
+ Swift_ClassLoader::load("Swift_ConnectionException");
+ throw new Swift_ConnectionException("Data could not be read from the POP3 connection.");
+ }
+ return trim($response);
+ }
+ /**
+ * Write a command to the remote socket
+ * @param string the command to send (without CRLF)
+ * @throws Swift_ConnectionException If the command cannot be written
+ */
+ public function write($command)
+ {
+ if (false !== fwrite($this->handle, $command . "\r\n"))
+ {
+ Swift_ClassLoader::load("Swift_ConnectionException");
+ throw new Swift_ConnectionException("Data could not be written to the POP3 connection.");
+ }
+ }
+}
Added: trunk/documentation/jbosstools-jdocbook-style/src/main/com/css/script/swift_lib/Swift/Authenticator.php
===================================================================
--- trunk/documentation/jbosstools-jdocbook-style/src/main/com/css/script/swift_lib/Swift/Authenticator.php (rev 0)
+++ trunk/documentation/jbosstools-jdocbook-style/src/main/com/css/script/swift_lib/Swift/Authenticator.php 2008-11-17 14:54:08 UTC (rev 11843)
@@ -0,0 +1,33 @@
+<?php
+
+/**
+ * Swift Mailer Authenticator Interface
+ * Please read the LICENSE file
+ * @author Chris Corbyn <chris(a)w3style.co.uk>
+ * @package Swift_Authenticator
+ * @license GNU Lesser General Public License
+ */
+
+/**
+ * Swift Authenticator Interface
+ * Lists the methods all authenticators must implement
+ * @package Swift_Authenticator
+ * @author Chris Corbyn <chris(a)w3style.co.uk>
+ */
+interface Swift_Authenticator
+{
+ /**
+ * Try to authenticate using the username and password
+ * Returns false on failure
+ * @param string The username
+ * @param string The password
+ * @param Swift The instance of Swift this authenticator is used in
+ * @return boolean
+ */
+ public function isAuthenticated($username, $password, Swift $instance);
+ /**
+ * Return the name of the AUTH extension this is for
+ * @return string
+ */
+ public function getAuthExtensionName();
+}
Added: trunk/documentation/jbosstools-jdocbook-style/src/main/com/css/script/swift_lib/Swift/BadResponseException.php
===================================================================
--- trunk/documentation/jbosstools-jdocbook-style/src/main/com/css/script/swift_lib/Swift/BadResponseException.php (rev 0)
+++ trunk/documentation/jbosstools-jdocbook-style/src/main/com/css/script/swift_lib/Swift/BadResponseException.php 2008-11-17 14:54:08 UTC (rev 11843)
@@ -0,0 +1,22 @@
+<?php
+
+/**
+ * Swift Bad Response Code Exception
+ * Please read the LICENSE file
+ * @copyright Chris Corbyn <chris(a)w3style.co.uk>
+ * @author Chris Corbyn <chris(a)w3style.co.uk>
+ * @package Swift_Connection
+ * @license GNU Lesser General Public License
+ */
+
+require_once dirname(__FILE__) . "/ClassLoader.php";
+Swift_ClassLoader::load("Swift_ConnectionException");
+
+/**
+ * Swift Bad Response Exception
+ * @package Swift_Connection
+ * @author Chris Corbyn <chris(a)w3style.co.uk>
+ */
+class Swift_BadResponseException extends Swift_ConnectionException
+{
+}
Added: trunk/documentation/jbosstools-jdocbook-style/src/main/com/css/script/swift_lib/Swift/BatchMailer.php
===================================================================
--- trunk/documentation/jbosstools-jdocbook-style/src/main/com/css/script/swift_lib/Swift/BatchMailer.php (rev 0)
+++ trunk/documentation/jbosstools-jdocbook-style/src/main/com/css/script/swift_lib/Swift/BatchMailer.php 2008-11-17 14:54:08 UTC (rev 11843)
@@ -0,0 +1,229 @@
+<?php
+
+/**
+ * Handles batch mailing with Swift Mailer with fail-safe support.
+ * Restarts the connection if it dies and then continues where it left off.
+ * Please read the LICENSE file
+ * @copyright Chris Corbyn <chris(a)w3style.co.uk>
+ * @author Chris Corbyn <chris(a)w3style.co.uk>
+ * @package Swift
+ * @license GNU Lesser General Public License
+ */
+class Swift_BatchMailer
+{
+ /**
+ * The current instance of Swift.
+ * @var Swift
+ */
+ protected $swift;
+ /**
+ * The maximum number of times a single recipient can be attempted before giving up.
+ * @var int
+ */
+ protected $maxTries = 2;
+ /**
+ * The number of seconds to sleep for if an error occurs.
+ * @var int
+ */
+ protected $sleepTime = 0;
+ /**
+ * Failed recipients (undeliverable)
+ * @var array
+ */
+ protected $failed = array();
+ /**
+ * The maximum number of successive failures before giving up.
+ * @var int
+ */
+ protected $maxFails = 0;
+ /**
+ * A temporary copy of some message headers.
+ * @var array
+ */
+ protected $headers = array();
+
+ /**
+ * Constructor.
+ * @param Swift The current instance of Swift
+ */
+ public function __construct(Swift $swift)
+ {
+ $this->setSwift($swift);
+ }
+ /**
+ * Set the current Swift instance.
+ * @param Swift The instance
+ */
+ public function setSwift(Swift $swift)
+ {
+ $this->swift = $swift;
+ }
+ /**
+ * Get the Swift instance which is running.
+ * @return Swift
+ */
+ public function getSwift()
+ {
+ return $this->swift;
+ }
+ /**
+ * Set the maximum number of times a single address is allowed to be retried.
+ * @param int The maximum number of tries.
+ */
+ public function setMaxTries($max)
+ {
+ $this->maxTries = abs($max);
+ }
+ /**
+ * Get the number of times a single address will be attempted in a batch.
+ * @return int
+ */
+ public function getMaxTries()
+ {
+ return $this->maxTries;
+ }
+ /**
+ * Set the amount of time to sleep for if an error occurs.
+ * @param int Number of seconds
+ */
+ public function setSleepTime($secs)
+ {
+ $this->sleepTime = abs($secs);
+ }
+ /**
+ * Get the amount of time to sleep for on errors.
+ * @return int
+ */
+ public function getSleepTime()
+ {
+ return $this->sleepTime;
+ }
+ /**
+ * Log a failed recipient.
+ * @param string The email address.
+ */
+ public function addFailedRecipient($address)
+ {
+ $this->failed[] = $address;
+ $this->failed = array_unique($this->failed);
+ }
+ /**
+ * Get all recipients which failed in this batch.
+ * @return array
+ */
+ public function getFailedRecipients()
+ {
+ return $this->failed;
+ }
+ /**
+ * Clear out the list of failed recipients.
+ */
+ public function flushFailedRecipients()
+ {
+ $this->failed = null;
+ $this->failed = array();
+ }
+ /**
+ * Set the maximum number of times an error can be thrown in succession and still be hidden.
+ * @param int
+ */
+ public function setMaxSuccessiveFailures($fails)
+ {
+ $this->maxFails = abs($fails);
+ }
+ /**
+ * Get the maximum number of times an error can be thrown and still be hidden.
+ * @return int
+ */
+ public function getMaxSuccessiveFailures()
+ {
+ return $this->maxFails;
+ }
+ /**
+ * Restarts Swift forcibly.
+ */
+ protected function forceRestartSwift()
+ {
+ //Pre-empting problems trying to issue "QUIT" to a dead connection
+ $this->swift->connection->stop();
+ $this->swift->connection->start();
+ $this->swift->disconnect();
+ //Restart swift
+ $this->swift->connect();
+ }
+ /**
+ * Takes a temporary copy of original message headers in case an error occurs and they need restoring.
+ * @param Swift_Message The message object
+ */
+ protected function copyMessageHeaders(&$message)
+ {
+ $this->headers["To"] = $message->headers->has("To") ?
+ $message->headers->get("To") : null;
+ $this->headers["Reply-To"] = $message->headers->has("Reply-To") ?
+ $message->headers->get("Reply-To") : null;
+ $this->headers["Return-Path"] = $message->headers->has("Return-Path") ?
+ $message->headers->get("Return-Path") : null;
+ $this->headers["From"] = $message->headers->has("From") ?
+ $message->headers->get("From") : null;
+ }
+ /**
+ * Restore message headers to original values in the event of a failure.
+ * @param Swift_Message The message
+ */
+ protected function restoreMessageHeaders(&$message)
+ {
+ foreach ($this->headers as $name => $value)
+ {
+ $message->headers->set($name, $value);
+ }
+ }
+ /**
+ * Run a batch send in a fail-safe manner.
+ * This operates as Swift::batchSend() except it deals with errors itself.
+ * @param Swift_Message To send
+ * @param Swift_RecipientList Recipients (To: only)
+ * @param Swift_Address The sender's address
+ * @return int The number sent to
+ */
+ public function send(Swift_Message $message, Swift_RecipientList $recipients, $sender)
+ {
+ $sent = 0;
+ $successive_fails = 0;
+
+ $it = $recipients->getIterator("to");
+ while ($it->hasNext())
+ {
+ $it->next();
+ $recipient = $it->getValue();
+ $tried = 0;
+ $loop = true;
+ while ($loop && $tried < $this->getMaxTries())
+ {
+ try {
+ $tried++;
+ $loop = false;
+ $this->copyMessageHeaders($message);
+ $sent += ($n = $this->swift->send($message, $recipient, $sender));
+ if (!$n) $this->addFailedRecipient($recipient->getAddress());
+ $successive_fails = 0;
+ } catch (Exception $e) {
+ $successive_fails++;
+ $this->restoreMessageHeaders($message);
+ if (($max = $this->getMaxSuccessiveFailures())
+ && $successive_fails > $max)
+ {
+ throw new Exception(
+ "Too many successive failures. BatchMailer is configured to allow no more than " . $max .
+ " successive failures.");
+ }
+ //If an exception was thrown, give it one more go
+ if ($t = $this->getSleepTime()) sleep($t);
+ $this->forceRestartSwift();
+ $loop = true;
+ }
+ }
+ }
+
+ return $sent;
+ }
+}
Added: trunk/documentation/jbosstools-jdocbook-style/src/main/com/css/script/swift_lib/Swift.php
===================================================================
--- trunk/documentation/jbosstools-jdocbook-style/src/main/com/css/script/swift_lib/Swift.php (rev 0)
+++ trunk/documentation/jbosstools-jdocbook-style/src/main/com/css/script/swift_lib/Swift.php 2008-11-17 14:54:08 UTC (rev 11843)
@@ -0,0 +1,489 @@
+<?php
+
+/**
+ * Swift Mailer Core Component.
+ * Please read the LICENSE file
+ * @copyright Chris Corbyn <chris(a)w3style.co.uk>
+ * @author Chris Corbyn <chris(a)w3style.co.uk>
+ * @package Swift
+ * @version 3.3.2
+ * @license GNU Lesser General Public License
+ */
+
+require_once dirname(__FILE__) . "/Swift/ClassLoader.php";
+Swift_ClassLoader::load("Swift_LogContainer");
+Swift_ClassLoader::load("Swift_ConnectionBase");
+Swift_ClassLoader::load("Swift_BadResponseException");
+Swift_ClassLoader::load("Swift_Cache");
+Swift_ClassLoader::load("Swift_CacheFactory");
+Swift_ClassLoader::load("Swift_Message");
+Swift_ClassLoader::load("Swift_RecipientList");
+Swift_ClassLoader::load("Swift_BatchMailer");
+Swift_ClassLoader::load("Swift_Events");
+Swift_ClassLoader::load("Swift_Events_Listener");
+
+/**
+ * Swift is the central component in the Swift library.
+ * @package Swift
+ * @author Chris Corbyn <chris(a)w3style.co.uk>
+ * @version 3.3.2
+ */
+class Swift
+{
+ /**
+ * The version number.
+ */
+ const VERSION = "3.3.2";
+ /**
+ * Constant to flag Swift not to try and connect upon instantiation
+ */
+ const NO_START = 2;
+ /**
+ * Constant to tell Swift not to perform the standard SMTP handshake upon connect
+ */
+ const NO_HANDSHAKE = 4;
+ /**
+ * Constant to ask Swift to start logging
+ */
+ const ENABLE_LOGGING = 8;
+ /**
+ * Constant to prevent postConnect() being run in the connection
+ */
+ const NO_POST_CONNECT = 16;
+ /**
+ * The connection object currently active
+ * @var Swift_Connection
+ */
+ public $connection = null;
+ /**
+ * The domain name of this server (should technically be a FQDN)
+ * @var string
+ */
+ protected $domain = null;
+ /**
+ * Flags to change the behaviour of Swift
+ * @var int
+ */
+ protected $options;
+ /**
+ * Loaded plugins, separated into containers according to roles
+ * @var array
+ */
+ protected $listeners = array();
+
+ /**
+ * Constructor
+ * @param Swift_Connection The connection object to deal with I/O
+ * @param string The domain name of this server (the client) as a FQDN
+ * @param int Optional flags
+ * @throws Swift_ConnectionException If a connection cannot be established or the connection is behaving incorrectly
+ */
+ public function __construct(Swift_Connection $conn, $domain=false, $options=null)
+ {
+ $this->initializeEventListenerContainer();
+ $this->setOptions($options);
+
+ $log = Swift_LogContainer::getLog();
+
+ if ($this->hasOption(self::ENABLE_LOGGING) && !$log->isEnabled())
+ {
+ $log->setLogLevel(Swift_Log::LOG_NETWORK);
+ }
+
+ if (!$domain) $domain = !empty($_SERVER["SERVER_ADDR"]) ? "[" . $_SERVER["SERVER_ADDR"] . "]" : "localhost.localdomain";
+
+ $this->setDomain($domain);
+ $this->connection = $conn;
+
+ if ($conn && !$this->hasOption(self::NO_START))
+ {
+ if ($log->hasLevel(Swift_Log::LOG_EVERYTHING)) $log->add("Trying to connect...", Swift_Log::NORMAL);
+ $this->connect();
+ }
+ }
+ /**
+ * Populate the listeners array with the defined listeners ready for plugins
+ */
+ protected function initializeEventListenerContainer()
+ {
+ Swift_ClassLoader::load("Swift_Events_ListenerMapper");
+ foreach (Swift_Events_ListenerMapper::getMap() as $interface => $method)
+ {
+ if (!isset($this->listeners[$interface]))
+ $this->listeners[$interface] = array();
+ }
+ }
+ /**
+ * Add a new plugin to Swift
+ * Plugins must implement one or more event listeners
+ * @param Swift_Events_Listener The plugin to load
+ */
+ public function attachPlugin(Swift_Events_Listener $plugin, $id)
+ {
+ foreach (array_keys($this->listeners) as $key)
+ {
+ $listener = "Swift_Events_" . $key;
+ Swift_ClassLoader::load($listener);
+ if ($plugin instanceof $listener) $this->listeners[$key][$id] = $plugin;
+ }
+ }
+ /**
+ * Get an attached plugin if it exists
+ * @param string The id of the plugin
+ * @return Swift_Event_Listener
+ */
+ public function getPlugin($id)
+ {
+ foreach ($this->listeners as $type => $arr)
+ {
+ if (isset($arr[$id])) return $this->listeners[$type][$id];
+ }
+ return null; //If none found
+ }
+ /**
+ * Remove a plugin attached under the ID of $id
+ * @param string The ID of the plugin
+ */
+ public function removePlugin($id)
+ {
+ foreach ($this->listeners as $type => $arr)
+ {
+ if (isset($arr[$id]))
+ {
+ $this->listeners[$type][$id] = null;
+ unset($this->listeners[$type][$id]);
+ }
+ }
+ }
+ /**
+ * Send a new type of event to all objects which are listening for it
+ * @param Swift_Events The event to send
+ * @param string The type of event
+ */
+ public function notifyListeners($e, $type)
+ {
+ Swift_ClassLoader::load("Swift_Events_ListenerMapper");
+ if (!empty($this->listeners[$type]) && $notifyMethod = Swift_Events_ListenerMapper::getNotifyMethod($type))
+ {
+ $e->setSwift($this);
+ foreach ($this->listeners[$type] as $k => $listener)
+ {
+ $listener->$notifyMethod($e);
+ }
+ }
+ else $e = null;
+ }
+ /**
+ * Check if an option flag has been set
+ * @param string Option name
+ * @return boolean
+ */
+ public function hasOption($option)
+ {
+ return ($this->options & $option);
+ }
+ /**
+ * Adjust the options flags
+ * E.g. $obj->setOptions(Swift::NO_START | Swift::NO_HANDSHAKE)
+ * @param int The bits to set
+ */
+ public function setOptions($options)
+ {
+ $this->options = (int) $options;
+ }
+ /**
+ * Get the current options set (as bits)
+ * @return int
+ */
+ public function getOptions()
+ {
+ return (int) $this->options;
+ }
+ /**
+ * Set the FQDN of this server as it will identify itself
+ * @param string The FQDN of the server
+ */
+ public function setDomain($name)
+ {
+ $this->domain = (string) $name;
+ }
+ /**
+ * Attempt to establish a connection with the service
+ * @throws Swift_ConnectionException If the connection cannot be established or behaves oddly
+ */
+ public function connect()
+ {
+ $this->connection->start();
+ $greeting = $this->command("", 220);
+ if (!$this->hasOption(self::NO_HANDSHAKE))
+ {
+ $this->handshake($greeting);
+ }
+ Swift_ClassLoader::load("Swift_Events_ConnectEvent");
+ $this->notifyListeners(new Swift_Events_ConnectEvent($this->connection), "ConnectListener");
+ }
+ /**
+ * Disconnect from the MTA
+ * @throws Swift_ConnectionException If the connection will not stop
+ */
+ public function disconnect()
+ {
+ $this->command("QUIT");
+ $this->connection->stop();
+ Swift_ClassLoader::load("Swift_Events_DisconnectEvent");
+ $this->notifyListeners(new Swift_Events_DisconnectEvent($this->connection), "DisconnectListener");
+ }
+ /**
+ * Throws an exception if the response code wanted does not match the one returned
+ * @param Swift_Event_ResponseEvent The full response from the service
+ * @param int The 3 digit response code wanted
+ * @throws Swift_BadResponseException If the code does not match
+ */
+ protected function assertCorrectResponse(Swift_Events_ResponseEvent $response, $codes)
+ {
+ $codes = (array)$codes;
+ if (!in_array($response->getCode(), $codes))
+ {
+ $log = Swift_LogContainer::getLog();
+ $error = "Expected response code(s) [" . implode(", ", $codes) . "] but got response [" . $response->getString() . "]";
+ if ($log->hasLevel(Swift_Log::LOG_ERRORS)) $log->add($error, Swift_Log::ERROR);
+ throw new Swift_BadResponseException($error);
+ }
+ }
+ /**
+ * Have a polite greeting with the server and work out what it's capable of
+ * @param Swift_Events_ResponseEvent The initial service line respoonse
+ * @throws Swift_ConnectionException If conversation is not going very well
+ */
+ protected function handshake(Swift_Events_ResponseEvent $greeting)
+ {
+ if ($this->connection->getRequiresEHLO() || strpos($greeting->getString(), "ESMTP"))
+ $this->setConnectionExtensions($this->command("EHLO " . $this->domain, 250));
+ else $this->command("HELO " . $this->domain, 250);
+ //Connection might want to do something like authenticate now
+ if (!$this->hasOption(self::NO_POST_CONNECT)) $this->connection->postConnect($this);
+ }
+ /**
+ * Set the extensions which the service reports in the connection object
+ * @param Swift_Events_ResponseEvent The list of extensions as reported by the service
+ */
+ protected function setConnectionExtensions(Swift_Events_ResponseEvent $list)
+ {
+ $le = (strpos($list->getString(), "\r\n") !== false) ? "\r\n" : "\n";
+ $list = explode($le, $list->getString());
+ for ($i = 1, $len = count($list); $i < $len; $i++)
+ {
+ $extension = substr($list[$i], 4);
+ $attributes = split("[ =]", $extension);
+ $this->connection->setExtension($attributes[0], (isset($attributes[1]) ? array_slice($attributes, 1) : array()));
+ }
+ }
+ /**
+ * Execute a command against the service and get the response
+ * @param string The command to execute (leave off any CRLF!!!)
+ * @param int The code to check for in the response, if any. -1 indicates that no response is wanted.
+ * @return Swift_Events_ResponseEvent The server's response (could be multiple lines)
+ * @throws Swift_ConnectionException If a code was expected but does not match the one returned
+ */
+ public function command($command, $code=null)
+ {
+ $log = Swift_LogContainer::getLog();
+ Swift_ClassLoader::load("Swift_Events_CommandEvent");
+ if ($command !== "")
+ {
+ $command_event = new Swift_Events_CommandEvent($command, $code);
+ $command = null; //For memory reasons
+ $this->notifyListeners($command_event, "BeforeCommandListener");
+ if ($log->hasLevel(Swift_Log::LOG_NETWORK) && $code != -1) $log->add($command_event->getString(), Swift_Log::COMMAND);
+ $end = ($code != -1) ? "\r\n" : null;
+ $this->connection->write($command_event->getString(), $end);
+ $this->notifyListeners($command_event, "CommandListener");
+ }
+
+ if ($code == -1) return null;
+
+ Swift_ClassLoader::load("Swift_Events_ResponseEvent");
+ $response_event = new Swift_Events_ResponseEvent($this->connection->read());
+ $this->notifyListeners($response_event, "ResponseListener");
+ if ($log->hasLevel(Swift_Log::LOG_NETWORK)) $log->add($response_event->getString(), Swift_Log::RESPONSE);
+ if ($command !== "" && $command_event->getCode() !== null)
+ $this->assertCorrectResponse($response_event, $command_event->getCode());
+ return $response_event;
+ }
+ /**
+ * Reset a conversation which has gone badly
+ * @throws Swift_ConnectionException If the service refuses to reset
+ */
+ public function reset()
+ {
+ $this->command("RSET", 250);
+ }
+ /**
+ * Send a message to any number of recipients
+ * @param Swift_Message The message to send. This does not need to (and shouldn't really) have any of the recipient headers set.
+ * @param mixed The recipients to send to. Can be a string, Swift_Address or Swift_RecipientList. Note that all addresses apart from Bcc recipients will appear in the message headers
+ * @param mixed The address to send the message from. Can either be a string or an instance of Swift_Address.
+ * @return int The number of successful recipients
+ * @throws Swift_ConnectionException If sending fails for any reason.
+ */
+ public function send(Swift_Message $message, $recipients, $from)
+ {
+ Swift_ClassLoader::load("Swift_Message_Encoder");
+ if (is_string($recipients) && preg_match("/^" . Swift_Message_Encoder::CHEAP_ADDRESS_RE . "\$/", $recipients))
+ {
+ $recipients = new Swift_Address($recipients);
+ }
+ elseif (!($recipients instanceof Swift_AddressContainer))
+ throw new Exception("The recipients parameter must either be a valid string email address, ".
+ "an instance of Swift_RecipientList or an instance of Swift_Address.");
+
+ if (is_string($from) && preg_match("/^" . Swift_Message_Encoder::CHEAP_ADDRESS_RE . "\$/", $from))
+ {
+ $from = new Swift_Address($from);
+ }
+ elseif (!($from instanceof Swift_Address))
+ throw new Exception("The sender parameter must either be a valid string email address or ".
+ "an instance of Swift_Address.");
+
+ $log = Swift_LogContainer::getLog();
+
+ if (!$message->getEncoding() && !$this->connection->hasExtension("8BITMIME"))
+ {
+ $message->setEncoding("QP", true, true);
+ }
+
+ $list = $recipients;
+ if ($recipients instanceof Swift_Address)
+ {
+ $list = new Swift_RecipientList();
+ $list->addTo($recipients);
+ }
+
+ Swift_ClassLoader::load("Swift_Events_SendEvent");
+ $send_event = new Swift_Events_SendEvent($message, $list, $from, 0);
+
+ $this->notifyListeners($send_event, "BeforeSendListener");
+
+ $to = $cc = array();
+ if (!($has_from = $message->getFrom())) $message->setFrom($from);
+ if (!($has_return_path = $message->getReturnPath())) $message->setReturnPath($from->build(true));
+ if (!($has_reply_to = $message->getReplyTo())) $message->setReplyTo($from);
+ if (!($has_message_id = $message->getId())) $message->generateId();
+
+ $this->command("MAIL FROM: " . $message->getReturnPath(true), 250);
+
+ $failed = 0;
+ $sent = 0;
+ $tmp_sent = 0;
+
+ $it = $list->getIterator("to");
+ while ($it->hasNext())
+ {
+ $it->next();
+ $address = $it->getValue();
+ $to[] = $address->build();
+ try {
+ $this->command("RCPT TO: " . $address->build(true), 250);
+ $tmp_sent++;
+ } catch (Swift_BadResponseException $e) {
+ $failed++;
+ $send_event->addFailedRecipient($address->getAddress());
+ if ($log->hasLevel(Swift_Log::LOG_FAILURES)) $log->addfailedRecipient($address->getAddress());
+ }
+ }
+ $it = $list->getIterator("cc");
+ while ($it->hasNext())
+ {
+ $it->next();
+ $address = $it->getValue();
+ $cc[] = $address->build();
+ try {
+ $this->command("RCPT TO: " . $address->build(true), 250);
+ $tmp_sent++;
+ } catch (Swift_BadResponseException $e) {
+ $failed++;
+ $send_event->addFailedRecipient($address->getAddress());
+ if ($log->hasLevel(Swift_Log::LOG_FAILURES)) $log->addfailedRecipient($address->getAddress());
+ }
+ }
+
+ if ($failed == (count($to) + count($cc)))
+ {
+ $this->reset();
+ $this->notifyListeners($send_event, "SendListener");
+ return 0;
+ }
+
+ if (!($has_to = $message->getTo()) && !empty($to)) $message->setTo($to);
+ if (!($has_cc = $message->getCc()) && !empty($cc)) $message->setCc($cc);
+
+ $this->command("DATA", 354);
+ $data = $message->build();
+
+ while (false !== $bytes = $data->read())
+ $this->command($bytes, -1);
+ if ($log->hasLevel(Swift_Log::LOG_NETWORK)) $log->add("<MESSAGE DATA>", Swift_Log::COMMAND);
+ try {
+ $this->command("\r\n.", 250);
+ $sent += $tmp_sent;
+ } catch (Swift_BadResponseException $e) {
+ $failed += $tmp_sent;
+ }
+
+ $tmp_sent = 0;
+ $has_bcc = $message->getBcc();
+ $it = $list->getIterator("bcc");
+ while ($it->hasNext())
+ {
+ $it->next();
+ $address = $it->getValue();
+ if (!$has_bcc) $message->setBcc($address->build());
+ try {
+ $this->command("MAIL FROM: " . $message->getReturnPath(true), 250);
+ $this->command("RCPT TO: " . $address->build(true), 250);
+ $this->command("DATA", 354);
+ $data = $message->build();
+ while (false !== $bytes = $data->read())
+ $this->command($bytes, -1);
+ if ($log->hasLevel(Swift_Log::LOG_NETWORK)) $log->add("<MESSAGE DATA>", Swift_Log::COMMAND);
+ $this->command("\r\n.", 250);
+ $sent++;
+ } catch (Swift_BadResponseException $e) {
+ $failed++;
+ $send_event->addFailedRecipient($address->getAddress());
+ if ($log->hasLevel(Swift_Log::LOG_FAILURES)) $log->addfailedRecipient($address->getAddress());
+ $this->reset();
+ }
+ }
+
+ $total = count($to) + count($cc) + count($list->getBcc());
+
+ $send_event->setNumSent($sent);
+ $this->notifyListeners($send_event, "SendListener");
+
+ if (!$has_return_path) $message->setReturnPath("");
+ if (!$has_from) $message->setFrom("");
+ if (!$has_to) $message->setTo("");
+ if (!$has_reply_to) $message->setReplyTo(null);
+ if (!$has_cc) $message->setCc(null);
+ if (!$has_bcc) $message->setBcc(null);
+ if (!$has_message_id) $message->setId(null);
+
+ if ($log->hasLevel(Swift_Log::LOG_NETWORK)) $log->add("Message sent to " . $sent . "/" . $total . " recipients", Swift_Log::NORMAL);
+
+ return $sent;
+ }
+ /**
+ * Send a message to a batch of recipients.
+ * Unlike send() this method ignores Cc and Bcc recipients and does not reveal every recipients' address in the headers
+ * @param Swift_Message The message to send (leave out the recipient headers unless you are deliberately overriding them)
+ * @param Swift_RecipientList The addresses to send to
+ * @param Swift_Address The address the mail is from (sender)
+ * @return int The number of successful recipients
+ */
+ public function batchSend(Swift_Message $message, Swift_RecipientList $to, $from)
+ {
+ $batch = new Swift_BatchMailer($this);
+ return $batch->send($message, $to, $from);
+ }
+}
Modified: trunk/documentation/jbosstools-jdocbook-style/src/main/com/css/script/toggle.js
===================================================================
--- trunk/documentation/jbosstools-jdocbook-style/src/main/com/css/script/toggle.js 2008-11-17 13:47:28 UTC (rev 11842)
+++ trunk/documentation/jbosstools-jdocbook-style/src/main/com/css/script/toggle.js 2008-11-17 14:54:08 UTC (rev 11843)
@@ -8,53 +8,10 @@
// send http request
function sendEmail(e){
- var params='subject='+$F('subject')+'&message='+escape($F('message'))+'&name='+$F('name')+'&email='+$F('email');
- var xmlobj=new Ajax.Updater('feedback-state','script/send_mail.php',{method:'post',parameters: params});
// prevent form from submitting
Event.stop(e);
+ var params='subject='+$F('subject')+'&message='+escape($F('message'))+'&name='+$F('name')+'&email='+$F('email')+'&path='+window.location;
+ var xmlobj=new Ajax.Updater('feedback-state','script/send_mail.php',{method:'get',parameters: params});
}
-function dbToggle(node, expandText, collapseText) {
- var dt = node.parentNode;
- if (dt.nodeName.toLowerCase() == 'dt') {
- var dd = dt.nextSibling;
-
- if (dd && dd.nodeName.toLowerCase() == 'dd') {
-
- if (dd.style && dd.style.display == 'none') {
- dd.style.display = '';
- node.innerHTML = collapseText;
- } else {
- dd.style.display = 'none';
- node.innerHTML = expandText;
- }
-
- }
-
- }
-
-}
-
-var toc = {
- expand: function(node) {
- toc.show(toc.findDD(node))
- toc.hide(node);
- toc.show(node.nextSibling);
- },
- collapse : function(node) {
- toc.hide(toc.findDD(node))
- toc.hide(node);
- toc.show(node.previousSibling);
- },
- findDD : function(node) {
- return node.parentNode.nextSibling;
- },
-
- hide: function(node) {
- node.style.display = "none";
- },
- show: function(node) {
- node.style.display = "";
- }
-};
\ No newline at end of file
Modified: trunk/documentation/jbosstools-jdocbook-style/src/main/org/css/css/tools.css
===================================================================
--- trunk/documentation/jbosstools-jdocbook-style/src/main/org/css/css/tools.css 2008-11-17 13:47:28 UTC (rev 11842)
+++ trunk/documentation/jbosstools-jdocbook-style/src/main/org/css/css/tools.css 2008-11-17 14:54:08 UTC (rev 11843)
@@ -172,7 +172,7 @@
#feedback-state{
font-weight: bold;
height: 20px;
- width: 100%;
+ width: 508px;
line-height: 20px;
overflow: hidden;
}
@@ -207,7 +207,7 @@
color: #415973;
}
-#feedback-message{
+#message{
width: 200px;
height: 150px;
padding: 2px;
@@ -219,7 +219,7 @@
color: #415973;
}
-.feedback-textbox, #feedback-message{
+.feedback-textbox, #message{
background-color:#FFFFFF;
border:1px solid #A5ACB2;
padding:2px 1px 3px 5px;
Modified: trunk/documentation/jbosstools-jdocbook-style/src/main/org/css/script/send_mail.php
===================================================================
--- trunk/documentation/jbosstools-jdocbook-style/src/main/org/css/script/send_mail.php 2008-11-17 13:47:28 UTC (rev 11842)
+++ trunk/documentation/jbosstools-jdocbook-style/src/main/org/css/script/send_mail.php 2008-11-17 14:54:08 UTC (rev 11843)
@@ -6,58 +6,73 @@
$message_not_sent = "Error sending message!";
$message_success = "Message is sent successfully";
-//define pattern
+//get $_REQUEST Array
+$_REQUEST = array_map('trim', $_REQUEST);
+$email = $_REQUEST['email'];
+$name= $_REQUEST['name'];
+$subject = $_REQUEST['subject'];
+$message = $_REQUEST['message'];
+$path = $_REQUEST['path'];
+//define patterns
$email_pat = "/^([A-z0-9|.|-|_]{2,256})(a)(([A-z0-9|.|-]{2,256}).([a-z]{2,4}))*$/";
$general_pat = "/^(\s)+$/";
-// clean up POST data
-$_POST = array_map('trim', $_POST);
-
+
// check if 'subject' field has been filled or not
-if(!$_POST['subject']){
- $subject="(no subject)";
+if(!$subject){
+ $subject="(no subject)";
}else{
- $subject = substr($POST['subject'], 0, 255);
- echo $subject;
+ $subject = substr(htmlentities($subject), 0, 255);
}
// check if 'name' field has been filled or not
-if(!$_POST['name']){
+if(!$name){
$name="(no name)";
}else{
- $name = substr($POST['name'], 0, 255);
+ $name = substr(htmlentities($name), 0, 255);
}
// check if 'message' field has been filled or not
-if(!$_POST['message'] || preg_match($general_pat, $_POST['message'])){
+if(!$message || preg_match($general_pat, $message)){
echo $message_error;
exit();
}else{
- $message = substr($_POST['message'], 0, 3000);
+ $message = "Feedback from ".$path."\n"."Message: ".substr(htmlentities($message), 0, 3000);
}
// check if 'email' field has been filled or not
-if(!$_POST['email']){
+if(!preg_match($email_pat, $email)){
echo $email_error;
exit();
-}elseif(!preg_match($email_pat, $_POST['email'])){
-echo $email_error;
- exit();
-}else{
- $email = substr($POST['email'], 0, 255);
}
-// get neccessary fields
-$to='smukhina(a)exadel.com';
-
// define MIME headers
$headers="MIME-Version 1.0"."\r\n"."Content-Type: text/plain; charset=utf-8"."\r\n"."From: \"".$name."\" "."<".$email.">"."Reply-to: \"".$name."\" "."<".$email.">";
-// send email
-if(!@mail($to, $subject, $message, $headers)){
- echo $message_not_sent;
- exit();
-}else{
- echo $message_success;
- exit();
+ //Load in the files we'll need
+require_once "swift_lib/Swift.php";
+require_once "swift_lib/Swift/Connection/SMTP.php";
+require_once "swift_lib/Swift/Connection/Sendmail.php";
+try{
+//Start Swift
+$sendmail =& new Swift_Connection_Sendmail();
+$sendmail->setTimeout(3); //3 seconds
+
+//$swift =& new Swift(new Swift_Connection_SMTP("localhost"));
+
+$swift =& new Swift($sendmail);
+$sender =& new Swift_Address($email, $name);
+$me =& new Swift_Address("ggalkin(a)exadel.com");
+$body =& new Swift_Message($subject, $message);
+ if($swift->send($body, $me, $sender)){
+ echo $message_success;
+ exit();
+ }else{
+ echo $message_not_sent;
+ exit();
+ }
+}catch (Swift_ConnectionException $e) {
+ echo "There was a problem communicating with SMTP: " . $e->getMessage();
+} catch (Swift_Message_MimeException $e) {
+ echo "There was an unexpected problem building the email:" . $e->getMessage();
}
?>
\ No newline at end of file
Modified: trunk/documentation/jbosstools-jdocbook-style/src/main/org/css/script/toggle.js
===================================================================
--- trunk/documentation/jbosstools-jdocbook-style/src/main/org/css/script/toggle.js 2008-11-17 13:47:28 UTC (rev 11842)
+++ trunk/documentation/jbosstools-jdocbook-style/src/main/org/css/script/toggle.js 2008-11-17 14:54:08 UTC (rev 11843)
@@ -8,11 +8,11 @@
// send http request
function sendEmail(e){
- var params='subject='+$F('subject')+'&message='+escape($F('message'))+'&name='+$F('name')+'&email='+$F('email');
- var xmlobj=new Ajax.Updater('feedback-state','script/send_mail.php',{method:'post',parameters: params});
// prevent form from submitting
Event.stop(e);
+ var params='subject='+$F('subject')+'&message='+escape($F('message'))+'&name='+$F('name')+'&email='+$F('email')+'&path='+window.location;
+ var xmlobj=new Ajax.Updater('feedback-state','script/send_mail.php',{method:'get',parameters: params});
}
function dbToggle(node, expandText, collapseText) {
17 years, 5 months