Author: rob.stryker(a)jboss.com
Date: 2011-07-29 05:18:35 -0400 (Fri, 29 Jul 2011)
New Revision: 33347
Added:
trunk/as/plugins/org.jboss.ide.eclipse.as.classpath.core/src/org/jboss/ide/eclipse/as/classpath/core/runtime/CustomRuntimeClasspathModel.java
trunk/as/plugins/org.jboss.ide.eclipse.as.classpath.ui/src/org/jboss/ide/eclipse/as/classpath/ui/containers/
trunk/as/plugins/org.jboss.ide.eclipse.as.classpath.ui/src/org/jboss/ide/eclipse/as/classpath/ui/containers/custom/
trunk/as/plugins/org.jboss.ide.eclipse.as.classpath.ui/src/org/jboss/ide/eclipse/as/classpath/ui/containers/custom/CustomClasspathPreferencePage.java
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.archives.webtools/src/org/jboss/ide/eclipse/archives/webtools/filesets/DefaultFilesetPreferencePage.java
trunk/as/plugins/org.jboss.ide.eclipse.archives.webtools/src/org/jboss/ide/eclipse/archives/webtools/filesets/Fileset.java
trunk/as/plugins/org.jboss.ide.eclipse.archives.webtools/src/org/jboss/ide/eclipse/archives/webtools/filesets/FilesetContentProvider.java
trunk/as/plugins/org.jboss.ide.eclipse.archives.webtools/src/org/jboss/ide/eclipse/archives/webtools/filesets/FilesetDialog.java
trunk/as/plugins/org.jboss.ide.eclipse.archives.webtools/src/org/jboss/ide/eclipse/archives/webtools/filesets/FilesetUtil.java
trunk/as/plugins/org.jboss.ide.eclipse.as.classpath.core/META-INF/MANIFEST.MF
trunk/as/plugins/org.jboss.ide.eclipse.as.classpath.core/src/org/jboss/ide/eclipse/as/classpath/core/runtime/ClientAllRuntimeClasspathProvider.java
trunk/as/plugins/org.jboss.ide.eclipse.as.classpath.ui/META-INF/MANIFEST.MF
trunk/as/plugins/org.jboss.ide.eclipse.as.classpath.ui/plugin.xml
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/resolvers/ConfigNameResolver.java
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/preferences/ServerTypePreferencePage.java
Log:
JBIDE-1354 - implementation with a preference page
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.archives.webtools/src/org/jboss/ide/eclipse/archives/webtools/filesets/DefaultFilesetPreferencePage.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.archives.webtools/src/org/jboss/ide/eclipse/archives/webtools/filesets/DefaultFilesetPreferencePage.java 2011-07-29
08:56:15 UTC (rev 33346)
+++
trunk/as/plugins/org.jboss.ide.eclipse.archives.webtools/src/org/jboss/ide/eclipse/archives/webtools/filesets/DefaultFilesetPreferencePage.java 2011-07-29
09:18:35 UTC (rev 33347)
@@ -24,7 +24,6 @@
import org.jboss.ide.eclipse.as.ui.preferences.ServerTypePreferencePage;
public class DefaultFilesetPreferencePage extends ServerTypePreferencePage {
- private FilesetPreferenceComposite rootComp;
@Override
protected Control createContents(Composite parent) {
rootComp = new FilesetPreferenceComposite(parent, SWT.NONE);
@@ -38,7 +37,7 @@
ArrayList<Object> list;
Fileset[] arr;
for( int i = 0; i < changed2.length; i++ ) {
- list = rootComp.getDataForServer(changed2[i]);
+ list = rootComp.getDataForComboSelection(changed2[i]);
arr = (Fileset[]) list.toArray(new Fileset[list.size()]);
IPath fileToWrite = FilesetUtil.DEFAULT_FS_ROOT.append(changed2[i]);
FilesetUtil.saveFilesets(fileToWrite.toFile(), arr);
@@ -72,7 +71,7 @@
super.initializeDataModel();
}
- protected Object[] getCurrentServerDataModel() {
+ protected Object[] getCurrentSelectionDataModel() {
return getCurrentServerSets();
}
@@ -80,7 +79,7 @@
String id = getCurrentId();
ArrayList<Object> list = new ArrayList<Object>();
if( id != null ) {
- list = getDataForServer(id);
+ list = getDataForComboSelection(id);
if( list == null ) {
IPath fileToRead = FilesetUtil.DEFAULT_FS_ROOT.append(id);
Fileset[] sets = FilesetUtil.loadFilesets(fileToRead.toFile(), null);
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.archives.webtools/src/org/jboss/ide/eclipse/archives/webtools/filesets/Fileset.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.archives.webtools/src/org/jboss/ide/eclipse/archives/webtools/filesets/Fileset.java 2011-07-29
08:56:15 UTC (rev 33346)
+++
trunk/as/plugins/org.jboss.ide.eclipse.archives.webtools/src/org/jboss/ide/eclipse/archives/webtools/filesets/Fileset.java 2011-07-29
09:18:35 UTC (rev 33347)
@@ -10,19 +10,26 @@
******************************************************************************/
package org.jboss.ide.eclipse.archives.webtools.filesets;
+import java.io.File;
+
import org.eclipse.core.internal.variables.StringSubstitutionEngine;
import org.eclipse.core.internal.variables.StringVariableManager;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
+import org.eclipse.wst.server.core.IRuntime;
import org.eclipse.wst.server.core.IServer;
+import org.jboss.ide.eclipse.archives.core.asf.DirectoryScanner;
+import org.jboss.ide.eclipse.archives.core.model.DirectoryScannerFactory;
public class Fileset implements Cloneable {
private static final String HASH_SEPARATOR = "::_::"; //$NON-NLS-1$
private static final String SEP = "\n"; //$NON-NLS-1$
private String name, folder, includesPattern, excludesPattern;
+ private IRuntime runtime;
private IServer server;
+
public Fileset() {
}
public Fileset(String string) {
@@ -45,18 +52,31 @@
public String toString() {
return name + SEP + folder + SEP + includesPattern + SEP + excludesPattern;
}
- /**
+
+ public static final String JBOSS_CONFIG_DIR_ARG = "${jboss_config_dir}";
//$NON-NLS-1$
+ public static final String JBOSS_SERVER_ARG = "${jboss_config}";
//$NON-NLS-1$
+
+ public static final String getConfigDirSubstitute(IRuntime rt) {
+ return "${jboss_config_dir:" + rt.getName() + "}"; //$NON-NLS-1$
//$NON-NLS-2$
+ }
+
+ public static final String getServerSubstitute(IRuntime rt) {
+ return "${jboss_config:" + rt.getName() + "}"; //$NON-NLS-1$
//$NON-NLS-2$
+ }
+
+ /**
* @return the folder
*/
public String getFolder() {
+ return getFolder(folder, runtime);
+ }
+
+ public static String getFolder(String folder, IRuntime runtime) {
String tmp = folder == null ? "" : folder; //$NON-NLS-1$
- if( server != null ) {
- tmp = tmp.replace("${jboss_config_dir}", //$NON-NLS-1$
- "${jboss_config_dir:" + server.getName() + "}"); //$NON-NLS-1$
//$NON-NLS-2$
- tmp = tmp.replace("${jboss_config}", //$NON-NLS-1$
- "${jboss_config:" + server.getName() + "}"); //$NON-NLS-1$
//$NON-NLS-2$
+ if( runtime != null ) {
+ tmp = tmp.replace(JBOSS_CONFIG_DIR_ARG, getConfigDirSubstitute(runtime));
+ tmp = tmp.replace(JBOSS_SERVER_ARG, getServerSubstitute(runtime));
}
-
try {
StringSubstitutionEngine engine = new StringSubstitutionEngine();
tmp = engine.performStringSubstitution(tmp, true,
@@ -64,9 +84,8 @@
} catch( CoreException ce ) {}
IPath p = new Path(tmp);
- if( !p.isAbsolute() && server != null ) {
- if( server.getRuntime() != null )
- p = server.getRuntime().getLocation().append(p);
+ if( !p.isAbsolute() && runtime != null ) {
+ p = runtime.getLocation().append(p);
}
return p.toString();
}
@@ -122,9 +141,22 @@
this.name = name;
}
- public IServer getServer() { return this.server; }
- public void setServer(IServer server) { this.server = server; }
-
+ public IServer getServer() {
+ return this.server;
+ }
+ public void setServer(IServer server) {
+ this.server = server;
+ this.runtime = server == null ? null : server.getRuntime();
+ }
+ public IRuntime getRuntime() {
+ return runtime;
+ }
+ public void setRuntime(IRuntime rt) {
+ runtime = rt;
+ if( server == null || server.getRuntime().equals(rt))
+ server = null;
+ }
+
public Object clone() {
try {
return super.clone();
@@ -142,4 +174,32 @@
public int hashCode() {
return (name + HASH_SEPARATOR + folder + HASH_SEPARATOR + includesPattern +
HASH_SEPARATOR + excludesPattern + HASH_SEPARATOR).hashCode();
}
+
+ public IPath[] findPaths() {
+ String dir = getFolder();
+ String includes = getIncludesPattern();
+ String excludes = getExcludesPattern();
+ return findPaths(dir, includes, excludes);
+ }
+ public static IPath[] findPaths(String dir, String includes, String excludes) {
+ IPath[] paths = new IPath[0];
+ try {
+ if (dir != null && new File(dir).exists()) {
+ DirectoryScanner scanner = DirectoryScannerFactory
+ .createDirectoryScanner(dir, null, includes, excludes,
+ null, false, 1, true);
+ if (scanner != null) {
+ String[] files = scanner.getIncludedFiles();
+ paths = new IPath[files.length];
+ for (int i = 0; i < files.length; i++) {
+ paths[i] = new Path(files[i]);
+ }
+ }
+ }
+ } catch (IllegalStateException ise) {
+ }
+ return paths;
+ }
+
+
}
\ No newline at end of file
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.archives.webtools/src/org/jboss/ide/eclipse/archives/webtools/filesets/FilesetContentProvider.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.archives.webtools/src/org/jboss/ide/eclipse/archives/webtools/filesets/FilesetContentProvider.java 2011-07-29
08:56:15 UTC (rev 33346)
+++
trunk/as/plugins/org.jboss.ide.eclipse.archives.webtools/src/org/jboss/ide/eclipse/archives/webtools/filesets/FilesetContentProvider.java 2011-07-29
09:18:35 UTC (rev 33347)
@@ -21,8 +21,6 @@
import org.eclipse.jface.viewers.ITreeContentProvider;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.wst.server.core.IServer;
-import org.jboss.ide.eclipse.archives.core.asf.DirectoryScanner;
-import org.jboss.ide.eclipse.archives.core.model.DirectoryScannerFactory;
import org.jboss.ide.eclipse.as.core.server.internal.ServerAttributeHelper;
public class FilesetContentProvider implements ITreeContentProvider {
@@ -185,8 +183,7 @@
Fileset fs = (Fileset) parentElement;
IPath[] paths = null;
try {
- paths = findPaths(fs.getFolder(), fs.getIncludesPattern(), fs
- .getExcludesPattern());
+ paths = findPaths(fs);
} catch (BuildException be) {
return new Object[] {};
}
@@ -227,24 +224,8 @@
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
}
- private IPath[] findPaths(String dir, String includes, String excludes) {
- IPath[] paths = new IPath[0];
- try {
- if (dir != null) {
- DirectoryScanner scanner = DirectoryScannerFactory
- .createDirectoryScanner(dir, null, includes, excludes,
- null, false, 1, true);
- if (scanner != null) {
- String[] files = scanner.getIncludedFiles();
- paths = new IPath[files.length];
- for (int i = 0; i < files.length; i++) {
- paths[i] = new Path(files[i]);
- }
- }
- }
- } catch (IllegalStateException ise) {
- }
- return paths;
+ private IPath[] findPaths(Fileset fs) {
+ return fs.findPaths();
}
private static void addPath(ArrayList<PathWrapper> children,
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.archives.webtools/src/org/jboss/ide/eclipse/archives/webtools/filesets/FilesetDialog.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.archives.webtools/src/org/jboss/ide/eclipse/archives/webtools/filesets/FilesetDialog.java 2011-07-29
08:56:15 UTC (rev 33346)
+++
trunk/as/plugins/org.jboss.ide.eclipse.archives.webtools/src/org/jboss/ide/eclipse/archives/webtools/filesets/FilesetDialog.java 2011-07-29
09:18:35 UTC (rev 33347)
@@ -10,10 +10,6 @@
******************************************************************************/
package org.jboss.ide.eclipse.archives.webtools.filesets;
-import java.io.File;
-import java.util.ArrayList;
-import java.util.Iterator;
-
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
import org.eclipse.jface.dialogs.IDialogConstants;
@@ -36,9 +32,6 @@
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;
import org.eclipse.wst.server.core.IServer;
-import org.jboss.ide.eclipse.archives.core.asf.DirectoryScanner;
-import org.jboss.ide.eclipse.archives.core.model.DirectoryScannerFactory;
-import
org.jboss.ide.eclipse.archives.core.model.DirectoryScannerFactory.DirectoryScannerExtension.FileWrapper;
import org.jboss.ide.eclipse.archives.ui.util.composites.FilesetPreviewComposite;
import org.jboss.ide.eclipse.archives.webtools.Messages;
@@ -240,28 +233,7 @@
return fileset;
}
-
private static IPath[] findPaths(String dir, String includes, String excludes) {
- try {
- if( dir != null ) {
- DirectoryScanner scanner =
- DirectoryScannerFactory.createDirectoryScanner(dir, null, includes, excludes, null,
false, 1, false);
- if( scanner != null ) {
- Iterator<File> i = scanner.iterator();
- ArrayList<IPath> paths2 = new ArrayList<IPath>();
- while(i.hasNext() && paths2.size() < 30) {
- FileWrapper fw = (FileWrapper)i.next();
- paths2.add(new Path(fw.getFilesetRelative()));
- }
-
- return (IPath[]) paths2.toArray(new IPath[paths2.size()]);
- }
- }
- } catch( IllegalStateException ise ) {}
- catch(Exception e) {
- e.printStackTrace();
- }
- return new IPath[]{};
+ return Fileset.findPaths(dir, includes, excludes);
}
-
}
\ No newline at end of file
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.archives.webtools/src/org/jboss/ide/eclipse/archives/webtools/filesets/FilesetUtil.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.archives.webtools/src/org/jboss/ide/eclipse/archives/webtools/filesets/FilesetUtil.java 2011-07-29
08:56:15 UTC (rev 33346)
+++
trunk/as/plugins/org.jboss.ide.eclipse.archives.webtools/src/org/jboss/ide/eclipse/archives/webtools/filesets/FilesetUtil.java 2011-07-29
09:18:35 UTC (rev 33347)
@@ -1,3 +1,13 @@
+/*******************************************************************************
+ * 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.archives.webtools.filesets;
import java.io.File;
@@ -31,6 +41,14 @@
}
public static Fileset[] loadFilesets(InputStream is, IServer server) {
+ Fileset[] sets = loadFilesets(is);
+ for( int i = 0; i < sets.length; i++ ) {
+ sets[i].setServer(server);
+ }
+ return sets;
+ }
+
+ public static Fileset[] loadFilesets(InputStream is) {
Fileset[] filesets = null;
XMLMemento memento = XMLMemento.createReadRoot(is);
IMemento[] categoryMementos = memento.getChildren("fileset");//$NON-NLS-1$
@@ -42,7 +60,6 @@
includes = categoryMementos[i].getString("includes");//$NON-NLS-1$
excludes = categoryMementos[i].getString("excludes");//$NON-NLS-1$
filesets[i] = new Fileset(name, folder, includes, excludes);
- filesets[i].setServer(server);
}
return filesets == null ? new Fileset[] { } : filesets;
}
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.classpath.core/META-INF/MANIFEST.MF
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.classpath.core/META-INF/MANIFEST.MF 2011-07-29
08:56:15 UTC (rev 33346)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.classpath.core/META-INF/MANIFEST.MF 2011-07-29
09:18:35 UTC (rev 33347)
@@ -12,7 +12,8 @@
org.eclipse.jst.server.core;bundle-version="1.2.101",
org.eclipse.wst.common.project.facet.core;bundle-version="1.4.200",
org.eclipse.jst.common.project.facet.core;bundle-version="1.4.200",
- org.jboss.ide.eclipse.as.core
+ org.jboss.ide.eclipse.as.core,
+ org.jboss.ide.eclipse.archives.webtools;bundle-version="2.2.0"
Bundle-ActivationPolicy: lazy
Export-Package: org.jboss.ide.eclipse.as.classpath.core,
org.jboss.ide.eclipse.as.classpath.core.ejb3,
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.classpath.core/src/org/jboss/ide/eclipse/as/classpath/core/runtime/ClientAllRuntimeClasspathProvider.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.classpath.core/src/org/jboss/ide/eclipse/as/classpath/core/runtime/ClientAllRuntimeClasspathProvider.java 2011-07-29
08:56:15 UTC (rev 33346)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.classpath.core/src/org/jboss/ide/eclipse/as/classpath/core/runtime/ClientAllRuntimeClasspathProvider.java 2011-07-29
09:18:35 UTC (rev 33347)
@@ -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,
@@ -16,7 +16,7 @@
import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.Arrays;
-import java.util.HashSet;
+import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
@@ -33,6 +33,7 @@
import org.jboss.ide.eclipse.as.classpath.core.ClasspathCorePlugin;
import org.jboss.ide.eclipse.as.classpath.core.Messages;
import org.jboss.ide.eclipse.as.classpath.core.RuntimeKey;
+import
org.jboss.ide.eclipse.as.classpath.core.runtime.CustomRuntimeClasspathModel.IDefaultPathProvider;
/**
* This class uses the "throw everything you can find" strategy
@@ -111,34 +112,12 @@
if (runtimeClasspath != null) {
return runtimeClasspath;
}
- IPath loc = key.getLocation();
- IPath configPath = key.getConfigPath();
- String rtID = key.getId();
- Set<Entry> list = new HashSet<Entry>();
- if(AS_32.equals(rtID)) list = get32(loc, configPath);
- if(AS_40.equals(rtID)) list = get40(loc,configPath);
- if(AS_42.equals(rtID)) list = get42(loc,configPath);
- if(AS_50.equals(rtID)) list = get50(loc,configPath);
- if(EAP_43.equals(rtID)) list = getEAP43(loc,configPath);
-
- // Added cautiously, not sure on changes, may change
- if(AS_51.equals(rtID)) list = get50(loc,configPath);
- if(AS_60.equals(rtID)) list = get60(loc,configPath);
- if(EAP_50.equals(rtID)) list = get50(loc,configPath);
-
- if( AS_70.equals(rtID)) list = get70(loc);
-
- if( list == null ) {
- runtimeClasspath = new IClasspathEntry[0];
- } else {
- List<IClasspathEntry> entries = convert(list);
- runtimeClasspath = entries.toArray(new IClasspathEntry[entries.size()]);
- }
+ runtimeClasspath = getClasspathEntriesForRuntime(runtime);
ClasspathCorePlugin.getRuntimeClasspaths().put(key, runtimeClasspath);
return runtimeClasspath;
}
- protected List<IClasspathEntry> convert(Set<Entry> list) {
+ protected List<IClasspathEntry> convert(Collection<Entry> list) {
List<IClasspathEntry> fin = new ArrayList<IClasspathEntry>();
Iterator<Entry> i = list.iterator();
while(i.hasNext()) {
@@ -147,72 +126,17 @@
return fin;
}
- protected Set<Entry> get32(IPath location, IPath configPath) {
- Set<Entry> list = new HashSet<Entry>();
- addPaths(location.append(LIB), list);
- addPaths(configPath.append(LIB), list);
- addPaths(location.append(CLIENT), list);
- return list;
+ protected IClasspathEntry[] getClasspathEntriesForRuntime(IRuntime rt) {
+ IDefaultPathProvider[] sets =
CustomRuntimeClasspathModel.getInstance().getEntries(rt.getRuntimeType());
+ IPath[] allPaths = CustomRuntimeClasspathModel.getInstance().getAllEntries(rt, sets);
+ ArrayList<Entry> entries = new ArrayList<Entry>();
+ for( int i = 0; i < allPaths.length; i++ ) {
+ addSinglePath(allPaths[i], entries);
+ }
+ List<IClasspathEntry> ret = convert(entries);
+ return (IClasspathEntry[]) ret.toArray(new IClasspathEntry[ret.size()]);
}
- protected Set<Entry> get40(IPath location, IPath configPath) {
- Set<Entry> list = new HashSet<Entry>();
- addPaths(location.append(LIB), list);
- addPaths(configPath.append(LIB), list);
- IPath deployPath = configPath.append(DEPLOY);
- addPaths(deployPath.append(JBOSS_WEB_DEPLOYER).append(JSF_LIB), list);
- addPaths(deployPath.append(AOP_JDK5_DEPLOYER), list);
- addPaths(deployPath.append(EJB3_DEPLOYER), list);
- addPaths(location.append(CLIENT), list);
- return list;
- }
-
- protected Set<Entry> get42(IPath location, IPath configPath) {
- return get40(location, configPath);
- }
-
- protected Set<Entry> getEAP43(IPath location, IPath configPath) {
- return get40(location, configPath);
- }
-
- protected Set<Entry> get50(IPath location, IPath configPath) {
- Set<Entry> list = new HashSet<Entry>();
- addPaths(location.append(COMMON).append(LIB), list);
- addPaths(location.append(LIB), list);
- addPaths(configPath.append(LIB), list);
- IPath deployerPath = configPath.append(DEPLOYERS);
- IPath deployPath = configPath.append(DEPLOY);
- addPaths(deployPath.append(JBOSSWEB_SAR).append(JSF_LIB),list);
- addPaths(deployPath.append(JBOSSWEB_SAR).append(JBOSS_WEB_SERVICE_JAR),list);
- addPaths(deployPath.append(JBOSSWEB_SAR).append(JSTL_JAR),list);
- addPaths(deployerPath.append(AS5_AOP_DEPLOYER), list);
- addPaths(deployerPath.append(EJB3_DEPLOYER), list);
- addPaths(deployerPath.append(WEBBEANS_DEPLOYER).append(JSR299_API_JAR), list);
- addPaths(location.append(CLIENT), list);
- return list;
- }
-
- protected Set<Entry> get60(IPath location, IPath configPath) {
- Set<Entry> list = new HashSet<Entry>();
- list.addAll(get50(location, configPath));
- addPaths(configPath.append(DEPLOYERS).append(REST_EASY_DEPLOYER), list);
- addPaths(configPath.append(DEPLOYERS).append(JSF_DEPLOYER).append(MOJARRA_20).append(JSF_LIB),
list);
- return list;
- }
-
- protected Set<Entry> get70(IPath location) {
- Set<Entry> list = new HashSet<Entry>();
- SimpleFileFilter filter = new SimpleFileFilter(new
String[]{"jsf-api-1.2_13.jar", "jsf-impl-1.2_13.jar"}); // Problematic
jar //$NON-NLS-1$
- addPaths(location.append(AS7_MODULES).append(JAVAX), list, true, filter);
- addPaths(location.append(AS7_MODULES).append("org/hibernate/validator"),list,
true);
- addPaths(location.append(AS7_MODULES).append("org/resteasy"),list, true);
- addPaths(location.append(AS7_MODULES).append("org/picketbox"),list, true);
- addPaths(location.append(AS7_MODULES).append("org/jboss/as/controller-client/main/"),list,
true);
- addPaths(location.append(AS7_MODULES).append("org/jboss/dmr/main/"),list,
true);
-
- return list;
- }
-
protected IClasspathEntry getEntry(Entry entry) {
return
JavaRuntime.newArchiveRuntimeClasspathEntry(entry.getPath()).getClasspathEntry();
}
@@ -261,7 +185,11 @@
return;
}
list.add(new Entry(p, p.lastSegment(), p.toFile().length()));
-
}
-
+ protected void addSinglePath(IPath p, ArrayList<Entry> list) {
+ if (!p.toFile().exists()) {
+ return;
+ }
+ list.add(new Entry(p, p.lastSegment(), p.toFile().length()));
+ }
}
Added:
trunk/as/plugins/org.jboss.ide.eclipse.as.classpath.core/src/org/jboss/ide/eclipse/as/classpath/core/runtime/CustomRuntimeClasspathModel.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.classpath.core/src/org/jboss/ide/eclipse/as/classpath/core/runtime/CustomRuntimeClasspathModel.java
(rev 0)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.classpath.core/src/org/jboss/ide/eclipse/as/classpath/core/runtime/CustomRuntimeClasspathModel.java 2011-07-29
09:18:35 UTC (rev 33347)
@@ -0,0 +1,220 @@
+/*******************************************************************************
+ * 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.classpath.core.runtime;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.wst.server.core.IRuntime;
+import org.eclipse.wst.server.core.IRuntimeType;
+import org.eclipse.wst.server.core.internal.XMLMemento;
+import org.jboss.ide.eclipse.archives.webtools.filesets.Fileset;
+import org.jboss.ide.eclipse.archives.webtools.filesets.FilesetUtil;
+import org.jboss.ide.eclipse.as.core.JBossServerCorePlugin;
+import org.jboss.ide.eclipse.as.core.util.IJBossRuntimeResourceConstants;
+import org.jboss.ide.eclipse.as.core.util.IJBossToolingConstants;
+
+public class CustomRuntimeClasspathModel implements IJBossToolingConstants,
IJBossRuntimeResourceConstants {
+ protected static IPath DEFAULT_CLASSPATH_FS_ROOT =
JBossServerCorePlugin.getGlobalSettingsLocation().append("filesets").append("runtimeClasspaths");
//$NON-NLS-1$ //$NON-NLS-2$
+
+ private static CustomRuntimeClasspathModel instance;
+ public static CustomRuntimeClasspathModel getInstance() {
+ if( instance == null )
+ instance = new CustomRuntimeClasspathModel();
+ return instance;
+ }
+
+ public static interface IDefaultPathProvider {
+ public IPath[] getAbsolutePaths();
+ public void setRuntime(IRuntime rt);
+ }
+
+ public static class PathProviderFileset extends Fileset implements IDefaultPathProvider
{
+ public PathProviderFileset(Fileset set) {
+ super(set.getName(), set.getRawFolder(), set.getIncludesPattern(),
set.getExcludesPattern());
+ }
+ public PathProviderFileset(String baseFolder) {
+ this("", baseFolder, "**/*.jar", "");
+ }
+ public PathProviderFileset(String name, String folder, String inc, String exc) {
+ super(name, folder, inc, exc);
+ }
+ public IPath[] getAbsolutePaths() {
+ IPath[] setPaths = findPaths();
+ IPath[] absolute = new IPath[setPaths.length];
+ for( int j = 0; j < setPaths.length; j++ ) {
+ absolute[j] = new Path(getFolder()).append(setPaths[j]);
+ }
+ return absolute;
+ }
+ }
+
+ public IDefaultPathProvider[] getEntries(IRuntimeType type) {
+ IDefaultPathProvider[] sets = loadFilesets(type);
+ if( sets == null || sets.length == 0) {
+ return getDefaultEntries(type);
+ }
+ return sets;
+ }
+
+ public IDefaultPathProvider[] getDefaultEntries(IRuntimeType type) {
+ String rtID = type.getId();
+ if(AS_32.equals(rtID))
+ return getDefaultAS3Entries();
+ if(AS_40.equals(rtID))
+ return getDefaultAS40Entries();
+ if(AS_42.equals(rtID))
+ return getDefaultAS40Entries();
+ if(AS_50.equals(rtID))
+ return getDefaultAS50Entries();
+ if(EAP_43.equals(rtID))
+ return getDefaultEAP43Entries();
+ // Added cautiously, not sure on changes, may change
+ if(AS_51.equals(rtID))
+ return getDefaultAS50Entries();
+ if(AS_60.equals(rtID))
+ return getDefaultAS60Entries();
+ if(EAP_50.equals(rtID))
+ return getDefaultAS50Entries();
+
+ if(AS_70.equals(type.getId()))
+ return getDefaultAS70Entries();
+ return new IDefaultPathProvider[]{};
+ }
+
+ public IPath[] getDefaultPaths(IRuntime rt) {
+ return getAllEntries(rt, getDefaultEntries(rt.getRuntimeType()));
+ }
+
+
+ protected IDefaultPathProvider[] getDefaultAS3Entries() {
+ ArrayList<PathProviderFileset> sets = new
ArrayList<PathProviderFileset>();
+ String configPath = "${jboss_config_dir}";
+ String deployerPath = configPath + "/" + DEPLOYERS;
+ String deployPath = configPath + "/" + DEPLOY;
+ sets.add(new PathProviderFileset(LIB));
+ sets.add(new PathProviderFileset(configPath + "/" + LIB));
+ sets.add(new PathProviderFileset(CLIENT));
+ return sets.toArray(new PathProviderFileset[sets.size()]);
+ }
+
+ protected IDefaultPathProvider[] getDefaultAS40Entries() {
+ ArrayList<PathProviderFileset> sets = new
ArrayList<PathProviderFileset>();
+ String configPath = "${jboss_config_dir}";
+ String deployerPath = configPath + "/" + DEPLOYERS;
+ String deployPath = configPath + "/" + DEPLOY;
+ sets.add(new PathProviderFileset(LIB));
+ sets.add(new PathProviderFileset(configPath + "/" + LIB));
+ sets.add(new PathProviderFileset(deployPath + "/" + JBOSS_WEB_DEPLOYER +
"/" + JSF_LIB));
+ sets.add(new PathProviderFileset(deployPath + "/" + AOP_JDK5_DEPLOYER));
+ sets.add(new PathProviderFileset(deployPath + "/" + EJB3_DEPLOYER));
+ sets.add(new PathProviderFileset(CLIENT));
+ return sets.toArray(new PathProviderFileset[sets.size()]);
+ }
+
+ protected IDefaultPathProvider[] get42() {
+ return getDefaultAS40Entries();
+ }
+
+ protected IDefaultPathProvider[] getDefaultEAP43Entries() {
+ return getDefaultAS40Entries();
+ }
+
+ protected IDefaultPathProvider[] getDefaultAS50Entries() {
+ ArrayList<PathProviderFileset> sets = new
ArrayList<PathProviderFileset>();
+ String configPath = "${jboss_config_dir}";
+ String deployerPath = configPath + "/" + DEPLOYERS;
+ String deployPath = configPath + "/" + DEPLOY;
+ sets.add(new PathProviderFileset(COMMON + "/" + LIB));
+ sets.add(new PathProviderFileset(LIB));
+ sets.add(new PathProviderFileset(configPath + "/" + LIB));
+
+ sets.add(new PathProviderFileset(deployPath + "/" + JBOSSWEB_SAR +
"/" + JSF_LIB));
+ sets.add(new PathProviderFileset(deployPath + "/" + JBOSSWEB_SAR +
"/" + JBOSS_WEB_SERVICE_JAR));
+ sets.add(new PathProviderFileset(deployPath + "/" + JBOSSWEB_SAR +
"/" + JSTL_JAR));
+ sets.add(new PathProviderFileset(deployerPath + "/" + AS5_AOP_DEPLOYER));
+ sets.add(new PathProviderFileset(deployerPath + "/" + EJB3_DEPLOYER));
+ sets.add(new PathProviderFileset(deployerPath + "/" + WEBBEANS_DEPLOYER +
"/" +JSR299_API_JAR));
+ sets.add(new PathProviderFileset(CLIENT));
+ return sets.toArray(new PathProviderFileset[sets.size()]);
+ }
+
+ public IDefaultPathProvider[] getDefaultAS60Entries() {
+ ArrayList<IDefaultPathProvider> sets = new
ArrayList<IDefaultPathProvider>();
+ String configPath = "${jboss_config_dir}";
+ sets.addAll(Arrays.asList(getDefaultAS50Entries()));
+ sets.add(new PathProviderFileset(configPath + "/" + DEPLOYERS + "/"
+ REST_EASY_DEPLOYER));
+ sets.add(new PathProviderFileset(configPath + "/" + DEPLOYERS + "/"
+ JSF_DEPLOYER + "/" + MOJARRA_20 + "/" + JSF_LIB));
+ return sets.toArray(new PathProviderFileset[sets.size()]);
+ }
+ public IDefaultPathProvider[] getDefaultAS70Entries() {
+ ArrayList<IDefaultPathProvider> sets = new
ArrayList<IDefaultPathProvider>();
+ sets.add(new PathProviderFileset("", "modules/javax",
"**/*.jar", "**/jsf-api-1.2*.jar"));
+ sets.add(new PathProviderFileset("modules/org/hibernate/validator"));
+ sets.add(new PathProviderFileset("modules/org/resteasy"));
+ sets.add(new PathProviderFileset("modules/org/picketbox"));
+ sets.add(new
PathProviderFileset("modules/org/jboss/as/controller-client/main/"));
+ sets.add(new PathProviderFileset("modules/org/jboss/dmr/main/"));
+ sets.add(new PathProviderFileset("modules/org/jboss/logging/main"));
+ sets.add(new
PathProviderFileset("modules/org/jboss/resteasy/resteasy-jaxb-provider/main"));
+ sets.add(new
PathProviderFileset("modules/org/jboss/resteasy/resteasy-jaxrs/main"));
+ sets.add(new
PathProviderFileset("modules/org/jboss/resteasy/resteasy-multipart-provider/main"));
+
+ return (IDefaultPathProvider[]) sets.toArray(new IDefaultPathProvider[sets.size()]);
+ }
+
+ public IPath[] getAllEntries(IRuntime runtime, IDefaultPathProvider[] sets) {
+ ArrayList<IPath> retval = new ArrayList<IPath>();
+ for( int i = 0; i < sets.length; i++ ) {
+ sets[i].setRuntime(runtime);
+ IPath[] absolute = sets[i].getAbsolutePaths();
+ for( int j = 0; j < absolute.length; j++ ) {
+ if( !retval.contains(absolute[j]))
+ retval.add(absolute[j]);
+ }
+ }
+ return (IPath[]) retval.toArray(new IPath[retval.size()]);
+ }
+
+
+ /*
+ * Persistance of the model
+ */
+
+ public static IDefaultPathProvider[] loadFilesets(IRuntimeType rt) {
+ IPath fileToRead = DEFAULT_CLASSPATH_FS_ROOT.append(rt.getId());
+ Fileset[] sets = FilesetUtil.loadFilesets(fileToRead.toFile(), null);
+ PathProviderFileset[] newSets = new PathProviderFileset[sets.length];
+ for( int i = 0; i < sets.length; i++ ) {
+ newSets[i] = new PathProviderFileset(sets[i]);
+ }
+ return newSets;
+ }
+
+ public static void saveFilesets(IRuntimeType runtime, IDefaultPathProvider[] sets) {
+ IPath fileToWrite = DEFAULT_CLASSPATH_FS_ROOT.append(runtime.getId());
+ XMLMemento memento = XMLMemento.createWriteRoot("classpathProviders");
//$NON-NLS-1$
+ for( int i = 0; i < sets.length; i++ ) {
+ if( sets[i] instanceof Fileset) {
+ Fileset fs = (Fileset)sets[i];
+ XMLMemento child =
(XMLMemento)memento.createChild("fileset");//$NON-NLS-1$
+ child.putString("name", fs.getName());//$NON-NLS-1$
+ child.putString("folder", fs.getRawFolder());//$NON-NLS-1$
+ child.putString("includes", fs.getIncludesPattern());//$NON-NLS-1$
+ child.putString("excludes", fs.getExcludesPattern());//$NON-NLS-1$
+ } else {
+ // TODO
+ }
+ }
+ }
+}
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.classpath.ui/META-INF/MANIFEST.MF
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.classpath.ui/META-INF/MANIFEST.MF 2011-07-29
08:56:15 UTC (rev 33346)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.classpath.ui/META-INF/MANIFEST.MF 2011-07-29
09:18:35 UTC (rev 33347)
@@ -12,7 +12,9 @@
org.eclipse.wst.server.ui;bundle-version="1.1.305",
org.eclipse.jdt.ui;bundle-version="3.7.0",
org.eclipse.jdt.core;bundle-version="3.7.0",
- org.eclipse.core.resources;bundle-version="3.7.100"
+ org.eclipse.core.resources;bundle-version="3.7.100",
+ org.jboss.ide.eclipse.as.ui;bundle-version="2.2.0",
+ org.jboss.ide.eclipse.archives.webtools;bundle-version="2.2.0"
Bundle-ActivationPolicy: lazy
Bundle-Vendor: %Bundle-Vendor.0
Bundle-Localization: plugin
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.classpath.ui/plugin.xml
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.classpath.ui/plugin.xml 2011-07-29 08:56:15
UTC (rev 33346)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.classpath.ui/plugin.xml 2011-07-29 09:18:35
UTC (rev 33347)
@@ -34,5 +34,15 @@
id="org.jboss.ide.eclipse.as.classpath.core.javaee-5.0">
</classpathContainerPage>
</extension>
+ <extension
+ point="org.eclipse.ui.preferencePages">
+ <page
+ id="org.jboss.ide.eclipse.as.classpath.ui.containers.custom"
+ name="Default Classpath Entries"
+ category="org.eclipse.wst.server.ui.runtime.preferencePage"
+
class="org.jboss.ide.eclipse.as.classpath.ui.containers.custom.CustomClasspathPreferencePage">
+ <keywordReference
id="org.eclipse.wst.server.preferenceKeywords"/>
+ </page>
+ </extension>
</plugin>
Added:
trunk/as/plugins/org.jboss.ide.eclipse.as.classpath.ui/src/org/jboss/ide/eclipse/as/classpath/ui/containers/custom/CustomClasspathPreferencePage.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.classpath.ui/src/org/jboss/ide/eclipse/as/classpath/ui/containers/custom/CustomClasspathPreferencePage.java
(rev 0)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.classpath.ui/src/org/jboss/ide/eclipse/as/classpath/ui/containers/custom/CustomClasspathPreferencePage.java 2011-07-29
09:18:35 UTC (rev 33347)
@@ -0,0 +1,212 @@
+/*******************************************************************************
+ * 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.classpath.ui.containers.custom;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.Iterator;
+
+import org.eclipse.core.runtime.preferences.IEclipsePreferences;
+import org.eclipse.core.runtime.preferences.InstanceScope;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.window.Window;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.wst.server.core.IRuntimeType;
+import org.eclipse.wst.server.core.IServer;
+import org.eclipse.wst.server.core.ServerCore;
+import org.jboss.ide.eclipse.archives.webtools.filesets.Fileset;
+import org.jboss.ide.eclipse.archives.webtools.filesets.FilesetDialog;
+import org.jboss.ide.eclipse.archives.webtools.filesets.FilesetLabelProvider;
+import org.jboss.ide.eclipse.as.classpath.core.runtime.CustomRuntimeClasspathModel;
+import
org.jboss.ide.eclipse.as.classpath.core.runtime.CustomRuntimeClasspathModel.IDefaultPathProvider;
+import org.jboss.ide.eclipse.as.ui.JBossServerUIPlugin;
+import org.jboss.ide.eclipse.as.ui.preferences.ServerTypePreferencePage;
+import org.osgi.service.prefs.BackingStoreException;
+
+/*
+ * Should be unified with DefaultFilesetPreferencePage
+ * needs abstract superclass in jboss.as.ui plugin
+ */
+public class CustomClasspathPreferencePage extends ServerTypePreferencePage {
+ private static final String LAST_SELECTED_RUNTIME_TYPE =
"org.jboss.ide.eclipse.as.classpath.ui.containers.custom.CustomClasspathPreferencePage.LAST_RUNTIME_SELECTED";
//$NON-NLS-1$
+
+ protected Control createContents(Composite parent) {
+ rootComp = new CustomClasspathPreferenceComposite(parent, SWT.NONE);
+ rootComp.setLayoutData(new GridData(GridData.FILL_BOTH));
+ rootComp.layout();
+ return rootComp;
+ }
+ public boolean performOk() {
+ String[] changed2 = rootComp.getChanged();
+ ArrayList<Object> list;
+ IDefaultPathProvider[] arr;
+ for( int i = 0; i < changed2.length; i++ ) {
+ String runtimeId = changed2[i];
+ IRuntimeType rt = ServerCore.findRuntimeType(runtimeId);
+ list = rootComp.getDataForComboSelection(changed2[i]);
+ arr = (IDefaultPathProvider[]) list.toArray(new IDefaultPathProvider[list.size()]);
+ CustomRuntimeClasspathModel.saveFilesets(rt, arr);
+ }
+
+ // Save the recently selected
+ String lastSelected = rootComp.getCurrentId();
+ IEclipsePreferences prefs = new
InstanceScope().getNode(JBossServerUIPlugin.PLUGIN_ID);
+ prefs.put(LAST_SELECTED_RUNTIME_TYPE, lastSelected);
+ try {
+ prefs.flush();
+ } catch(BackingStoreException e) {
+ }
+
+ rootComp.clearChanged();
+ return true;
+ }
+
+ public class CustomClasspathPreferenceComposite extends
AbstractComboDataPreferenceComposite {
+ public CustomClasspathPreferenceComposite(Composite parent, int style) {
+ super(parent, style);
+ }
+ protected void initializeSelection() {
+ IEclipsePreferences prefs = new
InstanceScope().getNode(JBossServerUIPlugin.PLUGIN_ID);
+ String last =prefs.get(LAST_SELECTED_RUNTIME_TYPE, null);
+ if( last == null )
+ super.initializeSelection();
+ else {
+ IRuntimeType[] types = getRuntimeTypes();
+ for( int i = 0; i < types.length; i++ ) {
+ if( types[i].getId().equals(last)) {
+ combo.select(i);
+ return;
+ }
+ }
+ }
+ }
+
+ protected LabelProvider getLabelProvider() {
+ return new FilesetLabelProvider(){
+ public String getText(Object element) {
+ if( element instanceof Fileset ) {
+ Fileset fs = (Fileset)element;
+ return fs.getRawFolder() + " - [" + fs.getIncludesPattern() + "]
- [" + fs.getExcludesPattern() + "]";
+ }
+ return super.getText(element);
+ }
+ };
+ }
+ public String getDescriptionLabel() {
+ return "Set classpath filesets for this runtime type";
+ }
+
+ protected Object[] getCurrentComboSelectionDefaultDataModel() {
+ String id = getCurrentId();
+ IRuntimeType rtType = ServerCore.findRuntimeType(id);
+ CustomRuntimeClasspathModel.IDefaultPathProvider[] sets =
CustomRuntimeClasspathModel.getInstance().getDefaultEntries(rtType);
+ return sets;
+ }
+
+ protected IDefaultPathProvider[] getCurrentSelectionDataModel() {
+ String id = getCurrentId();
+ ArrayList<Object> list = new ArrayList<Object>();
+ if( id != null ) {
+ list = getDataForComboSelection(id);
+ if( list == null ) {
+ IRuntimeType rtType = ServerCore.findRuntimeType(id);
+ if( rtType != null ) {
+ CustomRuntimeClasspathModel.IDefaultPathProvider[] sets =
CustomRuntimeClasspathModel.getInstance().getEntries(rtType);
+ list = new ArrayList<Object>();
+ list.addAll(Arrays.asList(sets));
+ cacheMap.put(id, list);
+ }
+ }
+ }
+ return (IDefaultPathProvider[]) list.toArray(new IDefaultPathProvider[list.size()]);
+ }
+
+ protected String getAllOptionString() {
+ return "All Runtime Types";
+ }
+
+ private IRuntimeType[] types = null;
+ private IRuntimeType[] getRuntimeTypes() {
+ if( types == null ) {
+ ArrayList<IRuntimeType> retval = new ArrayList<IRuntimeType>();
+ ArrayList<IRuntimeType> all = new ArrayList<IRuntimeType>(
+ Arrays.asList( ServerCore.getRuntimeTypes()));
+ if( !getAllServerTypes()) {
+ Iterator<IRuntimeType> i = all.iterator();
+ IRuntimeType t;
+ while(i.hasNext()) {
+ t = i.next();
+ if( !t.getId().startsWith("org.jboss.ide.eclipse.as.")) {//$NON-NLS-1$
+ i.remove();
+ }
+ }
+ }
+ retval = all;
+ Collections.sort(retval, new Comparator<IRuntimeType>(){
+ public int compare(IRuntimeType o1, IRuntimeType o2) {
+ return o1.getName().compareTo(o2.getName());
+ }});
+ types = (IRuntimeType[]) all.toArray(new IRuntimeType[all.size()]);
+ }
+ return types;
+ }
+ protected boolean showAllOption() {
+ return false;
+ }
+ protected String getIdAtIndex(int index) {
+ IRuntimeType type = getRuntimeTypes()[index];
+ String id = type.getId();
+ return id;
+ }
+
+ protected class EntryFilesetDialog extends FilesetDialog {
+ protected EntryFilesetDialog(Shell parentShell,
+ String defaultLocation, IServer server) {
+ super(parentShell, defaultLocation, server);
+ }
+ public Fileset getFileset() {
+ return new CustomRuntimeClasspathModel.PathProviderFileset(fileset);
+ }
+ }
+
+ @Override
+ protected void addPressed() {
+ FilesetDialog d = new EntryFilesetDialog(addButton.getShell(), "", null);
//$NON-NLS-1$
+ d.setShowViewer(false);
+ if( d.open() == Window.OK) {
+ // For now, just add fileset
+ Fileset fs = d.getFileset();
+ addObject(fs);
+ }
+ }
+
+ @Override
+ protected boolean getAllServerTypes() {
+ return false;
+ }
+
+ @Override
+ protected String[] getComboItemNames() {
+ IRuntimeType[] types = getRuntimeTypes();
+ String[] names = new String[types.length];
+ for( int i = 0; i < types.length; i++ )
+ names[i] = types[i].getName();
+ return names;
+ }
+
+ }
+}
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/resolvers/ConfigNameResolver.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/resolvers/ConfigNameResolver.java 2011-07-29
08:56:15 UTC (rev 33346)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/resolvers/ConfigNameResolver.java 2011-07-29
09:18:35 UTC (rev 33347)
@@ -4,6 +4,7 @@
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.variables.IDynamicVariable;
import org.eclipse.core.variables.IDynamicVariableResolver;
+import org.eclipse.wst.server.core.IRuntime;
import org.eclipse.wst.server.core.IServer;
import org.eclipse.wst.server.core.ServerCore;
import org.jboss.ide.eclipse.as.core.server.IJBossServerRuntime;
@@ -20,35 +21,65 @@
}
protected String handleConfig(IDynamicVariable variable, String argument) {
+ IJBossServerRuntime ajbsrt = null;
IServer[] servers = ServerCore.getServers();
for( int i = 0; i < servers.length; i++ ) {
if( servers[i].getName().equals(argument)) {
- IJBossServerRuntime ajbsrt = (IJBossServerRuntime) servers[i].getRuntime()
- .loadAdapter(IJBossServerRuntime.class,
+ ajbsrt = (IJBossServerRuntime) servers[i].getRuntime()
+ .loadAdapter(IJBossServerRuntime.class,
new NullProgressMonitor());
- String config = null;
- if( ajbsrt != null )
- config = ajbsrt.getJBossConfiguration();
- if( config != null )
- return config;
+ break;
}
}
+ if( ajbsrt == null ) {
+ IRuntime[] runtimes = ServerCore.getRuntimes();
+ for( int i = 0; i < runtimes.length; i++ ) {
+ if( runtimes[i].getName().equals(argument)) {
+ ajbsrt = (IJBossServerRuntime) runtimes[i]
+ .loadAdapter(IJBossServerRuntime.class,
+ new NullProgressMonitor());
+ break;
+ }
+ }
+ }
+ if( ajbsrt != null ) {
+ String config = null;
+ if( ajbsrt != null )
+ config = ajbsrt.getJBossConfiguration();
+ if( config != null )
+ return config;
+ }
return null;
}
protected String handleConfigDir(IDynamicVariable variable, String argument) {
+ IJBossServerRuntime ajbsrt = null;
IServer[] servers = ServerCore.getServers();
for( int i = 0; i < servers.length; i++ ) {
if( servers[i].getName().equals(argument)) {
- IJBossServerRuntime ajbsrt = (IJBossServerRuntime) servers[i].getRuntime()
+ ajbsrt = (IJBossServerRuntime) servers[i].getRuntime()
.loadAdapter(IJBossServerRuntime.class,
new NullProgressMonitor());
- String config = null;
- if( ajbsrt != null )
- config =
ajbsrt.getConfigLocationFullPath().append(ajbsrt.getJBossConfiguration()).toString();
- if( config != null )
- return config;
+ break;
}
}
+ if( ajbsrt == null ) {
+ IRuntime[] runtimes = ServerCore.getRuntimes();
+ for( int i = 0; i < runtimes.length; i++ ) {
+ if( runtimes[i].getName().equals(argument)) {
+ ajbsrt = (IJBossServerRuntime) runtimes[i]
+ .loadAdapter(IJBossServerRuntime.class,
+ new NullProgressMonitor());
+ break;
+ }
+ }
+ }
+ if( ajbsrt != null ) {
+ String config = null;
+ if( ajbsrt != null )
+ config =
ajbsrt.getConfigLocationFullPath().append(ajbsrt.getJBossConfiguration()).toString();
+ if( config != null )
+ return config;
+ }
return null;
}
}
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/preferences/ServerTypePreferencePage.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/preferences/ServerTypePreferencePage.java 2011-07-29
08:56:15 UTC (rev 33346)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/preferences/ServerTypePreferencePage.java 2011-07-29
09:18:35 UTC (rev 33347)
@@ -45,7 +45,7 @@
import org.eclipse.wst.server.core.ServerCore;
import org.jboss.ide.eclipse.as.ui.UIUtil;
-public class ServerTypePreferencePage extends PreferencePage implements
+public abstract class ServerTypePreferencePage extends PreferencePage implements
IWorkbenchPreferencePage {
public ServerTypePreferencePage() {
@@ -62,39 +62,51 @@
public void init(IWorkbench workbench) {
}
+ protected AbstractComboDataPreferenceComposite rootComp;
+
@Override
- protected Control createContents(Composite parent) {
- ServerTypePreferenceComposite c = new ServerTypePreferenceComposite(parent, SWT.NONE);
- c.setLayoutData(new GridData(GridData.FILL_BOTH));
- c.layout();
- return c;
- }
+ protected abstract Control createContents(Composite parent);
+// rootComp = new ServerTypePreferenceComposite(parent, SWT.NONE);
+// rootComp.setLayoutData(new GridData(GridData.FILL_BOTH));
+// rootComp.layout();
+// return rootComp;
+// }
+
+ protected void performDefaults() {
+ String id = rootComp.getCurrentId();
+ ArrayList<Object> o = new ArrayList<Object>();
+ o.addAll(Arrays.asList(rootComp.getCurrentComboSelectionDefaultDataModel()));
+ rootComp.cacheMap.put(id, o);
+ rootComp.changed.add(id);
+ rootComp.viewer.refresh();
+ updateApplyButton();
+ }
- public static class ServerTypePreferenceComposite extends Composite {
+ public static abstract class AbstractComboDataPreferenceComposite extends Composite {
protected ArrayList<String> changed;
protected HashMap<String, ArrayList<Object>> cacheMap;
- protected Combo servers;
+ protected Combo combo;
protected TreeViewer viewer;
protected Button addButton;
protected Button removeButton;
protected Button moveUp;
protected Button moveDown;
- public ServerTypePreferenceComposite(Composite parent, int style) {
+ public AbstractComboDataPreferenceComposite(Composite parent, int style) {
super(parent, style);
setLayout(new FormLayout());
Label l = new Label(this, SWT.None);
l.setText(getDescriptionLabel());
l.setLayoutData(createFormData(0,5,null,0,0,5,100,-5));
- servers = new Combo(this, SWT.READ_ONLY);
- servers.setLayoutData(createFormData(l,5,null,0,0,5,null,0));
- servers.setItems(getComboItems());
+ combo = new Combo(this, SWT.READ_ONLY);
+ combo.setLayoutData(createFormData(l,5,null,0,0,5,null,0));
+ combo.setItems(getComboItems());
viewer = new TreeViewer(this);
viewer.getTree().setLayoutData(createFormData(
- servers,5,100,-5,0,5,80,0));
+ combo,5,100,-5,0,5,80,0));
viewer.setLabelProvider(getLabelProvider());
viewer.setContentProvider(getContentProvider());
viewer.addSelectionChangedListener(new ISelectionChangedListener() {
@@ -105,25 +117,29 @@
Composite buttonWrapper = new Composite(this, SWT.NONE);
- buttonWrapper.setLayoutData(createFormData(servers,5,null,0,viewer.getTree(),5,100,-5));
+ buttonWrapper.setLayoutData(createFormData(combo,5,null,0,viewer.getTree(),5,100,-5));
buttonWrapper.setLayout(new GridLayout(1, true));
createRightColumnButtons(buttonWrapper);
- servers.addSelectionListener(new SelectionListener() {
+ combo.addSelectionListener(new SelectionListener() {
public void widgetDefaultSelected(SelectionEvent e) {
}
public void widgetSelected(SelectionEvent e) {
- getCurrentServerDataModel(); // force load
+ getCurrentSelectionDataModel(); // force load
viewer.refresh();
updateMoveUpMoveDown();
} });
- servers.select(0);
+ initializeSelection();
initializeDataModel(); // force load
viewer.setInput(ResourcesPlugin.getWorkspace());
updateMoveUpMoveDown();
}
+ protected void initializeSelection() {
+ combo.select(0);
+ }
+
protected void handleViewerSelectionChanged() {
updateMoveUpMoveDown();
}
@@ -140,7 +156,7 @@
enableUp = enableDown = false;
} else {
Object selected = sel.getFirstElement();
- Object[] arr = getCurrentServerDataModel();
+ Object[] arr = getCurrentSelectionDataModel();
ArrayList<Object> asList = new ArrayList<Object>();
asList.addAll(Arrays.asList(arr));
int index = asList.indexOf(selected);
@@ -161,7 +177,7 @@
protected void initializeDataModel() {
cacheMap = new HashMap<String, ArrayList<Object>>();
changed = new ArrayList<String>();
- getCurrentServerDataModel();
+ getCurrentSelectionDataModel();
}
public String getDescriptionLabel() {
@@ -198,7 +214,7 @@
protected void insertMoveUpDown(Composite c) {
moveUp = new Button(c, SWT.PUSH);
- moveUp.setText("MoveUp");
+ moveUp.setText("Move Up");
moveUp.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
moveDown = new Button(c, SWT.PUSH);
moveDown.setText("Move down");
@@ -219,10 +235,22 @@
}
});
}
- protected Object[] getCurrentServerDataModel() {
+
+ /**
+ * Return the current list of objects for the selected server type
+ * @return
+ */
+ protected Object[] getCurrentSelectionDataModel() {
return new Object[]{};
}
+ /**
+ * Get the defaults for this data model
+ * @return
+ */
+ protected Object[] getCurrentComboSelectionDefaultDataModel() {
+ return new Object[]{};
+ }
protected void addObject(Object o) {
if( o != null ) {
@@ -249,15 +277,14 @@
Object o = sel.getFirstElement();
removeObject(o);
}
- protected void addPressed() {
- // TODO
- }
+ protected abstract void addPressed();
+
protected void moveUpPressed() {
IStructuredSelection sel = (IStructuredSelection)viewer.getSelection();
Object fs = (Object)sel.getFirstElement();
String id = getCurrentId();
- Object[] sets = getCurrentServerDataModel();
+ Object[] sets = getCurrentSelectionDataModel();
ArrayList<Object> asList = new ArrayList<Object>();
asList.addAll(Arrays.asList(sets));
int ind = asList.indexOf(fs);
@@ -274,7 +301,7 @@
IStructuredSelection sel = (IStructuredSelection)viewer.getSelection();
Object fs = (Object)sel.getFirstElement();
String id = getCurrentId();
- Object[] sets = getCurrentServerDataModel();
+ Object[] sets = getCurrentSelectionDataModel();
ArrayList<Object> asList = new ArrayList<Object>();
asList.addAll(Arrays.asList(sets));
int ind = asList.indexOf(fs);
@@ -287,20 +314,22 @@
viewer.refresh();
}
- protected String getCurrentId() {
- int index = servers.getSelectionIndex();
- if( showAllServerTypeOption() && index == 0 )
- return "All Servers";
+ protected abstract String getAllOptionString();
+
+ public String getCurrentId() {
+ int index = combo.getSelectionIndex();
+ if( showAllOption() && index == 0 )
+ return getAllOptionString();
if( index == -1 )
return null;
- int i2 = showAllServerTypeOption() ? index - 1 : index;
- IServerType type = getServerTypes()[i2];
- String id = type.getId();
- return id;
+ int i2 = showAllOption() ? index - 1 : index;
+ return getIdAtIndex(i2);
}
- public ArrayList<Object> getDataForServer(String serverId) {
- return cacheMap.get(serverId);
+ protected abstract String getIdAtIndex(int index);
+
+ public ArrayList<Object> getDataForComboSelection(String id) {
+ return cacheMap.get(id);
}
protected LabelProvider getLabelProvider() {
@@ -315,7 +344,7 @@
public void dispose() {
}
public Object[] getElements(Object inputElement) {
- return getCurrentServerDataModel();
+ return getCurrentSelectionDataModel();
}
public boolean hasChildren(Object element) {
return false;
@@ -334,23 +363,51 @@
return true;
}
// Return true if we show a combo option for "all server types" or not
- protected boolean showAllServerTypeOption() {
+ protected boolean showAllOption() {
return true;
}
- private String[] getComboItems() {
+ protected String[] getComboItems() {
ArrayList<String> list = new ArrayList<String>();
- if( showAllServerTypeOption())
+ if( showAllOption())
list.add(0,"All Server Types");
- IServerType[] types = getServerTypes();
- for( int i = 0; i < types.length; i++ )
- list.add(types[i].getName());
+ String[] names = getComboItemNames();
+ list.addAll(Arrays.asList(names));
return (String[]) list.toArray(new String[list.size()]);
}
+ protected abstract String[] getComboItemNames();
+
+ private FormData createFormData(Object topStart, int topOffset,
+ Object bottomStart, int bottomOffset, Object leftStart,
+ int leftOffset, Object rightStart, int rightOffset) {
+ return UIUtil.createFormData2(topStart, topOffset, bottomStart, bottomOffset,
leftStart, leftOffset, rightStart, rightOffset);
+ }
+
+ public String[] getChanged() {
+ return (String[]) changed.toArray(new String[changed.size()]);
+ }
+
+ public void clearChanged() {
+ changed.clear();
+ }
+ } // inner class ends
+
+ public static abstract class ServerTypePreferenceComposite extends
AbstractComboDataPreferenceComposite {
+ public ServerTypePreferenceComposite(Composite parent, int style) {
+ super(parent, style);
+ }
+ protected String[] getComboItemNames() {
+ IServerType[] types = getComboModel();
+ String[] names = new String[types.length];
+ for( int i = 0; i < types.length; i++ )
+ names[i] = types[i].getName();
+ return names;
+ }
+
private IServerType[] types = null;
- private IServerType[] getServerTypes() {
+ private IServerType[] getComboModel() {
if( types == null ) {
ArrayList<IServerType> retval = new ArrayList<IServerType>();
ArrayList<IServerType> all = new ArrayList<IServerType>(
@@ -374,22 +431,16 @@
}
return types;
}
-
- private FormData createFormData(Object topStart, int topOffset,
- Object bottomStart, int bottomOffset, Object leftStart,
- int leftOffset, Object rightStart, int rightOffset) {
- return UIUtil.createFormData2(topStart, topOffset, bottomStart, bottomOffset,
leftStart, leftOffset, rightStart, rightOffset);
+ protected String getIdAtIndex(int index) {
+ IServerType type = getComboModel()[index];
+ String id = type.getId();
+ return id;
}
-
- public String[] getChanged() {
- return (String[]) changed.toArray(new String[changed.size()]);
+ protected String getAllOptionString() {
+ return "All Servers";
}
-
- public void clearChanged() {
- changed.clear();
- }
- } // inner class ends
-
+ }
+
public boolean performOk() {
// TODO do stuff
return true;