Author: rob.stryker(a)jboss.com
Date: 2007-05-03 12:52:14 -0400 (Thu, 03 May 2007)
New Revision: 1996
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/JBossServerUIPlugin.java
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/server/JBossServerTableViewer.java
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/server/ServerTableViewer.java
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/server/extensions/JBossServerViewExtension.java
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/server/extensions/ServerViewProvider.java
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/server/providers/FilesetViewProvider.java
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/server/providers/ModuleViewProvider.java
Log:
Changes to API for the viewer in response to EXIN-150 and EXIN-149
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/JBossServerUIPlugin.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/JBossServerUIPlugin.java 2007-05-03
14:47:03 UTC (rev 1995)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/JBossServerUIPlugin.java 2007-05-03
16:52:14 UTC (rev 1996)
@@ -22,16 +22,13 @@
package org.jboss.ide.eclipse.as.ui;
import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Comparator;
import java.util.MissingResourceException;
import java.util.ResourceBundle;
-import org.eclipse.core.runtime.IConfigurationElement;
-import org.eclipse.core.runtime.IExtensionRegistry;
import org.eclipse.core.runtime.Platform;
import org.eclipse.ui.IStartup;
import org.eclipse.ui.plugin.AbstractUIPlugin;
+import org.eclipse.wst.server.core.IServer;
import org.jboss.ide.eclipse.as.core.JBossServerCorePlugin;
import org.jboss.ide.eclipse.as.ui.views.server.extensions.ServerViewProvider;
import org.osgi.framework.BundleContext;
@@ -107,11 +104,11 @@
- public ServerViewProvider[] getEnabledViewProviders() {
+ public ServerViewProvider[] getEnabledViewProviders(IServer server) {
ServerViewProvider[] serverViewExtensions = getAllServerViewProviders();
ArrayList list = new ArrayList();
for( int i = 0; i < serverViewExtensions.length; i++ ) {
- if( serverViewExtensions[i].isEnabled()) {
+ if( serverViewExtensions[i].isEnabled() &&
serverViewExtensions[i].supports(server)) {
list.add(serverViewExtensions[i]);
}
}
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/server/JBossServerTableViewer.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/server/JBossServerTableViewer.java 2007-05-03
14:47:03 UTC (rev 1995)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/server/JBossServerTableViewer.java 2007-05-03
16:52:14 UTC (rev 1996)
@@ -1,6 +1,9 @@
package org.jboss.ide.eclipse.as.ui.views.server;
import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Iterator;
+import java.util.List;
import java.util.Properties;
import org.eclipse.jface.action.Action;
@@ -186,7 +189,10 @@
public Object[] getElements(Object inputElement) {
if( inputElement == null ) return new Object[0];
- return JBossServerUIPlugin.getDefault().getEnabledViewProviders();
+ IServer tmp = (IServer)getInput();
+ if( tmp == null )
+ return new Object[0];
+ return JBossServerUIPlugin.getDefault().getEnabledViewProviders(tmp);
}
public Object[] getChildren(Object parentElement) {
@@ -225,7 +231,8 @@
}
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
- ServerViewProvider[] providers =
JBossServerUIPlugin.getDefault().getEnabledViewProviders();
+ ServerViewProvider[] providers = JBossServerUIPlugin.getDefault().
+ getEnabledViewProviders(newInput instanceof IServer ? (IServer)newInput : null);
for( int i = 0; i < providers.length; i++ ) {
try {
providers[i].getDelegate().getContentProvider().inputChanged(viewer, oldInput,
newInput);
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/server/ServerTableViewer.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/server/ServerTableViewer.java 2007-05-03
14:47:03 UTC (rev 1995)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/server/ServerTableViewer.java 2007-05-03
16:52:14 UTC (rev 1996)
@@ -86,7 +86,7 @@
public class TrimmedServerContentProvider implements IStructuredContentProvider,
ITreeContentProvider {
public Object[] getElements(Object element) {
- return ServerConverter.getDeployableServersAsIServers();
+ return ServerCore.getServers();
}
public void inputChanged(Viewer theViewer, Object oldInput, Object newInput) {
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/server/extensions/JBossServerViewExtension.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/server/extensions/JBossServerViewExtension.java 2007-05-03
14:47:03 UTC (rev 1995)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/server/extensions/JBossServerViewExtension.java 2007-05-03
16:52:14 UTC (rev 1996)
@@ -1,5 +1,6 @@
package org.jboss.ide.eclipse.as.ui.views.server.extensions;
+import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.jface.action.IMenuManager;
import org.eclipse.jface.viewers.ITreeContentProvider;
import org.eclipse.jface.viewers.LabelProvider;
@@ -8,6 +9,9 @@
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.views.properties.IPropertySheetPage;
+import org.eclipse.wst.server.core.IServer;
+import org.jboss.ide.eclipse.as.core.server.JBossServer;
+import org.jboss.ide.eclipse.as.core.server.attributes.IDeployableServer;
import org.jboss.ide.eclipse.as.ui.preferencepages.ViewProviderPreferenceComposite;
import org.jboss.ide.eclipse.as.ui.views.server.JBossServerView;
import org.jboss.ide.eclipse.as.ui.views.server.JBossServerTableViewer.ContentWrapper;
@@ -99,4 +103,20 @@
protected void addElement(Object parent, Object child) {
JBossServerView.getDefault().getJBViewer().add(new ContentWrapper(parent, provider),
new ContentWrapper(child, provider));
}
+
+ // what servers should i show for?
+ protected boolean supports(IServer server) {
+ if( server == null ) return false;
+ return isJBossDeployable(server);
+ }
+
+ // show for anything that's jboss deployable
+ protected boolean isJBossDeployable(IServer server) {
+ return (IDeployableServer)server.loadAdapter(IDeployableServer.class, new
NullProgressMonitor()) != null;
+ }
+
+ // show only for full jboss servers
+ protected boolean isJBossServer(IServer server) {
+ return (JBossServer)server.loadAdapter(JBossServer.class, new NullProgressMonitor()) !=
null;
+ }
}
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/server/extensions/ServerViewProvider.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/server/extensions/ServerViewProvider.java 2007-05-03
14:47:03 UTC (rev 1995)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/server/extensions/ServerViewProvider.java 2007-05-03
16:52:14 UTC (rev 1996)
@@ -5,6 +5,7 @@
import org.eclipse.core.runtime.Preferences;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.swt.graphics.Image;
+import org.eclipse.wst.server.core.IServer;
import org.jboss.ide.eclipse.as.ui.JBossServerUIPlugin;
import org.osgi.framework.Bundle;
@@ -108,6 +109,9 @@
}
}
+ public boolean supports(IServer server) {
+ return getDelegate().supports(server);
+ }
public int getWeight() {
return weight;
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/server/providers/FilesetViewProvider.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/server/providers/FilesetViewProvider.java 2007-05-03
14:47:03 UTC (rev 1995)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/server/providers/FilesetViewProvider.java 2007-05-03
16:52:14 UTC (rev 1996)
@@ -78,15 +78,17 @@
createFilter = new Action() {
public void run() {
IDeployableServer server =
(IDeployableServer)contentProvider.server.loadAdapter(IDeployableServer.class, new
NullProgressMonitor());
- FilesetDialog d = new FilesetDialog(new Shell(), server);
- if( d.open() == Window.OK ) {
- Fileset fs = d.getFileset();
- Fileset[] filesetsNew = new Fileset[filesets.length + 1];
- System.arraycopy(filesets, 0, filesetsNew, 0, filesets.length);
- filesetsNew[filesetsNew.length-1] = fs;
- filesets = filesetsNew;
- saveFilesets(true);
- refreshViewer();
+ if( server != null ) {
+ FilesetDialog d = new FilesetDialog(new Shell(), server);
+ if( d.open() == Window.OK ) {
+ Fileset fs = d.getFileset();
+ Fileset[] filesetsNew = new Fileset[filesets.length + 1];
+ System.arraycopy(filesets, 0, filesetsNew, 0, filesets.length);
+ filesetsNew[filesetsNew.length-1] = fs;
+ filesets = filesetsNew;
+ saveFilesets(true);
+ refreshViewer();
+ }
}
}
};
@@ -186,7 +188,7 @@
public IServer server;
public Object[] getChildren(Object parentElement) {
if( parentElement instanceof ServerViewProvider ) {
- return filesets;
+ return filesets == null ? new Object[]{} : filesets;
} else if( parentElement instanceof Fileset ) {
Fileset fs = (Fileset)parentElement;
IPath[] paths = ArchivesCore.findMatchingPaths(
@@ -227,12 +229,14 @@
IServer server = contentProvider.server;
if( server != null ) {
IDeployableServer jbs = (IDeployableServer)server.loadAdapter(IDeployableServer.class,
new NullProgressMonitor());
- ServerAttributeHelper helper = jbs.getAttributeHelper();
- List tmp = helper.getAttribute(FILESET_KEY, new ArrayList());
- String[] asStrings = (String[]) tmp.toArray(new String[tmp.size()]);
- filesets = new Fileset[asStrings.length];
- for( int i = 0; i < asStrings.length; i++ ) {
- filesets[i] = new Fileset(asStrings[i]);
+ if( jbs != null ) {
+ ServerAttributeHelper helper = jbs.getAttributeHelper();
+ List tmp = helper.getAttribute(FILESET_KEY, new ArrayList());
+ String[] asStrings = (String[]) tmp.toArray(new String[tmp.size()]);
+ filesets = new Fileset[asStrings.length];
+ for( int i = 0; i < asStrings.length; i++ ) {
+ filesets[i] = new Fileset(asStrings[i]);
+ }
}
}
}
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/server/providers/ModuleViewProvider.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/server/providers/ModuleViewProvider.java 2007-05-03
14:47:03 UTC (rev 1995)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/server/providers/ModuleViewProvider.java 2007-05-03
16:52:14 UTC (rev 1996)
@@ -118,6 +118,10 @@
return labelProvider;
}
+ public boolean supports(IServer server) {
+ return true;
+ }
+
class ModuleContentProvider implements ITreeContentProvider {