JBoss Tools SVN: r33011 - in trunk/maven/plugins: org.jboss.tools.maven.core/src/org/jboss/tools/maven/core/profiles and 2 other directories.
by jbosstools-commits@lists.jboss.org
Author: fbricon
Date: 2011-07-18 09:15:17 -0400 (Mon, 18 Jul 2011)
New Revision: 33011
Added:
trunk/maven/plugins/org.jboss.tools.maven.core/src/org/jboss/tools/maven/core/profiles/ProfileState.java
trunk/maven/plugins/org.jboss.tools.maven.core/src/org/jboss/tools/maven/core/profiles/ProfileStatus.java
trunk/maven/plugins/org.jboss.tools.maven.ui/src/org/jboss/tools/maven/ui/internal/profiles/ActiveMavenProfilesNode.java
trunk/maven/plugins/org.jboss.tools.maven.ui/src/org/jboss/tools/maven/ui/internal/profiles/ActiveProfilesContentProvider.java
trunk/maven/plugins/org.jboss.tools.maven.ui/src/org/jboss/tools/maven/ui/internal/profiles/ActiveProfilesLabelProvider.java
trunk/maven/plugins/org.jboss.tools.maven.ui/src/org/jboss/tools/maven/ui/internal/profiles/ProfileSelection.java
trunk/maven/plugins/org.jboss.tools.maven.ui/src/org/jboss/tools/maven/ui/internal/profiles/ProfileSelectionStatus.java
Modified:
trunk/maven/plugins/org.jboss.tools.maven.core/src/org/jboss/tools/maven/core/internal/profiles/ProfileManager.java
trunk/maven/plugins/org.jboss.tools.maven.core/src/org/jboss/tools/maven/core/profiles/IProfileManager.java
trunk/maven/plugins/org.jboss.tools.maven.ui/plugin.xml
trunk/maven/plugins/org.jboss.tools.maven.ui/src/org/jboss/tools/maven/ui/internal/profiles/ProfileSelectionHandler.java
trunk/maven/plugins/org.jboss.tools.maven.ui/src/org/jboss/tools/maven/ui/internal/profiles/SelectProfilesDialog.java
Log:
JBIDE-8969 : Enable multiple project selection
Modified: trunk/maven/plugins/org.jboss.tools.maven.core/src/org/jboss/tools/maven/core/internal/profiles/ProfileManager.java
===================================================================
--- trunk/maven/plugins/org.jboss.tools.maven.core/src/org/jboss/tools/maven/core/internal/profiles/ProfileManager.java 2011-07-18 12:16:44 UTC (rev 33010)
+++ trunk/maven/plugins/org.jboss.tools.maven.core/src/org/jboss/tools/maven/core/internal/profiles/ProfileManager.java 2011-07-18 13:15:17 UTC (rev 33011)
@@ -1,9 +1,14 @@
package org.jboss.tools.maven.core.internal.profiles;
+import java.util.ArrayList;
+import java.util.Collection;
import java.util.Collections;
+import java.util.HashSet;
+import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
+import java.util.Set;
import org.apache.maven.model.Profile;
import org.apache.maven.settings.Settings;
@@ -17,6 +22,8 @@
import org.eclipse.m2e.core.project.MavenUpdateRequest;
import org.eclipse.m2e.core.project.ResolverConfiguration;
import org.jboss.tools.maven.core.profiles.IProfileManager;
+import org.jboss.tools.maven.core.profiles.ProfileState;
+import org.jboss.tools.maven.core.profiles.ProfileStatus;
public class ProfileManager implements IProfileManager {
@@ -25,7 +32,9 @@
final boolean isOffline,
final boolean isForceUpdate,
IProgressMonitor monitor) throws CoreException {
-
+ if (mavenProjectFacade == null) {
+ return;
+ }
final IProjectConfigurationManager configurationManager = MavenPlugin.getProjectConfigurationManager();
final ResolverConfiguration configuration =configurationManager
.getResolverConfiguration(mavenProjectFacade.getProject());
@@ -117,4 +126,99 @@
return false;
}
+ public List<ProfileStatus> getProfilesStatuses(
+ IMavenProjectFacade facade) throws CoreException {
+ if (facade == null) {
+ return Collections.emptyList();
+ }
+
+ ResolverConfiguration resolverConfiguration = MavenPlugin.getProjectConfigurationManager()
+ .getResolverConfiguration(facade.getProject());
+
+ List<String> configuredProfiles = resolverConfiguration.getActiveProfileList();
+
+ final List<Profile> activeProfiles = facade.getMavenProject().getActiveProfiles();
+
+ List<Profile> projectProfiles = new ArrayList<Profile>(facade.getMavenProject().getModel().getProfiles());
+
+ final Map<Profile, Boolean> availableSettingsProfiles = getAvailableSettingProfiles();
+ Set<Profile> settingsProfiles = new HashSet<Profile>(availableSettingsProfiles.keySet());
+
+ List<ProfileStatus> statuses = new ArrayList<ProfileStatus>();
+
+ //First we put user configured profiles
+ for (String pId : configuredProfiles) {
+ if ("".equals(pId.trim())) continue;
+ boolean isDisabled = pId.startsWith("!");
+ String id = (isDisabled)?pId.substring(1):pId;
+ ProfileStatus status = new ProfileStatus(id);
+ status.setUserSelected(true);
+ ProfileState state = isDisabled?ProfileState.Disabled
+ :ProfileState.Active;
+ status.setActivationState(state);
+
+ Profile p = get(id, projectProfiles);
+
+ if (p == null){
+ p = get(id, settingsProfiles);
+ if(p != null){
+ status.setAutoActive(availableSettingsProfiles.get(p));
+ }
+ }
+
+ if (p == null) {
+ status.setSource("undefined");
+ } else {
+ status.setSource(p.getSource());
+ }
+ statuses.add(status);
+ }
+
+ //Iterate on the remaining project profiles
+ addStatuses(statuses, projectProfiles, new ActivationPredicate() {
+ @Override
+ boolean isActive(Profile p) {
+ return ProfileManager.this.isActive(p, activeProfiles);
+ }
+ });
+
+ //Iterate on the remaining settings profiles
+ addStatuses(statuses, settingsProfiles, new ActivationPredicate() {
+ @Override
+ boolean isActive(Profile p) {
+ return availableSettingsProfiles.get(p);
+ }
+ });
+ return Collections.unmodifiableList(statuses);
+ }
+
+ private void addStatuses(List<ProfileStatus> statuses, Collection<Profile> profiles, ActivationPredicate predicate) {
+ for (Profile p : profiles) {
+ ProfileStatus status = new ProfileStatus(p.getId());
+ status.setSource(p.getSource());
+ boolean isActive = predicate.isActive(p);
+ ProfileState activationState = (isActive)?ProfileState.Active:ProfileState.Inactive;
+ status.setAutoActive(isActive);
+ status.setActivationState(activationState);
+ statuses.add(status);
+ }
+ }
+
+ private Profile get(String id, Collection<Profile> profiles) {
+ Iterator<Profile> ite = profiles.iterator();
+ Profile found = null;
+ while(ite.hasNext()) {
+ Profile p = ite.next();
+ if(p.getId().equals(id)) {
+ found = p;
+ ite.remove();
+ break;
+ }
+ }
+ return found;
+ }
+
+ private abstract class ActivationPredicate {
+ abstract boolean isActive(Profile p);
+ }
}
Modified: trunk/maven/plugins/org.jboss.tools.maven.core/src/org/jboss/tools/maven/core/profiles/IProfileManager.java
===================================================================
--- trunk/maven/plugins/org.jboss.tools.maven.core/src/org/jboss/tools/maven/core/profiles/IProfileManager.java 2011-07-18 12:16:44 UTC (rev 33010)
+++ trunk/maven/plugins/org.jboss.tools.maven.core/src/org/jboss/tools/maven/core/profiles/IProfileManager.java 2011-07-18 13:15:17 UTC (rev 33011)
@@ -2,6 +2,7 @@
import java.util.List;
import java.util.Map;
+import java.util.Set;
import org.apache.maven.model.Profile;
import org.eclipse.core.runtime.CoreException;
@@ -24,7 +25,9 @@
* @throws CoreException
*/
Map<Profile, Boolean> getAvailableProfiles(IMavenProjectFacade mavenProjectFacade) throws CoreException;
-
+
+ List<ProfileStatus> getProfilesStatuses(IMavenProjectFacade mavenProjectFacade) throws CoreException;
+
/**
* Returns an unmodifiable Map of all the available profiles defined in the
* Maven settings.xml file.<br/>
Added: trunk/maven/plugins/org.jboss.tools.maven.core/src/org/jboss/tools/maven/core/profiles/ProfileState.java
===================================================================
--- trunk/maven/plugins/org.jboss.tools.maven.core/src/org/jboss/tools/maven/core/profiles/ProfileState.java (rev 0)
+++ trunk/maven/plugins/org.jboss.tools.maven.core/src/org/jboss/tools/maven/core/profiles/ProfileState.java 2011-07-18 13:15:17 UTC (rev 33011)
@@ -0,0 +1,18 @@
+package org.jboss.tools.maven.core.profiles;
+
+public enum ProfileState {
+ Disabled(false),
+ Inactive(false),
+ Active(true);
+
+ private boolean active;
+
+ ProfileState(boolean active) {
+ this.active = active;
+ }
+
+ public boolean isActive() {
+ return active;
+ }
+
+}
Added: trunk/maven/plugins/org.jboss.tools.maven.core/src/org/jboss/tools/maven/core/profiles/ProfileStatus.java
===================================================================
--- trunk/maven/plugins/org.jboss.tools.maven.core/src/org/jboss/tools/maven/core/profiles/ProfileStatus.java (rev 0)
+++ trunk/maven/plugins/org.jboss.tools.maven.core/src/org/jboss/tools/maven/core/profiles/ProfileStatus.java 2011-07-18 13:15:17 UTC (rev 33011)
@@ -0,0 +1,100 @@
+package org.jboss.tools.maven.core.profiles;
+
+public class ProfileStatus {
+ private String id;
+ private boolean autoActive;
+ private boolean userSelected;
+ private ProfileState activationState;
+ private String source;
+
+ public ProfileStatus(String id) {
+ this.id = id;
+ }
+
+ public String getId() {
+ return id;
+ }
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public boolean isAutoActive() {
+ return autoActive;
+ }
+
+ public void setAutoActive(boolean autoActive) {
+ this.autoActive = autoActive;
+ }
+
+ public ProfileState getActivationState() {
+ return activationState;
+ }
+ public void setActivationState(ProfileState activationState) {
+ this.activationState = activationState;
+ }
+ public String getSource() {
+ return source;
+ }
+ public void setSource(String source) {
+ this.source = source;
+ }
+
+ public boolean isUserSelected() {
+ return userSelected;
+ }
+
+ public void setUserSelected(boolean userSelected) {
+ this.userSelected = userSelected;
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result
+ + ((activationState == null) ? 0 : activationState.hashCode());
+ result = prime * result + (autoActive ? 1231 : 1237);
+ result = prime * result + ((id == null) ? 0 : id.hashCode());
+ result = prime * result + ((source == null) ? 0 : source.hashCode());
+ result = prime * result + (userSelected ? 1231 : 1237);
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ ProfileStatus other = (ProfileStatus) obj;
+ if (activationState != other.activationState)
+ return false;
+ if (autoActive != other.autoActive)
+ return false;
+ if (id == null) {
+ if (other.id != null)
+ return false;
+ } else if (!id.equals(other.id))
+ return false;
+ if (source == null) {
+ if (other.source != null)
+ return false;
+ } else if (!source.equals(other.source))
+ return false;
+ if (userSelected != other.userSelected)
+ return false;
+ return true;
+ }
+
+ @Override
+ public String toString() {
+ return "ProfileStatus [id=" + id + ", autoActive=" + autoActive
+ + ", userSelected=" + userSelected + ", activationState="
+ + activationState + ", source=" + source + "]";
+ }
+
+
+
+}
Modified: trunk/maven/plugins/org.jboss.tools.maven.ui/plugin.xml
===================================================================
--- trunk/maven/plugins/org.jboss.tools.maven.ui/plugin.xml 2011-07-18 12:16:44 UTC (rev 33010)
+++ trunk/maven/plugins/org.jboss.tools.maven.ui/plugin.xml 2011-07-18 13:15:17 UTC (rev 33011)
@@ -153,4 +153,55 @@
</repository></pattern>
</template>
</extension>
+ <!--
+ <extension
+ point="org.eclipse.ui.navigator.viewer">
+ <viewerContentBinding
+ viewerId="org.eclipse.ui.navigator.ProjectExplorer">
+ <includes>
+ <contentExtension
+ isRoot="false"
+ pattern="org.jboss.tools.maven.profiles.navigatorContent">
+ </contentExtension>
+ </includes>
+ </viewerContentBinding>
+ </extension>
+
+
+ <extension point="org.eclipse.ui.navigator.navigatorContent">
+ <navigatorContent id="org.jboss.tools.maven.profiles.navigatorContent"
+ contentProvider="org.jboss.tools.maven.ui.internal.profiles.ActiveProfilesContentProvider"
+ labelProvider="org.jboss.tools.maven.ui.internal.profiles.ActiveProfilesLabelProvider"
+ appearsBefore="org.eclipse.jdt.java.ui.javaContent"
+ name="Active Maven Profiles"
+ activeByDefault="true"
+ icon="icons/maven-profiles.gif"
+ priority="normal">
+
+ <possibleChildren>
+ <instanceof value="org.jboss.tools.maven.ui.internal.profiles.ActiveMavenProfilesNode"/>
+ </possibleChildren>
+
+ <triggerPoints>
+ <or>
+ <instanceof
+ value="org.jboss.tools.maven.ui.internal.profiles.ActiveMavenProfilesNode">
+ </instanceof>
+ <and>
+ <instanceof
+ value="org.eclipse.core.resources.IProject">
+ </instanceof>
+ <test
+ forcePluginActivation="true"
+ property="org.eclipse.core.resources.projectNature"
+ value="org.eclipse.m2e.core.maven2Nature">
+ </test>
+ </and>
+ </or>
+ </triggerPoints>
+
+ </navigatorContent>
+ </extension>
+ -->
+
</plugin>
Added: trunk/maven/plugins/org.jboss.tools.maven.ui/src/org/jboss/tools/maven/ui/internal/profiles/ActiveMavenProfilesNode.java
===================================================================
--- trunk/maven/plugins/org.jboss.tools.maven.ui/src/org/jboss/tools/maven/ui/internal/profiles/ActiveMavenProfilesNode.java (rev 0)
+++ trunk/maven/plugins/org.jboss.tools.maven.ui/src/org/jboss/tools/maven/ui/internal/profiles/ActiveMavenProfilesNode.java 2011-07-18 13:15:17 UTC (rev 33011)
@@ -0,0 +1,70 @@
+/*************************************************************************************
+ * Copyright (c) 2009-2011 Red Hat, Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * JBoss by Red Hat - Initial implementation.
+ ************************************************************************************/
+
+package org.jboss.tools.maven.ui.internal.profiles;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.maven.model.Profile;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.ui.model.IWorkbenchAdapter;
+import org.jboss.tools.maven.ui.Activator;
+
+
+/**
+ * Maven profile resource node
+ *
+ * @author Fred Bricon
+ */
+public class ActiveMavenProfilesNode implements IWorkbenchAdapter {
+
+ private Object[] ids = null;
+
+ public static ImageDescriptor icon = Activator.imageDescriptorFromPlugin(Activator.PLUGIN_ID, "icons/maven-profiles.png");
+
+
+ public ActiveMavenProfilesNode(List<Profile> profiles) {
+ ids = getProfileIds(profiles);
+ }
+
+ public Object[] getResources() {
+ return ids;
+ }
+
+ private Object[] getProfileIds(List<Profile> profiles) {
+ if(profiles != null && !profiles.isEmpty()) {
+ List<String> idList = new ArrayList<String>(profiles.size());
+ for (Profile p : profiles) {
+ idList.add(p.getId());
+ }
+ return idList.toArray();
+ }
+ return null;
+ }
+
+ public String getLabel(Object o) {
+ return "Active Maven profiles";
+ }
+
+ public ImageDescriptor getImageDescriptor(Object object) {
+ return icon;
+ }
+
+ public Object getParent(Object o) {
+ return null;
+ }
+
+ public Object[] getChildren(Object o) {
+ return ids;
+ }
+
+}
Added: trunk/maven/plugins/org.jboss.tools.maven.ui/src/org/jboss/tools/maven/ui/internal/profiles/ActiveProfilesContentProvider.java
===================================================================
--- trunk/maven/plugins/org.jboss.tools.maven.ui/src/org/jboss/tools/maven/ui/internal/profiles/ActiveProfilesContentProvider.java (rev 0)
+++ trunk/maven/plugins/org.jboss.tools.maven.ui/src/org/jboss/tools/maven/ui/internal/profiles/ActiveProfilesContentProvider.java 2011-07-18 13:15:17 UTC (rev 33011)
@@ -0,0 +1,60 @@
+package org.jboss.tools.maven.ui.internal.profiles;
+
+import java.util.List;
+
+import org.apache.maven.model.Profile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.jface.viewers.IStructuredContentProvider;
+import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.m2e.core.MavenPlugin;
+import org.eclipse.m2e.core.internal.IMavenConstants;
+import org.eclipse.m2e.core.project.IMavenProjectFacade;
+
+public class ActiveProfilesContentProvider implements
+ITreeContentProvider {
+
+ public void dispose() {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public Object[] getElements(Object inputElement) {
+ if (inputElement instanceof IProject) {
+ IProject project = (IProject) inputElement;
+ try {
+ if (project.isAccessible() && project.hasNature(IMavenConstants.NATURE_ID)) {
+ IMavenProjectFacade facade = MavenPlugin.getMavenProjectRegistry().getProject(project);
+ if (facade != null && facade.getMavenProject() != null) {
+ List<Profile> profiles = facade.getMavenProject().getActiveProfiles();
+ return new Object[] { new ActiveMavenProfilesNode(profiles)};
+ }
+ }
+ } catch (CoreException e) {
+ e.printStackTrace();
+ }
+ }
+ return null;
+ }
+
+ public Object[] getChildren(Object parentElement) {
+ return getElements(parentElement);
+ }
+
+ public Object getParent(Object element) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public boolean hasChildren(Object element) {
+ // TODO Auto-generated method stub
+ return true;
+ }
+
+}
Added: trunk/maven/plugins/org.jboss.tools.maven.ui/src/org/jboss/tools/maven/ui/internal/profiles/ActiveProfilesLabelProvider.java
===================================================================
--- trunk/maven/plugins/org.jboss.tools.maven.ui/src/org/jboss/tools/maven/ui/internal/profiles/ActiveProfilesLabelProvider.java (rev 0)
+++ trunk/maven/plugins/org.jboss.tools.maven.ui/src/org/jboss/tools/maven/ui/internal/profiles/ActiveProfilesLabelProvider.java 2011-07-18 13:15:17 UTC (rev 33011)
@@ -0,0 +1,56 @@
+/*************************************************************************************
+ * Copyright (c) 2009-2011 Red Hat, Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * JBoss by Red Hat - Initial implementation.
+ ************************************************************************************/
+package org.jboss.tools.maven.ui.internal.profiles;
+
+import org.eclipse.jface.viewers.ILabelProvider;
+import org.eclipse.jface.viewers.ILabelProviderListener;
+import org.eclipse.swt.graphics.Image;
+
+public class ActiveProfilesLabelProvider implements ILabelProvider {
+
+ //public static ImageDescriptor icon = Activator.imageDescriptorFromPlugin(Activator.PLUGIN_ID, "icons/maven-profiles.png");
+
+ public Image image = null;
+
+ public ActiveProfilesLabelProvider() {
+ //image = icon.createImage();
+ }
+
+ public void addListener(ILabelProviderListener listener) {
+ }
+
+ public void dispose() {
+ if (image != null) {
+ image.dispose();
+ }
+ }
+
+ public boolean isLabelProperty(Object element, String property) {
+ return true;
+ }
+
+ public void removeListener(ILabelProviderListener listener) {
+ }
+
+ public Image getImage(Object element) {
+ return image;
+ }
+
+ public String getText(Object element) {
+ if(element instanceof ActiveMavenProfilesNode) {
+ return ((ActiveMavenProfilesNode)element).getLabel(null);
+ } else if (element instanceof String) {
+ return element.toString();
+ }
+ return null;
+ }
+
+}
Added: trunk/maven/plugins/org.jboss.tools.maven.ui/src/org/jboss/tools/maven/ui/internal/profiles/ProfileSelection.java
===================================================================
--- trunk/maven/plugins/org.jboss.tools.maven.ui/src/org/jboss/tools/maven/ui/internal/profiles/ProfileSelection.java (rev 0)
+++ trunk/maven/plugins/org.jboss.tools.maven.ui/src/org/jboss/tools/maven/ui/internal/profiles/ProfileSelection.java 2011-07-18 13:15:17 UTC (rev 33011)
@@ -0,0 +1,51 @@
+/*************************************************************************************
+ * Copyright (c) 2009-2011 Red Hat, Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * JBoss by Red Hat - Initial implementation.
+ ************************************************************************************/
+package org.jboss.tools.maven.ui.internal.profiles;
+
+import org.jboss.tools.maven.core.profiles.ProfileState;
+
+public class ProfileSelection {
+ private String id;
+ private Boolean autoActive;
+ private Boolean selected;
+ private ProfileState activationState;
+ private String source;
+ public String getId() {
+ return id;
+ }
+ public void setId(String id) {
+ this.id = id;
+ }
+ public Boolean getAutoActive() {
+ return autoActive;
+ }
+ public void setAutoActive(Boolean autoActive) {
+ this.autoActive = autoActive;
+ }
+ public Boolean getSelected() {
+ return selected;
+ }
+ public void setSelected(Boolean selected) {
+ this.selected = selected;
+ }
+ public ProfileState getActivationState() {
+ return activationState;
+ }
+ public void setActivationState(ProfileState activationState) {
+ this.activationState = activationState;
+ }
+ public String getSource() {
+ return source;
+ }
+ public void setSource(String source) {
+ this.source = source;
+ }
+}
Modified: trunk/maven/plugins/org.jboss.tools.maven.ui/src/org/jboss/tools/maven/ui/internal/profiles/ProfileSelectionHandler.java
===================================================================
--- trunk/maven/plugins/org.jboss.tools.maven.ui/src/org/jboss/tools/maven/ui/internal/profiles/ProfileSelectionHandler.java 2011-07-18 12:16:44 UTC (rev 33010)
+++ trunk/maven/plugins/org.jboss.tools.maven.ui/src/org/jboss/tools/maven/ui/internal/profiles/ProfileSelectionHandler.java 2011-07-18 13:15:17 UTC (rev 33011)
@@ -1,11 +1,23 @@
+/*************************************************************************************
+ * Copyright (c) 2009-2011 Red Hat, Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * JBoss by Red Hat - Initial implementation.
+ ************************************************************************************/
package org.jboss.tools.maven.ui.internal.profiles;
+import java.util.ArrayList;
+import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
+import java.util.List;
import java.util.Map;
import java.util.Set;
-import org.apache.maven.model.Profile;
import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
@@ -30,6 +42,8 @@
import org.eclipse.ui.handlers.HandlerUtil;
import org.jboss.tools.maven.core.MavenCoreActivator;
import org.jboss.tools.maven.core.profiles.IProfileManager;
+import org.jboss.tools.maven.core.profiles.ProfileState;
+import org.jboss.tools.maven.core.profiles.ProfileStatus;
import org.jboss.tools.maven.ui.Activator;
import org.jboss.tools.maven.ui.Messages;
@@ -49,36 +63,89 @@
System.out.print("Select projects "+facades);
final IProfileManager profileManager = MavenCoreActivator.getDefault().getProfileManager();
-
- Map<Profile, Boolean> availableProfiles;
- Map<Profile, Boolean> availableSettingsProfiles;
- final IMavenProjectFacade facade = facades.iterator().next();
+ final List<ProfileSelection> sharedProfiles;
+ final Map<IMavenProjectFacade, List<ProfileStatus>> allProfiles;
try {
- availableProfiles = profileManager.getAvailableProfiles(facade);
-
- availableSettingsProfiles = profileManager.getAvailableSettingProfiles();
-
+ allProfiles = getAllProfiles(facades, profileManager);
+ sharedProfiles = getSharedProfiles(allProfiles);
} catch (CoreException e) {
throw new ExecutionException("Unable to open the Maven Profile selection dialog", e);
}
final SelectProfilesDialog dialog = new SelectProfilesDialog(window.getShell(),
- facade,
- availableProfiles,
- availableSettingsProfiles);
+ facades,
+ sharedProfiles);
if(dialog.open() == Window.OK) {
+
WorkspaceJob job = new WorkspaceJob(Messages.ProfileManager_Updating_maven_profiles) {
public IStatus runInWorkspace(IProgressMonitor monitor) {
try {
-
- profileManager.updateActiveProfiles(facade, dialog.getSelectedProfiles(),
+
+ for (Map.Entry<IMavenProjectFacade, List<ProfileStatus>> entry : allProfiles.entrySet()){
+
+ IMavenProjectFacade facade = entry.getKey();
+ List<String> activeProfiles = getActiveProfiles(sharedProfiles, entry.getValue());
+
+ profileManager.updateActiveProfiles(facade, activeProfiles,
dialog.isOffline(), dialog.isForceUpdate(), monitor);
+ }
} catch (CoreException ex) {
Activator.log(ex);
return ex.getStatus();
}
return Status.OK_STATUS;
}
+
+ private List<String> getActiveProfiles(
+ List<ProfileSelection> sharedProfiles,
+ List<ProfileStatus> availableProfiles) {
+ List<String> ids = new ArrayList<String>();
+
+ for (ProfileStatus st : availableProfiles) {
+ ProfileSelection selection = findSelectedProfile(st.getId(), sharedProfiles);
+ String id = null;
+ boolean isDisabled = false;
+ if (selection == null) {
+ //was not displayed. Use existing value.
+ if (st.isUserSelected()) {
+ id = st.getId();
+ isDisabled = st.getActivationState().equals(ProfileState.Disabled);
+ }
+ } else {
+ if (null == selection.getSelected()) {
+ //Value was displayed but its state is unknown, use previous state
+ if (st.isUserSelected()) {
+ id = st.getId();
+ isDisabled = st.getActivationState().equals(ProfileState.Disabled);
+ }
+ } else {
+ //Value was displayed and is consistent
+ if (Boolean.TRUE.equals(selection.getSelected())) {
+ id = st.getId();
+ isDisabled = st.getActivationState().equals(ProfileState.Disabled);
+ }
+ }
+ }
+
+ if (id != null) {
+ if (isDisabled) {
+ id = "!"+id;
+ }
+ ids.add(id);
+ }
+ }
+ return ids;
+ }
+
+ private ProfileSelection findSelectedProfile(String id,
+ List<ProfileSelection> sharedProfiles) {
+ for (ProfileSelection sel : sharedProfiles) {
+ if (id.equals(sel.getId())) {
+ return sel;
+ }
+ }
+ return null;
+ }
};
job.setRule( MavenPlugin.getProjectConfigurationManager().getRule());
job.schedule();
@@ -87,6 +154,86 @@
return null;
}
+ private List<ProfileSelection> getSharedProfiles(
+ Map<IMavenProjectFacade, List<ProfileStatus>> projectProfilesMap) {
+
+ List<ProfileStatus> currentSelection = null;
+ List<List<ProfileStatus>> projectProfiles = new ArrayList<List<ProfileStatus>>(projectProfilesMap.values());
+ int smallestSize = Integer.MAX_VALUE;
+ for(List<ProfileStatus> profiles : projectProfiles ){
+ int size = profiles.size();
+ if (size < smallestSize) {
+ smallestSize = size;
+ currentSelection = profiles;
+ }
+ }
+ projectProfiles.remove(currentSelection);
+
+ //Init the smallest profiles selection possible
+ List<ProfileSelection> selection = new ArrayList<ProfileSelection>();
+ for(ProfileStatus p : currentSelection) {
+ ProfileSelection ps = new ProfileSelection();
+ ps.setId(p.getId());
+ ps.setActivationState(p.getActivationState());
+ ps.setAutoActive(p.isAutoActive());
+ ps.setSource(p.getSource());
+ ps.setSelected(p.isUserSelected());
+ selection.add(ps);
+ }
+
+ if (!projectProfiles.isEmpty()) {
+ //Restrict to the common profiles only
+ Iterator<ProfileSelection> ite = selection.iterator();
+
+ while (ite.hasNext()) {
+ ProfileSelection p = ite.next();
+ for (List<ProfileStatus> statuses : projectProfiles) {
+ ProfileStatus s = hasProfile(p.getId(), statuses);
+ if (s == null) {
+ //remove any non-common profile selection
+ ite.remove();
+ break;
+ }
+ //reset non common settings
+ if (p.getAutoActive() != null && !p.getAutoActive().equals(s.isAutoActive())) {
+ p.setAutoActive(null);
+ }
+ if (p.getSource() != null && !p.getSource().equals(s.getSource())) {
+ p.setSource(null);
+ }
+ if (p.getSelected() != null && !p.getSelected().equals(s.isUserSelected())) {
+ p.setSelected(null);
+ }
+ if (p.getActivationState() != null && !p.getActivationState().equals(s.getActivationState())){
+ p.setActivationState(null);
+ p.setAutoActive(null);
+ }
+ }
+ }
+ }
+
+ return selection;
+ }
+
+ private ProfileStatus hasProfile(String id, List<ProfileStatus> statuses) {
+ for (ProfileStatus p : statuses){
+ if (id.equals(p.getId())){
+ return p;
+ }
+ }
+ return null;
+ }
+
+ private Map<IMavenProjectFacade, List<ProfileStatus>> getAllProfiles(final Set<IMavenProjectFacade> facades,
+ final IProfileManager profileManager) throws CoreException {
+ Map<IMavenProjectFacade, List<ProfileStatus>> allProfiles =
+ new HashMap<IMavenProjectFacade, List<ProfileStatus>>(facades.size());
+ for (IMavenProjectFacade facade : facades) {
+ allProfiles.put(facade, profileManager.getProfilesStatuses(facade));
+ }
+ return allProfiles;
+ }
+
/**
* Returns an IMavenProjectFacade from the selected IResource, or from the active editor
* @param event
Added: trunk/maven/plugins/org.jboss.tools.maven.ui/src/org/jboss/tools/maven/ui/internal/profiles/ProfileSelectionStatus.java
===================================================================
--- trunk/maven/plugins/org.jboss.tools.maven.ui/src/org/jboss/tools/maven/ui/internal/profiles/ProfileSelectionStatus.java (rev 0)
+++ trunk/maven/plugins/org.jboss.tools.maven.ui/src/org/jboss/tools/maven/ui/internal/profiles/ProfileSelectionStatus.java 2011-07-18 13:15:17 UTC (rev 33011)
@@ -0,0 +1,15 @@
+/*************************************************************************************
+ * Copyright (c) 2009-2011 Red Hat, Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * JBoss by Red Hat - Initial implementation.
+ ************************************************************************************/
+package org.jboss.tools.maven.ui.internal.profiles;
+
+public enum ProfileSelectionStatus {
+ Undefined, Inactivated, Activated, Disabled
+}
Modified: trunk/maven/plugins/org.jboss.tools.maven.ui/src/org/jboss/tools/maven/ui/internal/profiles/SelectProfilesDialog.java
===================================================================
--- trunk/maven/plugins/org.jboss.tools.maven.ui/src/org/jboss/tools/maven/ui/internal/profiles/SelectProfilesDialog.java 2011-07-18 12:16:44 UTC (rev 33010)
+++ trunk/maven/plugins/org.jboss.tools.maven.ui/src/org/jboss/tools/maven/ui/internal/profiles/SelectProfilesDialog.java 2011-07-18 13:15:17 UTC (rev 33011)
@@ -1,29 +1,28 @@
-/*******************************************************************************
- * Copyright (c) 2011 Sonatype, Inc.
- * All rights reserved. This program and the accompanying materials
+/*************************************************************************************
+ * Copyright (c) 2009-2011 Red Hat, Inc. and others.
+ * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
- *
+ *
* Contributors:
- * Sonatype, Inc. - initial API and implementation
- *******************************************************************************/
+ * JBoss by Red Hat - Initial implementation.
+ ************************************************************************************/
package org.jboss.tools.maven.ui.internal.profiles;
-import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
+import java.util.Set;
-import org.apache.maven.model.Profile;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.action.IMenuListener;
import org.eclipse.jface.action.IMenuManager;
import org.eclipse.jface.action.MenuManager;
import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jface.dialogs.TitleAreaDialog;
+import org.eclipse.jface.viewers.CheckStateChangedEvent;
import org.eclipse.jface.viewers.CheckboxTableViewer;
+import org.eclipse.jface.viewers.ICheckStateListener;
import org.eclipse.jface.viewers.IStructuredContentProvider;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.ITableColorProvider;
@@ -33,8 +32,6 @@
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.m2e.core.MavenPlugin;
import org.eclipse.m2e.core.project.IMavenProjectFacade;
-import org.eclipse.m2e.core.project.IProjectConfigurationManager;
-import org.eclipse.m2e.core.project.ResolverConfiguration;
import org.eclipse.osgi.util.NLS;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionEvent;
@@ -54,6 +51,7 @@
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Table;
import org.eclipse.swt.widgets.TableColumn;
+import org.jboss.tools.maven.core.profiles.ProfileState;
import org.jboss.tools.maven.ui.Messages;
public class SelectProfilesDialog extends TitleAreaDialog implements
@@ -66,41 +64,22 @@
private Button offlineModeBtn;
private Button forceUpdateBtn;
- private final IMavenProjectFacade facade;
-
- private List<Map.Entry<Profile, Boolean>> availableProfiles;
- private List<String> initialInactiveProfileIds = new ArrayList<String>();
- private List<String> initialActiveProfileIds = new ArrayList<String>();
- private List<String> inactiveProfileIds = new ArrayList<String>();
- private List<String> selectedProfiles;
-
private boolean offlineMode ;
private boolean forceUpdate;
- public SelectProfilesDialog(Shell parentShell, IMavenProjectFacade facade,
- Map<Profile, Boolean> availableProjectProfiles,
- Map<Profile, Boolean> availableSettingsProfiles) {
+ List<ProfileSelection> sharedProfiles;
+ Set<IMavenProjectFacade> facades;
+ IMavenProjectFacade facade;
+
+ public SelectProfilesDialog(Shell parentShell, Set<IMavenProjectFacade> facades,
+ List<ProfileSelection> sharedProfiles) {
super(parentShell);
-
- this.facade = facade;
-
- availableProfiles = new ArrayList<Map.Entry<Profile, Boolean>>(availableProjectProfiles.entrySet());
- availableProfiles.addAll(availableSettingsProfiles.entrySet());
-
offlineMode = MavenPlugin.getMavenConfiguration().isOffline();
-
- final IProjectConfigurationManager configurationManager = MavenPlugin
- .getProjectConfigurationManager();
- final ResolverConfiguration configuration = configurationManager
- .getResolverConfiguration(facade.getProject());
- for (String p : configuration.getActiveProfileList()) {
- if (p.startsWith("!")) { //$NON-NLS-1$
- initialInactiveProfileIds.add(p.substring(1));
- } else {
- initialActiveProfileIds.add(p);
- }
+ this.facades = facades;
+ if(facades.size() == 1){
+ facade = facades.iterator().next();
}
- inactiveProfileIds.addAll(initialInactiveProfileIds);
+ this.sharedProfiles = sharedProfiles;
}
@Override
@@ -127,19 +106,34 @@
container.setLayoutData(new GridData(GridData.FILL_BOTH));
setTitle(Messages.SelectProfilesDialog_Maven_profile_selection);
- setMessage(NLS.bind(
- Messages.SelectProfilesDialog_Select_the_active_Maven_profiles,
- facade.getProject().getName()));
+ String text;
+ if (facade == null) {
+ text = "Select the active profiles for selected projects";
+ } else {
+ text = NLS.bind(
+ Messages.SelectProfilesDialog_Select_the_active_Maven_profiles,
+ facade.getProject().getName());
+ }
+ setMessage(text);
- boolean hasProfiles = !availableProfiles.isEmpty();
+ boolean hasProfiles = !sharedProfiles.isEmpty();
Label lblAvailable = new Label(container, SWT.NONE);
String textLabel;
if (hasProfiles) {
- textLabel = Messages.SelectProfilesDialog_Available_profiles;
+ if (facade == null) {
+ textLabel = "Common profiles for selected projects";
+ } else {
+ textLabel = Messages.SelectProfilesDialog_Available_profiles;
+ }
} else {
- textLabel = Messages.SelectProfilesDialog_Project_has_no_available_profiles;
+ if (facade == null) {
+ textLabel = "There are no common profiles for the selected projects";
+ } else {
+ textLabel =
+ NLS.bind(Messages.SelectProfilesDialog_Project_has_no_available_profiles, facade.getProject().getName());
+ }
}
- lblAvailable.setText(NLS.bind(textLabel, facade.getProject().getName()));
+ lblAvailable.setText(textLabel);
lblAvailable.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true,
false, 2, 1));
@@ -187,7 +181,22 @@
profileTableViewer.setLabelProvider(new ProfileLabelProvider(parent
.getFont()));
- profileTableViewer.setInput(availableProfiles);
+
+ profileTableViewer.addCheckStateListener(new ICheckStateListener() {
+
+ public void checkStateChanged(CheckStateChangedEvent event) {
+ ProfileSelection profile = (ProfileSelection) event.getElement();
+ if (profileTableViewer.getGrayed(profile)) {
+ profileTableViewer.setGrayed(profile, false);
+ }
+ profile.setSelected(profileTableViewer.getChecked(profile));
+ if (profile.getActivationState() == null) {
+ profile.setActivationState(ProfileState.Active);
+ }
+ }
+ });
+
+ profileTableViewer.setInput(sharedProfiles);
addSelectionButton(container, Messages.SelectProfilesDialog_SelectAll, true);
@@ -220,8 +229,14 @@
button.setText(label);
button.addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent e) {
- for (Map.Entry<Profile, Boolean> entry : availableProfiles) {
- profileTableViewer.setChecked(entry, ischecked);
+ profileTableViewer.setAllGrayed(false);
+ for (ProfileSelection profile : sharedProfiles) {
+ profileTableViewer.setChecked(profile, ischecked);
+
+ profile.setSelected(profileTableViewer.getChecked(profile));
+ if (profile.getActivationState() == null) {
+ profile.setActivationState(ProfileState.Active);
+ }
}
}
@@ -233,19 +248,6 @@
return button;
}
- @SuppressWarnings("unchecked")
- private Map.Entry<Profile, Boolean> getEntry(Object o) {
- if (o instanceof Map.Entry<?, ?>) {
- return (Map.Entry<Profile, Boolean>) o;
- }
- return null;
- }
-
- private boolean isDeactivated(Entry<Profile, Boolean> entry) {
- return entry != null
- && inactiveProfileIds.contains(entry.getKey().getId());
- }
-
@Override
protected void createButtonsForButtonBar(Composite parent) {
if (profileTableViewer != null) {
@@ -257,20 +259,8 @@
@Override
protected void okPressed() {
if (profileTableViewer != null) {
- Object[] obj = profileTableViewer.getCheckedElements();
- List<String> selectedProfiles = new ArrayList<String>(obj.length);
- for (int i = 0; i < obj.length; i++) {
- @SuppressWarnings("unchecked")
- Map.Entry<Profile, Boolean> entry = (Map.Entry<Profile, Boolean>) obj[i];
- String id = entry.getKey().getId();
- if (isDeactivated(entry)) {
- selectedProfiles.add("!" + id); //$NON-NLS-1$
- } else {
- selectedProfiles.add(id);
- }
- }
- this.selectedProfiles = selectedProfiles;
-
+ //Object[] obj = profileTableViewer.getCheckedElements();
+ //for (int i = 0; i < obj.length; i++) {}
offlineMode = offlineModeBtn.getSelection();
forceUpdate = forceUpdateBtn.getSelection();
}
@@ -285,11 +275,14 @@
profileTableViewer.getControl().setMenu(contextMenu);
menuMgr.setRemoveAllWhenShown(true);
- for (Map.Entry<Profile, Boolean> entry : availableProfiles) {
- String id = entry.getKey().getId();
- boolean isSelected = initialActiveProfileIds.contains(id)
- || inactiveProfileIds.contains(id);
- profileTableViewer.setChecked(entry, isSelected);
+ for (ProfileSelection p : sharedProfiles) {
+ Boolean selected = p.getSelected();
+ if (selected ==null || p.getActivationState() == null) {
+ profileTableViewer.setGrayed(p, true);
+ profileTableViewer.setChecked(p, true);
+ } else if(selected != null) {
+ profileTableViewer.setChecked(p, selected );
+ }
}
}
@@ -299,44 +292,53 @@
IStructuredSelection selection = (IStructuredSelection) profileTableViewer
.getSelection();
if (!selection.isEmpty()) {
- final Map.Entry<Profile, Boolean> entry = getEntry(selection.getFirstElement());
- final boolean isDeactivated = isDeactivated(entry);
-
- if (isDeactivated) {
- inactiveProfileIds.remove(entry.getKey().getId());
- } else {
- inactiveProfileIds.add(entry.getKey().getId());
- profileTableViewer.setChecked(entry, true);
- }
+ final ProfileSelection entry = (ProfileSelection) selection.getFirstElement();
+ entry.setActivationState(ProfileState.Active);
+ profileTableViewer.setChecked(entry, true);
+ profileTableViewer.setGrayed(entry, false);
profileTableViewer.refresh();
}
super.run();
}
};
+ final Action deActivationAction = new Action("") { //$NON-NLS-1$
+ @Override
+ public void run() {
+ IStructuredSelection selection = (IStructuredSelection) profileTableViewer
+ .getSelection();
+ if (!selection.isEmpty()) {
+ final ProfileSelection entry = (ProfileSelection) selection.getFirstElement();
+ entry.setActivationState(ProfileState.Disabled);
+ profileTableViewer.setChecked(entry, true);
+ profileTableViewer.setGrayed(entry, false);
+ profileTableViewer.refresh();
+ }
+ super.run();
+ }
+ };
+
public void menuAboutToShow(IMenuManager manager) {
IStructuredSelection selection = (IStructuredSelection) profileTableViewer
.getSelection();
if (!selection.isEmpty()) {
- final Map.Entry<Profile, Boolean> entry = getEntry(selection
- .getFirstElement());
- final boolean isDeactivated = isDeactivated(entry);
- String text;
- if (isDeactivated) {
+ final ProfileSelection entry = (ProfileSelection) selection.getFirstElement();
+ String text = "";
+ ProfileState state = entry.getActivationState();
+ if ( state == null || state.equals(ProfileState.Disabled)) {
text = Messages.SelectProfilesDialog_Activate_menu;
- } else {
+ activationAction.setText(NLS.bind(text, entry.getId()));
+ manager.add(activationAction);
+ }
+ if( !ProfileState.Disabled.equals(state)) {
text = Messages.SelectProfilesDialog_Deactivate_menu;
+ deActivationAction.setText(NLS.bind(text, entry.getId()));
+ manager.add(deActivationAction);
}
- activationAction.setText(NLS.bind(text, entry.getKey().getId()));
- manager.add(activationAction);
}
}
- public List<String> getSelectedProfiles() {
- return selectedProfiles;
- }
-
public boolean isOffline() {
return offlineMode;
}
@@ -362,9 +364,9 @@
}
public Font getFont(Object element, int columnIndex) {
- Entry<Profile, Boolean> entry = getEntry(element);
+ ProfileSelection entry = (ProfileSelection) element;
Font font = null;
- if (entry != null && Boolean.TRUE.equals(entry.getValue())
+ if (Boolean.TRUE.equals(entry.getAutoActive())
&& PROFILE_ID_COLUMN == columnIndex) {
font = implicitActivationFont;
}
@@ -372,8 +374,8 @@
}
public Color getForeground(Object element, int columnIndex) {
- Entry<Profile, Boolean> entry = getEntry(element);
- if (isDeactivated(entry)) {
+ ProfileSelection entry = (ProfileSelection) element;
+ if (ProfileState.Disabled.equals(entry.getActivationState())) {
return inactiveColor;
}
return null;
@@ -388,20 +390,20 @@
}
public String getColumnText(Object element, int columnIndex) {
- Entry<Profile, Boolean> entry = getEntry(element);
+ ProfileSelection entry = (ProfileSelection) element;
StringBuilder text = new StringBuilder();
if (entry != null) {
- boolean isDeactivated = isDeactivated(entry);
- Profile profile = entry.getKey();
if (columnIndex == PROFILE_ID_COLUMN) {
- text.append(profile.getId());
- if (isDeactivated) {
+ text.append(entry.getId());
+
+ ProfileState state = entry.getActivationState();
+ if (state == ProfileState.Disabled) {
text.append(Messages.SelectProfilesDialog_deactivated);
- } else if (Boolean.TRUE.equals(entry.getValue())) {
+ } else if (Boolean.TRUE.equals(entry.getAutoActive())) {
text.append(Messages.SelectProfilesDialog_autoactivated);
}
} else if (columnIndex == SOURCE_COLUMN) {
- text.append(profile.getSource());
+ text.append(entry.getSource());
}
}
return text.toString();
14 years, 9 months
JBoss Tools SVN: r33010 - trunk/seam/tests/org.jboss.tools.seam.ui.bot.test/src/org/jboss/tools/seam/ui/bot/test/examples.
by jbosstools-commits@lists.jboss.org
Author: lzoubek(a)redhat.com
Date: 2011-07-18 08:16:44 -0400 (Mon, 18 Jul 2011)
New Revision: 33010
Modified:
trunk/seam/tests/org.jboss.tools.seam.ui.bot.test/src/org/jboss/tools/seam/ui/bot/test/examples/DVDStore22EAR.java
Log:
JBQA-4798: forgotten sleep
Modified: trunk/seam/tests/org.jboss.tools.seam.ui.bot.test/src/org/jboss/tools/seam/ui/bot/test/examples/DVDStore22EAR.java
===================================================================
--- trunk/seam/tests/org.jboss.tools.seam.ui.bot.test/src/org/jboss/tools/seam/ui/bot/test/examples/DVDStore22EAR.java 2011-07-18 12:11:16 UTC (rev 33009)
+++ trunk/seam/tests/org.jboss.tools.seam.ui.bot.test/src/org/jboss/tools/seam/ui/bot/test/examples/DVDStore22EAR.java 2011-07-18 12:16:44 UTC (rev 33010)
@@ -4,15 +4,10 @@
import org.jboss.tools.ui.bot.ext.config.Annotations.Seam;
import org.jboss.tools.ui.bot.ext.config.Annotations.Server;
import org.jboss.tools.ui.bot.ext.config.Annotations.ServerState;
-import org.junit.AfterClass;
@SWTBotTestRequires(server=@Server(state=ServerState.Running),seam=(a)Seam(version="2.2"))
public class DVDStore22EAR extends SeamExample {
- @AfterClass
- public static void time() {
- bot.sleep(Long.MAX_VALUE);
- }
@Override
public String[] getProjectNames() {
return new String[] {"dvdstore22","dvdstore22-ear","dvdstore22-ejb","dvdstore22-test"};
14 years, 9 months
JBoss Tools SVN: r33009 - in trunk/seam/tests/org.jboss.tools.seam.ui.bot.test: src/org/jboss/tools/seam/ui/bot/test and 1 other directories.
by jbosstools-commits@lists.jboss.org
Author: lzoubek(a)redhat.com
Date: 2011-07-18 08:11:16 -0400 (Mon, 18 Jul 2011)
New Revision: 33009
Added:
trunk/seam/tests/org.jboss.tools.seam.ui.bot.test/src/org/jboss/tools/seam/ui/bot/test/examples/
trunk/seam/tests/org.jboss.tools.seam.ui.bot.test/src/org/jboss/tools/seam/ui/bot/test/examples/Booking22EAR.java
trunk/seam/tests/org.jboss.tools.seam.ui.bot.test/src/org/jboss/tools/seam/ui/bot/test/examples/DVDStore22EAR.java
trunk/seam/tests/org.jboss.tools.seam.ui.bot.test/src/org/jboss/tools/seam/ui/bot/test/examples/SeamExample.java
Modified:
trunk/seam/tests/org.jboss.tools.seam.ui.bot.test/META-INF/MANIFEST.MF
Log:
seam bot tests: added booking and dvdstore project example tests
Modified: trunk/seam/tests/org.jboss.tools.seam.ui.bot.test/META-INF/MANIFEST.MF
===================================================================
--- trunk/seam/tests/org.jboss.tools.seam.ui.bot.test/META-INF/MANIFEST.MF 2011-07-18 11:53:03 UTC (rev 33008)
+++ trunk/seam/tests/org.jboss.tools.seam.ui.bot.test/META-INF/MANIFEST.MF 2011-07-18 12:11:16 UTC (rev 33009)
@@ -18,3 +18,4 @@
Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Bundle-Vendor: JBoss by Red Hat
+Export-Package: org.jboss.tools.seam.ui.bot.test.examples
Added: trunk/seam/tests/org.jboss.tools.seam.ui.bot.test/src/org/jboss/tools/seam/ui/bot/test/examples/Booking22EAR.java
===================================================================
--- trunk/seam/tests/org.jboss.tools.seam.ui.bot.test/src/org/jboss/tools/seam/ui/bot/test/examples/Booking22EAR.java (rev 0)
+++ trunk/seam/tests/org.jboss.tools.seam.ui.bot.test/src/org/jboss/tools/seam/ui/bot/test/examples/Booking22EAR.java 2011-07-18 12:11:16 UTC (rev 33009)
@@ -0,0 +1,26 @@
+package org.jboss.tools.seam.ui.bot.test.examples;
+
+import org.jboss.tools.ui.bot.ext.config.Annotations.SWTBotTestRequires;
+import org.jboss.tools.ui.bot.ext.config.Annotations.Seam;
+import org.jboss.tools.ui.bot.ext.config.Annotations.Server;
+import org.jboss.tools.ui.bot.ext.config.Annotations.ServerState;
+
+@SWTBotTestRequires(server=@Server(state=ServerState.Running),seam=(a)Seam(version="2.2"))
+public class Booking22EAR extends SeamExample {
+
+ @Override
+ public String[] getProjectNames() {
+ return new String[] {"booking22","booking22-ear","booking22-ejb","booking22-test"};
+ }
+
+ @Override
+ public String getExampleName() {
+ return "Seam 2.2 Booking Example - EAR (including a tutorial)";
+ }
+ @Override
+ protected void executeExample() {
+ runExample();
+ checkDeployment("http://localhost:8080/booking22/home.seam","About this example application");
+ execSeamTestNG(getProjectNames()[getProjectNames().length-1], "testngjdk6.launch", "testngjdk6");
+ }
+}
Added: trunk/seam/tests/org.jboss.tools.seam.ui.bot.test/src/org/jboss/tools/seam/ui/bot/test/examples/DVDStore22EAR.java
===================================================================
--- trunk/seam/tests/org.jboss.tools.seam.ui.bot.test/src/org/jboss/tools/seam/ui/bot/test/examples/DVDStore22EAR.java (rev 0)
+++ trunk/seam/tests/org.jboss.tools.seam.ui.bot.test/src/org/jboss/tools/seam/ui/bot/test/examples/DVDStore22EAR.java 2011-07-18 12:11:16 UTC (rev 33009)
@@ -0,0 +1,30 @@
+package org.jboss.tools.seam.ui.bot.test.examples;
+
+import org.jboss.tools.ui.bot.ext.config.Annotations.SWTBotTestRequires;
+import org.jboss.tools.ui.bot.ext.config.Annotations.Seam;
+import org.jboss.tools.ui.bot.ext.config.Annotations.Server;
+import org.jboss.tools.ui.bot.ext.config.Annotations.ServerState;
+import org.junit.AfterClass;
+
+@SWTBotTestRequires(server=@Server(state=ServerState.Running),seam=(a)Seam(version="2.2"))
+public class DVDStore22EAR extends SeamExample {
+
+ @AfterClass
+ public static void time() {
+ bot.sleep(Long.MAX_VALUE);
+ }
+ @Override
+ public String[] getProjectNames() {
+ return new String[] {"dvdstore22","dvdstore22-ear","dvdstore22-ejb","dvdstore22-test"};
+ }
+ @Override
+ public String getExampleName() {
+ return "Seam 2.2 DVD Store Example - EAR (including a test project)";
+ }
+ @Override
+ protected void executeExample() {
+ runExample();
+ checkDeployment("http://localhost:8080/dvdstore22/home","Welcome to the DVD Store");
+ execSeamTestNG(getProjectNames()[getProjectNames().length-1], "testngjdk6.launch", "testngjdk6");
+ }
+}
Added: trunk/seam/tests/org.jboss.tools.seam.ui.bot.test/src/org/jboss/tools/seam/ui/bot/test/examples/SeamExample.java
===================================================================
--- trunk/seam/tests/org.jboss.tools.seam.ui.bot.test/src/org/jboss/tools/seam/ui/bot/test/examples/SeamExample.java (rev 0)
+++ trunk/seam/tests/org.jboss.tools.seam.ui.bot.test/src/org/jboss/tools/seam/ui/bot/test/examples/SeamExample.java 2011-07-18 12:11:16 UTC (rev 33009)
@@ -0,0 +1,98 @@
+package org.jboss.tools.seam.ui.bot.test.examples;
+
+import org.eclipse.swt.widgets.MenuItem;
+import org.eclipse.swtbot.swt.finder.SWTBot;
+import org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException;
+import org.eclipse.swtbot.swt.finder.finders.UIThreadRunnable;
+import org.eclipse.swtbot.swt.finder.results.WidgetResult;
+import org.eclipse.swtbot.swt.finder.utils.SWTBotPreferences;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotBrowser;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotCLabel;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotMenu;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem;
+import org.jboss.tools.ui.bot.ext.ExampleTest;
+import org.jboss.tools.ui.bot.ext.SWTTestExt;
+import org.jboss.tools.ui.bot.ext.Timing;
+import org.jboss.tools.ui.bot.ext.helper.ContextMenuHelper;
+import org.jboss.tools.ui.bot.ext.types.IDELabel;
+
+public class SeamExample extends ExampleTest {
+
+ @Override
+ public String getExampleCategory() {
+ return "Seam";
+ }
+ protected void runExample() {
+ util.waitForNonIgnoredJobs(Timing.time100S());// for project build
+ packageExplorer.runOnServer(getProjectNames()[0]);
+ util.waitForNonIgnoredJobs();//wait for publishing
+ bot.sleep(Timing.time20S());//wait for deployment
+ }
+ protected void checkDeployment(String url, String searchString) {
+ long delay = SWTBotPreferences.TIMEOUT;
+ SWTBotPreferences.TIMEOUT = delay * 4;
+ SWTBotBrowser b = bot.browser();
+ b.setUrl(url);
+ String page = b.getText();
+ SWTBotPreferences.TIMEOUT = delay;
+ assertTrue("Example was not successfully deployed, server returned :"+page,page.contains(searchString));
+ }
+
+ protected void execSeamTestNG(String project, String launchFile, String launchName){
+ runTestNG(project, launchFile, launchName);
+ SWTTestExt.util.waitForNonIgnoredJobs(Timing.time100S());
+ bot.sleep(Timing.time(30*1000));
+ SWTBot ngBot = bot.viewByTitle("Results of running suite").bot();
+ int k = 0;
+ SWTBotCLabel l = ngBot.clabel(k);
+
+ int passed = -1;
+ int failed = -1;
+ int skipped = -1;
+
+ while ( (passed < 0) || (failed < 0) || (skipped < 0) ) {
+ String txt = l.getText();
+ if (txt.startsWith("Passed")) passed = Integer.valueOf(txt.split(":")[1].trim());
+ if (txt.startsWith("Failed")) failed = Integer.valueOf(txt.split(":")[1].trim());
+ if (txt.startsWith("Skipped")) skipped = Integer.valueOf(txt.split(":")[1].trim());
+ k++;
+ l = ngBot.clabel(k);
+ }
+ assertTrue("Failed test(s).", failed == 0);
+ assertTrue("Skipped test(s).", skipped == 0);
+ assertTrue("No passing tests.", passed > 0);
+ }
+
+ private void runTestNG(String project, String launchFile, final String launchName) {
+ SWTBot viewBot = packageExplorer.bot();
+ packageExplorer.selectProject(project);
+ SWTBotTreeItem item = packageExplorer.selectTreeItem(launchFile, new String[] {project});
+ ContextMenuHelper.prepareTreeItemForContextMenu(viewBot.tree(), item);
+ final SWTBotMenu menuRunAs = viewBot.menu(IDELabel.Menu.RUN).menu(IDELabel.Menu.RUN_AS);
+ final MenuItem menuItem = UIThreadRunnable
+ .syncExec(new WidgetResult<MenuItem>() {
+ public MenuItem run() {
+ int menuItemIndex = 0;
+ MenuItem menuItem = null;
+ final MenuItem[] menuItems = menuRunAs.widget.getMenu().getItems();
+ while (menuItem == null && menuItemIndex < menuItems.length){
+ log.info("Found item" +menuItems[menuItemIndex].getText());
+ if (menuItems[menuItemIndex].getText().indexOf(launchName) > - 1){
+ menuItem = menuItems[menuItemIndex];
+ }
+ else{
+ menuItemIndex++;
+ }
+ }
+ return menuItem;
+ }
+ });
+ if (menuItem != null){
+ new SWTBotMenu(menuItem).click();
+ }
+ else{
+ throw new WidgetNotFoundException(String.format("Unable to find Menu Item with Label '%s'",launchName));
+ }
+
+ }
+}
14 years, 9 months
JBoss Tools SVN: r33008 - in trunk/forge/plugins/org.jboss.tools.forge.runtime.ext/org.jboss.tools.forge.runtime.ext: .settings and 1 other directories.
by jbosstools-commits@lists.jboss.org
Author: koen.aers(a)jboss.com
Date: 2011-07-18 07:53:03 -0400 (Mon, 18 Jul 2011)
New Revision: 33008
Added:
trunk/forge/plugins/org.jboss.tools.forge.runtime.ext/org.jboss.tools.forge.runtime.ext/.classpath
trunk/forge/plugins/org.jboss.tools.forge.runtime.ext/org.jboss.tools.forge.runtime.ext/.project
trunk/forge/plugins/org.jboss.tools.forge.runtime.ext/org.jboss.tools.forge.runtime.ext/.settings/
trunk/forge/plugins/org.jboss.tools.forge.runtime.ext/org.jboss.tools.forge.runtime.ext/.settings/org.eclipse.jdt.core.prefs
trunk/forge/plugins/org.jboss.tools.forge.runtime.ext/org.jboss.tools.forge.runtime.ext/META-INF/
trunk/forge/plugins/org.jboss.tools.forge.runtime.ext/org.jboss.tools.forge.runtime.ext/META-INF/MANIFEST.MF
trunk/forge/plugins/org.jboss.tools.forge.runtime.ext/org.jboss.tools.forge.runtime.ext/build.properties
trunk/forge/plugins/org.jboss.tools.forge.runtime.ext/org.jboss.tools.forge.runtime.ext/src/
Modified:
trunk/forge/plugins/org.jboss.tools.forge.runtime.ext/org.jboss.tools.forge.runtime.ext/
Log:
Property changes on: trunk/forge/plugins/org.jboss.tools.forge.runtime.ext/org.jboss.tools.forge.runtime.ext
___________________________________________________________________
Added: svn:ignore
+ bin
Added: trunk/forge/plugins/org.jboss.tools.forge.runtime.ext/org.jboss.tools.forge.runtime.ext/.classpath
===================================================================
--- trunk/forge/plugins/org.jboss.tools.forge.runtime.ext/org.jboss.tools.forge.runtime.ext/.classpath (rev 0)
+++ trunk/forge/plugins/org.jboss.tools.forge.runtime.ext/org.jboss.tools.forge.runtime.ext/.classpath 2011-07-18 11:53:03 UTC (rev 33008)
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
Added: trunk/forge/plugins/org.jboss.tools.forge.runtime.ext/org.jboss.tools.forge.runtime.ext/.project
===================================================================
--- trunk/forge/plugins/org.jboss.tools.forge.runtime.ext/org.jboss.tools.forge.runtime.ext/.project (rev 0)
+++ trunk/forge/plugins/org.jboss.tools.forge.runtime.ext/org.jboss.tools.forge.runtime.ext/.project 2011-07-18 11:53:03 UTC (rev 33008)
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.jboss.tools.forge.runtime.ext</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
Added: trunk/forge/plugins/org.jboss.tools.forge.runtime.ext/org.jboss.tools.forge.runtime.ext/.settings/org.eclipse.jdt.core.prefs
===================================================================
--- trunk/forge/plugins/org.jboss.tools.forge.runtime.ext/org.jboss.tools.forge.runtime.ext/.settings/org.eclipse.jdt.core.prefs (rev 0)
+++ trunk/forge/plugins/org.jboss.tools.forge.runtime.ext/org.jboss.tools.forge.runtime.ext/.settings/org.eclipse.jdt.core.prefs 2011-07-18 11:53:03 UTC (rev 33008)
@@ -0,0 +1,8 @@
+#Mon Jul 18 13:48:41 CEST 2011
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
+org.eclipse.jdt.core.compiler.compliance=1.6
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.6
Added: trunk/forge/plugins/org.jboss.tools.forge.runtime.ext/org.jboss.tools.forge.runtime.ext/META-INF/MANIFEST.MF
===================================================================
--- trunk/forge/plugins/org.jboss.tools.forge.runtime.ext/org.jboss.tools.forge.runtime.ext/META-INF/MANIFEST.MF (rev 0)
+++ trunk/forge/plugins/org.jboss.tools.forge.runtime.ext/org.jboss.tools.forge.runtime.ext/META-INF/MANIFEST.MF 2011-07-18 11:53:03 UTC (rev 33008)
@@ -0,0 +1,6 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: Ext
+Bundle-SymbolicName: org.jboss.tools.forge.runtime.ext
+Bundle-Version: 1.0.0.qualifier
+Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Added: trunk/forge/plugins/org.jboss.tools.forge.runtime.ext/org.jboss.tools.forge.runtime.ext/build.properties
===================================================================
--- trunk/forge/plugins/org.jboss.tools.forge.runtime.ext/org.jboss.tools.forge.runtime.ext/build.properties (rev 0)
+++ trunk/forge/plugins/org.jboss.tools.forge.runtime.ext/org.jboss.tools.forge.runtime.ext/build.properties 2011-07-18 11:53:03 UTC (rev 33008)
@@ -0,0 +1,4 @@
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .
14 years, 9 months
JBoss Tools SVN: r33006 - trunk/forge/tests/org.jboss.tools.forge.ui.test.
by jbosstools-commits@lists.jboss.org
Author: koen.aers(a)jboss.com
Date: 2011-07-18 07:41:01 -0400 (Mon, 18 Jul 2011)
New Revision: 33006
Modified:
trunk/forge/tests/org.jboss.tools.forge.ui.test/
Log:
initial version of the test plugin for org.jboss.forge.ui
Property changes on: trunk/forge/tests/org.jboss.tools.forge.ui.test
___________________________________________________________________
Added: svn:ignore
+ bin
14 years, 9 months
JBoss Tools SVN: r33005 - in trunk/as/plugins: org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal and 3 other directories.
by jbosstools-commits@lists.jboss.org
Author: rob.stryker(a)jboss.com
Date: 2011-07-18 07:04:24 -0400 (Mon, 18 Jul 2011)
New Revision: 33005
Removed:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/v7/DelegatingJBoss7StartLaunchConfiguration.java
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/ExtensionManager.java
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/DelegatingServerBehavior.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/launch/DelegatingStartLaunchConfiguration.java
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/v7/DelegatingJBoss7ServerBehavior.java
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/v7/JBoss7ServerBehavior.java
trunk/as/plugins/org.jboss.ide.eclipse.as.rse.core/src/org/jboss/ide/eclipse/as/rse/core/RSECorePlugin.java
Log:
JBIDE-8960 - Unifying DelegatingJBoss7StartLaunchConfiguration and its super class
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/ExtensionManager.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/ExtensionManager.java 2011-07-18 11:00:38 UTC (rev 33004)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/ExtensionManager.java 2011-07-18 11:04:24 UTC (rev 33005)
@@ -30,6 +30,7 @@
import org.eclipse.wst.server.core.IModule;
import org.eclipse.wst.server.core.IServer;
import org.eclipse.wst.server.core.IServerType;
+import org.jboss.ide.eclipse.as.core.publishers.LocalPublishMethod;
import org.jboss.ide.eclipse.as.core.server.IJBossServerPublishMethodType;
import org.jboss.ide.eclipse.as.core.server.IJBossServerPublisher;
import org.jboss.ide.eclipse.as.core.server.IPollerFailureHandler;
@@ -37,6 +38,11 @@
import org.jboss.ide.eclipse.as.core.server.IServerStatePoller;
import org.jboss.ide.eclipse.as.core.server.internal.ServerPublishMethodType;
import org.jboss.ide.eclipse.as.core.server.internal.ServerStatePollerType;
+import org.jboss.ide.eclipse.as.core.server.internal.launch.IStartLaunchDelegate;
+import org.jboss.ide.eclipse.as.core.server.internal.launch.IStartLaunchSetupParticipant;
+import org.jboss.ide.eclipse.as.core.server.internal.launch.LocalJBossStartLaunchDelegate;
+import org.jboss.ide.eclipse.as.core.server.internal.v7.LocalJBoss7StartLaunchDelegate;
+import org.jboss.ide.eclipse.as.core.util.IJBossToolingConstants;
/**
* Manages the extensions for this plugin
@@ -331,4 +337,39 @@
defaultAlreadyStartedHandler = handler;
}
+
+ /**
+ * Temporary home for start launch setup participants and launch configs
+ * Should eventually be replaced by an extension point of some type
+ *
+ * TODO Convert this into a suitable fixed API
+ */
+ public static HashMap<String, IStartLaunchDelegate> JBoss7launchDelegates;
+ public static ArrayList<IStartLaunchSetupParticipant> JBoss7setupParticipants;
+ public static HashMap<String, IStartLaunchDelegate> JBossLaunchDelegates;
+ public static ArrayList<IStartLaunchSetupParticipant> JBossSetupParticipants;
+ static {
+ JBoss7setupParticipants = new ArrayList<IStartLaunchSetupParticipant>();
+ JBoss7launchDelegates = new HashMap<String, IStartLaunchDelegate>();
+ JBoss7setupParticipants.add(new LocalJBoss7StartLaunchDelegate());
+ JBoss7launchDelegates.put(LocalPublishMethod.LOCAL_PUBLISH_METHOD, new LocalJBoss7StartLaunchDelegate());
+
+ JBossSetupParticipants = new ArrayList<IStartLaunchSetupParticipant>();
+ JBossLaunchDelegates = new HashMap<String, IStartLaunchDelegate>();
+ JBossSetupParticipants.add(new LocalJBossStartLaunchDelegate());
+ JBossLaunchDelegates.put(LocalPublishMethod.LOCAL_PUBLISH_METHOD, new LocalJBossStartLaunchDelegate());
+ }
+ public HashMap<String, IStartLaunchDelegate> getLaunchDelegates(IServer server) {
+ if( server.getServerType().getId().equals(IJBossToolingConstants.SERVER_AS_70)) {
+ return JBoss7launchDelegates;
+ }
+ return JBossLaunchDelegates;
+ }
+ public ArrayList<IStartLaunchSetupParticipant> getSetupParticipants(IServer server) {
+ if( server.getServerType().getId().equals(IJBossToolingConstants.SERVER_AS_70)) {
+ return JBoss7setupParticipants;
+ }
+ return JBossSetupParticipants;
+ }
+
}
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/DelegatingServerBehavior.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/DelegatingServerBehavior.java 2011-07-18 11:00:38 UTC (rev 33004)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/DelegatingServerBehavior.java 2011-07-18 11:04:24 UTC (rev 33005)
@@ -98,7 +98,7 @@
* to participate?
*/
public void setupLaunchConfiguration(ILaunchConfigurationWorkingCopy workingCopy, IProgressMonitor monitor) throws CoreException {
- DelegatingStartLaunchConfiguration.setupLaunchConfiguration(workingCopy, getServer());
+ new DelegatingStartLaunchConfiguration().setupLaunchConfiguration(workingCopy, getServer());
}
public void setRunMode(String mode) {
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 2011-07-18 11:00:38 UTC (rev 33004)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/JBossServerBehavior.java 2011-07-18 11:04:24 UTC (rev 33005)
@@ -108,7 +108,7 @@
* to participate?
*/
public void setupLaunchConfiguration(ILaunchConfigurationWorkingCopy workingCopy, IProgressMonitor monitor) throws CoreException {
- DelegatingStartLaunchConfiguration.setupLaunchConfiguration(workingCopy, getServer());
+ new DelegatingStartLaunchConfiguration().setupLaunchConfiguration(workingCopy, getServer());
}
public void setRunMode(String mode) {
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/launch/DelegatingStartLaunchConfiguration.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/launch/DelegatingStartLaunchConfiguration.java 2011-07-18 11:00:38 UTC (rev 33004)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/launch/DelegatingStartLaunchConfiguration.java 2011-07-18 11:04:24 UTC (rev 33005)
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007 Red Hat, Inc.
+ * Copyright (c) 2011 Red Hat, Inc.
* Distributed under license by Red Hat, Inc. All rights reserved.
* This program is made available under the terms of the
* Eclipse Public License v1.0 which accompanies this distribution,
@@ -21,36 +21,24 @@
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
import org.eclipse.wst.server.core.IServer;
import org.eclipse.wst.server.core.ServerUtil;
-import org.jboss.ide.eclipse.as.core.publishers.LocalPublishMethod;
+import org.jboss.ide.eclipse.as.core.ExtensionManager;
import org.jboss.ide.eclipse.as.core.server.IJBossServerPublishMethodType;
import org.jboss.ide.eclipse.as.core.server.internal.DeployableServerBehavior;
import org.jboss.ide.eclipse.as.core.util.ServerConverter;
public class DelegatingStartLaunchConfiguration extends AbstractJBossStartLaunchConfiguration {
-
- private static HashMap<String, IStartLaunchDelegate> launchDelegates;
- private static ArrayList<IStartLaunchSetupParticipant> setupParticipants;
-
- static {
- setupParticipants = new ArrayList<IStartLaunchSetupParticipant>();
- setupParticipants.add(new LocalJBossStartLaunchDelegate());
- launchDelegates = new HashMap<String, IStartLaunchDelegate>();
- launchDelegates.put(LocalPublishMethod.LOCAL_PUBLISH_METHOD, new LocalJBossStartLaunchDelegate());
+ public ArrayList<IStartLaunchSetupParticipant> getSetupParticipants(IServer server) {
+ return ExtensionManager.getDefault().getSetupParticipants(server);
}
-
- public static void addLaunchDelegateMapping(String mode, IStartLaunchDelegate del) {
- launchDelegates.put(mode, del);
+ public HashMap<String, IStartLaunchDelegate> getLaunchDelegates(IServer server) {
+ return ExtensionManager.getDefault().getLaunchDelegates(server);
}
- public static void addSetupLaunchParticipant(IStartLaunchSetupParticipant participant) {
- setupParticipants.add(participant);
- }
-
// Allow all participants to set some defaults for their own details
// Participants should be careful not to change shared launch keys / values
// unless their operation mode (local / rse / etc) is in use
- public static void setupLaunchConfiguration(ILaunchConfigurationWorkingCopy workingCopy, IServer server) throws CoreException {
- for( Iterator<IStartLaunchSetupParticipant> i = setupParticipants.iterator(); i.hasNext(); ) {
+ public void setupLaunchConfiguration(ILaunchConfigurationWorkingCopy workingCopy, IServer server) throws CoreException {
+ for( Iterator<IStartLaunchSetupParticipant> i = getSetupParticipants(server).iterator(); i.hasNext(); ) {
i.next().setupLaunchConfiguration(workingCopy, server);
}
}
@@ -59,7 +47,7 @@
IServer server = ServerUtil.getServer(configuration);
DeployableServerBehavior beh = ServerConverter.getDeployableServerBehavior(server);
IJBossServerPublishMethodType type = beh.createPublishMethod().getPublishMethodType();
- return launchDelegates.get(type.getId());
+ return getLaunchDelegates(server).get(type.getId());
}
public void actualLaunch(ILaunchConfiguration configuration,
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/v7/DelegatingJBoss7ServerBehavior.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/v7/DelegatingJBoss7ServerBehavior.java 2011-07-18 11:00:38 UTC (rev 33004)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/v7/DelegatingJBoss7ServerBehavior.java 2011-07-18 11:04:24 UTC (rev 33005)
@@ -35,10 +35,10 @@
import org.jboss.ide.eclipse.as.core.publishers.LocalPublishMethod;
import org.jboss.ide.eclipse.as.core.publishers.PublishUtil;
import org.jboss.ide.eclipse.as.core.server.IDeployableServer;
-import org.jboss.ide.eclipse.as.core.server.IJBoss7ManagerService;
import org.jboss.ide.eclipse.as.core.server.IJBossServerPublishMethod;
import org.jboss.ide.eclipse.as.core.server.internal.DelegatingServerBehavior;
import org.jboss.ide.eclipse.as.core.server.internal.PollThread;
+import org.jboss.ide.eclipse.as.core.server.internal.launch.DelegatingStartLaunchConfiguration;
import org.jboss.ide.eclipse.as.core.util.LaunchCommandPreferences;
import org.jboss.ide.eclipse.as.core.util.ServerConverter;
@@ -73,7 +73,7 @@
public void setupLaunchConfiguration(ILaunchConfigurationWorkingCopy launchConfig, IProgressMonitor monitor)
throws CoreException {
// TODO: implement setup for RSE launch delegate too
- DelegatingJBoss7StartLaunchConfiguration.setupLaunchConfiguration(launchConfig, getServer());
+ new DelegatingStartLaunchConfiguration().setupLaunchConfiguration(launchConfig, getServer());
}
public void setProcess(IProcess process) {
Deleted: trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/v7/DelegatingJBoss7StartLaunchConfiguration.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/v7/DelegatingJBoss7StartLaunchConfiguration.java 2011-07-18 11:00:38 UTC (rev 33004)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/v7/DelegatingJBoss7StartLaunchConfiguration.java 2011-07-18 11:04:24 UTC (rev 33005)
@@ -1,102 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2011 Red Hat, Inc.
- * Distributed under license by Red Hat, Inc. All rights reserved.
- * This program is made available under the terms of the
- * Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
-package org.jboss.ide.eclipse.as.core.server.internal.v7;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.debug.core.ILaunch;
-import org.eclipse.debug.core.ILaunchConfiguration;
-import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
-import org.eclipse.wst.server.core.IServer;
-import org.eclipse.wst.server.core.ServerUtil;
-import org.jboss.ide.eclipse.as.core.publishers.LocalPublishMethod;
-import org.jboss.ide.eclipse.as.core.server.IJBossServerPublishMethodType;
-import org.jboss.ide.eclipse.as.core.server.internal.DeployableServerBehavior;
-import org.jboss.ide.eclipse.as.core.server.internal.launch.DelegatingStartLaunchConfiguration;
-import org.jboss.ide.eclipse.as.core.server.internal.launch.IStartLaunchDelegate;
-import org.jboss.ide.eclipse.as.core.server.internal.launch.IStartLaunchSetupParticipant;
-import org.jboss.ide.eclipse.as.core.util.ServerConverter;
-
-/**
- * @author Rob Stryker
- */
-public class DelegatingJBoss7StartLaunchConfiguration extends DelegatingStartLaunchConfiguration {
-
- private static HashMap<String, IStartLaunchDelegate> launchDelegates;
- private static ArrayList<IStartLaunchSetupParticipant> setupParticipants;
-
- static {
- setupParticipants = new ArrayList<IStartLaunchSetupParticipant>();
- setupParticipants.add(new LocalJBoss7StartLaunchDelegate());
- launchDelegates = new HashMap<String, IStartLaunchDelegate>();
- launchDelegates.put(LocalPublishMethod.LOCAL_PUBLISH_METHOD, new LocalJBoss7StartLaunchDelegate());
- }
-
- public static void addLaunchDelegateMapping(String mode, IStartLaunchDelegate del) {
- launchDelegates.put(mode, del);
- }
-
- public static void addSetupLaunchParticipant(IStartLaunchSetupParticipant participant) {
- setupParticipants.add(participant);
- }
-
- // Allow all participants to set some defaults for their own details
- // Participants should be careful not to change shared launch keys / values
- // unless their operation mode (local / rse / etc) is in use
- public static void setupLaunchConfiguration(ILaunchConfigurationWorkingCopy workingCopy, IServer server) throws CoreException {
- for( Iterator<IStartLaunchSetupParticipant> i = setupParticipants.iterator(); i.hasNext(); ) {
- IStartLaunchSetupParticipant setupParticipant = i.next();
- setupParticipant.setupLaunchConfiguration(workingCopy, server);
- }
- }
-
- protected IStartLaunchDelegate getDelegate(ILaunchConfiguration configuration) throws CoreException {
- IServer server = ServerUtil.getServer(configuration);
- DeployableServerBehavior beh = ServerConverter.getDeployableServerBehavior(server);
- IJBossServerPublishMethodType type = beh.createPublishMethod().getPublishMethodType();
- return launchDelegates.get(type.getId());
- }
-
- public void actualLaunch(ILaunchConfiguration configuration,
- String mode, ILaunch launch, IProgressMonitor monitor) throws CoreException {
- getDelegate(configuration).actualLaunch(this, configuration, mode, launch, monitor);
- }
-
- @Deprecated
- public void superActualLaunch(ILaunchConfiguration configuration,
- String mode, ILaunch launch, IProgressMonitor monitor) throws CoreException {
- super.actualLaunch(configuration, mode, launch, monitor);
- }
- /*
- * Ensures that the working directory and classpath are 100% accurate.
- * Merges proper required params into args and vm args
- */
- @Override
- public boolean preLaunchCheck(ILaunchConfiguration configuration, String mode, IProgressMonitor monitor) throws CoreException {
- return getDelegate(configuration).preLaunchCheck(configuration, mode, monitor);
- }
-
- @Override
- public void preLaunch(ILaunchConfiguration configuration,
- String mode, ILaunch launch, IProgressMonitor monitor) throws CoreException {
- getDelegate(configuration).preLaunch(configuration, mode, launch, monitor);
- }
-
- @Override
- public void postLaunch(ILaunchConfiguration configuration, String mode,
- ILaunch launch, IProgressMonitor monitor) throws CoreException {
- getDelegate(configuration).postLaunch(configuration, mode, launch, monitor);
- }
-}
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/v7/JBoss7ServerBehavior.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/v7/JBoss7ServerBehavior.java 2011-07-18 11:00:38 UTC (rev 33004)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/v7/JBoss7ServerBehavior.java 2011-07-18 11:04:24 UTC (rev 33005)
@@ -10,239 +10,11 @@
******************************************************************************/
package org.jboss.ide.eclipse.as.core.server.internal.v7;
-import java.text.MessageFormat;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.core.runtime.SubProgressMonitor;
-import org.eclipse.debug.core.DebugEvent;
-import org.eclipse.debug.core.DebugPlugin;
-import org.eclipse.debug.core.IDebugEventSetListener;
-import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
-import org.eclipse.debug.core.model.IProcess;
-import org.eclipse.wst.server.core.IModule;
-import org.jboss.ide.eclipse.as.core.JBossServerCorePlugin;
-import org.jboss.ide.eclipse.as.core.Messages;
-import org.jboss.ide.eclipse.as.core.extensions.events.IEventCodes;
-import org.jboss.ide.eclipse.as.core.extensions.events.ServerLogger;
-import org.jboss.ide.eclipse.as.core.publishers.LocalPublishMethod;
-import org.jboss.ide.eclipse.as.core.publishers.PublishUtil;
-import org.jboss.ide.eclipse.as.core.server.IDeployableServer;
-import org.jboss.ide.eclipse.as.core.server.IJBoss7ManagerService;
-import org.jboss.ide.eclipse.as.core.server.IJBossServerPublishMethod;
-import org.jboss.ide.eclipse.as.core.server.internal.DelegatingServerBehavior;
-import org.jboss.ide.eclipse.as.core.server.internal.PollThread;
-import org.jboss.ide.eclipse.as.core.util.LaunchCommandPreferences;
-import org.jboss.ide.eclipse.as.core.util.ServerConverter;
-
/**
* @deprecated replaced by {@link DelegatingJBoss7ServerBehavior}
*
* @author Rob Stryker
*/
-public class JBoss7ServerBehavior extends DelegatingServerBehavior {
-
- public static final String MARK_DO_DEPLOY = "org.jboss.ide.eclipse.as.core.server.internal.v7.JBoss7JSTPublisher.markUndeploy"; //$NON-NLS-1$
-
- private IProcess serverProcess;
- private IJBoss7ManagerService service;
- private IDebugEventSetListener serverProcessListener;
- private PollThread pollThread;
-
- private static HashMap<String, Class> delegateClassMap;
- static {
- delegateClassMap = new HashMap<String, Class>();
- delegateClassMap.put(LocalPublishMethod.LOCAL_PUBLISH_METHOD, LocalJBoss7BehaviorDelegate.class);
- }
-
- public static void addDelegateMapping(String s, Class c) {
- delegateClassMap.put(s, c);
- }
-
- protected HashMap<String, Class> getDelegateMap() {
- return delegateClassMap;
- }
-
- public boolean shouldSuspendScanner() {
- return false;
- }
-
- public void setupLaunchConfiguration(ILaunchConfigurationWorkingCopy launchConfig, IProgressMonitor monitor)
- throws CoreException {
- // TODO: implement setup for RSE launch delegate too
- new LocalJBoss7StartConfigurator(getServer()).configure(launchConfig);
- }
-
- public void setProcess(IProcess process) {
- this.serverProcess = process;
- initDebugListener(process);
- }
-
- private void initDebugListener(IProcess process) {
- DebugPlugin.getDefault().addDebugEventListener(serverProcessListener = new JBossServerLifecycleListener());
- }
-
- private void disposeServerProcessListener() {
- if( serverProcessListener != null ) {
- DebugPlugin.getDefault().removeDebugEventListener(serverProcessListener);
- serverProcess = null;
- if( pollThread != null )
- pollThread.cancel();
- }
- }
-
- @Override
- protected void publishModule(int kind, int deltaKind, IModule[] module, IProgressMonitor monitor)
- throws CoreException {
- super.publishModule(kind, deltaKind, module, monitor);
- }
-
- @Override
- protected void publishFinish(IProgressMonitor monitor) throws CoreException {
- // Handle the dodeploy
- createDoDeployMarkers(monitor);
- super.publishFinish(new SubProgressMonitor(monitor, 1));
- }
-
- private void createDoDeployMarkers(IProgressMonitor monitor) throws CoreException {
- if (!hasMarkedDoDeploy()) {
- return;
- }
- List<IPath> paths = getMarkedDoDeploy();
- monitor.beginTask("Completing Publishes", paths.size() + 1); //$NON-NLS-1$
- createDoDeployMarker(paths, monitor);
- }
-
- public void restartModule(IModule[] module, IProgressMonitor monitor) throws CoreException {
- IDeployableServer ds = ServerConverter.getDeployableServer(getServer());
- if( ds == null )
- return;
-
- IJBossServerPublishMethod method = getOrCreatePublishMethod();
- IPath depPath = PublishUtil.getDeployPath(method, module, ds);
- createDoDeployMarker(new IPath[]{depPath}, monitor);
- }
-
-
- protected IJBoss7ManagerService getService() throws Exception {
- if (service == null) {
- service = JBoss7ManagerUtil.getService(getServer());
- }
- return service;
- }
-
- private boolean isServerRunning(String host, int port) throws Exception {
- try {
- return getService().getServerState(host, port) == JBoss7ServerState.RUNNING;
- } catch (JBoss7ManangerConnectException e) {
- return false;
- }
- }
-
- public void stop(boolean force) {
- if( LaunchCommandPreferences.isIgnoreLaunchCommand(getServer())) {
- super.setServerStopped();
- return;
- }
- try {
- if (force) {
- if( serverProcess != null )
- serverProcess.terminate();
- } else {
- setServerStopping();
- String host = getServer().getHost();
- JBoss7Server server = ServerConverter.checkedGetJBossServer(getServer(), JBoss7Server.class);
- int mgmtPort = server.getManagementPort();
- // TODO: for now only local, implement for remote afterwards
- if (isServerRunning(host, mgmtPort)) {
- // The service and Poller will make sure the server is down
- getService().stop(host, mgmtPort);
- return;
- } else {
- if( serverProcess != null && !serverProcess.isTerminated()) {
- serverProcess.terminate();
- }
- }
- }
- } catch (Exception e) {
- IStatus status = new Status(IStatus.ERROR, JBossServerCorePlugin.PLUGIN_ID, MessageFormat.format(Messages.JBoss7ServerBehavior_could_not_stop, getServer().getName()), e);
- JBossServerCorePlugin.getDefault().getLog().log(status);
- }
- setServerStopped();
- }
-
- @Override
- public void dispose() {
- super.dispose();
- if (service != null) {
- service.dispose();
- }
- }
-
- @Override
- public void setServerStopped() {
- disposeServerProcessListener();
- logServerStopped();
- super.setServerStopped();
- }
-
- private void logServerStopped() {
- IStatus status = new Status(IStatus.INFO,
- JBossServerCorePlugin.PLUGIN_ID, IEventCodes.BEHAVIOR_PROCESS_TERMINATED,
- Messages.TERMINATED, null);
- ServerLogger.getDefault().log(getServer(), status);
- }
-
- private class JBossServerLifecycleListener implements IDebugEventSetListener {
-
- public void handleDebugEvents(DebugEvent[] events) {
- for (DebugEvent event : events) {
- if (serverProcess != null && serverProcess.equals(event.getSource())
- && event.getKind() == DebugEvent.TERMINATE) {
- setServerStopped();
- break;
- }
- }
- }
- }
-
- public void markDoDeploy(IPath path) {
- Object o = getPublishData(MARK_DO_DEPLOY);
- if(!(o instanceof List<?>)) {
- o = new ArrayList<IPath>();
- setPublishData(MARK_DO_DEPLOY, o);
- }
- List<IPath> list = (List<IPath>)o;
- if( !list.contains(path)) {
- list.add(path);
- }
-
- }
-
- public boolean hasMarkedDoDeploy() {
- return getMarkedDoDeploy().size() > 0;
- }
-
- private List<IPath> getMarkedDoDeploy() {
- Object o = getPublishData(MARK_DO_DEPLOY);
- if (!(o instanceof List<?>)) {
- return Collections.emptyList();
- }
- return (List<IPath>) o;
- }
- private void createDoDeployMarker(IPath[] paths, IProgressMonitor monitor) throws CoreException {
- List<IPath> allPaths = Arrays.asList(paths);
- createDoDeployMarker(allPaths, monitor);
- }
- private void createDoDeployMarker(List<IPath> paths, IProgressMonitor monitor) throws CoreException {
- DeploymentMarkerUtils.addDoDeployMarker(getOrCreatePublishMethod(), getServer(), paths, monitor);
- }
+public class JBoss7ServerBehavior extends DelegatingJBoss7ServerBehavior {
}
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.rse.core/src/org/jboss/ide/eclipse/as/rse/core/RSECorePlugin.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.rse.core/src/org/jboss/ide/eclipse/as/rse/core/RSECorePlugin.java 2011-07-18 11:00:38 UTC (rev 33004)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.rse.core/src/org/jboss/ide/eclipse/as/rse/core/RSECorePlugin.java 2011-07-18 11:04:24 UTC (rev 33005)
@@ -12,10 +12,9 @@
******************************************************************************/
package org.jboss.ide.eclipse.as.rse.core;
+import org.jboss.ide.eclipse.as.core.ExtensionManager;
import org.jboss.ide.eclipse.as.core.server.internal.DelegatingServerBehavior;
-import org.jboss.ide.eclipse.as.core.server.internal.launch.DelegatingStartLaunchConfiguration;
import org.jboss.ide.eclipse.as.core.server.internal.v7.DelegatingJBoss7ServerBehavior;
-import org.jboss.ide.eclipse.as.core.server.internal.v7.DelegatingJBoss7StartLaunchConfiguration;
import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
@@ -35,13 +34,11 @@
public void start(BundleContext bundleContext) throws Exception {
RSECorePlugin.context = bundleContext;
DelegatingServerBehavior.addDelegateMapping(RSEPublishMethod.RSE_ID, RSEBehaviourDelegate.class);
- DelegatingStartLaunchConfiguration.addLaunchDelegateMapping(RSEPublishMethod.RSE_ID, new RSEJBossStartLaunchDelegate());
- DelegatingStartLaunchConfiguration.addSetupLaunchParticipant(new RSEJBossStartLaunchDelegate());
-
DelegatingJBoss7ServerBehavior.addDelegateMapping(RSEPublishMethod.RSE_ID, RSEJBoss7BehaviourDelegate.class);
- DelegatingJBoss7StartLaunchConfiguration.addLaunchDelegateMapping(RSEPublishMethod.RSE_ID, new RSEJBoss7StartLaunchDelegate());
- DelegatingJBoss7StartLaunchConfiguration.addSetupLaunchParticipant(new RSEJBoss7StartLaunchDelegate());
-
+ ExtensionManager.JBossLaunchDelegates.put(RSEPublishMethod.RSE_ID, new RSEJBossStartLaunchDelegate());
+ ExtensionManager.JBossSetupParticipants.add(new RSEJBossStartLaunchDelegate());
+ ExtensionManager.JBoss7launchDelegates.put(RSEPublishMethod.RSE_ID, new RSEJBoss7StartLaunchDelegate());
+ ExtensionManager.JBoss7setupParticipants.add(new RSEJBoss7StartLaunchDelegate());
}
/*
14 years, 9 months
JBoss Tools SVN: r33004 - in trunk/forge: plugins/org.jboss.tools.forge.core/src/org/jboss/tools/forge/core/process and 6 other directories.
by jbosstools-commits@lists.jboss.org
Author: koen.aers(a)jboss.com
Date: 2011-07-18 07:00:38 -0400 (Mon, 18 Jul 2011)
New Revision: 33004
Added:
trunk/forge/plugins/org.jboss.tools.forge.core/src/org/jboss/tools/forge/core/io/ForgeInputStream.java
trunk/forge/plugins/org.jboss.tools.forge.core/src/org/jboss/tools/forge/core/io/ForgeOutputListener.java
trunk/forge/plugins/org.jboss.tools.forge.ui/src/org/jboss/tools/forge/ui/console/ForgeInputReadJob.java
trunk/forge/tests/org.jboss.tools.forge.core.test/src/org/jboss/tools/forge/core/io/ForgeInputStreamTest.java
Removed:
trunk/forge/plugins/org.jboss.tools.forge.core/src/org/jboss/tools/forge/core/io/ConsoleInputStream.java
trunk/forge/plugins/org.jboss.tools.forge.core/src/org/jboss/tools/forge/core/io/ForgeInputReadJob.java
trunk/forge/tests/org.jboss.tools.forge.core.test/src/org/jboss/tools/forge/core/io/ForgeInputReadJobTest.java
Modified:
trunk/forge/plugins/org.jboss.tools.forge.core/src/org/jboss/tools/forge/core/process/ForgeAbstractRuntime.java
trunk/forge/plugins/org.jboss.tools.forge.core/src/org/jboss/tools/forge/core/process/ForgeRuntime.java
trunk/forge/plugins/org.jboss.tools.forge.ui/META-INF/MANIFEST.MF
trunk/forge/plugins/org.jboss.tools.forge.ui/src/org/jboss/tools/forge/old/ConsolePartition.java
trunk/forge/plugins/org.jboss.tools.forge.ui/src/org/jboss/tools/forge/old/ConsolePartitioner.java
trunk/forge/plugins/org.jboss.tools.forge.ui/src/org/jboss/tools/forge/ui/console/Console.java
trunk/forge/plugins/org.jboss.tools.forge.ui/src/org/jboss/tools/forge/ui/console/ConsolePage.java
trunk/forge/plugins/org.jboss.tools.forge.ui/src/org/jboss/tools/forge/ui/console/ConsoleViewer.java
trunk/forge/plugins/org.jboss.tools.forge.ui/src/org/jboss/tools/forge/ui/part/ConsoleView.java
trunk/forge/tests/org.jboss.tools.forge.core.test/src/org/jboss/tools/forge/core/process/ForgeAbstractRuntimeTest.java
Log:
encapsulate the input and output streams of the forge runtime
Deleted: trunk/forge/plugins/org.jboss.tools.forge.core/src/org/jboss/tools/forge/core/io/ConsoleInputStream.java
===================================================================
--- trunk/forge/plugins/org.jboss.tools.forge.core/src/org/jboss/tools/forge/core/io/ConsoleInputStream.java 2011-07-18 10:58:26 UTC (rev 33003)
+++ trunk/forge/plugins/org.jboss.tools.forge.core/src/org/jboss/tools/forge/core/io/ConsoleInputStream.java 2011-07-18 11:00:38 UTC (rev 33004)
@@ -1,66 +0,0 @@
-package org.jboss.tools.forge.core.io;
-
-import java.io.IOException;
-import java.io.InputStream;
-
-public class ConsoleInputStream extends InputStream {
-
- private byte[] input = new byte[0];
- private int outPointer = 0;
- private int size = 0;
- private boolean eofSent = false;
- private boolean closed = false;
-
- public synchronized int read() throws IOException {
- waitForData();
- if (available() == -1) {
- return -1;
- }
-
- byte b = input[outPointer];
- outPointer++;
- if (outPointer == input.length) {
- outPointer = 0;
- }
- size -= 1;
- return b;
- }
-
- private void waitForData() {
- while (size == 0 && !closed) {
- try {
- wait();
- } catch (InterruptedException e) {}
- }
- }
-
- public synchronized void appendData(String text) {
- input = text.getBytes();
- size = text.length();
- outPointer = 0;
- notifyAll();
- }
-
- public int available() throws IOException {
- if (closed && eofSent) {
- throw new IOException("Input Stream Closed");
- } else if (size == 0) {
- if (!eofSent) {
- eofSent = true;
- return -1;
- }
- throw new IOException("Input Stream Closed");
- }
-
- return size;
- }
-
- public synchronized void close() throws IOException {
- if(closed) {
- throw new IOException("Input Stream Closed");
- }
- closed = true;
- notifyAll();
- }
-
-}
Deleted: trunk/forge/plugins/org.jboss.tools.forge.core/src/org/jboss/tools/forge/core/io/ForgeInputReadJob.java
===================================================================
--- trunk/forge/plugins/org.jboss.tools.forge.core/src/org/jboss/tools/forge/core/io/ForgeInputReadJob.java 2011-07-18 10:58:26 UTC (rev 33003)
+++ trunk/forge/plugins/org.jboss.tools.forge.core/src/org/jboss/tools/forge/core/io/ForgeInputReadJob.java 2011-07-18 11:00:38 UTC (rev 33004)
@@ -1,36 +0,0 @@
-package org.jboss.tools.forge.core.io;
-
-import java.io.IOException;
-import java.io.InputStream;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.core.runtime.jobs.Job;
-import org.eclipse.debug.core.model.IStreamsProxy;
-import org.jboss.tools.forge.core.ForgeCorePlugin;
-
-public class ForgeInputReadJob extends Job {
-
- private IStreamsProxy streamsProxy;
- private InputStream input;
-
- public ForgeInputReadJob(IStreamsProxy streamsProxy, InputStream input) {
- super("Forge Input Read Job");
- this.input = input;
- this.streamsProxy = streamsProxy;
- }
-
- protected IStatus run(IProgressMonitor monitor) {
- try {
- int read;
- while (input != null && (read = input.read()) != -1) {
- streamsProxy.write(new String(new char[] { (char)read }));
- }
- } catch (IOException e) {
- ForgeCorePlugin.log(e);
- }
- return Status.OK_STATUS;
- }
-
-}
Copied: trunk/forge/plugins/org.jboss.tools.forge.core/src/org/jboss/tools/forge/core/io/ForgeInputStream.java (from rev 32710, trunk/forge/plugins/org.jboss.tools.forge.core/src/org/jboss/tools/forge/core/io/ConsoleInputStream.java)
===================================================================
--- trunk/forge/plugins/org.jboss.tools.forge.core/src/org/jboss/tools/forge/core/io/ForgeInputStream.java (rev 0)
+++ trunk/forge/plugins/org.jboss.tools.forge.core/src/org/jboss/tools/forge/core/io/ForgeInputStream.java 2011-07-18 11:00:38 UTC (rev 33004)
@@ -0,0 +1,66 @@
+package org.jboss.tools.forge.core.io;
+
+import java.io.IOException;
+import java.io.InputStream;
+
+public class ForgeInputStream extends InputStream {
+
+ private byte[] input = new byte[0];
+ private int outPointer = 0;
+ private int size = 0;
+ private boolean eofSent = false;
+ private boolean closed = false;
+
+ public synchronized int read() throws IOException {
+ waitForData();
+ if (available() == -1) {
+ return -1;
+ }
+
+ byte b = input[outPointer];
+ outPointer++;
+ if (outPointer == input.length) {
+ outPointer = 0;
+ }
+ size -= 1;
+ return b;
+ }
+
+ private void waitForData() {
+ while (size == 0 && !closed) {
+ try {
+ wait();
+ } catch (InterruptedException e) {}
+ }
+ }
+
+ public synchronized void appendData(String text) {
+ input = text.getBytes();
+ size = text.length();
+ outPointer = 0;
+ notifyAll();
+ }
+
+ public int available() throws IOException {
+ if (closed && eofSent) {
+ throw new IOException("Input Stream Closed");
+ } else if (size == 0) {
+ if (!eofSent) {
+ eofSent = true;
+ return -1;
+ }
+ throw new IOException("Input Stream Closed");
+ }
+
+ return size;
+ }
+
+ public synchronized void close() throws IOException {
+ if(closed) {
+ throw new IOException("Input Stream Closed");
+ }
+ closed = true;
+ notifyAll();
+ }
+
+}
Added: trunk/forge/plugins/org.jboss.tools.forge.core/src/org/jboss/tools/forge/core/io/ForgeOutputListener.java
===================================================================
--- trunk/forge/plugins/org.jboss.tools.forge.core/src/org/jboss/tools/forge/core/io/ForgeOutputListener.java (rev 0)
+++ trunk/forge/plugins/org.jboss.tools.forge.core/src/org/jboss/tools/forge/core/io/ForgeOutputListener.java 2011-07-18 11:00:38 UTC (rev 33004)
@@ -0,0 +1,7 @@
+package org.jboss.tools.forge.core.io;
+
+public interface ForgeOutputListener {
+
+ void outputAvailable(String output);
+
+}
Modified: trunk/forge/plugins/org.jboss.tools.forge.core/src/org/jboss/tools/forge/core/process/ForgeAbstractRuntime.java
===================================================================
--- trunk/forge/plugins/org.jboss.tools.forge.core/src/org/jboss/tools/forge/core/process/ForgeAbstractRuntime.java 2011-07-18 10:58:26 UTC (rev 33003)
+++ trunk/forge/plugins/org.jboss.tools.forge.core/src/org/jboss/tools/forge/core/process/ForgeAbstractRuntime.java 2011-07-18 11:00:38 UTC (rev 33004)
@@ -2,6 +2,9 @@
import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.NullProgressMonitor;
@@ -14,15 +17,18 @@
import org.eclipse.debug.core.model.IStreamMonitor;
import org.eclipse.debug.core.model.IStreamsProxy;
import org.jboss.tools.forge.core.ForgeCorePlugin;
+import org.jboss.tools.forge.core.io.ForgeOutputListener;
public abstract class ForgeAbstractRuntime implements ForgeRuntime {
private IProcess process = null;
- private String state = STATE_NOT_RUNNING;
- private final TerminateListener terminateListener = new TerminateListener();
-
+ private String state = STATE_NOT_RUNNING;
+ private final TerminateListener terminateListener = new TerminateListener();
+ private MasterOutputListener masterOutputListener = new MasterOutputListener();
private PropertyChangeSupport propertyChangeSupport = new PropertyChangeSupport(this);
+ private List<ForgeOutputListener> outputListeners = new ArrayList<ForgeOutputListener>();
+
public IProcess getProcess() {
return process;
}
@@ -32,17 +38,26 @@
}
public void start(IProgressMonitor progressMonitor) {
- IStreamListener streamListener = null;
+ IStreamListener startupListener = null;
if (progressMonitor == null) {
progressMonitor = new NullProgressMonitor();
}
try {
progressMonitor.beginTask("Starting Forge", IProgressMonitor.UNKNOWN);
- streamListener = new StartupListener();
+ startupListener = new StartupListener();
process = ForgeLaunchHelper.launch(getName(), getLocation());
- setNewState(STATE_STARTING);
- DebugPlugin.getDefault().addDebugEventListener(terminateListener);
- process.getStreamsProxy().getOutputStreamMonitor().addListener(streamListener);
+ if (process != null) {
+ setNewState(STATE_STARTING);
+ DebugPlugin.getDefault().addDebugEventListener(terminateListener);
+ IStreamsProxy streamsProxy = process.getStreamsProxy();
+ if (streamsProxy != null) {
+ IStreamMonitor streamMonitor = streamsProxy.getOutputStreamMonitor();
+ if (streamMonitor != null) {
+ streamMonitor.addListener(startupListener);
+ streamMonitor.addListener(masterOutputListener);
+ }
+ }
+ }
progressMonitor.worked(1);
while (STATE_STARTING.equals(state)) {
if (progressMonitor.isCanceled()) {
@@ -62,7 +77,7 @@
if (streamsProxy != null) {
IStreamMonitor outputStreamMonitor = streamsProxy.getOutputStreamMonitor();
if (outputStreamMonitor != null) {
- outputStreamMonitor.removeListener(streamListener);
+ outputStreamMonitor.removeListener(startupListener);
}
}
}
@@ -70,6 +85,19 @@
}
}
+ public void sendInput(String str) {
+ if (process != null && !process.isTerminated()) {
+ IStreamsProxy streamProxy = process.getStreamsProxy();
+ if (streamProxy != null) {
+ try {
+ streamProxy.write(str);
+ } catch (IOException e) {
+ ForgeCorePlugin.log(e);
+ }
+ }
+ }
+ }
+
public void stop(IProgressMonitor progressMonitor) {
if (progressMonitor == null) {
progressMonitor = new NullProgressMonitor();
@@ -85,6 +113,13 @@
private void terminate() {
try {
if (process != null) {
+ IStreamsProxy streamsProxy = process.getStreamsProxy();
+ if (streamsProxy != null) {
+ IStreamMonitor streamMonitor = streamsProxy.getOutputStreamMonitor();
+ if (streamMonitor != null) {
+ streamMonitor.removeListener(masterOutputListener);
+ }
+ }
process.terminate();
}
} catch (DebugException e) {
@@ -106,6 +141,14 @@
propertyChangeSupport.removePropertyChangeListener(propertyChangeListener);
}
+ public void addOutputListener(ForgeOutputListener listener) {
+ outputListeners.add(listener);
+ }
+
+ public void removeOutputListener(ForgeOutputListener listener) {
+ outputListeners.remove(listener);
+ }
+
private class StartupListener implements IStreamListener {
@Override
public void streamAppended(String text, IStreamMonitor monitor) {
@@ -114,6 +157,15 @@
}
}
+ private class MasterOutputListener implements IStreamListener {
+ @Override
+ public void streamAppended(String text, IStreamMonitor monitor) {
+ for (ForgeOutputListener listener : outputListeners) {
+ listener.outputAvailable(text);
+ }
+ }
+ }
+
private class TerminateListener implements IDebugEventSetListener {
@Override
public void handleDebugEvents(DebugEvent[] events) {
Modified: trunk/forge/plugins/org.jboss.tools.forge.core/src/org/jboss/tools/forge/core/process/ForgeRuntime.java
===================================================================
--- trunk/forge/plugins/org.jboss.tools.forge.core/src/org/jboss/tools/forge/core/process/ForgeRuntime.java 2011-07-18 10:58:26 UTC (rev 33003)
+++ trunk/forge/plugins/org.jboss.tools.forge.core/src/org/jboss/tools/forge/core/process/ForgeRuntime.java 2011-07-18 11:00:38 UTC (rev 33004)
@@ -3,7 +3,7 @@
import java.beans.PropertyChangeListener;
import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.debug.core.model.IProcess;
+import org.jboss.tools.forge.core.io.ForgeOutputListener;
public interface ForgeRuntime {
@@ -17,9 +17,14 @@
String getLocation();
String getType();
String getState();
- IProcess getProcess();
void start(IProgressMonitor progressMonitor);
void stop(IProgressMonitor progressMonitor);
+
+ void sendInput(String str);
+
+ void addOutputListener(ForgeOutputListener outputListener);
+ void removeOutputListener(ForgeOutputListener outputListener);
+
void addPropertyChangeListener(PropertyChangeListener propertyChangeListener);
void removePropertyChangeListener(PropertyChangeListener propertyChangeListener);
Modified: trunk/forge/plugins/org.jboss.tools.forge.ui/META-INF/MANIFEST.MF
===================================================================
--- trunk/forge/plugins/org.jboss.tools.forge.ui/META-INF/MANIFEST.MF 2011-07-18 10:58:26 UTC (rev 33003)
+++ trunk/forge/plugins/org.jboss.tools.forge.ui/META-INF/MANIFEST.MF 2011-07-18 11:00:38 UTC (rev 33004)
@@ -20,3 +20,4 @@
Bundle-ActivationPolicy: lazy
Bundle-Activator: org.jboss.tools.forge.ui.ForgeUIPlugin
Bundle-ClassPath: .
+Export-Package: org.jboss.tools.forge.ui.console
Modified: trunk/forge/plugins/org.jboss.tools.forge.ui/src/org/jboss/tools/forge/old/ConsolePartition.java
===================================================================
--- trunk/forge/plugins/org.jboss.tools.forge.ui/src/org/jboss/tools/forge/old/ConsolePartition.java 2011-07-18 10:58:26 UTC (rev 33003)
+++ trunk/forge/plugins/org.jboss.tools.forge.ui/src/org/jboss/tools/forge/old/ConsolePartition.java 2011-07-18 11:00:38 UTC (rev 33004)
@@ -5,7 +5,7 @@
import org.eclipse.jface.text.ITypedRegion;
import org.eclipse.swt.custom.StyleRange;
import org.eclipse.ui.console.ConsolePlugin;
-import org.jboss.tools.forge.core.io.ConsoleInputStream;
+import org.jboss.tools.forge.core.io.ForgeInputStream;
public class ConsolePartition implements ITypedRegion {
public static final String OUTPUT_PARTITION_TYPE = ConsolePlugin.getUniqueIdentifier() + ".io_console_output_partition_type"; //$NON-NLS-1$
@@ -28,7 +28,7 @@
*/
private OutputStream outputStream;
@SuppressWarnings("unused")
- private ConsoleInputStream inputStream;
+ private ForgeInputStream inputStream;
private int length;
/**
@@ -44,7 +44,7 @@
/**
* Creates a new partition to contain input from a console
*/
- public ConsolePartition(ConsoleInputStream inputStream, String text) {
+ public ConsolePartition(ForgeInputStream inputStream, String text) {
this.inputStream = inputStream;
buffer = new StringBuffer(text);
length = text.length();
Modified: trunk/forge/plugins/org.jboss.tools.forge.ui/src/org/jboss/tools/forge/old/ConsolePartitioner.java
===================================================================
--- trunk/forge/plugins/org.jboss.tools.forge.ui/src/org/jboss/tools/forge/old/ConsolePartitioner.java 2011-07-18 10:58:26 UTC (rev 33003)
+++ trunk/forge/plugins/org.jboss.tools.forge.ui/src/org/jboss/tools/forge/old/ConsolePartitioner.java 2011-07-18 11:00:38 UTC (rev 33004)
@@ -25,7 +25,7 @@
import org.eclipse.ui.console.IConsoleDocumentPartitioner;
import org.eclipse.ui.progress.UIJob;
import org.eclipse.ui.progress.WorkbenchJob;
-import org.jboss.tools.forge.core.io.ConsoleInputStream;
+import org.jboss.tools.forge.core.io.ForgeInputStream;
import org.jboss.tools.forge.ui.console.Console;
/**
@@ -58,7 +58,7 @@
/**
* The input stream attached to this document.
*/
- private ConsoleInputStream inputStream;
+ private ForgeInputStream inputStream;
/**
* Flag to indicate that the updateJob is updating the document.
*/
@@ -94,7 +94,7 @@
private int fBuffer;
- private ConsolePartitioner(ConsoleInputStream inputStream, Console console) {
+ private ConsolePartitioner(ForgeInputStream inputStream, Console console) {
this.inputStream = inputStream;
this.console = console;
trimJob.setRule(console.getSchedulingRule());
Modified: trunk/forge/plugins/org.jboss.tools.forge.ui/src/org/jboss/tools/forge/ui/console/Console.java
===================================================================
--- trunk/forge/plugins/org.jboss.tools.forge.ui/src/org/jboss/tools/forge/ui/console/Console.java 2011-07-18 10:58:26 UTC (rev 33003)
+++ trunk/forge/plugins/org.jboss.tools.forge.ui/src/org/jboss/tools/forge/ui/console/Console.java 2011-07-18 11:00:38 UTC (rev 33004)
@@ -1,73 +1,74 @@
package org.jboss.tools.forge.ui.console;
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
import java.io.IOException;
-import org.eclipse.debug.core.DebugEvent;
-import org.eclipse.debug.core.DebugPlugin;
-import org.eclipse.debug.core.IDebugEventSetListener;
-import org.eclipse.debug.core.IStreamListener;
-import org.eclipse.debug.core.model.IProcess;
-import org.eclipse.debug.core.model.IStreamMonitor;
-import org.eclipse.debug.core.model.IStreamsProxy;
import org.eclipse.jface.text.BadLocationException;
import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.console.IConsoleDocumentPartitioner;
import org.eclipse.ui.console.IConsoleView;
import org.eclipse.ui.console.TextConsole;
import org.eclipse.ui.part.IPageBookViewPage;
-import org.jboss.tools.forge.core.io.ConsoleInputStream;
-import org.jboss.tools.forge.core.io.ForgeInputReadJob;
+import org.jboss.tools.forge.core.io.ForgeInputStream;
+import org.jboss.tools.forge.core.io.ForgeOutputListener;
+import org.jboss.tools.forge.core.process.ForgeRuntime;
+import org.jboss.tools.forge.ui.ForgeUIPlugin;
-public class Console extends TextConsole implements IDebugEventSetListener {
+public class Console extends TextConsole {
private ConsolePartitioner partitioner;
- private ConsoleInputStream inputStream;
- private IProcess process = null;
- private IStreamListener outputStreamListener;
+ private ForgeInputStream inputStream;
+ private RuntimeStopListener stopListener;
+ private ForgeOutputListener outputListener;
+ private ForgeRuntime runtime;
- public Console(IProcess process) {
+ public Console(ForgeRuntime runtime) {
super("Forge Console", null, null, true);
- this.process = process;
+ this.runtime = runtime;
initInputStream();
initPartitioner();
initCommandRecorder();
- initOutputStream();
+ initOutputListener();
initInputReadJob();
}
+ protected void init() {
+ super.init();
+ initInputStream();
+ initPartitioner();
+ initCommandRecorder();
+ initOutputListener();
+ initStopListener();
+ initInputReadJob();
+ }
+
private void initCommandRecorder() {
getDocument().addDocumentListener(new CommandRecorder());
}
private void initInputStream() {
- inputStream = new ConsoleInputStream();
+ inputStream = new ForgeInputStream();
}
- private void initOutputStream() {
- outputStreamListener = new IStreamListener() {
+ private void initStopListener() {
+ stopListener = new RuntimeStopListener();
+ runtime.addPropertyChangeListener(stopListener);
+ }
+
+ private void initOutputListener() {
+ outputListener = new ForgeOutputListener() {
@Override
- public void streamAppended(String text, IStreamMonitor monitor) {
- appendString(text);
+ public void outputAvailable(String output) {
+ appendString(output);
}
};
- IStreamMonitor streamMonitor = getOutputStreamMonitor();
- synchronized(streamMonitor) {
- streamMonitor.addListener(outputStreamListener);
- }
+ runtime.addOutputListener(outputListener);
}
- private IStreamMonitor getOutputStreamMonitor() {
- IStreamMonitor streamMonitor = null;
- IStreamsProxy streamsProxy = process.getStreamsProxy();
- if (streamsProxy != null) {
- streamMonitor = streamsProxy.getOutputStreamMonitor();
- }
- return streamMonitor;
- }
-
private void initInputReadJob() {
- ForgeInputReadJob inputReadJob = new ForgeInputReadJob(process.getStreamsProxy(), inputStream);
+ ForgeInputReadJob inputReadJob = new ForgeInputReadJob(runtime, inputStream);
inputReadJob.setSystem(true);
inputReadJob.schedule();
}
@@ -81,62 +82,31 @@
throw new UnsupportedOperationException();
}
- public ConsoleInputStream getInputStream() {
- return inputStream;
- }
-
protected IConsoleDocumentPartitioner getPartitioner() {
return partitioner;
}
public void dispose() {
+ if (!ForgeRuntime.STATE_NOT_RUNNING.equals(runtime.getState())) {
+ runtime.stop(null);
+ }
super.dispose();
- partitioner.disconnect();
- closeStreams();
- disposeStreams();
- DebugPlugin.getDefault().removeDebugEventListener(this);
}
-
- private synchronized void closeStreams() {
- try {
- inputStream.close();
- } catch (IOException e) {}
- }
-
- private synchronized void disposeStreams() {
- IStreamMonitor streamMonitor = getOutputStreamMonitor();
- if (streamMonitor != null) {
- synchronized(streamMonitor) {
- if (outputStreamListener != null) {
- streamMonitor.removeListener(outputStreamListener);
- }
- }
+
+ private void handleRuntimeStopped() {
+ try {
+ runtime.removePropertyChangeListener(stopListener);
+ stopListener = null;
+ runtime.removeOutputListener(outputListener);
+ outputListener = null;
+ partitioner.disconnect();
+ inputStream.close();
+ } catch (IOException e) {
+ ForgeUIPlugin.log(e);
}
- outputStreamListener = null;
- inputStream = null;
}
- public void handleDebugEvents(DebugEvent[] events) {
- for (int i = 0; i < events.length; i++) {
- DebugEvent event = events[i];
- if (event.getSource().equals(process)) {
- if (event.getKind() == DebugEvent.TERMINATE) {
- closeStreams();
- DebugPlugin.getDefault().removeDebugEventListener(this);
- }
- }
- }
- }
- protected void init() {
- super.init();
- if (process.isTerminated()) {
- closeStreams();
- } else {
- DebugPlugin.getDefault().addDebugEventListener(this);
- }
- }
-
private int lastLineLength = 0;
private int lastLinePosition = 0;
private StringBuffer escapeSequence = new StringBuffer();
@@ -208,5 +178,15 @@
private void handleMetaData(String metaData) {
System.out.println("meta data detected: " + metaData);
}
+
+ private class RuntimeStopListener implements PropertyChangeListener {
+ @Override
+ public void propertyChange(PropertyChangeEvent evt) {
+ if (ForgeRuntime.PROPERTY_STATE.equals(evt.getPropertyName()) &&
+ ForgeRuntime.STATE_NOT_RUNNING.equals(evt.getNewValue())) {
+ handleRuntimeStopped();
+ }
+ }
+ }
}
Modified: trunk/forge/plugins/org.jboss.tools.forge.ui/src/org/jboss/tools/forge/ui/console/ConsolePage.java
===================================================================
--- trunk/forge/plugins/org.jboss.tools.forge.ui/src/org/jboss/tools/forge/ui/console/ConsolePage.java 2011-07-18 10:58:26 UTC (rev 33003)
+++ trunk/forge/plugins/org.jboss.tools.forge.ui/src/org/jboss/tools/forge/ui/console/ConsolePage.java 2011-07-18 11:00:38 UTC (rev 33004)
@@ -1,26 +1,23 @@
package org.jboss.tools.forge.ui.console;
-import org.eclipse.debug.core.model.IProcess;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.ui.console.TextConsoleViewer;
import org.eclipse.ui.part.Page;
+import org.jboss.tools.forge.core.process.ForgeRuntime;
public class ConsolePage extends Page {
private TextConsoleViewer viewer;
- private Console console;
- private IProcess process;
+ private ForgeRuntime runtime;
- public ConsolePage(IProcess process) {
- this.process = process;
+ public ConsolePage(ForgeRuntime runtime) {
+ this.runtime = runtime;
}
@Override
public void createControl(Composite parent) {
- console = new Console(process);
- viewer = new ConsoleViewer(parent, console);
- console.initialize();
+ viewer = new ConsoleViewer(parent, runtime);
}
@Override
@@ -33,8 +30,4 @@
viewer.getControl().setFocus();
}
- public Console getConsole() {
- return console;
- }
-
}
Modified: trunk/forge/plugins/org.jboss.tools.forge.ui/src/org/jboss/tools/forge/ui/console/ConsoleViewer.java
===================================================================
--- trunk/forge/plugins/org.jboss.tools.forge.ui/src/org/jboss/tools/forge/ui/console/ConsoleViewer.java 2011-07-18 10:58:26 UTC (rev 33003)
+++ trunk/forge/plugins/org.jboss.tools.forge.ui/src/org/jboss/tools/forge/ui/console/ConsoleViewer.java 2011-07-18 11:00:38 UTC (rev 33004)
@@ -10,6 +10,7 @@
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.ui.console.TextConsoleViewer;
+import org.jboss.tools.forge.core.process.ForgeRuntime;
public class ConsoleViewer extends TextConsoleViewer {
@@ -17,29 +18,29 @@
private static String UP_ARROW = new Character((char)16).toString();
private static String DOWN_ARROW = new Character((char)14).toString();
- private Console console = null;
-
- public ConsoleViewer(Composite parent, Console console) {
- super(parent, console);
- this.console = console;
- getDocument().addDocumentListener(new DocumentListener());
+ private ForgeRuntime runtime = null;
+
+ public ConsoleViewer(Composite parent, ForgeRuntime runtime) {
+ super(parent, new Console(runtime));
+ this.runtime = runtime;
+ getDocument().addDocumentListener(new DocumentListener());
}
protected void handleVerifyEvent(VerifyEvent e) {
- console.getInputStream().appendData(e.text);
+ runtime.sendInput(e.text);
e.doit = false;
}
private void handleBackspace() {
- console.getInputStream().appendData(BACKSPACE);
+ runtime.sendInput(BACKSPACE);
}
private void handleArrowUp() {
- console.getInputStream().appendData(UP_ARROW);
+ runtime.sendInput(UP_ARROW);
}
private void handleArrowDown() {
- console.getInputStream().appendData(DOWN_ARROW);
+ runtime.sendInput(DOWN_ARROW);
}
private void handleF1Down() {
Added: trunk/forge/plugins/org.jboss.tools.forge.ui/src/org/jboss/tools/forge/ui/console/ForgeInputReadJob.java
===================================================================
--- trunk/forge/plugins/org.jboss.tools.forge.ui/src/org/jboss/tools/forge/ui/console/ForgeInputReadJob.java (rev 0)
+++ trunk/forge/plugins/org.jboss.tools.forge.ui/src/org/jboss/tools/forge/ui/console/ForgeInputReadJob.java 2011-07-18 11:00:38 UTC (rev 33004)
@@ -0,0 +1,38 @@
+package org.jboss.tools.forge.ui.console;
+
+import java.io.IOException;
+import java.io.InputStream;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.jobs.Job;
+import org.jboss.tools.forge.core.ForgeCorePlugin;
+import org.jboss.tools.forge.core.process.ForgeRuntime;
+
+public class ForgeInputReadJob extends Job {
+
+ private ForgeRuntime runtime;
+ private InputStream input;
+
+ public ForgeInputReadJob(ForgeRuntime runtime, InputStream input) {
+ super("Forge Input Read Job");
+ this.input = input;
+ this.runtime = runtime;
+ }
+
+ protected IStatus run(IProgressMonitor monitor) {
+ try {
+ int read;
+ while (input != null && (read = input.read()) != -1) {
+ runtime.sendInput(new String(new char[] { (char)read }));
+ }
+ } catch (IOException e) {
+ ForgeCorePlugin.log(e);
+ }
+ return Status.OK_STATUS;
+ }
+
+
+
+}
Modified: trunk/forge/plugins/org.jboss.tools.forge.ui/src/org/jboss/tools/forge/ui/part/ConsoleView.java
===================================================================
--- trunk/forge/plugins/org.jboss.tools.forge.ui/src/org/jboss/tools/forge/ui/part/ConsoleView.java 2011-07-18 10:58:26 UTC (rev 33003)
+++ trunk/forge/plugins/org.jboss.tools.forge.ui/src/org/jboss/tools/forge/ui/part/ConsoleView.java 2011-07-18 11:00:38 UTC (rev 33004)
@@ -7,7 +7,6 @@
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.jobs.Job;
-import org.eclipse.debug.core.DebugPlugin;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
@@ -19,7 +18,6 @@
import org.jboss.tools.forge.core.preferences.ForgeRuntimesPreferences;
import org.jboss.tools.forge.core.process.ForgeRuntime;
import org.jboss.tools.forge.ui.ForgeUIPlugin;
-import org.jboss.tools.forge.ui.console.Console;
import org.jboss.tools.forge.ui.console.ConsolePage;
public class ConsoleView extends ViewPart implements PropertyChangeListener {
@@ -123,16 +121,16 @@
private void createRunningPage() {
Control oldForgeIsRunning = running;
ConsolePage oldForgeIsRunningPage = runningPage;
- runningPage = new ConsolePage(runtime.getProcess());
+ runningPage = new ConsolePage(runtime);
runningPage.createControl(pageBook);
runningPage.init(new PageSite(getViewSite()));
running = runningPage.getControl();
if (oldForgeIsRunningPage != null) {
- Console oldConsole = oldForgeIsRunningPage.getConsole();
- if (oldConsole != null) {
- DebugPlugin.getDefault().removeDebugEventListener(oldConsole);
- oldConsole.dispose();
- }
+// Console oldConsole = oldForgeIsRunningPage.getConsole();
+// if (oldConsole != null) {
+// DebugPlugin.getDefault().removeDebugEventListener(oldConsole);
+// oldConsole.dispose();
+// }
oldForgeIsRunningPage.dispose();
}
if (oldForgeIsRunning != null) {
Deleted: trunk/forge/tests/org.jboss.tools.forge.core.test/src/org/jboss/tools/forge/core/io/ForgeInputReadJobTest.java
===================================================================
--- trunk/forge/tests/org.jboss.tools.forge.core.test/src/org/jboss/tools/forge/core/io/ForgeInputReadJobTest.java 2011-07-18 10:58:26 UTC (rev 33003)
+++ trunk/forge/tests/org.jboss.tools.forge.core.test/src/org/jboss/tools/forge/core/io/ForgeInputReadJobTest.java 2011-07-18 11:00:38 UTC (rev 33004)
@@ -1,66 +0,0 @@
-package org.jboss.tools.forge.core.io;
-
-import static org.junit.Assert.assertEquals;
-
-import java.io.IOException;
-import java.io.InputStream;
-
-import org.eclipse.debug.core.model.IStreamMonitor;
-import org.eclipse.debug.core.model.IStreamsProxy;
-import org.junit.Before;
-import org.junit.Test;
-
-public class ForgeInputReadJobTest {
-
- private int[] in;
- private String out;
-
- @Before
- public void setUp() {
- in = null;
- out = "";
- }
-
- @Test
- public void testNullInput() {
- ForgeInputReadJob forgeInputReadJob = new ForgeInputReadJob(new TestStreamProxy(), null);
- forgeInputReadJob.schedule();
- try {
- forgeInputReadJob.join();
- } catch (InterruptedException e) {}
- assertEquals("", out);
- }
-
- @Test
- public void testNormalInput() {
- in = new int[] { 'b', 'l', 'a', 'h', -1 };
- ForgeInputReadJob forgeInputReadJob = new ForgeInputReadJob(new TestStreamProxy(), new TestInputStream());
- forgeInputReadJob.schedule();
- try {
- forgeInputReadJob.join();
- } catch (InterruptedException e) {}
- assertEquals("blah", out);
- }
-
- private class TestStreamProxy implements IStreamsProxy {
- public IStreamMonitor getErrorStreamMonitor() {
- return null;
- }
- public IStreamMonitor getOutputStreamMonitor() {
- return null;
- }
- public void write(String str) throws IOException {
- out += str;
- }
- }
-
- private class TestInputStream extends InputStream {
- int index = 0;
- public int read() throws IOException {
- int result = in.length > index ? in[index] : -1;
- index++;
- return result;
- }
- }
-
-}
Added: trunk/forge/tests/org.jboss.tools.forge.core.test/src/org/jboss/tools/forge/core/io/ForgeInputStreamTest.java
===================================================================
--- trunk/forge/tests/org.jboss.tools.forge.core.test/src/org/jboss/tools/forge/core/io/ForgeInputStreamTest.java (rev 0)
+++ trunk/forge/tests/org.jboss.tools.forge.core.test/src/org/jboss/tools/forge/core/io/ForgeInputStreamTest.java 2011-07-18 11:00:38 UTC (rev 33004)
@@ -0,0 +1,14 @@
+package org.jboss.tools.forge.core.io;
+
+import static org.junit.Assert.*;
+
+import org.junit.Test;
+
+public class ForgeInputStreamTest {
+
+ @Test
+ public void test() {
+ fail("Not yet implemented");
+ }
+
+}
Modified: trunk/forge/tests/org.jboss.tools.forge.core.test/src/org/jboss/tools/forge/core/process/ForgeAbstractRuntimeTest.java
===================================================================
--- trunk/forge/tests/org.jboss.tools.forge.core.test/src/org/jboss/tools/forge/core/process/ForgeAbstractRuntimeTest.java 2011-07-18 10:58:26 UTC (rev 33003)
+++ trunk/forge/tests/org.jboss.tools.forge.core.test/src/org/jboss/tools/forge/core/process/ForgeAbstractRuntimeTest.java 2011-07-18 11:00:38 UTC (rev 33004)
@@ -17,6 +17,8 @@
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Platform;
+import org.eclipse.debug.core.model.IStreamMonitor;
+import org.eclipse.debug.core.model.IStreamsProxy;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
14 years, 9 months
JBoss Tools SVN: r33003 - in trunk/forge/plugins/org.jboss.tools.forge.runtime: META-INF and 1 other directory.
by jbosstools-commits@lists.jboss.org
Author: koen.aers(a)jboss.com
Date: 2011-07-18 06:58:26 -0400 (Mon, 18 Jul 2011)
New Revision: 33003
Modified:
trunk/forge/plugins/org.jboss.tools.forge.runtime/.classpath
trunk/forge/plugins/org.jboss.tools.forge.runtime/META-INF/MANIFEST.MF
trunk/forge/plugins/org.jboss.tools.forge.runtime/build.properties
Log:
export forge api towards use in the org.jboss.tools.forge.runtime.ext plugin
Modified: trunk/forge/plugins/org.jboss.tools.forge.runtime/.classpath
===================================================================
--- trunk/forge/plugins/org.jboss.tools.forge.runtime/.classpath 2011-07-18 10:55:46 UTC (rev 33002)
+++ trunk/forge/plugins/org.jboss.tools.forge.runtime/.classpath 2011-07-18 10:58:26 UTC (rev 33003)
@@ -1,5 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
+ <classpathentry exported="true" kind="lib" path="lib/javax.inject.jar"/>
+ <classpathentry exported="true" kind="lib" path="lib/cdi-api.jar"/>
+ <classpathentry exported="true" kind="lib" path="lib/forge-shell-api.jar"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="output" path="bin"/>
Modified: trunk/forge/plugins/org.jboss.tools.forge.runtime/META-INF/MANIFEST.MF
===================================================================
--- trunk/forge/plugins/org.jboss.tools.forge.runtime/META-INF/MANIFEST.MF 2011-07-18 10:55:46 UTC (rev 33002)
+++ trunk/forge/plugins/org.jboss.tools.forge.runtime/META-INF/MANIFEST.MF 2011-07-18 10:58:26 UTC (rev 33003)
@@ -4,3 +4,13 @@
Bundle-SymbolicName: org.jboss.tools.forge.runtime
Bundle-Version: 1.0.0.qualifier
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
+Bundle-ClassPath: lib/forge-shell-api.jar,
+ lib/cdi-api.jar,
+ lib/javax.inject.jar
+Export-Package: javax.enterprise.context,
+ javax.enterprise.event,
+ javax.inject,
+ org.jboss.forge,
+ org.jboss.forge.shell,
+ org.jboss.forge.shell.events,
+ org.jboss.forge.shell.plugins
Modified: trunk/forge/plugins/org.jboss.tools.forge.runtime/build.properties
===================================================================
--- trunk/forge/plugins/org.jboss.tools.forge.runtime/build.properties 2011-07-18 10:55:46 UTC (rev 33002)
+++ trunk/forge/plugins/org.jboss.tools.forge.runtime/build.properties 2011-07-18 10:58:26 UTC (rev 33003)
@@ -1,2 +1,7 @@
bin.includes = META-INF/,\
- .
+ .,\
+ lib/,\
+ lib/cdi-api.jar,\
+ lib/javax.inject.jar
+\
+
\ No newline at end of file
14 years, 9 months
JBoss Tools SVN: r33002 - in trunk/forge/tests/org.jboss.tools.forge.ui.test: .settings and 8 other directories.
by jbosstools-commits@lists.jboss.org
Author: koen.aers(a)jboss.com
Date: 2011-07-18 06:55:46 -0400 (Mon, 18 Jul 2011)
New Revision: 33002
Added:
trunk/forge/tests/org.jboss.tools.forge.ui.test/.classpath
trunk/forge/tests/org.jboss.tools.forge.ui.test/.project
trunk/forge/tests/org.jboss.tools.forge.ui.test/.settings/
trunk/forge/tests/org.jboss.tools.forge.ui.test/.settings/org.eclipse.jdt.core.prefs
trunk/forge/tests/org.jboss.tools.forge.ui.test/META-INF/
trunk/forge/tests/org.jboss.tools.forge.ui.test/META-INF/MANIFEST.MF
trunk/forge/tests/org.jboss.tools.forge.ui.test/build.properties
trunk/forge/tests/org.jboss.tools.forge.ui.test/src/
trunk/forge/tests/org.jboss.tools.forge.ui.test/src/org/
trunk/forge/tests/org.jboss.tools.forge.ui.test/src/org/jboss/
trunk/forge/tests/org.jboss.tools.forge.ui.test/src/org/jboss/tools/
trunk/forge/tests/org.jboss.tools.forge.ui.test/src/org/jboss/tools/forge/
trunk/forge/tests/org.jboss.tools.forge.ui.test/src/org/jboss/tools/forge/ui/
trunk/forge/tests/org.jboss.tools.forge.ui.test/src/org/jboss/tools/forge/ui/console/
trunk/forge/tests/org.jboss.tools.forge.ui.test/src/org/jboss/tools/forge/ui/console/ForgeInputReadJobTest.java
Log:
initial implementation of the forge ui tests
Added: trunk/forge/tests/org.jboss.tools.forge.ui.test/.classpath
===================================================================
--- trunk/forge/tests/org.jboss.tools.forge.ui.test/.classpath (rev 0)
+++ trunk/forge/tests/org.jboss.tools.forge.ui.test/.classpath 2011-07-18 10:55:46 UTC (rev 33002)
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
Added: trunk/forge/tests/org.jboss.tools.forge.ui.test/.project
===================================================================
--- trunk/forge/tests/org.jboss.tools.forge.ui.test/.project (rev 0)
+++ trunk/forge/tests/org.jboss.tools.forge.ui.test/.project 2011-07-18 10:55:46 UTC (rev 33002)
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.jboss.tools.forge.ui.test</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
Added: trunk/forge/tests/org.jboss.tools.forge.ui.test/.settings/org.eclipse.jdt.core.prefs
===================================================================
--- trunk/forge/tests/org.jboss.tools.forge.ui.test/.settings/org.eclipse.jdt.core.prefs (rev 0)
+++ trunk/forge/tests/org.jboss.tools.forge.ui.test/.settings/org.eclipse.jdt.core.prefs 2011-07-18 10:55:46 UTC (rev 33002)
@@ -0,0 +1,8 @@
+#Fri Jul 15 17:44:51 CEST 2011
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
+org.eclipse.jdt.core.compiler.compliance=1.6
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.6
Added: trunk/forge/tests/org.jboss.tools.forge.ui.test/META-INF/MANIFEST.MF
===================================================================
--- trunk/forge/tests/org.jboss.tools.forge.ui.test/META-INF/MANIFEST.MF (rev 0)
+++ trunk/forge/tests/org.jboss.tools.forge.ui.test/META-INF/MANIFEST.MF 2011-07-18 10:55:46 UTC (rev 33002)
@@ -0,0 +1,11 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: Forge UI Tests
+Bundle-SymbolicName: org.jboss.tools.forge.ui.test
+Bundle-Version: 1.0.0.qualifier
+Bundle-Vendor: JBoss by Red Hat
+Bundle-RequiredExecutionEnvironment: JavaSE-1.6
+Require-Bundle: org.junit;bundle-version="3.8.2",
+ org.eclipse.core.runtime;bundle-version="3.7.0",
+ org.jboss.tools.forge.core;bundle-version="1.0.0",
+ org.jboss.tools.forge.ui;bundle-version="1.0.0"
Added: trunk/forge/tests/org.jboss.tools.forge.ui.test/build.properties
===================================================================
--- trunk/forge/tests/org.jboss.tools.forge.ui.test/build.properties (rev 0)
+++ trunk/forge/tests/org.jboss.tools.forge.ui.test/build.properties 2011-07-18 10:55:46 UTC (rev 33002)
@@ -0,0 +1,4 @@
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .
Added: trunk/forge/tests/org.jboss.tools.forge.ui.test/src/org/jboss/tools/forge/ui/console/ForgeInputReadJobTest.java
===================================================================
--- trunk/forge/tests/org.jboss.tools.forge.ui.test/src/org/jboss/tools/forge/ui/console/ForgeInputReadJobTest.java (rev 0)
+++ trunk/forge/tests/org.jboss.tools.forge.ui.test/src/org/jboss/tools/forge/ui/console/ForgeInputReadJobTest.java 2011-07-18 10:55:46 UTC (rev 33002)
@@ -0,0 +1,83 @@
+package org.jboss.tools.forge.ui.console;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.Method;
+import java.lang.reflect.Proxy;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.jboss.tools.forge.core.process.ForgeRuntime;
+import org.junit.Before;
+import org.junit.Test;
+
+public class ForgeInputReadJobTest {
+
+ private int[] in;
+ private Map<String, List<Object>> invocations = new HashMap<String, List<Object>>();
+
+ @Before
+ public void setUp() {
+ in = null;
+ invocations.clear();
+ }
+
+ @Test
+ public void testNullInput() {
+ ForgeInputReadJob forgeInputReadJob = new ForgeInputReadJob(newForgeTestRuntime(), null);
+ forgeInputReadJob.run(null);
+ assertEquals(0, invocations.size());
+ }
+
+ @Test
+ public void testNormalInput() {
+ in = new int[] { 'b', 'l', 'a', 'h', -1 };
+ ForgeInputReadJob forgeInputReadJob = new ForgeInputReadJob(newForgeTestRuntime(), new TestInputStream());
+ forgeInputReadJob.run(null);
+ assertEquals(1, invocations.size());
+ List<Object> arguments = invocations.get("sendInput");
+ assertNotNull(arguments);
+ assertEquals(1, arguments.size());
+ assertEquals("blah", arguments.get(0));
+ }
+
+ private class TestInputStream extends InputStream {
+ int index = 0;
+ public int read() throws IOException {
+ int result = in.length > index ? in[index] : -1;
+ index++;
+ return result;
+ }
+ }
+
+ private ForgeRuntime newForgeTestRuntime() {
+ ForgeRuntime result = null;
+ try {
+ result = (ForgeRuntime)Proxy.newProxyInstance(
+ ForgeInputReadJobTest.this.getClass().getClassLoader(),
+ new Class[] { ForgeRuntime.class },
+ new ForgeTestRuntime());
+ } catch (Throwable t) {}
+ return result;
+ }
+
+ private class ForgeTestRuntime implements InvocationHandler {
+ @Override
+ public Object invoke(Object proxy, Method method, Object[] args)
+ throws Throwable {
+ List<Object> arguments = new ArrayList<Object>();
+ for (Object arg : args) {
+ arguments.add(arg);
+ }
+ invocations.put(method.getName(), arguments);
+ return null;
+ }
+ }
+
+}
14 years, 9 months