You can subscribe to this list here.
| 2005 |
Jan
|
Feb
|
Mar
(41) |
Apr
(9) |
May
|
Jun
|
Jul
(39) |
Aug
(38) |
Sep
(135) |
Oct
(220) |
Nov
(75) |
Dec
(74) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2006 |
Jan
(44) |
Feb
(160) |
Mar
(49) |
Apr
(69) |
May
(40) |
Jun
(52) |
Jul
(47) |
Aug
(51) |
Sep
(19) |
Oct
(22) |
Nov
(36) |
Dec
(76) |
| 2007 |
Jan
(154) |
Feb
(165) |
Mar
(186) |
Apr
(143) |
May
(175) |
Jun
(133) |
Jul
(203) |
Aug
(177) |
Sep
(136) |
Oct
|
Nov
|
Dec
|
|
From: <caw...@us...> - 2007-09-10 17:22:22
|
Revision: 3122
http://rubyeclipse.svn.sourceforge.net/rubyeclipse/?rev=3122&view=rev
Author: cawilliams
Date: 2007-09-10 10:22:13 -0700 (Mon, 10 Sep 2007)
Log Message:
-----------
include method arguments as local variable declarations. Resolves references to method arguments inside the method properly.
Modified Paths:
--------------
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/codeassist/SelectionEngine.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/SourceElementParser.java
Modified: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/codeassist/SelectionEngine.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/codeassist/SelectionEngine.java 2007-09-10 16:37:24 UTC (rev 3121)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/codeassist/SelectionEngine.java 2007-09-10 17:22:13 UTC (rev 3122)
@@ -28,6 +28,7 @@
import org.jruby.ast.InstVarNode;
import org.jruby.ast.LocalAsgnNode;
import org.jruby.ast.LocalVarNode;
+import org.jruby.ast.MethodDefNode;
import org.jruby.ast.ModuleNode;
import org.jruby.ast.Node;
import org.jruby.ast.VCallNode;
@@ -159,10 +160,17 @@
return completer.findType(fullyQualifiedName); // get fully qualified name of surrounding type!
}
if (isLocalVarRef(selected)) {
- // TODO Try the local namespace first!
- List<IRubyElement> possible = getChildrenWithName(script
- .getChildren(), IRubyElement.LOCAL_VARIABLE,
+ IRubyElement spanner = script.getElementAt(selected.getPosition().getStartOffset());
+ List<IRubyElement> possible = new ArrayList<IRubyElement>();
+ if (spanner instanceof IParent) {
+ IParent parent = (IParent) spanner;
+ possible = getChildrenWithName(parent.getChildren(), IRubyElement.LOCAL_VARIABLE,
+ getName(selected));
+ }
+ if (possible.isEmpty()) {
+ possible = getChildrenWithName(script.getChildren(), IRubyElement.LOCAL_VARIABLE,
getName(selected));
+ }
return possible.toArray(new IRubyElement[possible.size()]);
}
if (isInstanceVarRef(selected)) {
Modified: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/SourceElementParser.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/SourceElementParser.java 2007-09-10 16:37:24 UTC (rev 3121)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/SourceElementParser.java 2007-09-10 17:22:13 UTC (rev 3122)
@@ -30,6 +30,8 @@
import java.util.List;
import org.jruby.ast.AliasNode;
+import org.jruby.ast.ArgsNode;
+import org.jruby.ast.ArgumentNode;
import org.jruby.ast.ArrayNode;
import org.jruby.ast.AssignableNode;
import org.jruby.ast.CallNode;
@@ -50,9 +52,9 @@
import org.jruby.ast.InstAsgnNode;
import org.jruby.ast.InstVarNode;
import org.jruby.ast.IterNode;
+import org.jruby.ast.ListNode;
import org.jruby.ast.LocalAsgnNode;
import org.jruby.ast.ModuleNode;
-import org.jruby.ast.NewlineNode;
import org.jruby.ast.Node;
import org.jruby.ast.RootNode;
import org.jruby.ast.SClassNode;
@@ -186,7 +188,7 @@
} else {
requestor.enterMethod(methodInfo);
}
-
+
Instruction ins = super.visitDefnNode(iVisited); // now traverse it's body
int end = iVisited.getPosition().getEndOffset() - 2;
if (methodInfo.isConstructor) {
@@ -198,6 +200,38 @@
}
@Override
+ public Instruction visitArgsNode(ArgsNode iVisited) {
+ // Add args as local vars!
+ ListNode list = iVisited.getArgs();
+ if (list != null) {
+ for (int i = 0; i < list.size(); i++) {
+ Node arg = list.get(i);
+ FieldInfo field = new FieldInfo();
+ field.declarationStart = arg.getPosition().getStartOffset();
+ field.nameSourceStart = arg.getPosition().getStartOffset();
+ String name = ASTUtil.getNameReflectively(arg);
+ field.nameSourceEnd = arg.getPosition().getStartOffset()
+ + name.length() - 1;
+ field.name = name;
+ requestor.enterField(field);
+ requestor.exitField(arg.getPosition().getEndOffset() - 1);
+ }
+ }
+ ArgumentNode arg = iVisited.getRestArgNode();
+ if (arg != null) {
+ FieldInfo field = new FieldInfo();
+ field.declarationStart = arg.getPosition().getStartOffset() + 1;
+ field.nameSourceStart = arg.getPosition().getStartOffset() + 1;
+ String name = ASTUtil.getNameReflectively(arg);
+ field.nameSourceEnd = arg.getPosition().getStartOffset() + name.length();
+ field.name = name;
+ requestor.enterField(field);
+ requestor.exitField(arg.getPosition().getEndOffset());
+ }
+ return super.visitArgsNode(iVisited);
+ }
+
+ @Override
public Instruction visitDefsNode(DefsNode iVisited) {
MethodInfo methodInfo = new MethodInfo();
methodInfo.declarationStart = iVisited.getPosition().getStartOffset();
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2007-09-10 16:37:26
|
Revision: 3121
http://rubyeclipse.svn.sourceforge.net/rubyeclipse/?rev=3121&view=rev
Author: cawilliams
Date: 2007-09-10 09:37:24 -0700 (Mon, 10 Sep 2007)
Log Message:
-----------
actually include relevance/confidence number in proposal (we were just stuffing 100 in). Simplify the suggestMethods way of tryign to suggest all methods up the type heirarchy. Just use our new super type hierarchies! (rather than manually traversing up).
Modified Paths:
--------------
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/codeassist/CompletionEngine.java
Modified: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/codeassist/CompletionEngine.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/codeassist/CompletionEngine.java 2007-09-10 15:12:56 UTC (rev 3120)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/codeassist/CompletionEngine.java 2007-09-10 16:37:24 UTC (rev 3121)
@@ -44,6 +44,7 @@
import org.rubypeople.rdt.core.IRubyScript;
import org.rubypeople.rdt.core.ISourceRange;
import org.rubypeople.rdt.core.IType;
+import org.rubypeople.rdt.core.ITypeHierarchy;
import org.rubypeople.rdt.core.RubyCore;
import org.rubypeople.rdt.core.RubyModelException;
import org.rubypeople.rdt.core.search.CollectingSearchRequestor;
@@ -149,12 +150,14 @@
}
}
IType[] types = requestor.findType(name);
- for (int i = 0; i < types.length; i++) {
+ Map<String, CompletionProposal> mapAll = new HashMap<String, CompletionProposal>();
+ for (int i = 0; i < types.length; i++) {
Map<String, CompletionProposal> map = suggestMethods(guess.getConfidence(), types[i], true);
- list.addAll(map.values());
+ mapAll.putAll(map);
}
+ list.addAll(mapAll.values());
}
- list.addAll(suggestAllMethodsMatchingPrefix(script));
+ list.addAll(suggestAllMethodsMatchingPrefix(script)); // FIXME Only do this if we have no suggestions? Have a minimum length threshold?
Collections.sort(list, new CompletionProposalComparator());
for (CompletionProposal proposal : list) {
fRequestor.accept(proposal);
@@ -252,7 +255,7 @@
String typeName = "";
if (type != null)
typeName = type.getElementName();
- CompletionProposal proposal = suggestMethod(element, typeName, 100); // TODO Base confidence on accuracy in match?
+ CompletionProposal proposal = suggestMethod(element, typeName, 50); // TODO Base confidence on accuracy in match?
if (proposal != null) {
list.add(proposal);
}
@@ -306,10 +309,27 @@
private Map<String, CompletionProposal> suggestMethods(int confidence, IType type, boolean includeInstanceMethods) throws RubyModelException {
if (fVisitedTypes == null) fVisitedTypes = new HashSet<IType>();
fOriginalType = type;
- Map<String, CompletionProposal> list = doSuggestMethods(100, type, includeInstanceMethods);
- fVisitedTypes.clear();
+ // FIXME We want to avoid visiting the same types across the guesses too!
+ Map<String, CompletionProposal> proposals = new HashMap<String, CompletionProposal>();
+ ITypeHierarchy hierarchy = type.newSupertypeHierarchy(null);
+ IType[] all = hierarchy.getAllTypes();
+ for (int j = 0; j < all.length; j++) {
+ if (fVisitedTypes.contains(all[j])) continue;
+ fVisitedTypes.add(all[j]);
+ IMethod[] methods = all[j].getMethods();
+ if (methods != null) {
+ for (int k = 0; k < methods.length; k++) {
+ if (methods[k] == null) continue;
+ CompletionProposal proposal = suggestMethod(methods[k], all[j].getElementName(), confidence);
+ if (proposal != null && !proposals.containsKey(proposal.getName())) {
+ proposals.put(proposal.getName(), proposal); // If a method name matches an existing suggestion (i.e. its overriden in the subclass), don't suggest it again!
+ }
+ }
+ }
+ }
fOriginalType = null;
- return list;
+ fVisitedTypes.clear();
+ return proposals;
}
private List<CompletionProposal> sort(Map<String, CompletionProposal> proposals) {
@@ -370,7 +390,7 @@
return createProposal(replaceStart, type, name, 100, element);
}
private CompletionProposal createProposal(int replaceStart, int type, String name, int confidence, IRubyElement element) {
- CompletionProposal proposal = new CompletionProposal(type, name, 100);
+ CompletionProposal proposal = new CompletionProposal(type, name, confidence);
proposal.setReplaceRange(replaceStart, replaceStart + name.length());
proposal.setElement(element);
return proposal;
@@ -389,67 +409,6 @@
}
}
- private Map<String, CompletionProposal> doSuggestMethods(int confidence, IType type, boolean includeInstanceMethods) throws RubyModelException {
- Map<String, CompletionProposal> proposals = new HashMap<String, CompletionProposal>();
- if (type == null)
- return proposals;
- if (fVisitedTypes.contains(type)) return proposals;
- fVisitedTypes.add(type);
- IMethod[] methods = type.getMethods();
- if (methods != null) {
- for (int k = 0; k < methods.length; k++) {
- if (methods[k] == null) continue;
- if (!includeInstanceMethods && !methods[k].isSingleton()) {
- continue;
- }
- CompletionProposal proposal = suggestMethod(methods[k], type.getElementName(), confidence);
- if (proposal != null && !proposals.containsKey(proposal.getName())) {
- proposals.put(proposal.getName(), proposal); // If a method name matches an existing suggestion (i.e. its overriden in the subclass), don't suggest it again!
- }
- }
- }
- proposals.putAll(addModuleMethods(confidence - 1, type)); // Decrement confidence by one as a hack to make sure as we move up the inheritance chain we suggest "closer" parents methods first
- if (!type.isModule()) proposals.putAll(addSuperClassMethods(confidence - 1, type, includeInstanceMethods));
- return proposals;
- }
-
- private Map<String, CompletionProposal> addModuleMethods(int confidence, IType type) {
- Map<String, CompletionProposal> proposals = new HashMap<String, CompletionProposal>();
- String[] modules = null;
- try {
- modules = type.getIncludedModuleNames();
- } catch (RubyModelException e) {
- // ignore
- }
- if (modules == null || modules.length == 0) return proposals;
- RubyElementRequestor requestor = new RubyElementRequestor(type.getRubyScript());
- for (int i = 0; i < modules.length; i++) {
- IType[] moduleTypes = requestor.findType(modules[i]);
- for (int j = 0; j < moduleTypes.length; j++) {
- try {
- IType moduleType = moduleTypes[j];
- proposals.putAll(doSuggestMethods(confidence, moduleType, true));
- } catch (RubyModelException e) {
- // ignore
- }
- }
- }
- return proposals;
- }
-
- private Map<String, CompletionProposal> addSuperClassMethods(int confidence, IType type, boolean includeInstanceMethods) throws RubyModelException {
- Map<String, CompletionProposal> proposals = new HashMap<String, CompletionProposal>();
- String superClass = type.getSuperclassName();
- if (superClass == null) return proposals;
- RubyElementRequestor requestor = new RubyElementRequestor(type.getRubyScript());
- IType[] supers = requestor.findType(superClass);
- for (int i = 0; i < supers.length; i++) {
- IType superType = supers[i];
- proposals.putAll(doSuggestMethods(confidence, superType, includeInstanceMethods));
- }
- return proposals;
- }
-
private CompletionProposal suggestMethod(IMethod method, String typeName, int confidence) {
try {
int start = fContext.getReplaceStart();
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2007-09-10 15:12:58
|
Revision: 3120
http://rubyeclipse.svn.sourceforge.net/rubyeclipse/?rev=3120&view=rev
Author: cawilliams
Date: 2007-09-10 08:12:56 -0700 (Mon, 10 Sep 2007)
Log Message:
-----------
Modified Paths:
--------------
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/search/SearchPattern.java
Modified: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/search/SearchPattern.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/search/SearchPattern.java 2007-09-10 14:56:26 UTC (rev 3119)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/search/SearchPattern.java 2007-09-10 15:12:56 UTC (rev 3120)
@@ -952,6 +952,9 @@
char[] declaringQualification = null;
switch (element.getElementType()) {
case IRubyElement.FIELD :
+ case IRubyElement.INSTANCE_VAR :
+ case IRubyElement.CONSTANT :
+ case IRubyElement.CLASS_VAR :
IField field = (IField) element;
if (!ignoreDeclaringType) {
IType declaringClass = field.getDeclaringType();
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2007-09-10 14:56:32
|
Revision: 3119
http://rubyeclipse.svn.sourceforge.net/rubyeclipse/?rev=3119&view=rev
Author: cawilliams
Date: 2007-09-10 07:56:26 -0700 (Mon, 10 Sep 2007)
Log Message:
-----------
add a find references in hierarchy action
Modified Paths:
--------------
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/LocalVariable.java
Added Paths:
-----------
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/ILocalVariable.java
Added: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/ILocalVariable.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/ILocalVariable.java (rev 0)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/ILocalVariable.java 2007-09-10 14:56:26 UTC (rev 3119)
@@ -0,0 +1,42 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2006 IBM Corporation 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:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.rubypeople.rdt.core;
+
+/**
+ * Represents a local variable declared in a method or an initializer.
+ * <code>ILocalVariable</code> are pseudo-elements created as the result of a <code>ICodeAssist.codeSelect(...)</code>
+ * operation. They are not part of the Java model (<code>exists()</code> returns whether the parent exists rather than
+ * whether the local variable exists in the parent) and they are not included in the children of an <code>IMethod</code>
+ * or an <code>IInitializer</code>.
+ * <p>
+ * In particular such a pseudo-element should not be used as a handle. For example its name range won't be updated
+ * if the underlying source changes.
+ * </p><p>
+ * This interface is not intended to be implemented by clients.
+ * </p>
+ * @since 3.0
+ */
+public interface ILocalVariable extends IRubyElement, ISourceReference {
+
+ /**
+ * Returns the name of this local variable.
+ *
+ * @return the name of this local variable.
+ */
+ String getElementName();
+
+ /**
+ * Returns the source range of this local variable's name.
+ *
+ * @return the source range of this local variable's name
+ */
+ ISourceRange getNameRange() throws RubyModelException;
+}
Property changes on: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/ILocalVariable.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/LocalVariable.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/LocalVariable.java 2007-09-10 14:56:18 UTC (rev 3118)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/LocalVariable.java 2007-09-10 14:56:26 UTC (rev 3119)
@@ -28,13 +28,14 @@
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.IProgressMonitor;
+import org.rubypeople.rdt.core.ILocalVariable;
import org.rubypeople.rdt.internal.core.util.Util;
/**
* @author Chris
*
*/
-public class LocalVariable extends RubyField {
+public class LocalVariable extends RubyField implements ILocalVariable {
private int start;
private int end;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2007-09-10 14:56:25
|
Revision: 3118
http://rubyeclipse.svn.sourceforge.net/rubyeclipse/?rev=3118&view=rev
Author: cawilliams
Date: 2007-09-10 07:56:18 -0700 (Mon, 10 Sep 2007)
Log Message:
-----------
add a find references in hierarchy action
Modified Paths:
--------------
trunk/org.rubypeople.rdt.ui/plugin.xml
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/search/SearchMessages.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/search/SearchMessages.properties
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/actions/IRubyEditorActionDefinitionIds.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/actions/RdtActionConstants.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/actions/ReferencesSearchGroup.java
Added Paths:
-----------
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/actions/FindReferencesInHierarchyAction.java
Modified: trunk/org.rubypeople.rdt.ui/plugin.xml
===================================================================
--- trunk/org.rubypeople.rdt.ui/plugin.xml 2007-09-10 14:54:50 UTC (rev 3117)
+++ trunk/org.rubypeople.rdt.ui/plugin.xml 2007-09-10 14:56:18 UTC (rev 3118)
@@ -692,6 +692,12 @@
id="org.rubypeople.rdt.ui.edit.text.ruby.search.references.in.project">
</command>
<command
+ name="%ActionDefinition.referencesInHierarchy.name"
+ description="%ActionDefinition.referencesInHierarchy.description"
+ categoryId="org.eclipse.search.ui.category.search"
+ id="org.rubypeople.rdt.ui.edit.text.ruby.search.references.in.hierarchy">
+ </command>
+ <command
name="%ActionDefinition.referencesInWorkingSet.name"
description="%ActionDefinition.referencesInWorkingSet.description"
categoryId="org.eclipse.search.ui.category.search"
@@ -1174,6 +1180,14 @@
id="org.rubypeople.rdt.ui.actions.ReferencesInHierarchy">
</action>
<action
+ definitionId="org.rubypeople.rdt.ui.edit.text.ruby.search.references.in.hierarchy"
+ label="%InHierarchy.label"
+ retarget="true"
+ menubarPath="org.eclipse.search.menu/referencesSubMenu/group1"
+ allowLabelUpdate="true"
+ id="org.rubypeople.rdt.ui.actions.ReferencesInHierarchy">
+ </action>
+ <action
definitionId="org.rubypeople.rdt.ui.edit.text.ruby.search.references.in.project"
label="%InProject.label"
retarget="true"
Modified: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/search/SearchMessages.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/search/SearchMessages.java 2007-09-10 14:54:50 UTC (rev 3117)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/search/SearchMessages.java 2007-09-10 14:56:18 UTC (rev 3118)
@@ -192,6 +192,9 @@
public static String Search_FindWriteReferencesInProjectAction_label;
public static String Search_FindWriteReferencesInProjectAction_tooltip;
+ public static String Search_FindHierarchyReferencesAction_label;
+ public static String Search_FindHierarchyReferencesAction_tooltip;
+
static {
NLS.initializeMessages(BUNDLE_NAME, SearchMessages.class);
}
Modified: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/search/SearchMessages.properties
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/search/SearchMessages.properties 2007-09-10 14:54:50 UTC (rev 3117)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/search/SearchMessages.properties 2007-09-10 14:56:18 UTC (rev 3118)
@@ -128,6 +128,9 @@
Search_FindReferencesInWorkingSetAction_label= Working &Set...
Search_FindReferencesInWorkingSetAction_tooltip= Search for References to the Selected Element in a Working Set
+Search_FindHierarchyReferencesAction_label= &Hierarchy
+Search_FindHierarchyReferencesAction_tooltip= Search for References of the Selected Element in its Hierarchy
+
Search_FindReadReferencesAction_label= &Workspace
Search_FindReadReferencesAction_tooltip= Search for Read References to the Selected Element in the Workspace
Added: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/actions/FindReferencesInHierarchyAction.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/actions/FindReferencesInHierarchyAction.java (rev 0)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/actions/FindReferencesInHierarchyAction.java 2007-09-10 14:56:18 UTC (rev 3118)
@@ -0,0 +1,85 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2006 IBM Corporation 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:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.rubypeople.rdt.ui.actions;
+
+import org.eclipse.ui.IWorkbenchSite;
+import org.eclipse.ui.PlatformUI;
+import org.rubypeople.rdt.core.IField;
+import org.rubypeople.rdt.core.ILocalVariable;
+import org.rubypeople.rdt.core.IMethod;
+import org.rubypeople.rdt.core.IRubyElement;
+import org.rubypeople.rdt.core.IRubyScript;
+import org.rubypeople.rdt.core.IType;
+import org.rubypeople.rdt.core.RubyModelException;
+import org.rubypeople.rdt.core.search.IRubySearchScope;
+import org.rubypeople.rdt.core.search.SearchEngine;
+import org.rubypeople.rdt.internal.ui.IRubyHelpContextIds;
+import org.rubypeople.rdt.internal.ui.RubyPluginImages;
+import org.rubypeople.rdt.internal.ui.rubyeditor.RubyEditor;
+import org.rubypeople.rdt.internal.ui.search.RubySearchScopeFactory;
+import org.rubypeople.rdt.internal.ui.search.SearchMessages;
+import org.rubypeople.rdt.ui.search.ElementQuerySpecification;
+import org.rubypeople.rdt.ui.search.QuerySpecification;
+
+/**
+ * Finds references of the selected element in its hierarchy.
+ * The action is applicable to selections representing a Ruby element.
+ *
+ * <p>
+ * This class may be instantiated; it is not intended to be subclassed.
+ * </p>
+ *
+ * @since 2.0
+ */
+public class FindReferencesInHierarchyAction extends FindReferencesAction {
+
+ /**
+ * Creates a new <code>FindReferencesInHierarchyAction</code>. The action
+ * requires that the selection provided by the site's selection provider is of type
+ * <code>org.eclipse.jface.viewers.IStructuredSelection</code>.
+ *
+ * @param site the site providing context information for this action
+ */
+ public FindReferencesInHierarchyAction(IWorkbenchSite site) {
+ super(site);
+ }
+
+ /**
+ * Note: This constructor is for internal use only. Clients should not call this constructor.
+ * @param editor the Ruby editor
+ */
+ public FindReferencesInHierarchyAction(RubyEditor editor) {
+ super(editor);
+ }
+
+ Class[] getValidTypes() {
+ return new Class[] { IRubyScript.class, IType.class, IMethod.class, IField.class, ILocalVariable.class };
+ }
+
+ void init() {
+ setText(SearchMessages.Search_FindHierarchyReferencesAction_label);
+ setToolTipText(SearchMessages.Search_FindHierarchyReferencesAction_tooltip);
+ setImageDescriptor(RubyPluginImages.DESC_OBJS_SEARCH_REF);
+ PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IRubyHelpContextIds.FIND_REFERENCES_IN_HIERARCHY_ACTION);
+ }
+
+ QuerySpecification createQuery(IRubyElement element) throws RubyModelException {
+ IType type= getType(element);
+ if (type == null) {
+ return super.createQuery(element);
+ }
+ RubySearchScopeFactory factory= RubySearchScopeFactory.getInstance();
+ IRubySearchScope scope= SearchEngine.createHierarchyScope(type);
+ String description= factory.getHierarchyScopeDescription(type);
+ return new ElementQuerySpecification(element, getLimitTo(), scope, description);
+ }
+
+}
Property changes on: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/actions/FindReferencesInHierarchyAction.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/actions/IRubyEditorActionDefinitionIds.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/actions/IRubyEditorActionDefinitionIds.java 2007-09-10 14:54:50 UTC (rev 3117)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/actions/IRubyEditorActionDefinitionIds.java 2007-09-10 14:56:18 UTC (rev 3118)
@@ -78,6 +78,12 @@
public static final String SEARCH_REFERENCES_IN_PROJECT= "org.rubypeople.rdt.ui.edit.text.ruby.search.references.in.project"; //$NON-NLS-1$
/**
+ * Action definition ID of the search -> references in hierarchy action
+ * (value <code>"org.rubypeople.rdt.ui.edit.text.ruby.search.references.in.hierarchy"</code>).
+ */
+ public static final String SEARCH_REFERENCES_IN_HIERARCHY= "org.rubypeople.rdt.ui.edit.text.ruby.search.references.in.hierarchy"; //$NON-NLS-1$
+
+ /**
* Action definition ID of the search -> references in working set action
* (value <code>"org.rubypeople.rdt.ui.edit.text.ruby.search.references.in.working.set"</code>).
*/
Modified: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/actions/RdtActionConstants.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/actions/RdtActionConstants.java 2007-09-10 14:54:50 UTC (rev 3117)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/actions/RdtActionConstants.java 2007-09-10 14:56:18 UTC (rev 3118)
@@ -42,6 +42,12 @@
public static final String FIND_REFERENCES_IN_PROJECT= "org.rubypeople.rdt.ui.actions.ReferencesInProject"; //$NON-NLS-1$
/**
+ * Search menu: name of standard Find References in Hierarchy global action
+ * (value <code>"org.rubypeople.rdt.ui.actions.ReferencesInHierarchy"</code>).
+ */
+ public static final String FIND_REFERENCES_IN_HIERARCHY= "org.rubypeople.rdt.ui.actions.ReferencesInHierarchy"; //$NON-NLS-1$
+
+ /**
* Search menu: name of standard Find References in Working Set global action
* (value <code>"org.rubypeople.rdt.ui.actions.ReferencesInWorkingSet"</code>).
*/
Modified: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/actions/ReferencesSearchGroup.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/actions/ReferencesSearchGroup.java 2007-09-10 14:54:50 UTC (rev 3117)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/actions/ReferencesSearchGroup.java 2007-09-10 14:56:18 UTC (rev 3118)
@@ -52,7 +52,7 @@
private FindReferencesAction fFindReferencesAction;
private FindReferencesInProjectAction fFindReferencesInProjectAction;
-// private FindReferencesInHierarchyAction fFindReferencesInHierarchyAction;
+ private FindReferencesInHierarchyAction fFindReferencesInHierarchyAction;
private FindReferencesInWorkingSetAction fFindReferencesInWorkingSetAction;
/**
@@ -72,8 +72,8 @@
fFindReferencesInProjectAction= new FindReferencesInProjectAction(site);
fFindReferencesInProjectAction.setActionDefinitionId(IRubyEditorActionDefinitionIds.SEARCH_REFERENCES_IN_PROJECT);
-// fFindReferencesInHierarchyAction= new FindReferencesInHierarchyAction(site);
-// fFindReferencesInHierarchyAction.setActionDefinitionId(IRubyEditorActionDefinitionIds.SEARCH_REFERENCES_IN_HIERARCHY);
+ fFindReferencesInHierarchyAction= new FindReferencesInHierarchyAction(site);
+ fFindReferencesInHierarchyAction.setActionDefinitionId(IRubyEditorActionDefinitionIds.SEARCH_REFERENCES_IN_HIERARCHY);
fFindReferencesInWorkingSetAction= new FindReferencesInWorkingSetAction(site);
fFindReferencesInWorkingSetAction.setActionDefinitionId(IRubyEditorActionDefinitionIds.SEARCH_REFERENCES_IN_WORKING_SET);
@@ -83,7 +83,7 @@
ISelection selection= provider.getSelection();
registerAction(fFindReferencesAction, provider, selection);
registerAction(fFindReferencesInProjectAction, provider, selection);
-// registerAction(fFindReferencesInHierarchyAction, provider, selection);
+ registerAction(fFindReferencesInHierarchyAction, provider, selection);
registerAction(fFindReferencesInWorkingSetAction, provider, selection);
}
@@ -106,9 +106,9 @@
fFindReferencesInProjectAction.setActionDefinitionId(IRubyEditorActionDefinitionIds.SEARCH_REFERENCES_IN_PROJECT);
fEditor.setAction("SearchReferencesInProject", fFindReferencesInProjectAction); //$NON-NLS-1$
-// fFindReferencesInHierarchyAction= new FindReferencesInHierarchyAction(fEditor);
-// fFindReferencesInHierarchyAction.setActionDefinitionId(IRubyEditorActionDefinitionIds.SEARCH_REFERENCES_IN_HIERARCHY);
-// fEditor.setAction("SearchReferencesInHierarchy", fFindReferencesInHierarchyAction); //$NON-NLS-1$
+ fFindReferencesInHierarchyAction= new FindReferencesInHierarchyAction(fEditor);
+ fFindReferencesInHierarchyAction.setActionDefinitionId(IRubyEditorActionDefinitionIds.SEARCH_REFERENCES_IN_HIERARCHY);
+ fEditor.setAction("SearchReferencesInHierarchy", fFindReferencesInHierarchyAction); //$NON-NLS-1$
fFindReferencesInWorkingSetAction= new FindReferencesInWorkingSetAction(fEditor);
fFindReferencesInWorkingSetAction.setActionDefinitionId(IRubyEditorActionDefinitionIds.SEARCH_REFERENCES_IN_WORKING_SET);
@@ -164,7 +164,7 @@
MenuManager javaSearchMM= new MenuManager(getName(), IContextMenuConstants.GROUP_SEARCH);
addAction(fFindReferencesAction, javaSearchMM);
addAction(fFindReferencesInProjectAction, javaSearchMM);
-// addAction(fFindReferencesInHierarchyAction, javaSearchMM);
+ addAction(fFindReferencesInHierarchyAction, javaSearchMM);
javaSearchMM.add(new Separator());
@@ -186,12 +186,12 @@
if (provider != null) {
disposeAction(fFindReferencesAction, provider);
disposeAction(fFindReferencesInProjectAction, provider);
-// disposeAction(fFindReferencesInHierarchyAction, provider);
+ disposeAction(fFindReferencesInHierarchyAction, provider);
disposeAction(fFindReferencesInWorkingSetAction, provider);
}
fFindReferencesAction= null;
fFindReferencesInProjectAction= null;
-// fFindReferencesInHierarchyAction= null;
+ fFindReferencesInHierarchyAction= null;
fFindReferencesInWorkingSetAction= null;
updateGlobalActionHandlers();
super.dispose();
@@ -201,7 +201,7 @@
if (fActionBars != null) {
fActionBars.setGlobalActionHandler(RdtActionConstants.FIND_REFERENCES_IN_WORKSPACE, fFindReferencesAction);
fActionBars.setGlobalActionHandler(RdtActionConstants.FIND_REFERENCES_IN_PROJECT, fFindReferencesInProjectAction);
-// fActionBars.setGlobalActionHandler(RdtActionConstants.FIND_REFERENCES_IN_HIERARCHY, fFindReferencesInHierarchyAction);
+ fActionBars.setGlobalActionHandler(RdtActionConstants.FIND_REFERENCES_IN_HIERARCHY, fFindReferencesInHierarchyAction);
fActionBars.setGlobalActionHandler(RdtActionConstants.FIND_REFERENCES_IN_WORKING_SET, fFindReferencesInWorkingSetAction);
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2007-09-10 14:54:51
|
Revision: 3117
http://rubyeclipse.svn.sourceforge.net/rubyeclipse/?rev=3117&view=rev
Author: cawilliams
Date: 2007-09-10 07:54:50 -0700 (Mon, 10 Sep 2007)
Log Message:
-----------
when grabbing the remote gem index, just run the original input stream right into an InflaterInputStream, then read out of that into a big byte array.
This should help fix the Out of Memory errors (somewhat, we may still need to stop buffering it all up into one big byte array and tehn converting that into a String, instead writing it to a temp file and then reading that in as a character array/Strings).
Modified Paths:
--------------
trunk/com.aptana.rdt/src/com/aptana/rdt/internal/core/gems/GemManager.java
Modified: trunk/com.aptana.rdt/src/com/aptana/rdt/internal/core/gems/GemManager.java
===================================================================
--- trunk/com.aptana.rdt/src/com/aptana/rdt/internal/core/gems/GemManager.java 2007-09-10 13:26:00 UTC (rev 3116)
+++ trunk/com.aptana.rdt/src/com/aptana/rdt/internal/core/gems/GemManager.java 2007-09-10 14:54:50 UTC (rev 3117)
@@ -1,7 +1,6 @@
package com.aptana.rdt.internal.core.gems;
import java.io.BufferedReader;
-import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
@@ -24,7 +23,7 @@
import java.util.SortedSet;
import java.util.TreeSet;
import java.util.zip.DataFormatException;
-import java.util.zip.Inflater;
+import java.util.zip.InflaterInputStream;
import javax.xml.parsers.FactoryConfigurationError;
import javax.xml.parsers.ParserConfigurationException;
@@ -249,7 +248,7 @@
private List<String> getContents() throws MalformedURLException,
IOException, DataFormatException {
- String outputString = decompress(getZippedGemIndex());
+ String outputString = new String(getZippedGemIndex());
String[] lineArray = outputString.split("\n");
return Arrays.asList(lineArray);
}
@@ -261,13 +260,13 @@
try {
URL url = new URL(GEM_INDEX_URL);
URLConnection con = url.openConnection();
- content = (InputStream) con.getContent();
+ content = new InflaterInputStream((InputStream) con.getContent());
while (true) {
int bytesToRead = content.available();
byte[] tmp = new byte[bytesToRead];
int length = content.read(tmp);
if (length == -1)
- break;
+ break;
while ((index + length) > input.length) { // if we'll overflow the
// array, we need to
// expand it
@@ -296,36 +295,6 @@
return newInput;
}
- private String decompress(byte[] input) throws DataFormatException {
- // Decompress the bytes
- Inflater decompresser = new Inflater();
- decompresser.setInput(input);
-
- // Create an expandable byte array to hold the decompressed data
- ByteArrayOutputStream bos = new ByteArrayOutputStream(input.length);
-
- try {
- // Decompress the data
- byte[] buf = new byte[1024];
- while (!decompresser.finished()) {
- int count = decompresser.inflate(buf);
- bos.write(buf, 0, count);
- }
- // Get the decompressed data
- byte[] result = bos.toByteArray();
-
- // Decode the bytes into a String
- return new String(result);
- } catch (DataFormatException e) {
- return "";
- } finally {
- try {
- bos.close();
- } catch (IOException ioe) {}
- decompresser.end();
- }
- }
-
private Set<Gem> loadLocalGems() {
if (!isRubyGemsInstalled()) return new HashSet<Gem>();
GemParser parser = new GemParser();
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2007-09-10 13:26:02
|
Revision: 3116
http://rubyeclipse.svn.sourceforge.net/rubyeclipse/?rev=3116&view=rev
Author: cawilliams
Date: 2007-09-10 06:26:00 -0700 (Mon, 10 Sep 2007)
Log Message:
-----------
close connection to gem index once we've read it's contents in!
Modified Paths:
--------------
trunk/com.aptana.rdt/src/com/aptana/rdt/internal/core/gems/GemManager.java
Modified: trunk/com.aptana.rdt/src/com/aptana/rdt/internal/core/gems/GemManager.java
===================================================================
--- trunk/com.aptana.rdt/src/com/aptana/rdt/internal/core/gems/GemManager.java 2007-09-10 13:17:21 UTC (rev 3115)
+++ trunk/com.aptana.rdt/src/com/aptana/rdt/internal/core/gems/GemManager.java 2007-09-10 13:26:00 UTC (rev 3116)
@@ -254,27 +254,41 @@
return Arrays.asList(lineArray);
}
- private byte[] getZippedGemIndex() throws MalformedURLException, IOException {
- URL url = new URL(GEM_INDEX_URL);
- URLConnection con = url.openConnection();
- InputStream content = (InputStream) con.getContent();
+ private byte[] getZippedGemIndex() {
+ InputStream content = null;
byte[] input = new byte[1024];
int index = 0;
- while (true) {
- int bytesToRead = content.available();
- byte[] tmp = new byte[bytesToRead];
- int length = content.read(tmp);
- if (length == -1)
- break;
- while ((index + length) > input.length) { // if we'll overflow the
- // array, we need to
- // expand it
- byte[] newInput = new byte[input.length * 2];
- System.arraycopy(input, 0, newInput, 0, input.length);
- input = newInput;
+ try {
+ URL url = new URL(GEM_INDEX_URL);
+ URLConnection con = url.openConnection();
+ content = (InputStream) con.getContent();
+ while (true) {
+ int bytesToRead = content.available();
+ byte[] tmp = new byte[bytesToRead];
+ int length = content.read(tmp);
+ if (length == -1)
+ break;
+ while ((index + length) > input.length) { // if we'll overflow the
+ // array, we need to
+ // expand it
+ byte[] newInput = new byte[input.length * 2];
+ System.arraycopy(input, 0, newInput, 0, input.length);
+ input = newInput;
+ }
+ System.arraycopy(tmp, 0, input, index, length);
+ index += length;
}
- System.arraycopy(tmp, 0, input, index, length);
- index += length;
+ } catch (Exception e) {
+ AptanaRDTPlugin.log(e);
+ return new byte[0];
+ } finally {
+ try {
+ if (content != null) {
+ content.close();
+ }
+ } catch (IOException e) {
+ // ignore
+ }
}
// Strip byte array down to just length of the content we actually read in.
byte[] newInput = new byte[index];
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2007-09-10 13:17:26
|
Revision: 3115
http://rubyeclipse.svn.sourceforge.net/rubyeclipse/?rev=3115&view=rev
Author: cawilliams
Date: 2007-09-10 06:17:21 -0700 (Mon, 10 Sep 2007)
Log Message:
-----------
try to fix #5823 - Out of memory error after startup - "Loading remote gem information".
In decompress method, loop over inflater grabbing up to 1K of data at a time and stuffing it into a ByteArrayOutputStream, then turn that into a String. Rather than making a big byte array and trying to expand it all at once.
Modified Paths:
--------------
trunk/com.aptana.rdt/src/com/aptana/rdt/internal/core/gems/GemManager.java
Modified: trunk/com.aptana.rdt/src/com/aptana/rdt/internal/core/gems/GemManager.java
===================================================================
--- trunk/com.aptana.rdt/src/com/aptana/rdt/internal/core/gems/GemManager.java 2007-09-07 19:52:42 UTC (rev 3114)
+++ trunk/com.aptana.rdt/src/com/aptana/rdt/internal/core/gems/GemManager.java 2007-09-10 13:17:21 UTC (rev 3115)
@@ -1,6 +1,7 @@
package com.aptana.rdt.internal.core.gems;
import java.io.BufferedReader;
+import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
@@ -285,14 +286,30 @@
// Decompress the bytes
Inflater decompresser = new Inflater();
decompresser.setInput(input);
- byte[] result = new byte[input.length * 10]; // XXX This is a hack. I
- // have no idea what the
- // length should be here
- int resultLength = decompresser.inflate(result);
- decompresser.end();
- // Decode the bytes into a String
- return new String(result, 0, resultLength);
+ // Create an expandable byte array to hold the decompressed data
+ ByteArrayOutputStream bos = new ByteArrayOutputStream(input.length);
+
+ try {
+ // Decompress the data
+ byte[] buf = new byte[1024];
+ while (!decompresser.finished()) {
+ int count = decompresser.inflate(buf);
+ bos.write(buf, 0, count);
+ }
+ // Get the decompressed data
+ byte[] result = bos.toByteArray();
+
+ // Decode the bytes into a String
+ return new String(result);
+ } catch (DataFormatException e) {
+ return "";
+ } finally {
+ try {
+ bos.close();
+ } catch (IOException ioe) {}
+ decompresser.end();
+ }
}
private Set<Gem> loadLocalGems() {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2007-09-07 19:52:44
|
Revision: 3114
http://rubyeclipse.svn.sourceforge.net/rubyeclipse/?rev=3114&view=rev
Author: cawilliams
Date: 2007-09-07 12:52:42 -0700 (Fri, 07 Sep 2007)
Log Message:
-----------
add spelling check in ruby comments!
Added Paths:
-----------
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/spelling/engine/SpellEvent.java
Added: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/spelling/engine/SpellEvent.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/spelling/engine/SpellEvent.java (rev 0)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/spelling/engine/SpellEvent.java 2007-09-07 19:52:42 UTC (rev 3114)
@@ -0,0 +1,109 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2005 IBM Corporation 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:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+
+package org.rubypeople.rdt.internal.ui.text.spelling.engine;
+
+import java.util.Set;
+
+/**
+ * Spell event fired for words detected by a spell-check iterator.
+ *
+ * @since 3.0
+ */
+public class SpellEvent implements ISpellEvent {
+
+ /** The begin index of the word in the spell-checkable medium */
+ private final int fBegin;
+
+ /** The spell-checker that causes the event */
+ private final ISpellChecker fChecker;
+
+ /** The end index of the word in the spell-checkable medium */
+ private final int fEnd;
+
+ /** Was the word found in the dictionary? */
+ private final boolean fMatch;
+
+ /** Does the word start a new sentence? */
+ private final boolean fSentence;
+
+ /** The word that causes the spell event */
+ private final String fWord;
+
+ /**
+ * Creates a new spell event.
+ *
+ * @param checker
+ * The spell-checker that causes the event
+ * @param word
+ * The word that causes the event
+ * @param begin
+ * The begin index of the word in the spell-checkable medium
+ * @param end
+ * The end index of the word in the spell-checkable medium
+ * @param sentence
+ * <code>true</code> iff the word starts a new sentence,
+ * <code>false</code> otherwise
+ * @param match
+ * <code>true</code> iff the word was found in the dictionary,
+ * <code>false</code> otherwise
+ */
+ protected SpellEvent(final ISpellChecker checker, final String word, final int begin, final int end, final boolean sentence, final boolean match) {
+ fChecker= checker;
+ fEnd= end;
+ fBegin= begin;
+ fWord= word;
+ fSentence= sentence;
+ fMatch= match;
+ }
+
+ /*
+ * @see org.eclipse.jdt.internal.ui.text.spelling.engine.ISpellEvent#getBegin()
+ */
+ public final int getBegin() {
+ return fBegin;
+ }
+
+ /*
+ * @see org.eclipse.jdt.internal.ui.text.spelling.engine.ISpellEvent#getEnd()
+ */
+ public final int getEnd() {
+ return fEnd;
+ }
+
+ /*
+ * @see org.eclipse.jdt.internal.ui.text.spelling.engine.ISpellEvent#getProposals()
+ */
+ public final Set getProposals() {
+ return fChecker.getProposals(fWord, fSentence);
+ }
+
+ /*
+ * @see org.eclipse.jdt.internal.ui.text.spelling.engine.ISpellEvent#getWord()
+ */
+ public final String getWord() {
+ return fWord;
+ }
+
+ /*
+ * @see org.eclipse.jdt.internal.ui.text.spelling.engine.ISpellEvent#isMatch()
+ */
+ public final boolean isMatch() {
+ return fMatch;
+ }
+
+ /*
+ * @see org.eclipse.jdt.internal.ui.text.spelling.engine.ISpellEvent#isStart()
+ */
+ public final boolean isStart() {
+ return fSentence;
+ }
+}
Property changes on: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/spelling/engine/SpellEvent.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2007-09-07 19:46:30
|
Revision: 3113
http://rubyeclipse.svn.sourceforge.net/rubyeclipse/?rev=3113&view=rev
Author: cawilliams
Date: 2007-09-07 12:46:20 -0700 (Fri, 07 Sep 2007)
Log Message:
-----------
add spelling check in ruby comments!
Modified Paths:
--------------
trunk/org.rubypeople.rdt.ui/plugin.properties
trunk/org.rubypeople.rdt.ui/plugin.xml
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/RubyPluginImages.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/RubyUIMessages.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/RubyUIMessages.properties
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/preferences/PreferencesMessages.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/preferences/PreferencesMessages.properties
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/rubyeditor/IRubyAnnotation.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/rubyeditor/RubyDocumentProvider.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/RubyReconciler.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/correction/ProblemLocation.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/PreferenceConstants.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/text/RubySourceViewerConfiguration.java
Added Paths:
-----------
trunk/org.rubypeople.rdt.ui/icons/full/obj16/add_correction.gif
trunk/org.rubypeople.rdt.ui/icons/full/obj16/correction_rename.gif
trunk/org.rubypeople.rdt.ui/icons/full/obj16/never_translate.gif
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/preferences/SpellingConfigurationBlock.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/preferences/SpellingPreferenceBlock.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/CompositeReconcilingStrategy.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/RubyCompositeReconcilingStrategy.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/spelling/
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/spelling/AddWordProposal.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/spelling/ChangeCaseProposal.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/spelling/CoreSpellingProblem.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/spelling/DefaultSpellingEngine.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/spelling/RubySpellingEngine.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/spelling/RubySpellingProblem.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/spelling/RubySpellingReconcileStrategy.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/spelling/SpellCheckEngine.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/spelling/SpellCheckIterator.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/spelling/SpellReconcileDictionary.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/spelling/SpellingEngine.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/spelling/TaskTagDictionary.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/spelling/TextSpellingEngine.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/spelling/WordCorrectionProposal.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/spelling/WordIgnoreProposal.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/spelling/WordQuickFixProcessor.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/spelling/engine/
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/spelling/engine/AbstractSpellDictionary.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/spelling/engine/DefaultPhoneticDistanceAlgorithm.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/spelling/engine/DefaultPhoneticHashProvider.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/spelling/engine/DefaultSpellChecker.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/spelling/engine/IPhoneticDistanceAlgorithm.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/spelling/engine/IPhoneticHashProvider.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/spelling/engine/ISpellCheckEngine.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/spelling/engine/ISpellCheckIterator.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/spelling/engine/ISpellCheckPreferenceKeys.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/spelling/engine/ISpellChecker.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/spelling/engine/ISpellDictionary.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/spelling/engine/ISpellEvent.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/spelling/engine/ISpellEventListener.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/spelling/engine/LocaleSensitiveSpellDictionary.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/spelling/engine/PersistentSpellDictionary.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/spelling/engine/RankedWordProposal.java
Added: trunk/org.rubypeople.rdt.ui/icons/full/obj16/add_correction.gif
===================================================================
(Binary files differ)
Property changes on: trunk/org.rubypeople.rdt.ui/icons/full/obj16/add_correction.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/org.rubypeople.rdt.ui/icons/full/obj16/correction_rename.gif
===================================================================
(Binary files differ)
Property changes on: trunk/org.rubypeople.rdt.ui/icons/full/obj16/correction_rename.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/org.rubypeople.rdt.ui/icons/full/obj16/never_translate.gif
===================================================================
(Binary files differ)
Property changes on: trunk/org.rubypeople.rdt.ui/icons/full/obj16/never_translate.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Modified: trunk/org.rubypeople.rdt.ui/plugin.properties
===================================================================
--- trunk/org.rubypeople.rdt.ui/plugin.properties 2007-09-07 19:44:59 UTC (rev 3112)
+++ trunk/org.rubypeople.rdt.ui/plugin.properties 2007-09-07 19:46:20 UTC (rev 3113)
@@ -7,9 +7,12 @@
providerName=RubyPeople, Inc.
hyperlinkProvider=Hyperlink provider
-
callHierarchyViewName=Call Hierarchy
+#--- Spelling
+defaultSpellingEngine.label= Ruby spelling engine
+spellingQuickFixProcessor=Spelling Quick Fix Processor
+
# Browsing
Browsing.perspectiveName= Ruby Browsing
Browsing.viewCategoryName= Ruby Browsing
Modified: trunk/org.rubypeople.rdt.ui/plugin.xml
===================================================================
--- trunk/org.rubypeople.rdt.ui/plugin.xml 2007-09-07 19:44:59 UTC (rev 3112)
+++ trunk/org.rubypeople.rdt.ui/plugin.xml 2007-09-07 19:46:20 UTC (rev 3113)
@@ -1533,5 +1533,24 @@
class="org.rubypeople.rdt.internal.ui.text.correction.QuickFixProcessor"
id="org.rubypeople.rdt.ui.quickFixProcessor"
name="Default Quick Fix Processor"/>
+ <quickFixProcessor
+ name="%spellingQuickFixProcessor"
+ class="org.rubypeople.rdt.internal.ui.text.spelling.WordQuickFixProcessor"
+ id= "org.rubypeople.rdt.ui.text.correction.spelling.QuickFixProcessor">
+ <handledMarkerTypes>
+ <markerType id="org.rubypeople.rdt.internal.spelling"/>
+ </handledMarkerTypes>
+ </quickFixProcessor>
</extension>
+
+ <extension point="org.eclipse.ui.workbench.texteditor.spellingEngine">
+ <engine
+ preferencesClass="org.rubypeople.rdt.internal.ui.preferences.SpellingPreferenceBlock"
+ label="%defaultSpellingEngine.label"
+ class="org.rubypeople.rdt.internal.ui.text.spelling.DefaultSpellingEngine"
+ default="true"
+ id="org.rubypeople.rdt.internal.ui.text.spelling.DefaultSpellingEngine">
+ </engine>
+ </extension>
+
</plugin>
Modified: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/RubyPluginImages.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/RubyPluginImages.java 2007-09-07 19:44:59 UTC (rev 3112)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/RubyPluginImages.java 2007-09-07 19:46:20 UTC (rev 3113)
@@ -90,9 +90,7 @@
private static final String IMG_CTOOLS_RUBY_CONSTANT = NAME_PREFIX + "ruby_constant.gif";
public static final String IMG_OBJS_FIXABLE_PROBLEM= NAME_PREFIX + "quickfix_warning_obj.gif"; //$NON-NLS-1$
- private static final String IMG_OBJS_FIXABLE_ERROR= NAME_PREFIX + "quickfix_error_obj.gif"; //$NON-NLS-1$
-
- public static final String IMG_CORRECTION_CHANGE= NAME_PREFIX + "correction_change.gif"; //$NON-NLS-1$
+ private static final String IMG_OBJS_FIXABLE_ERROR= NAME_PREFIX + "quickfix_error_obj.gif"; //$NON-NLS-1$
public static final ImageDescriptor DESC_WIZBAN_NEWJPRJ = createUnManaged(T_WIZBAN, "newrprj_wiz.gif"); //$NON-NLS-1$
public static final ImageDescriptor DESC_WIZBAN_NEWCLASS = createUnManaged(T_WIZBAN, "newclass_wiz.gif"); //$NON-NLS-1$
@@ -205,7 +203,16 @@
public static final ImageDescriptor DESC_TOOL_LOADPATH_ORDER= createUnManaged(T_OBJ, "cp_order_obj.gif"); //$NON-NLS-1$
public static final ImageDescriptor DESC_TOOL_OPENTYPE= createUnManaged(T_ETOOL, "opentype.gif"); //$NON-NLS-1$
+ public static final String IMG_CORRECTION_RENAME= NAME_PREFIX + "correction_rename.gif"; //$NON-NLS-1$
+ public static final String IMG_CORRECTION_ADD= NAME_PREFIX + "add_correction.gif"; //$NON-NLS-1$
+ public static final String IMG_CORRECTION_CHANGE= NAME_PREFIX + "correction_change.gif"; //$NON-NLS-1$
+
+ public static final String IMG_OBJS_NLS_NEVER_TRANSLATE= NAME_PREFIX + "never_translate.gif"; //$NON-NLS-1$
+ public static final ImageDescriptor DESC_OBJS_NLS_NEVER_TRANSLATE= createManagedFromKey(T_OBJ, IMG_OBJS_NLS_NEVER_TRANSLATE);
+
static {
+ createManagedFromKey(T_OBJ, IMG_CORRECTION_RENAME);
+ createManagedFromKey(T_OBJ, IMG_CORRECTION_ADD);
createManagedFromKey(T_OBJ, IMG_CORRECTION_CHANGE);
createManagedFromKey(T_OBJ, IMG_OBJS_FIXABLE_ERROR);
createManagedFromKey(T_OBJ, IMG_OBJS_FIXABLE_PROBLEM);
Modified: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/RubyUIMessages.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/RubyUIMessages.java 2007-09-07 19:44:59 UTC (rev 3112)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/RubyUIMessages.java 2007-09-07 19:46:20 UTC (rev 3113)
@@ -94,8 +94,17 @@
public static String OpenTypeHierarchyUtil_error_open_perspective;
public static String OpenTypeHierarchyUtil_error_open_editor;
public static String OpenTypeHierarchyUtil_error_open_view;
-
public static String RubyUI_defaultDialogMessage;
+ public static String Spelling_error_case_label;
+ public static String Spelling_error_label;
+ public static String AbstractSpellingDictionary_encodingError;
+ public static String Spelling_dictionary_file_extension;
+ public static String Spelling_correct_label;
+ public static String Spelling_case_label;
+ public static String Spelling_add_info;
+ public static String Spelling_add_label;
+ public static String Spelling_ignore_info;
+ public static String Spelling_ignore_label;
private RubyUIMessages() {
}
Modified: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/RubyUIMessages.properties
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/RubyUIMessages.properties 2007-09-07 19:44:59 UTC (rev 3112)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/RubyUIMessages.properties 2007-09-07 19:46:20 UTC (rev 3113)
@@ -155,4 +155,19 @@
CoreUtility_buildall_taskname=Build all...
CoreUtility_buildproject_taskname=Build project ''{0}''...
-RubyElementLabels_default_package=(default)
\ No newline at end of file
+RubyElementLabels_default_package=(default)
+
+#########
+# Spelling
+#########
+
+Spelling_dictionary_file_extension=dictionary
+Spelling_error_label=The word ''{0}'' is not correctly spelled
+Spelling_correct_label=Change to ''{0}''
+Spelling_add_info=Adds the word ''{0}'' to the dictionary
+Spelling_add_label=Add ''{0}'' to dictionary
+Spelling_ignore_info=Always ignores ''{0}'' during the current session
+Spelling_ignore_label=Always ignore ''{0}''
+Spelling_case_label=Change to upper case
+Spelling_error_case_label= The word ''{0}'' should have an initial upper case letter
+AbstractSpellingDictionary_encodingError= Could not read: ''{0}'', where the bad characters are replaced by ''{1}''. Check the encoding of the spelling dictionary ({2}).
Modified: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/preferences/PreferencesMessages.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/preferences/PreferencesMessages.java 2007-09-07 19:44:59 UTC (rev 3112)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/preferences/PreferencesMessages.java 2007-09-07 19:46:20 UTC (rev 3113)
@@ -192,6 +192,28 @@
public static String KeywordInputDialog_error_entryExists;
public static String KeywordInputDialog_error_noSpace;
public static String RubyEditorPreferencePage_enableHovers;
+ public static String SpellingPreferencePage_dictionary_error;
+ public static String SpellingPreferencePage_locale_error;
+ public static String SpellingPreferencePage_empty_threshold;
+ public static String SpellingPreferencePage_invalid_threshold;
+ public static String SpellingPreferencePage_preferences_user;
+ public static String SpellingPreferencePage_ignore_digits_label;
+ public static String SpellingPreferencePage_ignore_mixed_label;
+ public static String SpellingPreferencePage_ignore_sentence_label;
+ public static String SpellingPreferencePage_ignore_upper_label;
+ public static String SpellingPreferencePage_ignore_url_label;
+ public static String SpellingPreferencePage_preferences_engine;
+ public static String SpellingPreferencePage_dictionary_label;
+ public static String SpellingPreferencePage_workspace_dictionary_label;
+ public static String SpellingPreferencePage_browse_label;
+ public static String SpellingPreferencePage_preferences_advanced;
+ public static String SpellingPreferencePage_proposals_threshold;
+ public static String SpellingPreferencePage_enable_contentassist_label;
+ public static String SpellingPreferencePage_filedialog_title;
+ public static String SpellingPreferencePage_filter_dictionary_extension;
+ public static String SpellingPreferencePage_filter_all_extension;
+ public static String SpellingPreferencePage_filter_dictionary_label;
+ public static String SpellingPreferencePage_filter_all_label;
static {
NLS.initializeMessages(BUNDLE_NAME, PreferencesMessages.class);
Modified: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/preferences/PreferencesMessages.properties
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/preferences/PreferencesMessages.properties 2007-09-07 19:44:59 UTC (rev 3112)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/preferences/PreferencesMessages.properties 2007-09-07 19:46:20 UTC (rev 3113)
@@ -220,4 +220,27 @@
BuildPathsPropertyPage_unsavedchanges_button_discard=Discard
BuildPathsPropertyPage_unsavedchanges_button_ignore=Apply Later
-RubyBuildConfigurationBlock_invalid_input={0} is not a valid number of problems.
\ No newline at end of file
+RubyBuildConfigurationBlock_invalid_input={0} is not a valid number of problems.
+
+SpellingPreferencePage_empty_threshold= A maximum number of correction proposals must be specified.
+SpellingPreferencePage_invalid_threshold=''{0}'' is not a valid maximum number of correction proposals.
+SpellingPreferencePage_ignore_digits_label=Ignore &words with digits
+SpellingPreferencePage_ignore_mixed_label=Ignore &mixed case words
+SpellingPreferencePage_ignore_sentence_label=Ignore &sentence capitalization
+SpellingPreferencePage_ignore_upper_label=Ignore u&pper case words
+SpellingPreferencePage_ignore_url_label=Ignore &internet addresses
+SpellingPreferencePage_proposals_threshold= Maximum &number of correction proposals:
+SpellingPreferencePage_dictionary_label=Plat&form dictionary:
+SpellingPreferencePage_workspace_dictionary_label=&User defined dictionary:
+SpellingPreferencePage_browse_label=&Browse...
+SpellingPreferencePage_dictionary_error=The dictionary file must be read/write accessible.
+SpellingPreferencePage_locale_error=There is no dictionary available for this language.
+SpellingPreferencePage_filedialog_title=Select dictionary
+SpellingPreferencePage_filter_dictionary_extension=*.dictionary
+SpellingPreferencePage_filter_all_extension=*.*
+SpellingPreferencePage_filter_dictionary_label=Dictionary Files
+SpellingPreferencePage_filter_all_label=All Files
+SpellingPreferencePage_enable_contentassist_label=Ma&ke dictionary available to content assist
+SpellingPreferencePage_preferences_user=&Options
+SpellingPreferencePage_preferences_engine=&Language
+SpellingPreferencePage_preferences_advanced=Ad&vanced
\ No newline at end of file
Added: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/preferences/SpellingConfigurationBlock.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/preferences/SpellingConfigurationBlock.java (rev 0)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/preferences/SpellingConfigurationBlock.java 2007-09-07 19:46:20 UTC (rev 3113)
@@ -0,0 +1,446 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2005 IBM Corporation 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:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+
+package org.rubypeople.rdt.internal.ui.preferences;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Locale;
+import java.util.Set;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Combo;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.FileDialog;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.preferences.IWorkbenchPreferenceContainer;
+import org.rubypeople.rdt.internal.corext.util.Messages;
+import org.rubypeople.rdt.internal.ui.dialogs.StatusInfo;
+import org.rubypeople.rdt.internal.ui.dialogs.StatusUtil;
+import org.rubypeople.rdt.internal.ui.text.spelling.SpellCheckEngine;
+import org.rubypeople.rdt.internal.ui.util.PixelConverter;
+import org.rubypeople.rdt.internal.ui.util.SWTUtil;
+import org.rubypeople.rdt.internal.ui.wizards.IStatusChangeListener;
+import org.rubypeople.rdt.ui.PreferenceConstants;
+
+/**
+ * Options configuration block for spell-check related settings.
+ *
+ * @since 3.0
+ */
+public class SpellingConfigurationBlock extends OptionsConfigurationBlock {
+
+ /** Preference keys for the preferences in this block */
+ private static final Key PREF_SPELLING_IGNORE_DIGITS= getRDTUIKey(PreferenceConstants.SPELLING_IGNORE_DIGITS);
+ private static final Key PREF_SPELLING_IGNORE_MIXED= getRDTUIKey(PreferenceConstants.SPELLING_IGNORE_MIXED);
+ private static final Key PREF_SPELLING_IGNORE_SENTENCE= getRDTUIKey(PreferenceConstants.SPELLING_IGNORE_SENTENCE);
+ private static final Key PREF_SPELLING_IGNORE_UPPER= getRDTUIKey(PreferenceConstants.SPELLING_IGNORE_UPPER);
+ private static final Key PREF_SPELLING_IGNORE_URLS= getRDTUIKey(PreferenceConstants.SPELLING_IGNORE_URLS);
+ private static final Key PREF_SPELLING_LOCALE= getRDTUIKey(PreferenceConstants.SPELLING_LOCALE);
+ private static final Key PREF_SPELLING_PROPOSAL_THRESHOLD= getRDTUIKey(PreferenceConstants.SPELLING_PROPOSAL_THRESHOLD);
+ private static final Key PREF_SPELLING_USER_DICTIONARY= getRDTUIKey(PreferenceConstants.SPELLING_USER_DICTIONARY);
+ private static final Key PREF_SPELLING_ENABLE_CONTENTASSIST= getRDTUIKey(PreferenceConstants.SPELLING_ENABLE_CONTENTASSIST);
+
+ /**
+ * Creates a selection dependency between a master and a slave control.
+ *
+ * @param master
+ * The master button that controls the state of the slave
+ * @param slave
+ * The slave control that is enabled only if the master is
+ * selected
+ */
+ protected static void createSelectionDependency(final Button master, final Control slave) {
+
+ master.addSelectionListener(new SelectionListener() {
+
+ public void widgetDefaultSelected(SelectionEvent event) {
+ // Do nothing
+ }
+
+ public void widgetSelected(SelectionEvent event) {
+ slave.setEnabled(master.getSelection());
+ }
+ });
+ slave.setEnabled(master.getSelection());
+ }
+
+ /**
+ * Returns the locale codes for the locale list.
+ *
+ * @param locales
+ * The list of locales
+ * @return Array of locale codes for the list
+ */
+ protected static String[] getDictionaryCodes(final Set locales) {
+
+ int index= 0;
+ Locale locale= null;
+
+ final String[] codes= new String[locales.size()];
+ for (final Iterator iterator= locales.iterator(); iterator.hasNext();) {
+
+ locale= (Locale)iterator.next();
+ codes[index++]= locale.toString();
+ }
+ return codes;
+ }
+
+ /**
+ * Returns the display labels for the locale list.
+ *
+ * @param locales
+ * The list of locales
+ * @return Array of display labels for the list
+ */
+ protected static String[] getDictionaryLabels(final Set locales) {
+
+ int index= 0;
+ Locale locale= null;
+
+ final String[] labels= new String[locales.size()];
+ for (final Iterator iterator= locales.iterator(); iterator.hasNext();) {
+
+ locale= (Locale)iterator.next();
+ labels[index++]= locale.getDisplayName();
+ }
+ return labels;
+ }
+
+ /**
+ * Validates that the file with the specified absolute path exists and can
+ * be opened.
+ *
+ * @param path
+ * The path of the file to validate
+ * @return <code>true</code> iff the file exists and can be opened,
+ * <code>false</code> otherwise
+ */
+ protected static IStatus validateAbsoluteFilePath(final String path) {
+
+ final StatusInfo status= new StatusInfo();
+ if (path.length() > 0) {
+
+ final File file= new File(path);
+ if (!file.isFile() || !file.isAbsolute() || !file.exists() || !file.canRead() || !file.canWrite())
+ status.setError(PreferencesMessages.SpellingPreferencePage_dictionary_error);
+
+ }
+ return status;
+ }
+
+ /**
+ * Validates that the specified locale is available.
+ *
+ * @param locale
+ * The locale to validate
+ * @return The status of the validation
+ */
+ protected static IStatus validateLocale(final String locale) {
+
+ final StatusInfo status= new StatusInfo(IStatus.ERROR, PreferencesMessages.SpellingPreferencePage_locale_error);
+ final Set locales= SpellCheckEngine.getAvailableLocales();
+
+ Locale current= null;
+ for (final Iterator iterator= locales.iterator(); iterator.hasNext();) {
+
+ current= (Locale)iterator.next();
+ if (current.toString().equals(locale))
+ return new StatusInfo();
+ }
+ return status;
+ }
+
+ /**
+ * Validates that the specified number is positive.
+ *
+ * @param number
+ * The number to validate
+ * @return The status of the validation
+ */
+ protected static IStatus validatePositiveNumber(final String number) {
+
+ final StatusInfo status= new StatusInfo();
+ if (number.length() == 0) {
+ status.setError(PreferencesMessages.SpellingPreferencePage_empty_threshold);
+ } else {
+ try {
+ final int value= Integer.parseInt(number);
+ if (value < 0) {
+ status.setError(Messages.format(PreferencesMessages.SpellingPreferencePage_invalid_threshold, number));
+ }
+ } catch (NumberFormatException exception) {
+ status.setError(Messages.format(PreferencesMessages.SpellingPreferencePage_invalid_threshold, number));
+ }
+ }
+ return status;
+ }
+
+ /** The dictionary path field */
+ private Text fDictionaryPath= null;
+
+ /** The status for the workspace dictionary file */
+ private IStatus fFileStatus= new StatusInfo();
+
+ /** The status for the proposal threshold */
+ private IStatus fThresholdStatus= new StatusInfo();
+
+ /**
+ * All controls
+ * @since 3.1
+ */
+ private Control[] fAllControls;
+
+ /**
+ * All previously enabled controls
+ * @since 3.1
+ */
+ private Control[] fEnabledControls;
+
+ /**
+ * Creates a new spelling configuration block.
+ *
+ * @param context
+ * The status change listener
+ * @param project
+ * The Java project
+ */
+ public SpellingConfigurationBlock(final IStatusChangeListener context, final IProject project, IWorkbenchPreferenceContainer container) {
+ super(context, project, getAllKeys(), container);
+
+ IStatus status= validateAbsoluteFilePath(getValue(PREF_SPELLING_USER_DICTIONARY));
+ if (status.getSeverity() != IStatus.OK)
+ setValue(PREF_SPELLING_USER_DICTIONARY, ""); //$NON-NLS-1$
+
+ status= validateLocale(getValue(PREF_SPELLING_LOCALE));
+ if (status.getSeverity() != IStatus.OK)
+ setValue(PREF_SPELLING_LOCALE, SpellCheckEngine.getDefaultLocale().toString());
+ }
+
+ protected Combo addComboBox(Composite parent, String label, Key key, String[] values, String[] valueLabels, int indent) {
+ ControlData data= new ControlData(key, values);
+
+ GridData gd= new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
+ gd.horizontalIndent= indent;
+
+ Label labelControl= new Label(parent, SWT.LEFT | SWT.WRAP);
+ labelControl.setText(label);
+ labelControl.setLayoutData(gd);
+
+ Combo comboBox= new Combo(parent, SWT.READ_ONLY);
+ comboBox.setItems(valueLabels);
+ comboBox.setData(data);
+ gd= new GridData(GridData.HORIZONTAL_ALIGN_FILL);
+ gd.horizontalSpan= 2;
+ comboBox.setLayoutData(gd);
+ comboBox.addSelectionListener(getSelectionListener());
+
+ fLabels.put(comboBox, labelControl);
+
+ String currValue= getValue(key);
+ comboBox.select(data.getSelection(currValue));
+
+ fComboBoxes.add(comboBox);
+ return comboBox;
+ }
+
+ /*
+ * @see org.eclipse.jdt.internal.ui.preferences.OptionsConfigurationBlock#createContents(org.eclipse.swt.widgets.Composite)
+ */
+ protected Control createContents(final Composite parent) {
+
+ Composite composite= new Composite(parent, SWT.NONE);
+ composite.setLayout(new GridLayout());
+
+ List allControls= new ArrayList();
+ final PixelConverter converter= new PixelConverter(parent);
+
+ final String[] trueFalse= new String[] { IPreferenceStore.TRUE, IPreferenceStore.FALSE };
+
+ Group user= new Group(composite, SWT.NONE);
+ user.setText(PreferencesMessages.SpellingPreferencePage_preferences_user);
+ user.setLayout(new GridLayout());
+ user.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+ allControls.add(user);
+
+ String label= PreferencesMessages.SpellingPreferencePage_ignore_digits_label;
+ Control slave= addCheckBox(user, label, PREF_SPELLING_IGNORE_DIGITS, trueFalse, 0);
+ allControls.add(slave);
+
+ label= PreferencesMessages.SpellingPreferencePage_ignore_mixed_label;
+ slave= addCheckBox(user, label, PREF_SPELLING_IGNORE_MIXED, trueFalse, 0);
+ allControls.add(slave);
+
+ label= PreferencesMessages.SpellingPreferencePage_ignore_sentence_label;
+ slave= addCheckBox(user, label, PREF_SPELLING_IGNORE_SENTENCE, trueFalse, 0);
+ allControls.add(slave);
+
+ label= PreferencesMessages.SpellingPreferencePage_ignore_upper_label;
+ slave= addCheckBox(user, label, PREF_SPELLING_IGNORE_UPPER, trueFalse, 0);
+ allControls.add(slave);
+
+ label= PreferencesMessages.SpellingPreferencePage_ignore_url_label;
+ slave= addCheckBox(user, label, PREF_SPELLING_IGNORE_URLS, trueFalse, 0);
+ allControls.add(slave);
+
+ final Group engine= new Group(composite, SWT.NONE);
+ engine.setText(PreferencesMessages.SpellingPreferencePage_preferences_engine);
+ engine.setLayout(new GridLayout(4, false));
+ engine.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+ allControls.add(engine);
+
+ label= PreferencesMessages.SpellingPreferencePage_dictionary_label;
+ final Set locales= SpellCheckEngine.getAvailableLocales();
+
+ Combo combo= addComboBox(engine, label, PREF_SPELLING_LOCALE, getDictionaryCodes(locales), getDictionaryLabels(locales), 0);
+ combo.setEnabled(locales.size() > 1);
+ allControls.add(combo);
+ allControls.add(fLabels.get(combo));
+
+ new Label(engine, SWT.NONE); // placeholder
+
+ label= PreferencesMessages.SpellingPreferencePage_workspace_dictionary_label;
+ fDictionaryPath= addTextField(engine, label, PREF_SPELLING_USER_DICTIONARY, 0, 0);
+ GridData gd= (GridData) fDictionaryPath.getLayoutData();
+ gd.grabExcessHorizontalSpace= true;
+ gd.widthHint= converter.convertWidthInCharsToPixels(40);
+ allControls.add(fDictionaryPath);
+ allControls.add(fLabels.get(fDictionaryPath));
+
+
+ Button button= new Button(engine, SWT.PUSH);
+ button.setText(PreferencesMessages.SpellingPreferencePage_browse_label);
+ button.addSelectionListener(new SelectionAdapter() {
+
+ public void widgetSelected(final SelectionEvent event) {
+ handleBrowseButtonSelected();
+ }
+ });
+ button.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END));
+ SWTUtil.setButtonDimensionHint(button);
+ allControls.add(button);
+
+ Group advanced= new Group(composite, SWT.NONE);
+ advanced.setText(PreferencesMessages.SpellingPreferencePage_preferences_advanced);
+ advanced.setLayout(new GridLayout(3, false));
+ advanced.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+ allControls.add(advanced);
+
+ label= PreferencesMessages.SpellingPreferencePage_proposals_threshold;
+ Text text= addTextField(advanced, label, PREF_SPELLING_PROPOSAL_THRESHOLD, 0, 0);
+ text.setTextLimit(3);
+ gd= new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
+ gd.widthHint= converter.convertWidthInCharsToPixels(4);
+ text.setLayoutData(gd);
+ allControls.add(text);
+ allControls.add(fLabels.get(text));
+
+ label= PreferencesMessages.SpellingPreferencePage_enable_contentassist_label;
+ button= addCheckBox(advanced, label, PREF_SPELLING_ENABLE_CONTENTASSIST, trueFalse, 0);
+ allControls.add(button);
+
+ fAllControls= (Control[]) allControls.toArray(new Control[allControls.size()]);
+
+// PlatformUI.getWorkbench().getHelpSystem().setHelp(composite, IJavaHelpContextIds.JAVA_EDITOR_PREFERENCE_PAGE);
+ return composite;
+ }
+
+ private static Key[] getAllKeys() {
+ return new Key[] { PREF_SPELLING_USER_DICTIONARY, PREF_SPELLING_IGNORE_DIGITS, PREF_SPELLING_IGNORE_MIXED, PREF_SPELLING_IGNORE_SENTENCE, PREF_SPELLING_IGNORE_UPPER, PREF_SPELLING_IGNORE_URLS, PREF_SPELLING_LOCALE, PREF_SPELLING_PROPOSAL_THRESHOLD, PREF_SPELLING_ENABLE_CONTENTASSIST };
+ }
+
+ /*
+ * @see org.eclipse.jdt.internal.ui.preferences.OptionsConfigurationBlock#getFullBuildDialogStrings(boolean)
+ */
+ protected final String[] getFullBuildDialogStrings(final boolean workspace) {
+ return null;
+ }
+
+ /**
+ * Handles selections of the browse button.
+ */
+ protected void handleBrowseButtonSelected() {
+
+ final FileDialog dialog= new FileDialog(fDictionaryPath.getShell(), SWT.OPEN);
+ dialog.setText(PreferencesMessages.SpellingPreferencePage_filedialog_title);
+ dialog.setFilterExtensions(new String[] { PreferencesMessages.SpellingPreferencePage_filter_dictionary_extension, PreferencesMessages.SpellingPreferencePage_filter_all_extension });
+ dialog.setFilterNames(new String[] { PreferencesMessages.SpellingPreferencePage_filter_dictionary_label, PreferencesMessages.SpellingPreferencePage_filter_all_label });
+
+ final String path= dialog.open();
+ if (path != null)
+ fDictionaryPath.setText(path);
+ }
+
+ /*
+ * @see org.eclipse.jdt.internal.ui.preferences.OptionsConfigurationBlock#validateSettings(java.lang.String,java.lang.String)
+ */
+ protected void validateSettings(final Key key, final String oldValue, final String newValue) {
+
+ if (key == null || PREF_SPELLING_PROPOSAL_THRESHOLD.equals(key))
+ fThresholdStatus= validatePositiveNumber(getValue(PREF_SPELLING_PROPOSAL_THRESHOLD));
+
+ if (key == null || PREF_SPELLING_USER_DICTIONARY.equals(key))
+ fFileStatus= validateAbsoluteFilePath(getValue(PREF_SPELLING_USER_DICTIONARY));
+
+ fContext.statusChanged(StatusUtil.getMostSevere(new IStatus[] { fThresholdStatus, fFileStatus }));
+ }
+
+ /*
+ * @see org.eclipse.jdt.internal.ui.preferences.OptionsConfigurationBlock#updateCheckBox(org.eclipse.swt.widgets.Button)
+ * @since 3.1
+ */
+ protected void updateCheckBox(Button curr) {
+ super.updateCheckBox(curr);
+ Event event= new Event();
+ event.type= SWT.Selection;
+ event.display= curr.getDisplay();
+ event.widget= curr;
+ curr.notifyListeners(SWT.Selection, event);
+ }
+
+ /**
+ * @since 3.1
+ */
+ protected void setEnabled(boolean enabled) {
+ if (enabled && fEnabledControls != null) {
+ for (int i= fEnabledControls.length - 1; i >= 0; i--)
+ fEnabledControls[i].setEnabled(true);
+ fEnabledControls= null;
+ }
+ if (!enabled && fEnabledControls == null) {
+ List enabledControls= new ArrayList();
+ for (int i= fAllControls.length - 1; i >= 0; i--) {
+ Control control= fAllControls[i];
+ if (control.isEnabled()) {
+ enabledControls.add(control);
+ control.setEnabled(false);
+ }
+ }
+ fEnabledControls= (Control[]) enabledControls.toArray(new Control[enabledControls.size()]);
+ }
+ }
+}
Property changes on: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/preferences/SpellingConfigurationBlock.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/preferences/SpellingPreferenceBlock.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/preferences/SpellingPreferenceBlock.java (rev 0)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/preferences/SpellingPreferenceBlock.java 2007-09-07 19:46:20 UTC (rev 3113)
@@ -0,0 +1,121 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2005 IBM Corporation 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:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+
+package org.rubypeople.rdt.internal.ui.preferences;
+
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.ui.texteditor.spelling.IPreferenceStatusMonitor;
+import org.eclipse.ui.texteditor.spelling.ISpellingPreferenceBlock;
+import org.rubypeople.rdt.internal.ui.wizards.IStatusChangeListener;
+
+/**
+ * Spelling preference block
+ *
+ * @since 3.1
+ */
+public class SpellingPreferenceBlock implements ISpellingPreferenceBlock {
+
+ private class NullStatusChangeListener implements IStatusChangeListener {
+
+ /*
+ * @see org.eclipse.jdt.internal.ui.wizards.IStatusChangeListener#statusChanged(org.eclipse.core.runtime.IStatus)
+ */
+ public void statusChanged(IStatus status) {
+ }
+ }
+
+ private class StatusChangeListenerAdapter implements IStatusChangeListener {
+
+ private IPreferenceStatusMonitor fMonitor;
+
+ private IStatus fStatus;
+
+ public StatusChangeListenerAdapter(IPreferenceStatusMonitor monitor) {
+ super();
+ fMonitor= monitor;
+ }
+
+ /*
+ * @see org.eclipse.jdt.internal.ui.wizards.IStatusChangeListener#statusChanged(org.eclipse.core.runtime.IStatus)
+ */
+ public void statusChanged(IStatus status) {
+ fStatus= status;
+ fMonitor.statusChanged(status);
+ }
+
+ public IStatus getStatus() {
+ return fStatus;
+ }
+ }
+
+ private SpellingConfigurationBlock fBlock= new SpellingConfigurationBlock(new NullStatusChangeListener(), null, null);
+
+ private SpellingPreferenceBlock.StatusChangeListenerAdapter fStatusMonitor;
+
+ /*
+ * @see org.eclipse.ui.texteditor.spelling.ISpellingPreferenceBlock#createControl(org.eclipse.swt.widgets.Composite)
+ */
+ public Control createControl(Composite parent) {
+ return fBlock.createContents(parent);
+ }
+
+ /*
+ * @see org.eclipse.ui.texteditor.spelling.ISpellingPreferenceBlock#initialize(org.eclipse.ui.texteditor.spelling.IPreferenceStatusMonitor)
+ */
+ public void initialize(IPreferenceStatusMonitor statusMonitor) {
+ fStatusMonitor= new StatusChangeListenerAdapter(statusMonitor);
+ fBlock.fContext= fStatusMonitor;
+ }
+
+ /*
+ * @see org.eclipse.ui.texteditor.spelling.ISpellingPreferenceBlock#canPerformOk()
+ */
+ public boolean canPerformOk() {
+ return fStatusMonitor == null || fStatusMonitor.getStatus() == null || !fStatusMonitor.getStatus().matches(IStatus.ERROR);
+ }
+
+ /*
+ * @see org.eclipse.ui.texteditor.spelling.ISpellingPreferenceBlock#performOk()
+ */
+ public void performOk() {
+ fBlock.performOk();
+ }
+
+ /*
+ * @see org.eclipse.ui.texteditor.spelling.ISpellingPreferenceBlock#performDefaults()
+ */
+ public void performDefaults() {
+ fBlock.performDefaults();
+ }
+
+ /*
+ * @see org.eclipse.ui.texteditor.spelling.ISpellingPreferenceBlock#performRevert()
+ */
+ public void performRevert() {
+ fBlock.performRevert();
+ }
+
+ /*
+ * @see org.eclipse.ui.texteditor.spelling.ISpellingPreferenceBlock#dispose()
+ */
+ public void dispose() {
+ fBlock.dispose();
+ }
+
+ /*
+ * @see org.eclipse.ui.texteditor.spelling.ISpellingPreferenceBlock#setEnabled(boolean)
+ */
+ public void setEnabled(boolean enabled) {
+ fBlock.setEnabled(enabled);
+ }
+}
Property changes on: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/preferences/SpellingPreferenceBlock.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/rubyeditor/IRubyAnnotation.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/rubyeditor/IRubyAnnotation.java 2007-09-07 19:44:59 UTC (rev 3112)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/rubyeditor/IRubyAnnotation.java 2007-09-07 19:46:20 UTC (rev 3113)
@@ -112,5 +112,13 @@
* <code>null<code> if no marker type can be evaluated.
*/
String getMarkerType();
+
+ /**
+ * Returns the problem arguments or <code>null</code> if no problem arguments can be evaluated.
+ *
+ * @return returns the problem arguments or <code>null</code> if no problem
+ * arguments can be evaluated.
+ */
+ String[] getArguments();
}
Modified: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/rubyeditor/RubyDocumentProvider.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/rubyeditor/RubyDocumentProvider.java 2007-09-07 19:44:59 UTC (rev 3112)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/rubyeditor/RubyDocumentProvider.java 2007-09-07 19:46:20 UTC (rev 3113)
@@ -582,6 +582,13 @@
public String getText() {
return fProblem.getMessage();
}
+
+ /*
+ * @see IRubyAnnotation#getArguments()
+ */
+ public String[] getArguments() {
+ return isProblem() ? fProblem.getArguments() : null;
+ }
/*
* @see IRubyAnnotation#isProblem()
Added: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/CompositeReconcilingStrategy.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/CompositeReconcilingStrategy.java (rev 0)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/CompositeReconcilingStrategy.java 2007-09-07 19:46:20 UTC (rev 3113)
@@ -0,0 +1,118 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2005 IBM Corporation 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:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.rubypeople.rdt.internal.ui.text;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.IRegion;
+import org.eclipse.jface.text.reconciler.DirtyRegion;
+import org.eclipse.jface.text.reconciler.IReconcilingStrategy;
+import org.eclipse.jface.text.reconciler.IReconcilingStrategyExtension;
+
+/**
+ * A reconciling strategy consisting of a sequence of internal reconciling strategies.
+ * By default, all requests are passed on to the contained strategies.
+ *
+ * @since 3.0
+ */
+public class CompositeReconcilingStrategy implements IReconcilingStrategy, IReconcilingStrategyExtension {
+
+ /** The list of internal reconciling strategies. */
+ private IReconcilingStrategy[] fStrategies;
+
+ /**
+ * Creates a new, empty composite reconciling strategy.
+ */
+ public CompositeReconcilingStrategy() {
+ }
+
+ /**
+ * Sets the reconciling strategies for this composite strategy.
+ *
+ * @param strategies the strategies to be set or <code>null</code>
+ */
+ public void setReconcilingStrategies(IReconcilingStrategy[] strategies) {
+ fStrategies= strategies;
+ }
+
+ /**
+ * Returns the previously set stratgies or <code>null</code>.
+ *
+ * @return the contained strategies or <code>null</code>
+ */
+ public IReconcilingStrategy[] getReconcilingStrategies() {
+ return fStrategies;
+ }
+
+ /*
+ * @see org.eclipse.jface.text.reconciler.IReconcilingStrategy#setDocument(org.eclipse.jface.text.IDocument)
+ */
+ public void setDocument(IDocument document) {
+ if (fStrategies == null)
+ return;
+
+ for (int i= 0; i < fStrategies.length; i++)
+ fStrategies[i].setDocument(document);
+ }
+
+ /*
+ * @see org.eclipse.jface.text.reconciler.IReconcilingStrategy#reconcile(org.eclipse.jface.text.reconciler.DirtyRegion, org.eclipse.jface.text.IRegion)
+ */
+ public void reconcile(DirtyRegion dirtyRegion, IRegion subRegion) {
+ if (fStrategies == null)
+ return;
+
+ for (int i= 0; i < fStrategies.length; i++)
+ fStrategies[i].reconcile(dirtyRegion, subRegion);
+ }
+
+ /*
+ * @see org.eclipse.jface.text.reconciler.IReconcilingStrategy#reconcile(org.eclipse.jface.text.IRegion)
+ */
+ public void reconcile(IRegion partition) {
+ if (fStrategies == null)
+ return;
+
+ for (int i= 0; i < fStrategies.length; i++)
+ fStrategies[i].reconcile(partition);
+ }
+
+ /*
+ * @see org.eclipse.jface.text.reconciler.IReconcilingStrategyExtension#setProgressMonitor(org.eclipse.core.runtime.IProgressMonitor)
+ */
+ public void setProgressMonitor(IProgressMonitor monitor) {
+ if (fStrategies == null)
+ return;
+
+ for (int i=0; i < fStrategies.length; i++) {
+ if (fStrategies[i] instanceof IReconcilingStrategyExtension) {
+ IReconcilingStrategyExtension extension= (IReconcilingStrategyExtension) fStrategies[i];
+ extension.setProgressMonitor(monitor);
+ }
+ }
+ }
+
+ /*
+ * @see org.eclipse.jface.text.reconciler.IReconcilingStrategyExtension#initialReconcile()
+ */
+ public void initialReconcile() {
+ if (fStrategies == null)
+ return;
+
+ for (int i=0; i < fStrategies.length; i++) {
+ if (fStrategies[i] instanceof IReconcilingStrategyExtension) {
+ IReconcilingStrategyExtension extension= (IReconcilingStrategyExtension) fStrategies[i];
+ extension.initialReconcile();
+ }
+ }
+ }
+}
Property changes on: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/CompositeReconcilingStrategy.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/RubyCompositeReconcilingStrategy.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/RubyCompositeReconcilingStrategy.java (rev 0)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/RubyCompositeReconcilingStrategy.java 2007-09-07 19:46:20 UTC (rev 3113)
@@ -0,0 +1,135 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2005 IBM Corporation 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:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.rubypeople.rdt.internal.ui.text;
+
+import org.eclipse.jface.text.IRegion;
+import org.eclipse.jface.text.reconciler.DirtyRegion;
+import org.eclipse.jface.text.reconciler.IReconcilingStrategy;
+import org.eclipse.jface.text.source.IAnnotationModel;
+import org.eclipse.ui.texteditor.IDocumentProvider;
+import org.eclipse.ui.texteditor.ITextEditor;
+import org.rubypeople.rdt.internal.ui.RubyPlugin;
+import org.rubypeople.rdt.internal.ui.text.ruby.IProblemRequestorExtension;
+import org.rubypeople.rdt.internal.ui.text.ruby.RubyReconcilingStrategy;
+import org.rubypeople.rdt.internal.ui.text.spelling.RubySpellingReconcileStrategy;
+
+/**
+ * Reconciling strategy for Ruby code. This is a composite strategy containing the
+ * regular java model reconciler and the comment spelling strategy.
+ *
+ * @since 3.0
+ */
+public class RubyCompositeReconcilingStrategy extends CompositeReconcilingStrategy {
+
+ private ITextEditor fEditor;
+ private RubyReconcilingStrategy fRubyStrategy;
+
+ /**
+ * Creates a new Ruby reconciling strategy.
+ *
+ * @param editor the editor of the strategy's reconciler
+ * @param documentPartitioning the document partitioning this strategy uses for configuration
+ */
+ public RubyCompositeReconcilingStrategy(ITextEditor editor, String documentPartitioning) {
+ fEditor= editor;
+ fRubyStrategy= new RubyReconcilingStrategy(editor);
+ setReconcilingStrategies(new IReconcilingStrategy[] {
+ fRubyStrategy,
+ new RubySpellingReconcileStrategy(editor)
+ });
+ }
+
+ /**
+ * Returns the problem requestor for the editor's input element.
+ *
+ * @return the problem requestor for the editor's input element
+ */
+ private IProblemRequestorExtension getProblemRequestorExtension() {
+ IDocumentProvider p= fEditor.getDocumentProvider();
+ if (p == null) {
+ // work around for https://bugs.eclipse.org/bugs/show_bug.cgi?id=51522
+ p= RubyPlugin.getDefault().getRubyDocumentProvider();
+ }
+ IAnnotationModel m= p.getAnnotationModel(fEditor.getEditorInput());
+ if (m instanceof IProblemRequestorExtension)
+ return (IProblemRequestorExtension) m;
+ return null;
+ }
+
+ /*
+ * @see org.eclipse.jface.text.reconciler.CompositeReconcilingStrategy#reconcile(org.eclipse.jface.text.reconciler.DirtyRegion, org.eclipse.jface.text.IRegion)
+ */
+ public void reconcile(DirtyRegion dirtyRegion, IRegion subRegion) {
+ IProblemRequestorExtension e= getProblemRequestorExtension();
+ if (e != null) {
+ try {
+ e.beginReportingSequence();
+ super.reconcile(dirtyRegion, subRegion);
+ } finally {
+ e.endReportingSequence();
+ }
+ } else {
+ super.reconcile(dirtyRegion, subRegion);
+ }
+ }
+
+ /*
+ * @see org.eclipse.jface.text.reconciler.CompositeReconcilingStrategy#reconcile(org.eclipse.jface.text.IRegion)
+ */
+ public void reconcile(IRegion partition) {
+ IProblemRequestorExtension e= getProblemRequestorExtension();
+ if (e != null) {
+ try {
+ e.beginReportingSequence();
+ super.reconcile(partition);
+ } finally {
+ e.endReportingSequence();
+ }
+ } else {
+ super.reconcile(partition);
+ }
+ }
+
+ /**
+ * Tells this strategy whether to inform its listeners.
+ *
+ * @param notify <code>true</code> if listeners should be notified
+ */
+ public void notifyListeners(boolean notify) {
+ fRubyStrategy.notifyListeners(notify);
+ }
+
+ /*
+ * @see org.eclipse.jface.text.reconciler.CompositeReconcilingStrategy#initialReconcile()
+ */
+ public void initialReconcile() {
+ IProblemRequestorExtension e= getProblemRequestorExtension();
+ if (e != null) {
+ try {
+ e.beginReportingSequence();
+ super.initialReconcile();
+ } finally {
+ e.endReportingSequence();
+ }
+ } else {
+ super.initialReconcile();
+ }
+ }
+
+ /**
+ * Called before reconciling is started.
+ *
+ * @since 3.0
+ */
+ public void aboutToBeReconciled() {
+ fRubyStrategy.aboutToBeReconciled();
+ }
+}
Property changes on: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/RubyCompositeReconcilingStrategy.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/RubyReconciler.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/RubyReconciler.java 2007-09-07 19:44:59 UTC (rev 3112)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/RubyReconciler.java 2007-09-07 19:46:20 UTC (rev 3113)
@@ -10,9 +10,9 @@
import org.eclipse.core.resources.IResourceChangeListener;
import org.eclipse.core.resources.IResourceDelta;
import org.eclipse.core.resources.IWorkspace;
+import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.ITextViewer;
import org.eclipse.jface.text.reconciler.DirtyRegion;
-import org.eclipse.jface.text.reconciler.IReconcilingStrategy;
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IFileEditorInput;
import org.eclipse.ui.texteditor.ITextEditor;
@@ -73,7 +73,7 @@
* @param strategy
* @param isIncremental
*/
- public RubyReconciler(ITextEditor editor, IReconcilingStrategy strategy, boolean isIncremental) {
+ public RubyReconciler(ITextEditor editor, RubyCompositeReconcilingStrategy strategy, boolean isIncremental) {
super(strategy, isIncremental);
this.fTextEditor = editor;
@@ -114,6 +114,8 @@
if (!fIninitalProcessDone) return;
super.forceReconciling();
+ RubyCompositeReconcilingStrategy strategy= (RubyCompositeReconcilingStrategy) getReconcilingStrategy(IDocument.DEFAULT_CONTENT_TYPE);
+ strategy.notifyListeners(false);
}
/*
@@ -127,5 +129,18 @@
}
fIninitalProcessDone = true;
}
+
+ @Override
+ protected void reconcilerReset() {
+ super.reconcilerReset();
+ RubyCompositeReconcilingStrategy strategy= (RubyCompositeReconcilingStrategy) getReconcilingStrategy(IDocument.DEFAULT_CONTENT_TYPE);
+ strategy.notifyListeners(true);
+ }
+
+ @Override
+ protected void aboutToBeReconciled() {
+ RubyCompositeReconcilingStrategy strategy= (RubyCompositeReconcilingStrategy) getReconcilingStrategy(IDocument.DEFAULT_CONTENT_TYPE);
+ strategy.aboutToBeReconciled();
+ }
}
Modified: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/correction/ProblemLocation.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/correction/ProblemLocation.java 2007-09-07 19:44:59 UTC (rev 3112)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/correction/ProblemLocation.java 2007-09-07 19:46:20 UTC (rev 3113)
@@ -26,7 +26,7 @@
public class ProblemLocation implements IProblemLocation {
private final int fId;
-// private final String[] fArguments;
+ private final String[] fArguments;
private final int fOffset;
private final int fLength;
private final boolean fIsError;
@@ -34,7 +34,7 @@
public ProblemLocation(int offset, int length, IRubyAnnotation annotation) {
fId= annotation.getId();
-// fArguments= annotation.getArguments();
+ fArguments= annotation.getArguments();
fOffset= offset;
fLength= length;
fIsError= RubyMarkerAnnotation.ERROR_ANNOTATION_TYPE.equals(annotation.getType());
@@ -45,7 +45,7 @@
public ProblemLocation(int offset, int length, int id, String[] arguments, boolean isError, String markerType) {
fId= id;
-// fArguments= arguments;
+ fArguments= arguments;
fOffset= offset;
fLength= length;
fIsError= isError;
@@ -54,7 +54,7 @@
public ProblemLocation(IProblem problem) {
fId= problem.getID();
-// fArguments= problem.getArguments();
+ fArguments= problem.getArguments();
fOffset= problem.getSourceStart();
fLength= problem.getSourceEnd() - fOffset + 1;
fIsError= problem.isError();
@@ -73,8 +73,7 @@
* @see org.eclipse.jdt.internal.ui.text.correction.IProblemLocation#getProblemArguments()
*/
public String[] getProblemArguments() {
-// return fArguments;
- return new String[0];
+ return fArguments;
}
/* (non-Javadoc)
Added: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/spelling/AddWordProposal.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/spelling/AddWordProposal.java (rev 0)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/spelling/AddWordProposal.java 2007-09-07 19:46:20 UTC (rev 3113)
@@ -0,0 +1,108 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2006 IBM Corporation 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:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+
+package org.rubypeople.rdt.internal.ui.text.spelling;
+
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.contentassist.IContextInformation;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.Point;
+import org.rubypeople.rdt.internal.corext.util.Messages;
+import org.rubypeople.rdt.internal.ui.RubyPluginImages;
+import org.rubypeople.rdt.internal.ui.RubyUIMessages;
+import org.rubypeople.rdt.internal.ui.text.spelling.engine.ISpellCheckEngine;
+import org.rubypeople.rdt.internal.ui.text.spelling.engine.ISpellChecker;
+import org.rubypeople.rdt.ui.PreferenceConstants;
+import org.rubypeople.rdt.ui.text.ruby.IInvocationContext;
+import org.rubypeople.rdt.ui.text.ruby.IRubyCompletionProposal;
+
+/**
+ * Proposal to add the unknown word to the dictionaries.
+ *
+ * @since 3.0
+ */
+public class AddWordProposal implements IRubyCompletionProposal {
+
+ /** The invocation context */
+ private final IInvocationContext fContext;
+
+ /** The word to add */
+ private final String fWord;
+
+ /**
+ * Creates a new add word proposal
+ *
+ * @param word
+ * The word to add
+ * @param context
+ * The invocation context
+ */
+ public AddWordProposal(final String word, final IInvocationContext context) {
+ fContext= context;
+ fWord= word;
+ }
+
+ /*
+ * @see org.eclipse.jface.text.contentassist.ICompletionProposal#apply(org.eclipse.jface.text.IDocument)
+ */
+ public final void apply(final IDocument document) {
+
+ final ISpellCheckEngine engine= SpellCheckEngine.getInstance();
+ final ISpellChecker checker= engine.createSpellChecker(engine.getLocale(), PreferenceConstants.getPreferenceStore());
+
+ if (checker != null) {
+ checker.addWord(fWord);
+ RubySpellingProblem.removeAllInActiveEditor(fWord);
+ }
+ }
+
+ /*
+ * @see org.eclipse.jface.text.contentassist.ICompletionProposal#getAdditionalProposalInfo()
+ */
+ public String getAdditionalProposalInfo() {
+ return Messages.format(RubyUIMessages.Spelling_add_info, new String[] { WordCorrectionProposal.getHtmlRepresentation(fWord)});
+ }
+
+ /*
+ * @see org.eclipse.jface.text.contentassist.ICompletionProposal#getContextInformation()
+ */
+ public final IContextInformation getContextInformation() {
+ return null;
+ }
+
+ /*
+ * @see org.eclipse.jface.text.contentassist.ICompletionProposal#getDisplayString()
+ */
+ public String getDisplayString() {
+ return Messages.format(RubyUIMessages.Spelling_add_label, new String[] { fWord });
+ }
+
+ /*
+ * @see org.eclipse.jface.text.contentassist.ICompletionProposal#getImage()
+ */
+ public Image getImage() {
+ return RubyPluginImages.get(RubyPluginImages.IMG_CORRECTION_ADD);
+ }
+
+ /*
+ * @see org.eclipse.jdt.ui.text.java.IRubyCompletionProposal#getRelevance()
+ */
+ public int getRelevance() {
+ return Integer.MIN_VALUE;
+ }
+
+ /*
+ * @see org.eclipse.jface.text.contentassist.ICompletionProposal#getSelection(org.eclipse.jface.text.IDocument)
+ */
+ public final Point getSelection(final IDocument document) {
+ return new Point(fContext.getSelectionOffset(), fContext.getSelectionLength());
+ }
+}
Property changes on: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/spelling/AddWordProposal.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/spelling/ChangeCaseProposal.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/spelling/...
[truncated message content] |
|
From: <caw...@us...> - 2007-09-07 19:45:01
|
Revision: 3112
http://rubyeclipse.svn.sourceforge.net/rubyeclipse/?rev=3112&view=rev
Author: cawilliams
Date: 2007-09-07 12:44:59 -0700 (Fri, 07 Sep 2007)
Log Message:
-----------
add arguments to problems
Modified Paths:
--------------
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/compiler/CategorizedProblem.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/compiler/IProblem.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/parser/DefaultProblem.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/parser/Error.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/parser/TaskTag.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/parser/Warning.java
Modified: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/compiler/CategorizedProblem.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/compiler/CategorizedProblem.java 2007-09-07 16:59:03 UTC (rev 3111)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/compiler/CategorizedProblem.java 2007-09-07 19:44:59 UTC (rev 3112)
@@ -140,4 +140,16 @@
public Object[] getExtraMarkerAttributeValues() {
return new Object[] {};
}
+
+public boolean isTask() {
+ return false;
}
+
+public boolean isError() {
+ return false;
+}
+
+public boolean isWarning() {
+ return false;
+}
+}
Modified: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/compiler/IProblem.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/compiler/IProblem.java 2007-09-07 16:59:03 UTC (rev 3111)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/compiler/IProblem.java 2007-09-07 19:44:59 UTC (rev 3112)
@@ -74,6 +74,12 @@
* @return the problem id
*/
int getID();
+
+ /**
+ * Answer back the original arguments recorded into the problem.
+ * @return the original arguments recorded into the problem
+ */
+ String[] getArguments();
/**
* Answer a localized, human-readable message string which describes the
Modified: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/parser/DefaultProblem.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/parser/DefaultProblem.java 2007-09-07 16:59:03 UTC (rev 3111)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/parser/DefaultProblem.java 2007-09-07 19:44:59 UTC (rev 3112)
@@ -65,4 +65,8 @@
public String getMarkerType() {
return isTask() ? MARKER_TYPE_TASK : MARKER_TYPE_PROBLEM;
}
+
+ public String[] getArguments() {
+ return null;
+ }
}
Modified: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/parser/Error.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/parser/Error.java 2007-09-07 16:59:03 UTC (rev 3111)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/parser/Error.java 2007-09-07 19:44:59 UTC (rev 3112)
@@ -23,13 +23,4 @@
public boolean isError() {
return true;
}
-
- public boolean isWarning() {
- return false;
- }
-
- public boolean isTask() {
- return false;
- }
-
}
Modified: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/parser/TaskTag.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/parser/TaskTag.java 2007-09-07 16:59:03 UTC (rev 3111)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/parser/TaskTag.java 2007-09-07 19:44:59 UTC (rev 3112)
@@ -22,14 +22,6 @@
return priority;
}
- public boolean isError() {
- return false;
- }
-
- public boolean isWarning() {
- return false;
- }
-
public boolean isTask() {
return true;
}
Modified: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/parser/Warning.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/parser/Warning.java 2007-09-07 16:59:03 UTC (rev 3111)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/parser/Warning.java 2007-09-07 19:44:59 UTC (rev 3112)
@@ -23,12 +23,4 @@
public boolean isWarning() {
return true;
}
-
- public boolean isError() {
- return false;
- }
-
- public boolean isTask() {
- return false;
- }
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2007-09-07 16:59:05
|
Revision: 3111
http://rubyeclipse.svn.sourceforge.net/rubyeclipse/?rev=3111&view=rev
Author: cawilliams
Date: 2007-09-07 09:59:03 -0700 (Fri, 07 Sep 2007)
Log Message:
-----------
make us able to open files inside external libraries (sort of).
Modified Paths:
--------------
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/rubyeditor/EditorUtility.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/rubyeditor/ExternalRubyFileEditorInput.java
Modified: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/rubyeditor/EditorUtility.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/rubyeditor/EditorUtility.java 2007-09-07 16:29:04 UTC (rev 3110)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/rubyeditor/EditorUtility.java 2007-09-07 16:59:03 UTC (rev 3111)
@@ -34,6 +34,7 @@
import org.rubypeople.rdt.core.IRubyScript;
import org.rubypeople.rdt.core.ISourceRange;
import org.rubypeople.rdt.core.ISourceReference;
+import org.rubypeople.rdt.core.LocalFileStorage;
import org.rubypeople.rdt.core.RubyCore;
import org.rubypeople.rdt.core.RubyModelException;
import org.rubypeople.rdt.internal.core.ExternalRubyScript;
@@ -46,7 +47,7 @@
public class EditorUtility {
/**
- * Opens a Ruby editor for an element (IJavaElement, IFile, IStorage...)
+ * Opens a Ruby editor for an element (IRubyElement, IFile, IStorage...)
* @return the IEditorPart or null if wrong element type or opening failed
*/
public static IEditorPart openInEditor(Object inputElement, boolean activate) throws RubyModelException, PartInitException {
@@ -134,6 +135,10 @@
if (input instanceof IFile)
return new FileEditorInput((IFile) input);
+
+ if (input instanceof LocalFileStorage) {
+ return new ExternalRubyFileEditorInput((LocalFileStorage)input);
+ }
return null;
}
Modified: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/rubyeditor/ExternalRubyFileEditorInput.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/rubyeditor/ExternalRubyFileEditorInput.java 2007-09-07 16:29:04 UTC (rev 3110)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/rubyeditor/ExternalRubyFileEditorInput.java 2007-09-07 16:59:03 UTC (rev 3111)
@@ -23,6 +23,10 @@
public ExternalRubyFileEditorInput(File file) {
storage = new LocalFileStorage(file);
}
+
+ public ExternalRubyFileEditorInput(LocalFileStorage file) {
+ storage = file;
+ }
public boolean exists() {
return storage.getFile().exists();
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2007-09-07 16:29:07
|
Revision: 3110
http://rubyeclipse.svn.sourceforge.net/rubyeclipse/?rev=3110&view=rev
Author: cawilliams
Date: 2007-09-07 09:29:04 -0700 (Fri, 07 Sep 2007)
Log Message:
-----------
include non ruby resources inside external source folders. Wrap them in LocalFileStorage class. Use that class in UI, instead of SystemFileStorage (since it's the same implemntation).
Modified Paths:
--------------
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/ExternalSourceFolder.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/ExternalSourceFolderRoot.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/util/Util.java
Added Paths:
-----------
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/LocalFileStorage.java
Added: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/LocalFileStorage.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/LocalFileStorage.java (rev 0)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/LocalFileStorage.java 2007-09-07 16:29:04 UTC (rev 3110)
@@ -0,0 +1,120 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2005 IBM Corporation 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:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.rubypeople.rdt.core;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+
+import org.eclipse.core.resources.IStorage;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.PlatformObject;
+import org.eclipse.core.runtime.Status;
+
+/**
+ * Implementation of storage for a local file
+ * (<code>java.io.File</code>).
+ * <p>
+ * This class may be instantiated; it is not intended to be subclassed.
+ * </p>
+ * @see IStorage
+ * @since 3.0
+ */
+public class LocalFileStorage extends PlatformObject implements IStorage {
+
+ /**
+ * The file this storage refers to.
+ */
+ private File fFile;
+
+ /**
+ * Constructs and returns storage for the given file.
+ *
+ * @param file a local file
+ */
+ public LocalFileStorage(File file){
+ setFile(file);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.core.resources.IStorage#getContents()
+ */
+ public InputStream getContents() throws CoreException {
+ try {
+ return new FileInputStream(getFile());
+ } catch (IOException e){
+ throw new CoreException(new Status(IStatus.ERROR, RubyCore.PLUGIN_ID, -1, "IO Exception opening file", e));
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.core.resources.IStorage#getFullPath()
+ */
+ public IPath getFullPath() {
+ try {
+ return new Path(getFile().getCanonicalPath());
+ } catch (IOException e) {
+ RubyCore.log(e);
+ return null;
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.core.resources.IStorage#getName()
+ */
+ public String getName() {
+ return getFile().getName();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.core.resources.IStorage#isReadOnly()
+ */
+ public boolean isReadOnly() {
+ return true;
+ }
+
+ /**
+ * Sets the file associated with this storage
+ *
+ * @param file a local file
+ */
+ private void setFile(File file) {
+ fFile = file;
+ }
+
+ /**
+ * Returns the file associated with this storage
+ *
+ * @return file
+ */
+ public File getFile() {
+ return fFile;
+ }
+
+ /* (non-Javadoc)
+ * @see java.lang.Object#equals(java.lang.Object)
+ */
+ public boolean equals(Object object) {
+ return object instanceof LocalFileStorage &&
+ getFile().equals(((LocalFileStorage)object).getFile());
+ }
+
+ /* (non-Javadoc)
+ * @see java.lang.Object#hashCode()
+ */
+ public int hashCode() {
+ return getFile().hashCode();
+ }
+}
Property changes on: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/LocalFileStorage.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/ExternalSourceFolder.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/ExternalSourceFolder.java 2007-09-07 16:28:56 UTC (rev 3109)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/ExternalSourceFolder.java 2007-09-07 16:29:04 UTC (rev 3110)
@@ -3,10 +3,12 @@
import java.io.File;
import java.util.ArrayList;
import java.util.HashMap;
+import java.util.List;
import org.eclipse.core.runtime.IProgressMonitor;
import org.rubypeople.rdt.core.IRubyElement;
import org.rubypeople.rdt.core.IRubyScript;
+import org.rubypeople.rdt.core.LocalFileStorage;
import org.rubypeople.rdt.core.RubyModelException;
import org.rubypeople.rdt.core.WorkingCopyOwner;
import org.rubypeople.rdt.internal.core.util.MementoTokenizer;
@@ -42,6 +44,7 @@
ArrayList<IRubyElement> vChildren = new ArrayList<IRubyElement>();
File file = getPath().toFile();
File[] members = file.listFiles();
+ List<LocalFileStorage> files = new ArrayList<LocalFileStorage>();
for (int i = 0, max = members.length; i < max; i++) {
File child = members[i];
if (!child.isDirectory()) {
@@ -49,9 +52,15 @@
if (Util.isValidRubyScriptName(child.getName())) {
childElement = new ExternalRubyScript(this, child.getName(), DefaultWorkingCopyOwner.PRIMARY);
vChildren.add(childElement);
+ } else {
+ files.add(new LocalFileStorage(child));
}
}
}
+ if (info instanceof SourceFolderInfo) {
+ SourceFolderInfo duh = (SourceFolderInfo) info;
+ duh.setNonRubyResources(files.toArray(new Object[files.size()]));
+ }
IRubyElement[] children= new IRubyElement[vChildren.size()];
vChildren.toArray(children);
info.setChildren(children);
@@ -78,4 +87,17 @@
}
return null;
}
+
+ /**
+ * Returns an array of non-ruby resources contained in the receiver.
+ */
+ public Object[] getNonRubyResources() throws RubyModelException {
+ if (this.isDefaultPackage()) {
+ // We don't want to show non ruby resources of the default package (see PR #1G58NB8)
+ return RubyElementInfo.NO_NON_RUBY_RESOURCES;
+ } else {
+ return this.storedNonRubyResources();
+ }
+ }
+
}
Modified: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/ExternalSourceFolderRoot.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/ExternalSourceFolderRoot.java 2007-09-07 16:28:56 UTC (rev 3109)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/ExternalSourceFolderRoot.java 2007-09-07 16:29:04 UTC (rev 3110)
@@ -2,6 +2,7 @@
import java.io.File;
import java.util.ArrayList;
+import java.util.List;
import java.util.Map;
import org.eclipse.core.resources.IResource;
@@ -78,8 +79,7 @@
try {
RubyModelManager manager = RubyModelManager.getRubyModelManager();
- File[] members = folder.listFiles();
-
+ File[] members = folder.listFiles();
for (int i = 0, max = members.length; i < max; i++) {
File member = members[i];
String memberName = member.getName();
Modified: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/util/Util.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/util/Util.java 2007-09-07 16:28:56 UTC (rev 3109)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/util/Util.java 2007-09-07 16:29:04 UTC (rev 3110)
@@ -1074,4 +1074,55 @@
quickSortReverse(sortedCollection, left, original_right);
}
}
+
+ /**
+ * Returns the concatenation of the given array parts using the given separator between each
+ * part and appending the given name at the end.
+ * <br>
+ * <br>
+ * For example:<br>
+ * <ol>
+ * <li><pre>
+ * name = "c"
+ * array = { "a", "b" }
+ * separator = '.'
+ * => result = "a.b.c"
+ * </pre>
+ * </li>
+ * <li><pre>
+ * name = null
+ * array = { "a", "b" }
+ * separator = '.'
+ * => result = "a.b"
+ * </pre></li>
+ * <li><pre>
+ * name = " c"
+ * array = null
+ * separator = '.'
+ * => result = "c"
+ * </pre></li>
+ * </ol>
+ *
+ * @param array the given array
+ * @param name the given name
+ * @param separator the given separator
+ * @return the concatenation of the given array parts using the given separator between each
+ * part and appending the given name at the end
+ */
+ public static final String concatWith(
+ String[] array,
+ String name,
+ char separator) {
+
+ if (array == null || array.length == 0) return name;
+ if (name == null || name.length() == 0) return concatWith(array, separator);
+ StringBuffer buffer = new StringBuffer();
+ for (int i = 0, length = array.length; i < length; i++) {
+ buffer.append(array[i]);
+ buffer.append(separator);
+ }
+ buffer.append(name);
+ return buffer.toString();
+
+ }
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2007-09-07 16:28:58
|
Revision: 3109
http://rubyeclipse.svn.sourceforge.net/rubyeclipse/?rev=3109&view=rev
Author: cawilliams
Date: 2007-09-07 09:28:56 -0700 (Fri, 07 Sep 2007)
Log Message:
-----------
include non ruby resources inside external source folders. Wrap them in LocalFileStorage class. Use that class in UI, instead of SystemFileStorage (since it's the same implemntation).
Modified Paths:
--------------
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/rubyeditor/ExternalRubyFileEditorInput.java
Removed Paths:
-------------
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/rubyeditor/SystemFileStorage.java
Modified: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/rubyeditor/ExternalRubyFileEditorInput.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/rubyeditor/ExternalRubyFileEditorInput.java 2007-09-07 15:36:30 UTC (rev 3108)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/rubyeditor/ExternalRubyFileEditorInput.java 2007-09-07 16:28:56 UTC (rev 3109)
@@ -11,16 +11,17 @@
import org.eclipse.ui.IPersistableElement;
import org.eclipse.ui.IStorageEditorInput;
import org.eclipse.ui.editors.text.ILocationProvider;
+import org.rubypeople.rdt.core.LocalFileStorage;
/**
* @since 3.0
*/
public class ExternalRubyFileEditorInput implements IStorageEditorInput, ILocationProvider, IPersistableElement {
- private SystemFileStorage storage;
+ private LocalFileStorage storage;
public ExternalRubyFileEditorInput(File file) {
- storage = new SystemFileStorage(file);
+ storage = new LocalFileStorage(file);
}
public boolean exists() {
Deleted: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/rubyeditor/SystemFileStorage.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/rubyeditor/SystemFileStorage.java 2007-09-07 15:36:30 UTC (rev 3108)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/rubyeditor/SystemFileStorage.java 2007-09-07 16:28:56 UTC (rev 3109)
@@ -1,58 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.rubypeople.rdt.internal.ui.rubyeditor;
-
-import java.io.*;
-import org.eclipse.core.runtime.*;
-import org.eclipse.core.resources.*;
-import org.rubypeople.rdt.internal.ui.RubyPlugin;
-
-
-public class SystemFileStorage extends PlatformObject implements IStorage {
- private File file;
- /**
- * Constructor for SystemFileStorage.
- */
- public SystemFileStorage(File file) {
- this.file = file;
- }
-
- public File getFile() {
- return file;
- }
- public InputStream getContents() throws CoreException {
- try {
- return new FileInputStream(file);
- } catch (FileNotFoundException e) {
- IStatus status =
- new Status(IStatus.ERROR, RubyPlugin.PLUGIN_ID, IStatus.OK, null, e);
- throw new CoreException(status);
- }
- }
- public IPath getFullPath() {
- return new Path(file.getAbsolutePath());
- }
- public String getName() {
- return file.getName();
- }
- public boolean isReadOnly() {
- return true;
- }
-
- public boolean equals(Object object) {
- return object instanceof SystemFileStorage
- && getFile().equals(((SystemFileStorage) object).getFile());
- }
-
- public int hashCode() {
- return getFile().hashCode();
- }
-}
\ No newline at end of file
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2007-09-07 15:36:34
|
Revision: 3108
http://rubyeclipse.svn.sourceforge.net/rubyeclipse/?rev=3108&view=rev
Author: cawilliams
Date: 2007-09-07 08:36:30 -0700 (Fri, 07 Sep 2007)
Log Message:
-----------
remove duplicated IDs
Modified Paths:
--------------
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/RdtPerspectiveFactory.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/RubyUI.java
Removed Paths:
-------------
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/actions/IRubyActionSetIds.java
Modified: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/RdtPerspectiveFactory.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/RdtPerspectiveFactory.java 2007-09-07 15:23:35 UTC (rev 3107)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/RdtPerspectiveFactory.java 2007-09-07 15:36:30 UTC (rev 3108)
@@ -7,7 +7,7 @@
import org.eclipse.ui.console.IConsoleConstants;
import org.eclipse.ui.progress.IProgressConstants;
import org.rubypeople.rdt.ui.IRubyConstants;
-import org.rubypeople.rdt.ui.actions.IRubyActionSetIds;
+import org.rubypeople.rdt.ui.RubyUI;
public class RdtPerspectiveFactory implements IPerspectiveFactory {
@@ -33,8 +33,8 @@
bottomLeft.addView(IPageLayout.ID_OUTLINE);
layout.addActionSet(IDebugUIConstants.LAUNCH_ACTION_SET);
- layout.addActionSet(IRubyActionSetIds.RUBY_ACTION_SET_ID);
- layout.addActionSet(IRubyActionSetIds.ID_ELEMENT_CREATION_ACTION_SET);
+ layout.addActionSet(RubyUI.ID_ACTION_SET);
+ layout.addActionSet(RubyUI.ID_ELEMENT_CREATION_ACTION_SET);
layout.addActionSet(IPageLayout.ID_NAVIGATE_ACTION_SET);
// views - debugging
@@ -46,7 +46,7 @@
layout.addShowViewShortcut(IPageLayout.ID_RES_NAV);
// new actions - Ruby project creation wizard
- layout.addNewWizardShortcut("org.rubypeople.rdt.ui.wizards.RubyNewClassWizard"); //$NON-NLS-1$
+ layout.addNewWizardShortcut(IRubyConstants.ID_NEW_CLASS_WIZARD);
layout.addNewWizardShortcut("org.eclipse.ui.wizards.new.folder");//$NON-NLS-1$
layout.addNewWizardShortcut("org.eclipse.ui.wizards.new.file");//$NON-NLS-1$
layout.addNewWizardShortcut("org.eclipse.ui.editors.wizards.UntitledTextFileWizard");//$NON-NLS-1$
Modified: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/RubyUI.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/RubyUI.java 2007-09-07 15:23:35 UTC (rev 3107)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/RubyUI.java 2007-09-07 15:36:30 UTC (rev 3108)
@@ -56,9 +56,9 @@
/**
* The id of the Ruby action set
- * (value <code>"org.rubypeople.rdt.ui.RubyActionSet"</code>).
+ * (value <code>"org.rubypeople.rdt.ui.rubyActionSet"</code>).
*/
- public static final String ID_ACTION_SET = "org.rubypeople.rdt.ui.RubyActionSet"; //$NON-NLS-1$
+ public static final String ID_ACTION_SET = "org.rubypeople.rdt.ui.rubyActionSet"; //$NON-NLS-1$
/**
* The editor part id of the editor that presents Ruby compilation units
Deleted: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/actions/IRubyActionSetIds.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/actions/IRubyActionSetIds.java 2007-09-07 15:23:35 UTC (rev 3107)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/actions/IRubyActionSetIds.java 2007-09-07 15:36:30 UTC (rev 3108)
@@ -1,9 +0,0 @@
-package org.rubypeople.rdt.ui.actions;
-
-public interface IRubyActionSetIds {
- /**
- * (value <code>"org.rubypeople.rdt.ui.rubyActionSet"</code>).
- */
- public static final String RUBY_ACTION_SET_ID = "org.rubypeople.rdt.ui.rubyActionSet";
- public static final String ID_ELEMENT_CREATION_ACTION_SET = "org.rubypeople.rdt.ui.RubyElementCreationActionSet";
-}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2007-09-07 15:23:37
|
Revision: 3107
http://rubyeclipse.svn.sourceforge.net/rubyeclipse/?rev=3107&view=rev
Author: cawilliams
Date: 2007-09-07 08:23:35 -0700 (Fri, 07 Sep 2007)
Log Message:
-----------
add missing icons
Modified Paths:
--------------
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/wizards/buildpaths/newsourcepage/RemoveFromBuildpathAction.java
Added Paths:
-----------
trunk/org.rubypeople.rdt.ui/icons/full/dlcl16/add_linked_source_to_buildpath.gif
trunk/org.rubypeople.rdt.ui/icons/full/dlcl16/configure_build_path.gif
trunk/org.rubypeople.rdt.ui/icons/full/dlcl16/configure_buildpath_filters.gif
trunk/org.rubypeople.rdt.ui/icons/full/elcl16/add_linked_source_to_buildpath.gif
trunk/org.rubypeople.rdt.ui/icons/full/elcl16/configure_build_path.gif
trunk/org.rubypeople.rdt.ui/icons/full/elcl16/configure_buildpath_filters.gif
trunk/org.rubypeople.rdt.ui/icons/full/elcl16/remove_from_buildpath.gif
trunk/org.rubypeople.rdt.ui/icons/full/etool16/newpackfolder_wiz.gif
Added: trunk/org.rubypeople.rdt.ui/icons/full/dlcl16/add_linked_source_to_buildpath.gif
===================================================================
(Binary files differ)
Property changes on: trunk/org.rubypeople.rdt.ui/icons/full/dlcl16/add_linked_source_to_buildpath.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/org.rubypeople.rdt.ui/icons/full/dlcl16/configure_build_path.gif
===================================================================
(Binary files differ)
Property changes on: trunk/org.rubypeople.rdt.ui/icons/full/dlcl16/configure_build_path.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/org.rubypeople.rdt.ui/icons/full/dlcl16/configure_buildpath_filters.gif
===================================================================
(Binary files differ)
Property changes on: trunk/org.rubypeople.rdt.ui/icons/full/dlcl16/configure_buildpath_filters.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/org.rubypeople.rdt.ui/icons/full/elcl16/add_linked_source_to_buildpath.gif
===================================================================
(Binary files differ)
Property changes on: trunk/org.rubypeople.rdt.ui/icons/full/elcl16/add_linked_source_to_buildpath.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/org.rubypeople.rdt.ui/icons/full/elcl16/configure_build_path.gif
===================================================================
(Binary files differ)
Property changes on: trunk/org.rubypeople.rdt.ui/icons/full/elcl16/configure_build_path.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/org.rubypeople.rdt.ui/icons/full/elcl16/configure_buildpath_filters.gif
===================================================================
(Binary files differ)
Property changes on: trunk/org.rubypeople.rdt.ui/icons/full/elcl16/configure_buildpath_filters.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/org.rubypeople.rdt.ui/icons/full/elcl16/remove_from_buildpath.gif
===================================================================
(Binary files differ)
Property changes on: trunk/org.rubypeople.rdt.ui/icons/full/elcl16/remove_from_buildpath.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/org.rubypeople.rdt.ui/icons/full/etool16/newpackfolder_wiz.gif
===================================================================
(Binary files differ)
Property changes on: trunk/org.rubypeople.rdt.ui/icons/full/etool16/newpackfolder_wiz.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Modified: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/wizards/buildpaths/newsourcepage/RemoveFromBuildpathAction.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/wizards/buildpaths/newsourcepage/RemoveFromBuildpathAction.java 2007-09-07 15:12:44 UTC (rev 3106)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/wizards/buildpaths/newsourcepage/RemoveFromBuildpathAction.java 2007-09-07 15:23:35 UTC (rev 3107)
@@ -63,7 +63,7 @@
public class RemoveFromBuildpathAction extends Action implements ISelectionChangedListener {
private final IWorkbenchSite fSite;
- private List fSelectedElements; //IPackageFramgentRoot || IRubyProject || ClassPathContainer iff isEnabled()
+ private List fSelectedElements; // ISourceFolderRoot || IRubyProject || LoadPathContainer iff isEnabled()
public RemoveFromBuildpathAction(IWorkbenchSite site) {
super(NewWizardMessages.NewSourceContainerWorkbookPage_ToolBar_RemoveFromCP_label, RubyPluginImages.DESC_ELCL_REMOVE_FROM_BP);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2007-09-07 15:12:54
|
Revision: 3106
http://rubyeclipse.svn.sourceforge.net/rubyeclipse/?rev=3106&view=rev
Author: cawilliams
Date: 2007-09-07 08:12:44 -0700 (Fri, 07 Sep 2007)
Log Message:
-----------
add copy/paste/delete right-click context options to new Ruby Explorer view
Modified Paths:
--------------
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/RubyPlugin.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/packageview/PackageExplorerActionGroup.java
Added Paths:
-----------
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/actions/CCPActionGroup.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/actions/CopyAction.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/actions/PasteAction.java
Modified: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/RubyPlugin.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/RubyPlugin.java 2007-09-07 14:51:03 UTC (rev 3105)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/RubyPlugin.java 2007-09-07 15:12:44 UTC (rev 3106)
@@ -46,6 +46,7 @@
import org.eclipse.ui.PartInitException;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.editors.text.EditorsUI;
+import org.eclipse.ui.navigator.ICommonMenuConstants;
import org.eclipse.ui.plugin.AbstractUIPlugin;
import org.eclipse.ui.progress.WorkbenchJob;
import org.eclipse.ui.texteditor.ChainedPreferenceStore;
@@ -500,12 +501,11 @@
}
public static boolean isDebug() {
- // TODO set to true based on debugging/tracing!
- return false;
+ return getDefault().isDebugging();
}
/**
- * Creates the Java plugin standard groups in a context menu.
+ * Creates the Ruby plugin standard groups in a context menu.
*
* @param menu
* the menu manager to be populated
@@ -517,6 +517,7 @@
menu.add(new GroupMarker(IContextMenuConstants.GROUP_GOTO));
menu.add(new Separator(IContextMenuConstants.GROUP_OPEN));
menu.add(new GroupMarker(IContextMenuConstants.GROUP_SHOW));
+ menu.add(new Separator(ICommonMenuConstants.GROUP_EDIT));
menu.add(new Separator(IContextMenuConstants.GROUP_REORGANIZE));
menu.add(new Separator(IContextMenuConstants.GROUP_GENERATE));
menu.add(new Separator(IContextMenuConstants.GROUP_SEARCH));
Modified: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/packageview/PackageExplorerActionGroup.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/packageview/PackageExplorerActionGroup.java 2007-09-07 14:51:03 UTC (rev 3105)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/packageview/PackageExplorerActionGroup.java 2007-09-07 15:12:44 UTC (rev 3106)
@@ -56,10 +56,9 @@
import org.rubypeople.rdt.internal.ui.workingsets.ViewActionGroup;
import org.rubypeople.rdt.internal.ui.workingsets.WorkingSetActionGroup;
import org.rubypeople.rdt.ui.IContextMenuConstants;
-import org.rubypeople.rdt.ui.PreferenceConstants;
+import org.rubypeople.rdt.ui.actions.CCPActionGroup;
import org.rubypeople.rdt.ui.actions.CustomFiltersActionGroup;
import org.rubypeople.rdt.ui.actions.NavigateActionGroup;
-import org.rubypeople.rdt.ui.actions.RdtActionConstants;
import org.rubypeople.rdt.ui.actions.RubySearchActionGroup;
class PackageExplorerActionGroup extends CompositeActionGroup {
@@ -102,7 +101,7 @@
setGroups(new ActionGroup[] {
new NewWizardsActionGroup(site),
fNavigateActionGroup= new NavigateActionGroup(fPart),
-// new CCPActionGroup(fPart),
+ new CCPActionGroup(fPart),
new GenerateBuildPathActionGroup(fPart),
// new GenerateActionGroup(fPart),
// fRefactorActionGroup= new RefactorActionGroup(fPart),
Added: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/actions/CCPActionGroup.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/actions/CCPActionGroup.java (rev 0)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/actions/CCPActionGroup.java 2007-09-07 15:12:44 UTC (rev 3106)
@@ -0,0 +1,161 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2006 IBM Corporation 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:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.rubypeople.rdt.ui.actions;
+
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.action.IMenuManager;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.ISelectionProvider;
+import org.eclipse.swt.dnd.Clipboard;
+import org.eclipse.ui.IActionBars;
+import org.eclipse.ui.IViewPart;
+import org.eclipse.ui.IWorkbenchSite;
+import org.eclipse.ui.actions.ActionFactory;
+import org.eclipse.ui.actions.ActionGroup;
+import org.eclipse.ui.actions.DeleteResourceAction;
+import org.eclipse.ui.actions.SelectionListenerAction;
+import org.eclipse.ui.navigator.ICommonMenuConstants;
+import org.eclipse.ui.part.Page;
+import org.eclipse.ui.texteditor.IWorkbenchActionDefinitionIds;
+
+/**
+ * Action group that adds the copy, cut, paste actions to a view part's context
+ * menu and installs handlers for the corresponding global menu actions.
+ *
+ * <p>
+ * This class may be instantiated; it is not intended to be subclassed.
+ * </p>
+ *
+ * @since 2.0
+ */
+public class CCPActionGroup extends ActionGroup {
+
+ private IWorkbenchSite fSite;
+ private Clipboard fClipboard;
+
+ private SelectionListenerAction[] fActions;
+
+ private SelectionListenerAction fDeleteAction;
+ private SelectionListenerAction fCopyAction;
+// private SelectionDispatchAction fCopyQualifiedNameAction;
+ private PasteAction fPasteAction;
+// private SelectionListenerAction fCutAction;
+
+ /**
+ * Creates a new <code>CCPActionGroup</code>. The group requires that
+ * the selection provided by the view part's selection provider is of type
+ * <code>org.eclipse.jface.viewers.IStructuredSelection</code>.
+ *
+ * @param part the view part that owns this action group
+ */
+ public CCPActionGroup(IViewPart part) {
+ this(part.getSite());
+ }
+
+ /**
+ * Creates a new <code>CCPActionGroup</code>. The group requires that
+ * the selection provided by the page's selection provider is of type
+ * <code>org.eclipse.jface.viewers.IStructuredSelection</code>.
+ *
+ * @param page the page that owns this action group
+ */
+ public CCPActionGroup(Page page) {
+ this(page.getSite());
+ }
+
+ private CCPActionGroup(IWorkbenchSite site) {
+ fSite= site;
+ fClipboard= new Clipboard(site.getShell().getDisplay());
+
+ fPasteAction= new PasteAction(fSite.getShell(), fClipboard);
+ fPasteAction.setActionDefinitionId(IWorkbenchActionDefinitionIds.PASTE);
+
+ fCopyAction= new CopyAction(fSite.getShell(), fClipboard, fPasteAction);
+ fCopyAction.setActionDefinitionId(IWorkbenchActionDefinitionIds.COPY);
+
+// fCopyQualifiedNameAction= new CopyQualifiedNameAction(fSite, fClipboard, fPasteAction);
+// fCopyQualifiedNameAction.setActionDefinitionId(CopyQualifiedNameAction.JAVA_EDITOR_ACTION_DEFINITIONS_ID);
+
+// fCutAction= new CutAction(fSite.getShell(), fClipboard, fPasteAction);
+// fCutAction.setActionDefinitionId(IWorkbenchActionDefinitionIds.CUT);
+
+ fDeleteAction= new DeleteResourceAction(fSite.getShell());
+ fDeleteAction.setActionDefinitionId(IWorkbenchActionDefinitionIds.DELETE);
+
+ fActions= new SelectionListenerAction[] { /*fCutAction,*/ fCopyAction, /*fCopyQualifiedNameAction,*/ fPasteAction, fDeleteAction };
+ registerActionsAsSelectionChangeListeners();
+ }
+
+ private void registerActionsAsSelectionChangeListeners() {
+ ISelectionProvider provider = fSite.getSelectionProvider();
+ ISelection selection= provider.getSelection();
+ for (int i= 0; i < fActions.length; i++) {
+ SelectionListenerAction action= fActions[i];
+ provider.addSelectionChangedListener(action);
+ }
+ }
+
+ private void deregisterActionsAsSelectionChangeListeners() {
+ ISelectionProvider provider = fSite.getSelectionProvider();
+ for (int i= 0; i < fActions.length; i++) {
+ provider.removeSelectionChangedListener(fActions[i]);
+ }
+ }
+
+
+ /**
+ * Returns the delete action managed by this action group.
+ *
+ * @return the delete action. Returns <code>null</code> if the group
+ * doesn't provide any delete action
+ */
+ public IAction getDeleteAction() {
+ return fDeleteAction;
+ }
+
+ /* (non-Javadoc)
+ * Method declared in ActionGroup
+ */
+ public void fillActionBars(IActionBars actionBars) {
+ super.fillActionBars(actionBars);
+ actionBars.setGlobalActionHandler(ActionFactory.DELETE.getId(), fDeleteAction);
+ actionBars.setGlobalActionHandler(ActionFactory.COPY.getId(), fCopyAction);
+// actionBars.setGlobalActionHandler(CopyQualifiedNameAction.ACTION_HANDLER_ID, fCopyQualifiedNameAction);
+// actionBars.setGlobalActionHandler(ActionFactory.CUT.getId(), fCutAction);
+ actionBars.setGlobalActionHandler(ActionFactory.PASTE.getId(), fPasteAction);
+ }
+
+ /* (non-Javadoc)
+ * Method declared in ActionGroup
+ */
+ public void fillContextMenu(IMenuManager menu) {
+ super.fillContextMenu(menu);
+ for (int i= 0; i < fActions.length; i++) {
+ SelectionListenerAction action= fActions[i];
+// if (action == fCutAction && !fCutAction.isEnabled())
+// continue;
+ menu.appendToGroup(ICommonMenuConstants.GROUP_EDIT, action);
+ }
+ }
+
+ /*
+ * @see ActionGroup#dispose()
+ */
+ public void dispose() {
+ super.dispose();
+ if (fClipboard != null){
+ fClipboard.dispose();
+ fClipboard= null;
+ }
+ deregisterActionsAsSelectionChangeListeners();
+ }
+
+}
Property changes on: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/actions/CCPActionGroup.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/actions/CopyAction.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/actions/CopyAction.java (rev 0)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/actions/CopyAction.java 2007-09-07 15:12:44 UTC (rev 3106)
@@ -0,0 +1,234 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2006 IBM Corporation 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:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.rubypeople.rdt.ui.actions;
+
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.swt.SWTError;
+import org.eclipse.swt.dnd.Clipboard;
+import org.eclipse.swt.dnd.DND;
+import org.eclipse.swt.dnd.FileTransfer;
+import org.eclipse.swt.dnd.TextTransfer;
+import org.eclipse.swt.dnd.Transfer;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.actions.SelectionListenerAction;
+import org.eclipse.ui.internal.views.navigator.ResourceNavigatorMessages;
+import org.eclipse.ui.part.ResourceTransfer;
+
+/**
+ * Standard action for copying the currently selected resources to the clipboard.
+ * <p>
+ * This class may be instantiated; it is not intended to be subclassed.
+ * </p>
+ *
+ * @since 2.0
+ */
+/*package*/class CopyAction extends SelectionListenerAction {
+
+ /**
+ * The id of this action.
+ */
+ public static final String ID = PlatformUI.PLUGIN_ID + ".CopyAction"; //$NON-NLS-1$
+
+ /**
+ * The shell in which to show any dialogs.
+ */
+ private Shell shell;
+
+ /**
+ * System clipboard
+ */
+ private Clipboard clipboard;
+
+ /**
+ * Associated paste action. May be <code>null</code>
+ */
+ private PasteAction pasteAction;
+
+ /**
+ * Creates a new action.
+ *
+ * @param shell the shell for any dialogs
+ * @param clipboard a platform clipboard
+ */
+ public CopyAction(Shell shell, Clipboard clipboard) {
+ super(ResourceNavigatorMessages.CopyAction_title);
+ Assert.isNotNull(shell);
+ Assert.isNotNull(clipboard);
+ this.shell = shell;
+ this.clipboard = clipboard;
+ setToolTipText(ResourceNavigatorMessages.CopyAction_toolTip);
+ setId(CopyAction.ID);
+// PlatformUI.getWorkbench().getHelpSystem().setHelp(this,
+// INavigatorHelpContextIds.COPY_ACTION);
+ }
+
+ /**
+ * Creates a new action.
+ *
+ * @param shell the shell for any dialogs
+ * @param clipboard a platform clipboard
+ * @param pasteAction a paste action
+ *
+ * @since 2.0
+ */
+ public CopyAction(Shell shell, Clipboard clipboard, PasteAction pasteAction) {
+ this(shell, clipboard);
+ this.pasteAction = pasteAction;
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.action.Action#run()
+ */
+ public void run() {
+ /**
+ * The <code>CopyAction</code> implementation of this method defined
+ * on <code>IAction</code> copies the selected resources to the
+ * clipboard.
+ */
+ List selectedResources = getSelectedResources();
+ IResource[] resources = (IResource[]) selectedResources
+ .toArray(new IResource[selectedResources.size()]);
+
+ // Get the file names and a string representation
+ final int length = resources.length;
+ int actualLength = 0;
+ String[] fileNames = new String[length];
+ StringBuffer buf = new StringBuffer();
+ for (int i = 0; i < length; i++) {
+ IPath location = resources[i].getLocation();
+ // location may be null. See bug 29491.
+ if (location != null) {
+ fileNames[actualLength++] = location.toOSString();
+ }
+ if (i > 0) {
+ buf.append("\n"); //$NON-NLS-1$
+ }
+ buf.append(resources[i].getName());
+ }
+ // was one or more of the locations null?
+ if (actualLength < length) {
+ String[] tempFileNames = fileNames;
+ fileNames = new String[actualLength];
+ for (int i = 0; i < actualLength; i++) {
+ fileNames[i] = tempFileNames[i];
+ }
+ }
+ setClipboard(resources, fileNames, buf.toString());
+
+ // update the enablement of the paste action
+ // workaround since the clipboard does not suppot callbacks
+ if (pasteAction != null && pasteAction.getStructuredSelection() != null) {
+ pasteAction.selectionChanged(pasteAction.getStructuredSelection());
+ }
+ }
+
+ /**
+ * Set the clipboard contents. Prompt to retry if clipboard is busy.
+ *
+ * @param resources the resources to copy to the clipboard
+ * @param fileNames file names of the resources to copy to the clipboard
+ * @param names string representation of all names
+ */
+ private void setClipboard(IResource[] resources, String[] fileNames,
+ String names) {
+ try {
+ // set the clipboard contents
+ if (fileNames.length > 0) {
+ clipboard.setContents(new Object[] { resources, fileNames,
+ names },
+ new Transfer[] { ResourceTransfer.getInstance(),
+ FileTransfer.getInstance(),
+ TextTransfer.getInstance() });
+ } else {
+ clipboard.setContents(new Object[] { resources, names },
+ new Transfer[] { ResourceTransfer.getInstance(),
+ TextTransfer.getInstance() });
+ }
+ } catch (SWTError e) {
+ if (e.code != DND.ERROR_CANNOT_SET_CLIPBOARD) {
+ throw e;
+ }
+ if (MessageDialog
+ .openQuestion(
+ shell,
+ ResourceNavigatorMessages.CopyToClipboardProblemDialog_title, ResourceNavigatorMessages.CopyToClipboardProblemDialog_message)) {
+ setClipboard(resources, fileNames, names);
+ }
+ }
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.actions.BaseSelectionListenerAction#updateSelection(org.eclipse.jface.viewers.IStructuredSelection)
+ */
+ protected boolean updateSelection(IStructuredSelection selection) {
+
+ /**
+ * The <code>CopyAction</code> implementation of this
+ * <code>SelectionListenerAction</code> method enables this action if
+ * one or more resources of compatible types are selected.
+ */
+
+ if (!super.updateSelection(selection)) {
+ return false;
+ }
+
+ if (getSelectedNonResources().size() > 0) {
+ return false;
+ }
+
+ List selectedResources = getSelectedResources();
+ if (selectedResources.size() == 0) {
+ return false;
+ }
+
+ boolean projSelected = selectionIsOfType(IResource.PROJECT);
+ boolean fileFoldersSelected = selectionIsOfType(IResource.FILE
+ | IResource.FOLDER);
+ if (!projSelected && !fileFoldersSelected) {
+ return false;
+ }
+
+ // selection must be homogeneous
+ if (projSelected && fileFoldersSelected) {
+ return false;
+ }
+
+ // must have a common parent
+ IContainer firstParent = ((IResource) selectedResources.get(0))
+ .getParent();
+ if (firstParent == null) {
+ return false;
+ }
+
+ Iterator resourcesEnum = selectedResources.iterator();
+ while (resourcesEnum.hasNext()) {
+ IResource currentResource = (IResource) resourcesEnum.next();
+ if (!currentResource.getParent().equals(firstParent)) {
+ return false;
+ }
+ }
+
+ return true;
+ }
+
+}
+
Property changes on: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/actions/CopyAction.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/actions/PasteAction.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/actions/PasteAction.java (rev 0)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/actions/PasteAction.java 2007-09-07 15:12:44 UTC (rev 3106)
@@ -0,0 +1,264 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2006 IBM Corporation 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:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.rubypeople.rdt.ui.actions;
+
+import java.util.List;
+
+import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.swt.dnd.Clipboard;
+import org.eclipse.swt.dnd.FileTransfer;
+import org.eclipse.swt.dnd.TransferData;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.actions.CopyFilesAndFoldersOperation;
+import org.eclipse.ui.actions.CopyProjectOperation;
+import org.eclipse.ui.actions.SelectionListenerAction;
+import org.eclipse.ui.internal.views.navigator.ResourceNavigatorMessages;
+import org.eclipse.ui.part.ResourceTransfer;
+
+/**
+ * Standard action for pasting resources on the clipboard to the selected resource's location.
+ * <p>
+ * This class may be instantiated; it is not intended to be subclassed.
+ * </p>
+ *
+ * @since 2.0
+ */
+/*package*/class PasteAction extends SelectionListenerAction {
+
+ /**
+ * The id of this action.
+ */
+ public static final String ID = PlatformUI.PLUGIN_ID + ".PasteAction";//$NON-NLS-1$
+
+ /**
+ * The shell in which to show any dialogs.
+ */
+ private Shell shell;
+
+ /**
+ * System clipboard
+ */
+ private Clipboard clipboard;
+
+ /**
+ * Creates a new action.
+ *
+ * @param shell the shell for any dialogs
+ * @param clipboard the clipboard
+ */
+ public PasteAction(Shell shell, Clipboard clipboard) {
+ super(ResourceNavigatorMessages.PasteAction_title);
+ Assert.isNotNull(shell);
+ Assert.isNotNull(clipboard);
+ this.shell = shell;
+ this.clipboard = clipboard;
+ setToolTipText(ResourceNavigatorMessages.PasteAction_toolTip);
+ setId(PasteAction.ID);
+// PlatformUI.getWorkbench().getHelpSystem().setHelp(this,
+// INavigatorHelpContextIds.PASTE_ACTION);
+ }
+
+ /**
+ * Returns the actual target of the paste action. Returns null
+ * if no valid target is selected.
+ *
+ * @return the actual target of the paste action
+ */
+ private IResource getTarget() {
+ List selectedResources = getSelectedResources();
+
+ for (int i = 0; i < selectedResources.size(); i++) {
+ IResource resource = (IResource) selectedResources.get(i);
+
+ if (resource instanceof IProject && !((IProject) resource).isOpen()) {
+ return null;
+ }
+ if (resource.getType() == IResource.FILE) {
+ resource = resource.getParent();
+ }
+ if (resource != null) {
+ return resource;
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Returns whether any of the given resources are linked resources.
+ *
+ * @param resources resource to check for linked type. may be null
+ * @return true=one or more resources are linked. false=none of the
+ * resources are linked
+ */
+ private boolean isLinked(IResource[] resources) {
+ for (int i = 0; i < resources.length; i++) {
+ if (resources[i].isLinked()) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ /**
+ * Implementation of method defined on <code>IAction</code>.
+ */
+ public void run() {
+ // try a resource transfer
+ ResourceTransfer resTransfer = ResourceTransfer.getInstance();
+ IResource[] resourceData = (IResource[]) clipboard
+ .getContents(resTransfer);
+
+ if (resourceData != null && resourceData.length > 0) {
+ if (resourceData[0].getType() == IResource.PROJECT) {
+ // enablement checks for all projects
+ for (int i = 0; i < resourceData.length; i++) {
+ CopyProjectOperation operation = new CopyProjectOperation(
+ this.shell);
+ operation.copyProject((IProject) resourceData[i]);
+ }
+ } else {
+ // enablement should ensure that we always have access to a container
+ IContainer container = getContainer();
+
+ CopyFilesAndFoldersOperation operation = new CopyFilesAndFoldersOperation(
+ this.shell);
+ operation.copyResources(resourceData, container);
+ }
+ return;
+ }
+
+ // try a file transfer
+ FileTransfer fileTransfer = FileTransfer.getInstance();
+ String[] fileData = (String[]) clipboard.getContents(fileTransfer);
+
+ if (fileData != null) {
+ // enablement should ensure that we always have access to a container
+ IContainer container = getContainer();
+
+ CopyFilesAndFoldersOperation operation = new CopyFilesAndFoldersOperation(
+ this.shell);
+ operation.copyFiles(fileData, container);
+ }
+ }
+
+ /**
+ * Returns the container to hold the pasted resources.
+ */
+ private IContainer getContainer() {
+ List selection = getSelectedResources();
+ if (selection.get(0) instanceof IFile) {
+ return ((IFile) selection.get(0)).getParent();
+ } else {
+ return (IContainer) selection.get(0);
+ }
+ }
+
+ /**
+ * The <code>PasteAction</code> implementation of this
+ * <code>SelectionListenerAction</code> method enables this action if
+ * a resource compatible with what is on the clipboard is selected.
+ *
+ * -Clipboard must have IResource or java.io.File
+ * -Projects can always be pasted if they are open
+ * -Workspace folder may not be copied into itself
+ * -Files and folders may be pasted to a single selected folder in open
+ * project or multiple selected files in the same folder
+ */
+ protected boolean updateSelection(IStructuredSelection selection) {
+ if (!super.updateSelection(selection)) {
+ return false;
+ }
+
+ final IResource[][] clipboardData = new IResource[1][];
+ shell.getDisplay().syncExec(new Runnable() {
+ public void run() {
+ // clipboard must have resources or files
+ ResourceTransfer resTransfer = ResourceTransfer.getInstance();
+ clipboardData[0] = (IResource[]) clipboard
+ .getContents(resTransfer);
+ }
+ });
+ IResource[] resourceData = clipboardData[0];
+ boolean isProjectRes = resourceData != null && resourceData.length > 0
+ && resourceData[0].getType() == IResource.PROJECT;
+
+ if (isProjectRes) {
+ for (int i = 0; i < resourceData.length; i++) {
+ // make sure all resource data are open projects
+ // can paste open projects regardless of selection
+ if (resourceData[i].getType() != IResource.PROJECT
+ || ((IProject) resourceData[i]).isOpen() == false) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ if (getSelectedNonResources().size() > 0) {
+ return false;
+ }
+
+ IResource targetResource = getTarget();
+ // targetResource is null if no valid target is selected (e.g., open project)
+ // or selection is empty
+ if (targetResource == null) {
+ return false;
+ }
+
+ // can paste files and folders to a single selection (file, folder,
+ // open project) or multiple file selection with the same parent
+ List selectedResources = getSelectedResources();
+ if (selectedResources.size() > 1) {
+ for (int i = 0; i < selectedResources.size(); i++) {
+ IResource resource = (IResource) selectedResources.get(i);
+ if (resource.getType() != IResource.FILE) {
+ return false;
+ }
+ if (!targetResource.equals(resource.getParent())) {
+ return false;
+ }
+ }
+ }
+ if (resourceData != null) {
+ // linked resources can only be pasted into projects
+ if (isLinked(resourceData)
+ && targetResource.getType() != IResource.PROJECT
+ && targetResource.getType() != IResource.FOLDER) {
+ return false;
+ }
+
+ if (targetResource.getType() == IResource.FOLDER) {
+ // don't try to copy folder to self
+ for (int i = 0; i < resourceData.length; i++) {
+ if (targetResource.equals(resourceData[i])) {
+ return false;
+ }
+ }
+ }
+ return true;
+ }
+ TransferData[] transfers = clipboard.getAvailableTypes();
+ FileTransfer fileTransfer = FileTransfer.getInstance();
+ for (int i = 0; i < transfers.length; i++) {
+ if (fileTransfer.isSupportedType(transfers[i])) {
+ return true;
+ }
+ }
+ return false;
+ }
+}
+
Property changes on: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/actions/PasteAction.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2007-09-07 14:51:07
|
Revision: 3105
http://rubyeclipse.svn.sourceforge.net/rubyeclipse/?rev=3105&view=rev
Author: cawilliams
Date: 2007-09-07 07:51:03 -0700 (Fri, 07 Sep 2007)
Log Message:
-----------
don't fold/collapse empty subfolders
Modified Paths:
--------------
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/packageview/SourceFolderProvider.java
Modified: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/packageview/SourceFolderProvider.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/packageview/SourceFolderProvider.java 2007-09-07 14:24:58 UTC (rev 3104)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/packageview/SourceFolderProvider.java 2007-09-07 14:51:03 UTC (rev 3105)
@@ -99,7 +99,6 @@
}
private List filter(List children) throws RubyModelException {
- // FIXME Just remove this?
if (fFoldPackages) {
int size= children.size();
for (int i = 0; i < size; i++) {
@@ -439,8 +438,8 @@
}
private boolean arePackagesFoldedInHierarchicalLayout(){
- // TODO Uncomment and allow folding packages preference setting
+ // TODO Uncomment and allow folding packages preference setting?
// return PreferenceConstants.getPreferenceStore().getBoolean(PreferenceConstants.APPEARANCE_FOLD_PACKAGES_IN_PACKAGE_EXPLORER);
- return true;
+ return false;
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2007-09-07 14:25:00
|
Revision: 3104
http://rubyeclipse.svn.sourceforge.net/rubyeclipse/?rev=3104&view=rev
Author: cawilliams
Date: 2007-09-07 07:24:58 -0700 (Fri, 07 Sep 2007)
Log Message:
-----------
move CorextMessages to different package
Modified Paths:
--------------
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/corext/util/History.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/corext/util/OpenTypeHistory.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/corext/util/Resources.java
Added Paths:
-----------
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/corext/CorextMessages.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/corext/CorextMessages.properties
Removed Paths:
-------------
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/corext/util/CorextMessages.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/corext/util/CorextMessages.properties
Copied: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/corext/CorextMessages.java (from rev 3103, trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/corext/util/CorextMessages.java)
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/corext/CorextMessages.java (rev 0)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/corext/CorextMessages.java 2007-09-07 14:24:58 UTC (rev 3104)
@@ -0,0 +1,21 @@
+package org.rubypeople.rdt.internal.corext;
+
+import org.eclipse.osgi.util.NLS;
+
+public class CorextMessages extends NLS {
+
+ private static final String BUNDLE_NAME = CorextMessages.class.getName();
+
+ public static String History_error_serialize;
+ public static String History_error_read;
+ public static String TypeInfoHistory_consistency_check;
+
+ public static String Resources_fileModified;
+ public static String Resources_modifiedResources;
+ public static String Resources_outOfSync;
+ public static String Resources_outOfSyncResources;
+
+ static {
+ NLS.initializeMessages(BUNDLE_NAME, CorextMessages.class);
+ }
+}
Copied: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/corext/CorextMessages.properties (from rev 3103, trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/corext/util/CorextMessages.properties)
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/corext/CorextMessages.properties (rev 0)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/corext/CorextMessages.properties 2007-09-07 14:24:58 UTC (rev 3104)
@@ -0,0 +1,18 @@
+###############################################################################
+# Copyright (c) 2000, 2006 IBM Corporation 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:
+# IBM Corporation - initial API and implementation
+###############################################################################
+Resources_outOfSyncResources= Some resources are out of sync
+Resources_outOfSync= Resource ''{0}'' is out of sync with file system.
+Resources_modifiedResources= There are modified resources
+Resources_fileModified= File ''{0}'' has been modified since the beginning of the operation
+
+History_error_serialize= Problems serializing information to XML ''{0}''
+TypeInfoHistory_consistency_check=Checking consistency of type history...
+History_error_read=Problems reading information from XML ''{0}''
\ No newline at end of file
Deleted: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/corext/util/CorextMessages.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/corext/util/CorextMessages.java 2007-09-07 14:16:03 UTC (rev 3103)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/corext/util/CorextMessages.java 2007-09-07 14:24:58 UTC (rev 3104)
@@ -1,21 +0,0 @@
-package org.rubypeople.rdt.internal.corext.util;
-
-import org.eclipse.osgi.util.NLS;
-
-public class CorextMessages extends NLS {
-
- private static final String BUNDLE_NAME = CorextMessages.class.getName();
-
- public static String History_error_serialize;
- public static String History_error_read;
- public static String TypeInfoHistory_consistency_check;
-
- public static String Resources_fileModified;
- public static String Resources_modifiedResources;
- public static String Resources_outOfSync;
- public static String Resources_outOfSyncResources;
-
- static {
- NLS.initializeMessages(BUNDLE_NAME, CorextMessages.class);
- }
-}
Deleted: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/corext/util/CorextMessages.properties
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/corext/util/CorextMessages.properties 2007-09-07 14:16:03 UTC (rev 3103)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/corext/util/CorextMessages.properties 2007-09-07 14:24:58 UTC (rev 3104)
@@ -1,18 +0,0 @@
-###############################################################################
-# Copyright (c) 2000, 2006 IBM Corporation 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:
-# IBM Corporation - initial API and implementation
-###############################################################################
-Resources_outOfSyncResources= Some resources are out of sync
-Resources_outOfSync= Resource ''{0}'' is out of sync with file system.
-Resources_modifiedResources= There are modified resources
-Resources_fileModified= File ''{0}'' has been modified since the beginning of the operation
-
-History_error_serialize= Problems serializing information to XML ''{0}''
-TypeInfoHistory_consistency_check=Checking consistency of type history...
-History_error_read=Problems reading information from XML ''{0}''
\ No newline at end of file
Modified: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/corext/util/History.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/corext/util/History.java 2007-09-07 14:16:03 UTC (rev 3103)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/corext/util/History.java 2007-09-07 14:24:58 UTC (rev 3104)
@@ -37,6 +37,7 @@
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IStatus;
+import org.rubypeople.rdt.internal.corext.CorextMessages;
import org.rubypeople.rdt.internal.ui.RubyPlugin;
import org.rubypeople.rdt.internal.ui.RubyUIException;
import org.rubypeople.rdt.internal.ui.RubyUIStatus;
Modified: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/corext/util/OpenTypeHistory.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/corext/util/OpenTypeHistory.java 2007-09-07 14:16:03 UTC (rev 3103)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/corext/util/OpenTypeHistory.java 2007-09-07 14:24:58 UTC (rev 3104)
@@ -36,6 +36,7 @@
import org.rubypeople.rdt.core.RubyModelException;
import org.rubypeople.rdt.core.search.IRubySearchScope;
import org.rubypeople.rdt.core.search.SearchEngine;
+import org.rubypeople.rdt.internal.corext.CorextMessages;
import org.rubypeople.rdt.internal.ui.RubyPlugin;
import org.w3c.dom.Element;
Modified: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/corext/util/Resources.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/corext/util/Resources.java 2007-09-07 14:16:03 UTC (rev 3103)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/corext/util/Resources.java 2007-09-07 14:24:58 UTC (rev 3104)
@@ -29,6 +29,7 @@
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.MultiStatus;
import org.eclipse.core.runtime.Status;
+import org.rubypeople.rdt.internal.corext.CorextMessages;
import org.rubypeople.rdt.internal.ui.IRubyStatusConstants;
import org.rubypeople.rdt.internal.ui.RubyPlugin;
import org.rubypeople.rdt.internal.ui.RubyUIStatus;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2007-09-07 14:16:10
|
Revision: 3103
http://rubyeclipse.svn.sourceforge.net/rubyeclipse/?rev=3103&view=rev
Author: cawilliams
Date: 2007-09-07 07:16:03 -0700 (Fri, 07 Sep 2007)
Log Message:
-----------
add File Transfer Drag and Drop adapter
Modified Paths:
--------------
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/corext/util/CorextMessages.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/corext/util/CorextMessages.properties
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/packageview/PackageExplorerPart.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/packageview/PackagesMessages.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/packageview/PackagesMessages.properties
Added Paths:
-----------
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/corext/util/Resources.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/packageview/FileTransferDragAdapter.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/packageview/FileTransferDropAdapter.java
Modified: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/corext/util/CorextMessages.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/corext/util/CorextMessages.java 2007-09-07 13:47:58 UTC (rev 3102)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/corext/util/CorextMessages.java 2007-09-07 14:16:03 UTC (rev 3103)
@@ -9,6 +9,11 @@
public static String History_error_serialize;
public static String History_error_read;
public static String TypeInfoHistory_consistency_check;
+
+ public static String Resources_fileModified;
+ public static String Resources_modifiedResources;
+ public static String Resources_outOfSync;
+ public static String Resources_outOfSyncResources;
static {
NLS.initializeMessages(BUNDLE_NAME, CorextMessages.class);
Modified: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/corext/util/CorextMessages.properties
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/corext/util/CorextMessages.properties 2007-09-07 13:47:58 UTC (rev 3102)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/corext/util/CorextMessages.properties 2007-09-07 14:16:03 UTC (rev 3103)
@@ -1,3 +1,18 @@
+###############################################################################
+# Copyright (c) 2000, 2006 IBM Corporation 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:
+# IBM Corporation - initial API and implementation
+###############################################################################
+Resources_outOfSyncResources= Some resources are out of sync
+Resources_outOfSync= Resource ''{0}'' is out of sync with file system.
+Resources_modifiedResources= There are modified resources
+Resources_fileModified= File ''{0}'' has been modified since the beginning of the operation
+
History_error_serialize= Problems serializing information to XML ''{0}''
TypeInfoHistory_consistency_check=Checking consistency of type history...
History_error_read=Problems reading information from XML ''{0}''
\ No newline at end of file
Added: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/corext/util/Resources.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/corext/util/Resources.java (rev 0)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/corext/util/Resources.java 2007-09-07 14:16:03 UTC (rev 3103)
@@ -0,0 +1,237 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2005 IBM Corporation 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:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.rubypeople.rdt.internal.corext.util;
+
+import java.io.File;
+import java.net.URI;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.core.filesystem.EFS;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IResourceStatus;
+import org.eclipse.core.resources.ResourceAttributes;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.MultiStatus;
+import org.eclipse.core.runtime.Status;
+import org.rubypeople.rdt.internal.ui.IRubyStatusConstants;
+import org.rubypeople.rdt.internal.ui.RubyPlugin;
+import org.rubypeople.rdt.internal.ui.RubyUIStatus;
+
+public class Resources {
+
+ private Resources() {
+ }
+
+ /**
+ * Checks if the given resource is in sync with the underlying file system.
+ *
+ * @param resource the resource to be checked
+ * @return IStatus status describing the check's result. If <code>status.
+ * isOK()</code> returns <code>true</code> then the resource is in sync
+ */
+ public static IStatus checkInSync(IResource resource) {
+ return checkInSync(new IResource[] {resource});
+ }
+
+ /**
+ * Checks if the given resources are in sync with the underlying file
+ * system.
+ *
+ * @param resources the resources to be checked
+ * @return IStatus status describing the check's result. If <code>status.
+ * isOK() </code> returns <code>true</code> then the resources are in sync
+ */
+ public static IStatus checkInSync(IResource[] resources) {
+ IStatus result= null;
+ for (int i= 0; i < resources.length; i++) {
+ IResource resource= resources[i];
+ if (!resource.isSynchronized(IResource.DEPTH_INFINITE)) {
+ result= addOutOfSync(result, resource);
+ }
+ }
+ if (result != null)
+ return result;
+ return new Status(IStatus.OK, RubyPlugin.getPluginId(), IStatus.OK, "", null); //$NON-NLS-1$
+ }
+
+ /**
+ * Makes the given resource committable. Committable means that it is
+ * writeable and that its content hasn't changed by calling
+ * <code>validateEdit</code> for the given resource on <tt>IWorkspace</tt>.
+ *
+ * @param resource the resource to be checked
+ * @param context the context passed to <code>validateEdit</code>
+ * @return status describing the method's result. If <code>status.isOK()</code> returns <code>true</code> then the resources are committable.
+ *
+ * @see org.eclipse.core.resources.IWorkspace#validateEdit(org.eclipse.core.resources.IFile[], java.lang.Object)
+ */
+ public static IStatus makeCommittable(IResource resource, Object context) {
+ return makeCommittable(new IResource[] { resource }, context);
+ }
+
+ /**
+ * Makes the given resources committable. Committable means that all
+ * resources are writeable and that the content of the resources hasn't
+ * changed by calling <code>validateEdit</code> for a given file on
+ * <tt>IWorkspace</tt>.
+ *
+ * @param resources the resources to be checked
+ * @param context the context passed to <code>validateEdit</code>
+ * @return IStatus status describing the method's result. If <code>status.
+ * isOK()</code> returns <code>true</code> then the add resources are
+ * committable
+ *
+ * @see org.eclipse.core.resources.IWorkspace#validateEdit(org.eclipse.core.resources.IFile[], java.lang.Object)
+ */
+ public static IStatus makeCommittable(IResource[] resources, Object context) {
+ List readOnlyFiles= new ArrayList();
+ for (int i= 0; i < resources.length; i++) {
+ IResource resource= resources[i];
+ if (resource.getType() == IResource.FILE && isReadOnly(resource))
+ readOnlyFiles.add(resource);
+ }
+ if (readOnlyFiles.size() == 0)
+ return new Status(IStatus.OK, RubyPlugin.getPluginId(), IStatus.OK, "", null); //$NON-NLS-1$
+
+ Map oldTimeStamps= createModificationStampMap(readOnlyFiles);
+ IStatus status= ResourcesPlugin.getWorkspace().validateEdit(
+ (IFile[]) readOnlyFiles.toArray(new IFile[readOnlyFiles.size()]), context);
+ if (!status.isOK())
+ return status;
+
+ IStatus modified= null;
+ Map newTimeStamps= createModificationStampMap(readOnlyFiles);
+ for (Iterator iter= oldTimeStamps.keySet().iterator(); iter.hasNext();) {
+ IFile file= (IFile) iter.next();
+ if (!oldTimeStamps.get(file).equals(newTimeStamps.get(file)))
+ modified= addModified(modified, file);
+ }
+ if (modified != null)
+ return modified;
+ return new Status(IStatus.OK, RubyPlugin.getPluginId(), IStatus.OK, "", null); //$NON-NLS-1$
+ }
+
+ private static Map createModificationStampMap(List files){
+ Map map= new HashMap();
+ for (Iterator iter= files.iterator(); iter.hasNext(); ) {
+ IFile file= (IFile)iter.next();
+ map.put(file, new Long(file.getModificationStamp()));
+ }
+ return map;
+ }
+
+ private static IStatus addModified(IStatus status, IFile file) {
+ IStatus entry= RubyUIStatus.createError(
+ IRubyStatusConstants.VALIDATE_EDIT_CHANGED_CONTENT,
+ Messages.format(CorextMessages.Resources_fileModified, file.getFullPath().toString()),
+ null);
+ if (status == null) {
+ return entry;
+ } else if (status.isMultiStatus()) {
+ ((MultiStatus)status).add(entry);
+ return status;
+ } else {
+ MultiStatus result= new MultiStatus(RubyPlugin.getPluginId(),
+ IRubyStatusConstants.VALIDATE_EDIT_CHANGED_CONTENT,
+ CorextMessages.Resources_modifiedResources, null);
+ result.add(status);
+ result.add(entry);
+ return result;
+ }
+ }
+
+ private static IStatus addOutOfSync(IStatus status, IResource resource) {
+ IStatus entry= new Status(
+ IStatus.ERROR,
+ ResourcesPlugin.PI_RESOURCES,
+ IResourceStatus.OUT_OF_SYNC_LOCAL,
+ Messages.format(CorextMessages.Resources_outOfSync, resource.getFullPath().toString()),
+ null);
+ if (status == null) {
+ return entry;
+ } else if (status.isMultiStatus()) {
+ ((MultiStatus)status).add(entry);
+ return status;
+ } else {
+ MultiStatus result= new MultiStatus(
+ ResourcesPlugin.PI_RESOURCES,
+ IResourceStatus.OUT_OF_SYNC_LOCAL,
+ CorextMessages.Resources_outOfSyncResources, null);
+ result.add(status);
+ result.add(entry);
+ return result;
+ }
+ }
+
+ /**
+ * This method is used to generate a list of local locations to
+ * be used in DnD for file transfers.
+ *
+ * @param resources the array of resources to get the local
+ * locations for
+ * @return the local locations
+ */
+ public static String[] getLocationOSStrings(IResource[] resources) {
+ List result= new ArrayList(resources.length);
+ for (int i= 0; i < resources.length; i++) {
+ IPath location= resources[i].getLocation();
+ if (location != null)
+ result.add(location.toOSString());
+ }
+ return (String[]) result.toArray(new String[result.size()]);
+ }
+
+ /**
+ * Returns the location of the given resource. For local
+ * resources this is the OS path in the local file system. For
+ * remote resource this is the URI.
+ *
+ * @param resource the resource
+ * @return the location string or <code>null</code> if the
+ * location URI of the resource is <code>null</code>
+ */
+ public static String getLocationString(IResource resource) {
+ URI uri= resource.getLocationURI();
+ if (uri == null)
+ return null;
+ return EFS.SCHEME_FILE.equalsIgnoreCase(uri.getScheme())
+ ? new File(uri).getAbsolutePath()
+ : uri.toString();
+ }
+
+ public static boolean isReadOnly(IResource resource) {
+ ResourceAttributes resourceAttributes = resource.getResourceAttributes();
+ if (resourceAttributes == null) // not supported on this platform for this resource
+ return false;
+ return resourceAttributes.isReadOnly();
+ }
+
+ static void setReadOnly(IResource resource, boolean readOnly) {
+ ResourceAttributes resourceAttributes = resource.getResourceAttributes();
+ if (resourceAttributes == null) // not supported on this platform for this resource
+ return;
+
+ resourceAttributes.setReadOnly(readOnly);
+ try {
+ resource.setResourceAttributes(resourceAttributes);
+ } catch (CoreException e) {
+ RubyPlugin.log(e);
+ }
+ }
+}
Property changes on: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/corext/util/Resources.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/packageview/FileTransferDragAdapter.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/packageview/FileTransferDragAdapter.java (rev 0)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/packageview/FileTransferDragAdapter.java 2007-09-07 14:16:03 UTC (rev 3103)
@@ -0,0 +1,240 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2005 IBM Corporation 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:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.rubypeople.rdt.internal.ui.packageview;
+
+import java.lang.reflect.InvocationTargetException;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.MultiStatus;
+import org.eclipse.core.runtime.SubProgressMonitor;
+import org.eclipse.jface.dialogs.ProgressMonitorDialog;
+import org.eclipse.jface.operation.IRunnableWithProgress;
+import org.eclipse.jface.util.Assert;
+import org.eclipse.jface.util.TransferDragSourceListener;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.ISelectionProvider;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.swt.dnd.DND;
+import org.eclipse.swt.dnd.DragSourceAdapter;
+import org.eclipse.swt.dnd.DragSourceEvent;
+import org.eclipse.swt.dnd.FileTransfer;
+import org.eclipse.swt.dnd.Transfer;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.actions.WorkspaceModifyOperation;
+import org.rubypeople.rdt.core.IRubyElement;
+import org.rubypeople.rdt.core.ISourceFolderRoot;
+import org.rubypeople.rdt.internal.corext.util.Resources;
+import org.rubypeople.rdt.internal.ui.RubyPlugin;
+import org.rubypeople.rdt.internal.ui.util.ExceptionHandler;
+
+/**
+ * Drag support class to allow dragging of files and folder from
+ * the packages view to another application.
+ */
+class FileTransferDragAdapter extends DragSourceAdapter implements TransferDragSourceListener {
+
+ private ISelectionProvider fProvider;
+
+ FileTransferDragAdapter(ISelectionProvider provider) {
+ fProvider= provider;
+ Assert.isNotNull(fProvider);
+ }
+
+ public Transfer getTransfer() {
+ return FileTransfer.getInstance();
+ }
+
+ public void dragStart(DragSourceEvent event) {
+ event.doit= isDragable(fProvider.getSelection());
+ }
+
+ private boolean isDragable(ISelection s) {
+ if (!(s instanceof IStructuredSelection))
+ return false;
+ IStructuredSelection selection= (IStructuredSelection)s;
+ for (Iterator iter= selection.iterator(); iter.hasNext();) {
+ Object element= iter.next();
+ if (element instanceof IRubyElement) {
+ IRubyElement jElement= (IRubyElement)element;
+ int type= jElement.getElementType();
+ // valid elements are: roots, units and types. Don't allow dragging
+ // projects outside of eclipse
+ if (type != IRubyElement.SOURCE_FOLDER_ROOT &&
+ type != IRubyElement.SCRIPT && type != IRubyElement.TYPE)
+ return false;
+ ISourceFolderRoot root= (ISourceFolderRoot)jElement.getAncestor(IRubyElement.SOURCE_FOLDER_ROOT);
+ if (root != null && root.isArchive())
+ return false;
+ }
+ }
+ List resources= convertIntoResources(selection);
+ return resources.size() == selection.size();
+ }
+
+ public void dragSetData(DragSourceEvent event){
+ List elements= getResources();
+ if (elements == null || elements.size() == 0) {
+ event.data= null;
+ return;
+ }
+
+ event.data= getResourceLocations(elements);
+ }
+
+ private static String[] getResourceLocations(List resources) {
+ return Resources.getLocationOSStrings((IResource[]) resources.toArray(new IResource[resources.size()]));
+ }
+
+ public void dragFinished(DragSourceEvent event) {
+ if (!event.doit)
+ return;
+
+ if (event.detail == DND.DROP_MOVE) {
+ // http://bugs.eclipse.org/bugs/show_bug.cgi?id=30543
+ // handleDropMove(event);
+ } else if (event.detail == DND.DROP_NONE || event.detail == DND.DROP_TARGET_MOVE) {
+ handleRefresh(event);
+ }
+ }
+
+ /* package */ void handleDropMove(DragSourceEvent event) {
+ final List elements= getResources();
+ if (elements == null || elements.size() == 0)
+ return;
+
+ WorkspaceModifyOperation op= new WorkspaceModifyOperation() {
+ public void execute(IProgressMonitor monitor) throws CoreException {
+ try {
+ monitor.beginTask(PackagesMessages.DragAdapter_deleting, elements.size());
+ MultiStatus status= createMultiStatus();
+ Iterator iter= elements.iterator();
+ while(iter.hasNext()) {
+ IResource resource= (IResource)iter.next();
+ try {
+ monitor.subTask(resource.getFullPath().toOSString());
+ resource.delete(true, null);
+
+ } catch (CoreException e) {
+ status.add(e.getStatus());
+ } finally {
+ monitor.worked(1);
+ }
+ }
+ if (!status.isOK()) {
+ throw new CoreException(status);
+ }
+ } finally {
+ monitor.done();
+ }
+ }
+ };
+ runOperation(op, true, false);
+ }
+
+ private void handleRefresh(DragSourceEvent event) {
+ final Set roots= collectRoots(getResources());
+
+ WorkspaceModifyOperation op= new WorkspaceModifyOperation() {
+ public void execute(IProgressMonitor monitor) throws CoreException {
+ try {
+ monitor.beginTask(PackagesMessages.DragAdapter_refreshing, roots.size());
+ MultiStatus status= createMultiStatus();
+ Iterator iter= roots.iterator();
+ while (iter.hasNext()) {
+ IResource r= (IResource)iter.next();
+ try {
+ r.refreshLocal(IResource.DEPTH_ONE, new SubProgressMonitor(monitor, 1));
+ } catch (CoreException e) {
+ status.add(e.getStatus());
+ }
+ }
+ if (!status.isOK()) {
+ throw new CoreException(status);
+ }
+ } finally {
+ monitor.done();
+ }
+ }
+ };
+
+ runOperation(op, true, false);
+ }
+
+ protected Set collectRoots(final List elements) {
+ final Set roots= new HashSet(10);
+
+ Iterator iter= elements.iterator();
+ while (iter.hasNext()) {
+ IResource resource= (IResource)iter.next();
+ IResource parent= resource.getParent();
+ if (parent == null) {
+ roots.add(resource);
+ } else {
+ roots.add(parent);
+ }
+ }
+ return roots;
+ }
+
+ private List getResources() {
+ ISelection s= fProvider.getSelection();
+ if (!(s instanceof IStructuredSelection))
+ return null;
+
+ return convertIntoResources((IStructuredSelection)s);
+ }
+
+ private List convertIntoResources(IStructuredSelection selection) {
+ List result= new ArrayList(selection.size());
+ for (Iterator iter= selection.iterator(); iter.hasNext();) {
+ Object o= iter.next();
+ IResource r= null;
+ if (o instanceof IResource) {
+ r= (IResource)o;
+ } else if (o instanceof IAdaptable) {
+ r= (IResource)((IAdaptable)o).getAdapter(IResource.class);
+ }
+ // Only add resource for which we have a location
+ // in the local file system.
+ if (r != null && r.getLocation() != null) {
+ result.add(r);
+ }
+ }
+ return result;
+ }
+
+ private MultiStatus createMultiStatus() {
+ return new MultiStatus(RubyPlugin.getPluginId(),
+ IStatus.OK, PackagesMessages.DragAdapter_problem, null);
+ }
+
+ private void runOperation(IRunnableWithProgress op, boolean fork, boolean cancelable) {
+ try {
+ Shell parent= RubyPlugin.getActiveWorkbenchShell();
+ new ProgressMonitorDialog(parent).run(fork, cancelable, op);
+ } catch (InvocationTargetException e) {
+ String message= PackagesMessages.DragAdapter_problem;
+ String title= PackagesMessages.DragAdapter_problemTitle;
+ ExceptionHandler.handle(e, title, message);
+ } catch (InterruptedException e) {
+ // Do nothing. Operation has been canceled by user.
+ }
+ }
+}
Property changes on: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/packageview/FileTransferDragAdapter.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/packageview/FileTransferDropAdapter.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/packageview/FileTransferDropAdapter.java (rev 0)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/packageview/FileTransferDropAdapter.java 2007-09-07 14:16:03 UTC (rev 3103)
@@ -0,0 +1,123 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2005 IBM Corporation 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:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.rubypeople.rdt.internal.ui.packageview;
+
+import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.jface.util.TransferDropTargetListener;
+import org.eclipse.jface.viewers.AbstractTreeViewer;
+import org.eclipse.swt.dnd.DND;
+import org.eclipse.swt.dnd.DropTargetEvent;
+import org.eclipse.swt.dnd.FileTransfer;
+import org.eclipse.swt.dnd.Transfer;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.actions.CopyFilesAndFoldersOperation;
+import org.rubypeople.rdt.core.IRubyElement;
+import org.rubypeople.rdt.core.IRubyProject;
+import org.rubypeople.rdt.core.ISourceFolder;
+import org.rubypeople.rdt.core.ISourceFolderRoot;
+import org.rubypeople.rdt.core.RubyModelException;
+import org.rubypeople.rdt.internal.corext.util.Resources;
+import org.rubypeople.rdt.internal.ui.dnd.RdtViewerDropAdapter;
+import org.rubypeople.rdt.internal.ui.util.ExceptionHandler;
+
+/**
+ * Adapter to handle file drop from other applications.
+ */
+class FileTransferDropAdapter extends RdtViewerDropAdapter implements TransferDropTargetListener {
+
+ FileTransferDropAdapter(AbstractTreeViewer viewer) {
+ super(viewer, DND.FEEDBACK_SCROLL | DND.FEEDBACK_EXPAND);
+ }
+
+ //---- TransferDropTargetListener interface ---------------------------------------
+
+ public Transfer getTransfer() {
+ return FileTransfer.getInstance();
+ }
+
+ public boolean isEnabled(DropTargetEvent event) {
+ Object target= event.item != null ? event.item.getData() : null;
+ if (target == null)
+ return false;
+ return target instanceof IRubyElement || target instanceof IResource;
+ }
+
+ //---- Actual DND -----------------------------------------------------------------
+
+ public void validateDrop(Object target, DropTargetEvent event, int operation) {
+ event.detail= DND.DROP_NONE;
+
+ boolean isPackageFragment= target instanceof ISourceFolder;
+ boolean isRubyProject= target instanceof IRubyProject;
+ boolean isPackageFragmentRoot= target instanceof ISourceFolderRoot;
+ boolean isContainer= target instanceof IContainer;
+
+ if (!(isPackageFragment || isRubyProject || isPackageFragmentRoot || isContainer))
+ return;
+
+ if (isContainer) {
+ IContainer container= (IContainer)target;
+ if (container.isAccessible() && !Resources.isReadOnly(container))
+ event.detail= DND.DROP_COPY;
+ } else {
+ IRubyElement element= (IRubyElement)target;
+ if (!element.isReadOnly())
+ event.detail= DND.DROP_COPY;
+ }
+
+ return;
+ }
+
+ public void drop(Object dropTarget, final DropTargetEvent event) {
+ try {
+ int operation= event.detail;
+
+ event.detail= DND.DROP_NONE;
+ final Object data= event.data;
+ if (data == null || !(data instanceof String[]) || operation != DND.DROP_COPY)
+ return;
+
+ final IContainer target= getActualTarget(dropTarget);
+ if (target == null)
+ return;
+
+ // Run the import operation asynchronously.
+ // Otherwise the drag source (e.g., Windows Explorer) will be blocked
+ // while the operation executes. Fixes bug 35796.
+ Display.getCurrent().asyncExec(new Runnable() {
+ public void run() {
+ getShell().forceActive();
+ new CopyFilesAndFoldersOperation(getShell()).copyFiles((String[]) data, target);
+ // Import always performs a copy.
+ event.detail= DND.DROP_COPY;
+ }
+ });
+ } catch (RubyModelException e) {
+ String title= PackagesMessages.DropAdapter_errorTitle;
+ String message= PackagesMessages.DropAdapter_errorMessage;
+ ExceptionHandler.handle(e, getShell(), title, message);
+ }
+ }
+
+ private IContainer getActualTarget(Object dropTarget) throws RubyModelException{
+ if (dropTarget instanceof IContainer)
+ return (IContainer)dropTarget;
+ else if (dropTarget instanceof IRubyElement)
+ return getActualTarget(((IRubyElement)dropTarget).getCorrespondingResource());
+ return null;
+ }
+
+ private Shell getShell() {
+ return getViewer().getControl().getShell();
+ }
+}
Property changes on: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/packageview/FileTransferDropAdapter.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/packageview/PackageExplorerPart.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/packageview/PackageExplorerPart.java 2007-09-07 13:47:58 UTC (rev 3102)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/packageview/PackageExplorerPart.java 2007-09-07 14:16:03 UTC (rev 3103)
@@ -115,7 +115,6 @@
import org.rubypeople.rdt.core.RubyCore;
import org.rubypeople.rdt.core.RubyModelException;
import org.rubypeople.rdt.internal.core.util.Messages;
-import org.rubypeople.rdt.internal.ui.IRubyHelpContextIds;
import org.rubypeople.rdt.internal.ui.RubyPlugin;
import org.rubypeople.rdt.internal.ui.dnd.DelegatingDropAdapter;
import org.rubypeople.rdt.internal.ui.dnd.RdtViewerDragAdapter;
@@ -926,7 +925,7 @@
TransferDragSourceListener[] dragListeners= new TransferDragSourceListener[] {
new SelectionTransferDragAdapter(fViewer),
new ResourceTransferDragAdapter(fViewer),
-// new FileTransferDragAdapter(fViewer)
+ new FileTransferDragAdapter(fViewer)
};
fViewer.addDragSupport(ops, transfers, new RdtViewerDragAdapter(fViewer, dragListeners));
}
@@ -938,7 +937,7 @@
FileTransfer.getInstance()};
TransferDropTargetListener[] dropListeners= new TransferDropTargetListener[] {
new SelectionTransferDropAdapter(fViewer),
-// new FileTransferDropAdapter(fViewer),
+ new FileTransferDropAdapter(fViewer),
// new WorkingSetDropAdapter(this)
};
fViewer.addDropSupport(ops, transfers, new DelegatingDropAdapter(dropListeners));
@@ -1651,7 +1650,7 @@
case IRubyElement.TYPE:
case IRubyElement.METHOD:
case IRubyElement.FIELD:
- // select parent cu/classfile
+ // select parent script
element2= (IRubyElement)element2.getOpenable();
break;
case IRubyElement.RUBY_MODEL:
Modified: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/packageview/PackagesMessages.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/packageview/PackagesMessages.java 2007-09-07 13:47:58 UTC (rev 3102)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/packageview/PackagesMessages.java 2007-09-07 14:16:03 UTC (rev 3103)
@@ -43,6 +43,14 @@
public static String PackageExplorer_notFound;
public static String PackageExplorer_filteredDialog_title;
public static String PackageExplorer_removeFilters;
+
+ public static String DragAdapter_deleting;
+ public static String DragAdapter_refreshing;
+ public static String DragAdapter_problem;
+ public static String DragAdapter_problemTitle;
+
+ public static String DropAdapter_errorTitle;
+ public static String DropAdapter_errorMessage;
static {
NLS.initializeMessages(BUNDLE_NAME, PackagesMessages.class);
Modified: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/packageview/PackagesMessages.properties
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/packageview/PackagesMessages.properties 2007-09-07 13:47:58 UTC (rev 3102)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/packageview/PackagesMessages.properties 2007-09-07 14:16:03 UTC (rev 3103)
@@ -8,7 +8,13 @@
# Contributors:
# IBM Corporation - initial API and implementation
###############################################################################
+DragAdapter_deleting=Deleting ...
+DragAdapter_problem=Problem while moving or copying files.
+DragAdapter_problemTitle=Drag & Drop
+DragAdapter_refreshing=Refreshing...
+DropAdapter_errorTitle=Drag & Drop
+DropAdapter_errorMessage=Error while moving or copying files.
GotoType_action_label=&Type...
GotoType_action_description=Searches for and selects the type entered.
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2007-09-07 13:48:07
|
Revision: 3102
http://rubyeclipse.svn.sourceforge.net/rubyeclipse/?rev=3102&view=rev
Author: cawilliams
Date: 2007-09-07 06:47:58 -0700 (Fri, 07 Sep 2007)
Log Message:
-----------
fix computation of children - don't add duplicate subfolders
Modified Paths:
--------------
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/ExternalSourceFolderRoot.java
Modified: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/ExternalSourceFolderRoot.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/ExternalSourceFolderRoot.java 2007-09-07 13:47:22 UTC (rev 3101)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/ExternalSourceFolderRoot.java 2007-09-07 13:47:58 UTC (rev 3102)
@@ -77,7 +77,6 @@
vChildren.add(pkg);
try {
- RubyProject rubyProject = (RubyProject) getRubyProject();
RubyModelManager manager = RubyModelManager.getRubyModelManager();
File[] members = folder.listFiles();
@@ -87,8 +86,6 @@
if (member.isDirectory()) {
String[] newNames = Util.arrayConcat(pkgName, manager.intern(memberName));
computeFolderChildren(member, newNames, vChildren);
- ISourceFolder child = getSourceFolder(newNames);
- vChildren.add(child);
} else if (member.isFile()) {
// do nothing
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2007-09-07 13:47:23
|
Revision: 3101
http://rubyeclipse.svn.sourceforge.net/rubyeclipse/?rev=3101&view=rev
Author: cawilliams
Date: 2007-09-07 06:47:22 -0700 (Fri, 07 Sep 2007)
Log Message:
-----------
expand API for new Ruby Explorer view
Modified Paths:
--------------
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/IRubyModel.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/IRubyProject.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/ISourceFolder.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/RubyModel.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/RubyProject.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/SourceFolder.java
Modified: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/IRubyModel.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/IRubyModel.java 2007-09-07 13:46:11 UTC (rev 3100)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/IRubyModel.java 2007-09-07 13:47:22 UTC (rev 3101)
@@ -4,6 +4,7 @@
*/
package org.rubypeople.rdt.core;
+import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IWorkspace;
/**
@@ -56,4 +57,27 @@
* @return the workspace associated with this Ruby model
*/
IWorkspace getWorkspace();
+
+ /**
+ * Returns whether this Ruby model contains an <code>IRubyElement</code>
+ * whose resource is the given resource or a non-Ruby resource which is the
+ * given resource.
+ * <p>
+ * Note: no existency check is performed on the argument resource. If it is
+ * not accessible (see <code>IResource.isAccessible()</code>) yet but
+ * would be located in Ruby model range, then it will return
+ * <code>true</code>.
+ * </p>
+ * <p>
+ * If the resource is accessible, it can be reached by navigating the Ruby
+ * model down using the <code>getChildren()</code> and/or
+ * <code>getNonRubyResources()</code> methods.
+ * </p>
+ *
+ * @param resource
+ * the resource to check
+ * @return true if the resource is accessible through the Ruby model
+ * @since 2.1
+ */
+ boolean contains(IResource resource);
}
Modified: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/IRubyProject.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/IRubyProject.java 2007-09-07 13:46:11 UTC (rev 3100)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/IRubyProject.java 2007-09-07 13:47:22 UTC (rev 3101)
@@ -197,4 +197,18 @@
*/
ITypeHierarchy newTypeHierarchy(IRegion region, IProgressMonitor monitor)
throws RubyModelException;
+
+ /**
+ * Returns whether the given resource is on the loadpath of this project,
+ * that is, referenced from a loadpath entry and not explicitly excluded
+ * using an exclusion pattern.
+ *
+ * @param resource the given resource
+ * @return <code>true</code> if the given resource is on the loadpath of
+ * this project, <code>false</code> otherwise
+ * @see ILoadpathEntry#getInclusionPatterns()
+ * @see ILoadpathEntry#getExclusionPatterns()
+ * @since 2.1
+ */
+ boolean isOnLoadpath(IResource resource);
}
\ No newline at end of file
Modified: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/ISourceFolder.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/ISourceFolder.java 2007-09-07 13:46:11 UTC (rev 3100)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/ISourceFolder.java 2007-09-07 13:47:22 UTC (rev 3101)
@@ -121,7 +121,20 @@
* @see IClasspathEntry#getExclusionPatterns()
*/
Object[] getNonRubyResources() throws RubyModelException;
+
IRubyScript getRubyScript(String name);
+
boolean isDefaultPackage();
+
+ /**
+ * Returns whether this source folder's name is
+ * a prefix of other source folders in this source folder's
+ * root.
+ *
+ * @exception RubyModelException if this element does not exist or if an
+ * exception occurs while accessing its corresponding resource.
+ * @return true if this source folder's name is a prefix of other source fragments in this source folder's root, false otherwise
+ */
+ boolean hasSubfolders() throws RubyModelException;
}
Modified: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/RubyModel.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/RubyModel.java 2007-09-07 13:46:11 UTC (rev 3100)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/RubyModel.java 2007-09-07 13:47:22 UTC (rev 3101)
@@ -287,4 +287,29 @@
return 0;
}
+/*
+ * @see IRubyModel
+ */
+public boolean contains(IResource resource) {
+ switch (resource.getType()) {
+ case IResource.ROOT:
+ case IResource.PROJECT:
+ return true;
+ }
+ // file or folder
+ IRubyProject[] projects;
+ try {
+ projects = this.getRubyProjects();
+ } catch (RubyModelException e) {
+ return false;
+ }
+ for (int i = 0, length = projects.length; i < length; i++) {
+ RubyProject project = (RubyProject)projects[i];
+ if (!project.contains(resource)) {
+ return false;
+ }
+ }
+ return true;
}
+
+}
Modified: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/RubyProject.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/RubyProject.java 2007-09-07 13:46:11 UTC (rev 3100)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/RubyProject.java 2007-09-07 13:47:22 UTC (rev 3101)
@@ -2490,4 +2490,34 @@
op.runOperation(monitor);
return op.getResult();
}
+
+ /*
+ * @see IRubyProject
+ */
+ public boolean isOnLoadpath(IResource resource) {
+ IPath exactPath = resource.getFullPath();
+ IPath path = exactPath;
+
+ // ensure that folders are only excluded if all of their children are excluded
+ boolean isFolderPath = resource.getType() == IResource.FOLDER;
+
+ ILoadpathEntry[] classpath;
+ try {
+ classpath = this.getResolvedLoadpath(true/*ignoreUnresolvedEntry*/, false/*don't generateMarkerOnError*/, false/*don't returnResolutionInProgress*/);
+ } catch(RubyModelException e){
+ return false; // not a Ruby project
+ }
+ for (int i = 0; i < classpath.length; i++) {
+ ILoadpathEntry entry = classpath[i];
+ IPath entryPath = entry.getPath();
+ if (entryPath.equals(exactPath)) { // source folder roots must match exactly entry pathes (no exclusion there)
+ return true;
+ }
+ if (entryPath.isPrefixOf(path)
+ && !Util.isExcluded(path, ((LoadpathEntry)entry).fullInclusionPatternChars(), ((LoadpathEntry)entry).fullExclusionPatternChars(), isFolderPath)) {
+ return true;
+ }
+ }
+ return false;
+ }
}
Modified: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/SourceFolder.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/SourceFolder.java 2007-09-07 13:46:11 UTC (rev 3100)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/SourceFolder.java 2007-09-07 13:47:22 UTC (rev 3101)
@@ -16,6 +16,7 @@
import org.rubypeople.rdt.core.IRubyElement;
import org.rubypeople.rdt.core.IRubyScript;
import org.rubypeople.rdt.core.ISourceFolder;
+import org.rubypeople.rdt.core.ISourceFolderRoot;
import org.rubypeople.rdt.core.RubyModelException;
import org.rubypeople.rdt.core.WorkingCopyOwner;
import org.rubypeople.rdt.internal.core.util.MementoTokenizer;
@@ -243,5 +244,22 @@
protected char getHandleMementoDelimiter() {
return RubyElement.JEM_SOURCE_FOLDER;
}
+
+ /**
+ * @see ISourceFolder#hasSubfolders()
+ */
+ public boolean hasSubfolders() throws RubyModelException {
+ IRubyElement[] packages= ((ISourceFolderRoot)getParent()).getChildren();
+ int namesLength = this.names.length;
+ nextPackage: for (int i= 0, length = packages.length; i < length; i++) {
+ String[] otherNames = ((SourceFolder) packages[i]).names;
+ if (otherNames.length <= namesLength) continue nextPackage;
+ for (int j = 0; j < namesLength; j++)
+ if (!this.names[j].equals(otherNames[j]))
+ continue nextPackage;
+ return true;
+ }
+ return false;
+ }
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2007-09-07 13:46:13
|
Revision: 3100
http://rubyeclipse.svn.sourceforge.net/rubyeclipse/?rev=3100&view=rev
Author: cawilliams
Date: 2007-09-07 06:46:11 -0700 (Fri, 07 Sep 2007)
Log Message:
-----------
first cut at a replacement for Ruby Resources View - based on JDT's Package Explorer
Modified Paths:
--------------
trunk/org.rubypeople.rdt.ui/plugin.properties
trunk/org.rubypeople.rdt.ui/plugin.xml
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/RubyUIMessages.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/RubyUIMessages.properties
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/packageview/PackagesMessages.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/workingsets/WorkingSetMessages.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/workingsets/WorkingSetMessages.properties
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/IContextMenuConstants.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/PreferenceConstants.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/RubyElementLabels.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/RubyElementSorter.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/RubyUI.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/StandardRubyElementContentProvider.java
Added Paths:
-----------
trunk/org.rubypeople.rdt.ui/icons/full/dlcl16/collapseall.gif
trunk/org.rubypeople.rdt.ui/icons/full/elcl16/collapseall.gif
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/packageview/CollapseAllAction.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/packageview/CustomHashtable.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/packageview/GotoResourceAction.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/packageview/GotoTypeAction.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/packageview/IMultiElementTreeContentProvider.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/packageview/PackageExplorerActionGroup.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/packageview/PackageExplorerContentProvider.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/packageview/PackageExplorerLabelProvider.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/packageview/PackageExplorerPart.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/packageview/PackageExplorerProblemsDecorator.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/packageview/PackagesFrameSource.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/packageview/PackagesMessages.properties
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/packageview/SourceFolderProvider.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/packageview/ToggleLinkingAction.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/packageview/WorkingSetAwareContentProvider.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/packageview/WorkingSetAwareLabelProvider.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/packageview/WorkingSetAwareRubyElementSorter.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/viewsupport/FilterUpdater.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/viewsupport/TreeHierarchyLayoutProblemsDecorator.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/workingsets/ConfigureWorkingSetAction.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/workingsets/OpenCloseWorkingSetAction.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/workingsets/OpenPropertiesWorkingSetAction.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/workingsets/RemoveWorkingSetElementAction.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/workingsets/RubyWorkingSetUpdater.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/workingsets/ViewAction.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/workingsets/ViewActionGroup.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/workingsets/WorkingSetActionGroup.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/workingsets/WorkingSetConfigurationDialog.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/workingsets/WorkingSetShowActionGroup.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/IPackagesViewPart.java
Added: trunk/org.rubypeople.rdt.ui/icons/full/dlcl16/collapseall.gif
===================================================================
(Binary files differ)
Property changes on: trunk/org.rubypeople.rdt.ui/icons/full/dlcl16/collapseall.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/org.rubypeople.rdt.ui/icons/full/elcl16/collapseall.gif
===================================================================
(Binary files differ)
Property changes on: trunk/org.rubypeople.rdt.ui/icons/full/elcl16/collapseall.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Modified: trunk/org.rubypeople.rdt.ui/plugin.properties
===================================================================
--- trunk/org.rubypeople.rdt.ui/plugin.properties 2007-09-07 12:27:52 UTC (rev 3099)
+++ trunk/org.rubypeople.rdt.ui/plugin.properties 2007-09-07 13:46:11 UTC (rev 3100)
@@ -33,6 +33,7 @@
PreferencePage.rdtDebuggerPreferences=Debugger
viewCategoryName=Ruby
+packagesViewName=Ruby Explorer
hierarchyViewName=Hierarchy
appearancePrefName=Appearance
Modified: trunk/org.rubypeople.rdt.ui/plugin.xml
===================================================================
--- trunk/org.rubypeople.rdt.ui/plugin.xml 2007-09-07 12:27:52 UTC (rev 3099)
+++ trunk/org.rubypeople.rdt.ui/plugin.xml 2007-09-07 13:46:11 UTC (rev 3100)
@@ -377,6 +377,13 @@
name="%viewCategoryName"
id="org.rubypeople.rdt.ui.ruby">
</category>
+ <view
+ name="%packagesViewName"
+ icon="$nl$/icons/full/ctool16/ruby.gif"
+ category="org.rubypeople.rdt.ui.ruby"
+ class="org.rubypeople.rdt.internal.ui.packageview.PackageExplorerPart"
+ id="org.rubypeople.rdt.ui.PackageExplorer">
+ </view>
<view
name="%ViewRubyResources.name"
icon="icons/full/ctool16/ruby.gif"
Modified: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/RubyUIMessages.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/RubyUIMessages.java 2007-09-07 12:27:52 UTC (rev 3099)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/RubyUIMessages.java 2007-09-07 13:46:11 UTC (rev 3100)
@@ -95,6 +95,8 @@
public static String OpenTypeHierarchyUtil_error_open_editor;
public static String OpenTypeHierarchyUtil_error_open_view;
+ public static String RubyUI_defaultDialogMessage;
+
private RubyUIMessages() {
}
Modified: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/RubyUIMessages.properties
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/RubyUIMessages.properties 2007-09-07 12:27:52 UTC (rev 3099)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/RubyUIMessages.properties 2007-09-07 13:46:11 UTC (rev 3100)
@@ -3,6 +3,11 @@
# All Rights Reserved.
#########################################
+#######
+## dialogs
+#######
+RubyUI_defaultDialogMessage=Select entries:
+
#########################################
# RdtUiPlugin
#########################################
Added: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/packageview/CollapseAllAction.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/packageview/CollapseAllAction.java (rev 0)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/packageview/CollapseAllAction.java 2007-09-07 13:46:11 UTC (rev 3100)
@@ -0,0 +1,38 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2005 IBM Corporation 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:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.rubypeople.rdt.internal.ui.packageview;
+
+import org.eclipse.jface.action.Action;
+import org.eclipse.ui.PlatformUI;
+import org.rubypeople.rdt.internal.ui.IRubyHelpContextIds;
+import org.rubypeople.rdt.internal.ui.RubyPluginImages;
+
+/**
+ * Collapse all nodes.
+ */
+class CollapseAllAction extends Action {
+
+ private PackageExplorerPart fPackageExplorer;
+
+ CollapseAllAction(PackageExplorerPart part) {
+ super(PackagesMessages.CollapseAllAction_label);
+ setDescription(PackagesMessages.CollapseAllAction_description);
+ setToolTipText(PackagesMessages.CollapseAllAction_tooltip);
+ RubyPluginImages.setLocalImageDescriptors(this, "collapseall.gif"); //$NON-NLS-1$
+
+ fPackageExplorer= part;
+ PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IRubyHelpContextIds.COLLAPSE_ALL_ACTION);
+ }
+
+ public void run() {
+ fPackageExplorer.collapseAll();
+ }
+}
Property changes on: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/packageview/CollapseAllAction.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/packageview/CustomHashtable.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/packageview/CustomHashtable.java (rev 0)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/packageview/CustomHashtable.java 2007-09-07 13:46:11 UTC (rev 3100)
@@ -0,0 +1,403 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2005 IBM Corporation 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:
+ * Peter Shipton - original hashtable implementation
+ * Nick Edgar - added element comparer support
+ *******************************************************************************/
+
+package org.rubypeople.rdt.internal.ui.packageview;
+
+import java.util.Enumeration;
+import java.util.NoSuchElementException;
+
+import org.eclipse.jface.viewers.IElementComparer;
+
+/**
+ * CustomHashtable associates keys with values. Keys and values cannot be null.
+ * The size of the Hashtable is the number of key/value pairs it contains.
+ * The capacity is the number of key/value pairs the Hashtable can hold.
+ * The load factor is a float value which determines how full the Hashtable
+ * gets before expanding the capacity. If the load factor of the Hashtable
+ * is exceeded, the capacity is doubled.
+ * <p>
+ * CustomHashtable allows a custom comparator and hash code provider.
+ */
+/* package */final class CustomHashtable {
+
+ /**
+ * HashMapEntry is an internal class which is used to hold the entries of a Hashtable.
+ */
+ private static class HashMapEntry {
+ Object key, value;
+
+ HashMapEntry next;
+
+ HashMapEntry(Object theKey, Object theValue) {
+ key = theKey;
+ value = theValue;
+ }
+ }
+
+ private static final class EmptyEnumerator implements Enumeration {
+ public boolean hasMoreElements() {
+ return false;
+ }
+
+ public Object nextElement() {
+ throw new NoSuchElementException();
+ }
+ }
+
+ private class HashEnumerator implements Enumeration {
+ boolean key;
+
+ int start;
+
+ HashMapEntry entry;
+
+ HashEnumerator(boolean isKey) {
+ key = isKey;
+ start = firstSlot;
+ }
+
+ public boolean hasMoreElements() {
+ if (entry != null)
+ return true;
+ while (start <= lastSlot)
+ if (elementData[start++] != null) {
+ entry = elementData[start - 1];
+ return true;
+ }
+ return false;
+ }
+
+ public Object nextElement() {
+ if (hasMoreElements()) {
+ Object result = key ? entry.key : entry.value;
+ entry = entry.next;
+ return result;
+ } else
+ throw new NoSuchElementException();
+ }
+ }
+
+ transient int elementCount;
+
+ transient HashMapEntry[] elementData;
+
+ private float loadFactor;
+
+ private int threshold;
+
+ transient int firstSlot = 0;
+
+ transient int lastSlot = -1;
+
+ transient private IElementComparer comparer;
+
+ private static final EmptyEnumerator emptyEnumerator = new EmptyEnumerator();
+
+ /**
+ * The default capacity used when not specified in the constructor.
+ */
+ public static final int DEFAULT_CAPACITY = 13;
+
+ /**
+ * Constructs a new Hashtable using the default capacity
+ * and load factor.
+ */
+ public CustomHashtable() {
+ this(13);
+ }
+
+ /**
+ * Constructs a new Hashtable using the specified capacity
+ * and the default load factor.
+ *
+ * @param capacity the initial capacity
+ */
+ public CustomHashtable(int capacity) {
+ this(capacity, null);
+ }
+
+ /**
+ * Constructs a new hash table with the default capacity and the given
+ * element comparer.
+ *
+ * @param comparer the element comparer to use to compare keys and obtain
+ * hash codes for keys, or <code>null</code> to use the normal
+ * <code>equals</code> and <code>hashCode</code> methods
+ */
+ public CustomHashtable(IElementComparer comparer) {
+ this(DEFAULT_CAPACITY, comparer);
+ }
+
+ /**
+ * Constructs a new hash table with the given capacity and the given
+ * element comparer.
+ *
+ * @param capacity the maximum number of elements that can be added without
+ * rehashing
+ * @param comparer the element comparer to use to compare keys and obtain
+ * hash codes for keys, or <code>null</code> to use the normal
+ * <code>equals</code> and <code>hashCode</code> methods
+ */
+ public CustomHashtable(int capacity, IElementComparer comparer) {
+ if (capacity >= 0) {
+ elementCount = 0;
+ elementData = new HashMapEntry[capacity == 0 ? 1 : capacity];
+ firstSlot = elementData.length;
+ loadFactor = 0.75f;
+ computeMaxSize();
+ } else
+ throw new IllegalArgumentException();
+ this.comparer = comparer;
+ }
+
+ /**
+ * Constructs a new hash table with enough capacity to hold all keys in the
+ * given hash table, then adds all key/value pairs in the given hash table
+ * to the new one, using the given element comparer.
+ *
+ * @param table the hash table to add from
+ * @param comparer the element comparer to use to compare keys and obtain
+ * hash codes for keys, or <code>null</code> to use the normal
+ * <code>equals</code> and <code>hashCode</code> methods
+ */
+ public CustomHashtable(CustomHashtable table, IElementComparer comparer) {
+ this(table.size() * 2, comparer);
+ for (int i = table.elementData.length; --i >= 0;) {
+ HashMapEntry entry = table.elementData[i];
+ while (entry != null) {
+ put(entry.key, entry.value);
+ entry = entry.next;
+ }
+ }
+ }
+
+ private void computeMaxSize() {
+ threshold = (int) (elementData.length * loadFactor);
+ }
+
+ /**
+ * Answers if this Hashtable contains the specified object as a key
+ * of one of the key/value pairs.
+ *
+ * @param key the object to look for as a key in this Hashtable
+ * @return true if object is a key in this Hashtable, false otherwise
+ */
+ public boolean containsKey(Object key) {
+ return getEntry(key) != null;
+ }
+
+ /**
+ * Answers an Enumeration on the values of this Hashtable. The
+ * results of the Enumeration may be affected if the contents
+ * of this Hashtable are modified.
+ *
+ * @return an Enumeration of the values of this Hashtable
+ */
+ public Enumeration elements() {
+ if (elementCount == 0)
+ return emptyEnumerator;
+ return new HashEnumerator(false);
+ }
+
+ /**
+ * Answers the value associated with the specified key in
+ * this Hashtable.
+ *
+ * @param key the key of the value returned
+ * @return the value associated with the specified key, null if the specified key
+ * does not exist
+ */
+ public Object get(Object key) {
+ int index = (hashCode(key) & 0x7FFFFFFF) % elementData.length;
+ HashMapEntry entry = elementData[index];
+ while (entry != null) {
+ if (keyEquals(key, entry.key))
+ return entry.value;
+ entry = entry.next;
+ }
+ return null;
+ }
+
+ private HashMapEntry getEntry(Object key) {
+ int index = (hashCode(key) & 0x7FFFFFFF) % elementData.length;
+ HashMapEntry entry = elementData[index];
+ while (entry != null) {
+ if (keyEquals(key, entry.key))
+ return entry;
+ entry = entry.next;
+ }
+ return null;
+ }
+
+ /**
+ * Answers the hash code for the given key.
+ */
+ private int hashCode(Object key) {
+ if (comparer == null)
+ return key.hashCode();
+ else
+ return comparer.hashCode(key);
+ }
+
+ /**
+ * Compares two keys for equality.
+ */
+ private boolean keyEquals(Object a, Object b) {
+ if (comparer == null)
+ return a.equals(b);
+ else
+ return comparer.equals(a, b);
+ }
+
+ /**
+ * Answers an Enumeration on the keys of this Hashtable. The
+ * results of the Enumeration may be affected if the contents
+ * of this Hashtable are modified.
+ *
+ * @return an Enumeration of the keys of this Hashtable
+ */
+ public Enumeration keys() {
+ if (elementCount == 0)
+ return emptyEnumerator;
+ return new HashEnumerator(true);
+ }
+
+ /**
+ * Associate the specified value with the specified key in this Hashtable.
+ * If the key already exists, the old value is replaced. The key and value
+ * cannot be null.
+ *
+ * @param key the key to add
+ * @param value the value to add
+ * @return the old value associated with the specified key, null if the key did
+ * not exist
+ */
+ public Object put(Object key, Object value) {
+ if (key != null && value != null) {
+ int index = (hashCode(key) & 0x7FFFFFFF) % elementData.length;
+ HashMapEntry entry = elementData[index];
+ while (entry != null && !keyEquals(key, entry.key))
+ entry = entry.next;
+ if (entry == null) {
+ if (++elementCount > threshold) {
+ rehash();
+ index = (hashCode(key) & 0x7FFFFFFF) % elementData.length;
+ }
+ if (index < firstSlot)
+ firstSlot = index;
+ if (index > lastSlot)
+ lastSlot = index;
+ entry = new HashMapEntry(key, value);
+ entry.next = elementData[index];
+ elementData[index] = entry;
+ return null;
+ }
+ Object result = entry.value;
+ entry.key = key; // important to avoid hanging onto keys that are equal but "old" -- see bug 30607
+ entry.value = value;
+ return result;
+ } else
+ throw new NullPointerException();
+ }
+
+ /**
+ * Increases the capacity of this Hashtable. This method is sent when
+ * the size of this Hashtable exceeds the load factor.
+ */
+ private void rehash() {
+ int length = elementData.length << 1;
+ if (length == 0)
+ length = 1;
+ firstSlot = length;
+ lastSlot = -1;
+ HashMapEntry[] newData = new HashMapEntry[length];
+ for (int i = elementData.length; --i >= 0;) {
+ HashMapEntry entry = elementData[i];
+ while (entry != null) {
+ int index = (hashCode(entry.key) & 0x7FFFFFFF) % length;
+ if (index < firstSlot)
+ firstSlot = index;
+ if (index > lastSlot)
+ lastSlot = index;
+ HashMapEntry next = entry.next;
+ entry.next = newData[index];
+ newData[index] = entry;
+ entry = next;
+ }
+ }
+ elementData = newData;
+ computeMaxSize();
+ }
+
+ /**
+ * Remove the key/value pair with the specified key from this Hashtable.
+ *
+ * @param key the key to remove
+ * @return the value associated with the specified key, null if the specified key
+ * did not exist
+ */
+ public Object remove(Object key) {
+ HashMapEntry last = null;
+ int index = (hashCode(key) & 0x7FFFFFFF) % elementData.length;
+ HashMapEntry entry = elementData[index];
+ while (entry != null && !keyEquals(key, entry.key)) {
+ last = entry;
+ entry = entry.next;
+ }
+ if (entry != null) {
+ if (last == null)
+ elementData[index] = entry.next;
+ else
+ last.next = entry.next;
+ elementCount--;
+ return entry.value;
+ }
+ return null;
+ }
+
+ /**
+ * Answers the number of key/value pairs in this Hashtable.
+ *
+ * @return the number of key/value pairs in this Hashtable
+ */
+ public int size() {
+ return elementCount;
+ }
+
+ /**
+ * Answers the string representation of this Hashtable.
+ *
+ * @return the string representation of this Hashtable
+ */
+ public String toString() {
+ if (size() == 0)
+ return "{}"; //$NON-NLS-1$
+
+ StringBuffer buffer = new StringBuffer();
+ buffer.append('{');
+ for (int i = elementData.length; --i >= 0;) {
+ HashMapEntry entry = elementData[i];
+ while (entry != null) {
+ buffer.append(entry.key);
+ buffer.append('=');
+ buffer.append(entry.value);
+ buffer.append(", "); //$NON-NLS-1$
+ entry = entry.next;
+ }
+ }
+ // Remove the last ", "
+ if (elementCount > 0)
+ buffer.setLength(buffer.length() - 2);
+ buffer.append('}');
+ return buffer.toString();
+ }
+}
Property changes on: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/packageview/CustomHashtable.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/packageview/GotoResourceAction.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/packageview/GotoResourceAction.java (rev 0)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/packageview/GotoResourceAction.java 2007-09-07 13:46:11 UTC (rev 3100)
@@ -0,0 +1,76 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2005 IBM Corporation 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:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.rubypeople.rdt.internal.ui.packageview;
+
+import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.viewers.StructuredViewer;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.dialogs.ResourceListSelectionDialog;
+import org.rubypeople.rdt.core.IRubyElement;
+import org.rubypeople.rdt.core.IRubyModel;
+import org.rubypeople.rdt.core.RubyCore;
+import org.rubypeople.rdt.internal.ui.IRubyHelpContextIds;
+
+public class GotoResourceAction extends Action {
+
+ private PackageExplorerPart fPackageExplorer;
+
+ private static class GotoResourceDialog extends ResourceListSelectionDialog {
+ private IRubyModel fRubyModel;
+ public GotoResourceDialog(Shell parentShell, IContainer container, StructuredViewer viewer) {
+ super(parentShell, container, IResource.FILE | IResource.FOLDER | IResource.PROJECT);
+ fRubyModel= RubyCore.create(ResourcesPlugin.getWorkspace().getRoot());
+ setTitle(PackagesMessages.GotoResource_dialog_title);
+ PlatformUI.getWorkbench().getHelpSystem().setHelp(parentShell, IRubyHelpContextIds.GOTO_RESOURCE_DIALOG);
+ }
+ protected boolean select(IResource resource) {
+ IProject project= resource.getProject();
+ try {
+ if (project.getNature(RubyCore.NATURE_ID) != null)
+ return fRubyModel.contains(resource);
+ } catch (CoreException e) {
+ // do nothing. Consider resource;
+ }
+ return true;
+ }
+ }
+
+ public GotoResourceAction(PackageExplorerPart explorer) {
+ setText(PackagesMessages.GotoResource_action_label);
+ PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IRubyHelpContextIds.GOTO_RESOURCE_ACTION);
+ fPackageExplorer= explorer;
+ }
+
+ public void run() {
+ TreeViewer viewer= fPackageExplorer.getViewer();
+ GotoResourceDialog dialog= new GotoResourceDialog(fPackageExplorer.getSite().getShell(),
+ ResourcesPlugin.getWorkspace().getRoot(), viewer);
+ dialog.open();
+ Object[] result = dialog.getResult();
+ if (result == null || result.length == 0 || !(result[0] instanceof IResource))
+ return;
+ StructuredSelection selection= null;
+ IRubyElement element = RubyCore.create((IResource)result[0]);
+ if (element != null && element.exists())
+ selection= new StructuredSelection(element);
+ else
+ selection= new StructuredSelection(result[0]);
+ viewer.setSelection(selection, true);
+ }
+}
Property changes on: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/packageview/GotoResourceAction.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/packageview/GotoTypeAction.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/packageview/GotoTypeAction.java (rev 0)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/packageview/GotoTypeAction.java 2007-09-07 13:46:11 UTC (rev 3100)
@@ -0,0 +1,97 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2006 IBM Corporation 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:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.rubypeople.rdt.internal.ui.packageview;
+
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.dialogs.ProgressMonitorDialog;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.dialogs.SelectionDialog;
+import org.rubypeople.rdt.core.IRubyElement;
+import org.rubypeople.rdt.core.IRubyScript;
+import org.rubypeople.rdt.core.IType;
+import org.rubypeople.rdt.core.RubyModelException;
+import org.rubypeople.rdt.core.search.IRubySearchConstants;
+import org.rubypeople.rdt.core.search.SearchEngine;
+import org.rubypeople.rdt.internal.corext.util.Messages;
+import org.rubypeople.rdt.internal.ui.IRubyHelpContextIds;
+import org.rubypeople.rdt.internal.ui.RubyPlugin;
+import org.rubypeople.rdt.internal.ui.util.ExceptionHandler;
+import org.rubypeople.rdt.ui.RubyUI;
+
+class GotoTypeAction extends Action {
+
+ private PackageExplorerPart fPackageExplorer;
+
+ GotoTypeAction(PackageExplorerPart part) {
+ super();
+ setText(PackagesMessages.GotoType_action_label);
+ setDescription(PackagesMessages.GotoType_action_description);
+ fPackageExplorer= part;
+ PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IRubyHelpContextIds.GOTO_TYPE_ACTION);
+ }
+
+ public void run() {
+ Shell shell= RubyPlugin.getActiveWorkbenchShell();
+ SelectionDialog dialog= null;
+ try {
+ dialog= RubyUI.createTypeDialog(shell, new ProgressMonitorDialog(shell),
+ SearchEngine.createWorkspaceScope(), IRubySearchConstants.TYPE, false);
+ } catch (RubyModelException e) {
+ String title= getDialogTitle();
+ String message= PackagesMessages.GotoType_error_message;
+ ExceptionHandler.handle(e, title, message);
+ return;
+ }
+
+ dialog.setTitle(getDialogTitle());
+ dialog.setMessage(PackagesMessages.GotoType_dialog_message);
+ if (dialog.open() == IDialogConstants.CANCEL_ID) {
+ return;
+ }
+
+ Object[] types= dialog.getResult();
+ if (types != null && types.length > 0) {
+ gotoType((IType) types[0]);
+ }
+ }
+
+ private void gotoType(IType type) {
+ IRubyScript cu= (IRubyScript) type.getAncestor(IRubyElement.SCRIPT);
+ IRubyElement element= null;
+ if (cu != null) {
+ element= cu.getPrimary();
+ }
+ if (element != null) {
+ PackageExplorerPart view= PackageExplorerPart.openInActivePerspective();
+ if (view != null) {
+ view.selectReveal(new StructuredSelection(element));
+ if (!element.equals(getSelectedElement(view))) {
+ MessageDialog.openInformation(fPackageExplorer.getSite().getShell(),
+ getDialogTitle(),
+ Messages.format(PackagesMessages.PackageExplorer_element_not_present, element.getElementName()));
+ }
+ }
+ }
+ }
+
+ private Object getSelectedElement(PackageExplorerPart view) {
+ return ((IStructuredSelection)view.getSite().getSelectionProvider().getSelection()).getFirstElement();
+ }
+
+ private String getDialogTitle() {
+ return PackagesMessages.GotoType_dialog_title;
+ }
+}
Property changes on: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/packageview/GotoTypeAction.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/packageview/IMultiElementTreeContentProvider.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/packageview/IMultiElementTreeContentProvider.java (rev 0)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/packageview/IMultiElementTreeContentProvider.java 2007-09-07 13:46:11 UTC (rev 3100)
@@ -0,0 +1,18 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2006 IBM Corporation 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:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.rubypeople.rdt.internal.ui.packageview;
+
+import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.jface.viewers.TreePath;
+
+public interface IMultiElementTreeContentProvider extends ITreeContentProvider {
+ public TreePath[] getTreePaths(Object element);
+}
Property changes on: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/packageview/IMultiElementTreeContentProvider.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/packageview/PackageExplorerActionGroup.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/packageview/PackageExplorerActionGroup.java (rev 0)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/packageview/PackageExplorerActionGroup.java 2007-09-07 13:46:11 UTC (rev 3100)
@@ -0,0 +1,377 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2006 IBM Corporation 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:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+
+package org.rubypeople.rdt.internal.ui.packageview;
+
+import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.action.IMenuManager;
+import org.eclipse.jface.action.IToolBarManager;
+import org.eclipse.jface.action.Separator;
+import org.eclipse.jface.util.IPropertyChangeListener;
+import org.eclipse.jface.util.OpenStrategy;
+import org.eclipse.jface.util.PropertyChangeEvent;
+import org.eclipse.jface.viewers.DoubleClickEvent;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.ITreeSelection;
+import org.eclipse.jface.viewers.OpenEvent;
+import org.eclipse.jface.viewers.TreePath;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.KeyEvent;
+import org.eclipse.ui.IActionBars;
+import org.eclipse.ui.IMemento;
+import org.eclipse.ui.IWorkbenchActionConstants;
+import org.eclipse.ui.IWorkbenchPartSite;
+import org.eclipse.ui.IWorkingSet;
+import org.eclipse.ui.IWorkingSetManager;
+import org.eclipse.ui.actions.ActionFactory;
+import org.eclipse.ui.actions.ActionGroup;
+import org.eclipse.ui.actions.OpenInNewWindowAction;
+import org.eclipse.ui.views.framelist.BackAction;
+import org.eclipse.ui.views.framelist.ForwardAction;
+import org.eclipse.ui.views.framelist.Frame;
+import org.eclipse.ui.views.framelist.FrameAction;
+import org.eclipse.ui.views.framelist.FrameList;
+import org.eclipse.ui.views.framelist.GoIntoAction;
+import org.eclipse.ui.views.framelist.TreeFrame;
+import org.eclipse.ui.views.framelist.UpAction;
+import org.rubypeople.rdt.core.IOpenable;
+import org.rubypeople.rdt.core.IRubyElement;
+import org.rubypeople.rdt.core.IRubyScript;
+import org.rubypeople.rdt.core.RubyCore;
+import org.rubypeople.rdt.internal.ui.actions.CompositeActionGroup;
+import org.rubypeople.rdt.internal.ui.actions.NewWizardsActionGroup;
+import org.rubypeople.rdt.internal.ui.wizards.buildpaths.newsourcepage.GenerateBuildPathActionGroup;
+import org.rubypeople.rdt.internal.ui.workingsets.ViewActionGroup;
+import org.rubypeople.rdt.internal.ui.workingsets.WorkingSetActionGroup;
+import org.rubypeople.rdt.ui.IContextMenuConstants;
+import org.rubypeople.rdt.ui.PreferenceConstants;
+import org.rubypeople.rdt.ui.actions.CustomFiltersActionGroup;
+import org.rubypeople.rdt.ui.actions.NavigateActionGroup;
+import org.rubypeople.rdt.ui.actions.RdtActionConstants;
+import org.rubypeople.rdt.ui.actions.RubySearchActionGroup;
+
+class PackageExplorerActionGroup extends CompositeActionGroup {
+
+ private PackageExplorerPart fPart;
+
+ private FrameList fFrameList;
+ private GoIntoAction fZoomInAction;
+ private BackAction fBackAction;
+ private ForwardAction fForwardAction;
+ private UpAction fUpAction;
+ private GotoTypeAction fGotoTypeAction;
+// private GotoPackageAction fGotoPackageAction;
+ private GotoResourceAction fGotoResourceAction;
+ private CollapseAllAction fCollapseAllAction;
+
+
+ private ToggleLinkingAction fToggleLinkingAction;
+
+// private RefactorActionGroup fRefactorActionGroup;
+ private NavigateActionGroup fNavigateActionGroup;
+ private ViewActionGroup fViewActionGroup;
+
+ private CustomFiltersActionGroup fCustomFiltersActionGroup;
+
+ private IAction fGotoRequiredProjectAction;
+
+ public PackageExplorerActionGroup(PackageExplorerPart part) {
+ super();
+ fPart= part;
+ TreeViewer viewer= part.getViewer();
+
+ IPropertyChangeListener workingSetListener= new IPropertyChangeListener() {
+ public void propertyChange(PropertyChangeEvent event) {
+ doWorkingSetChanged(event);
+ }
+ };
+
+ IWorkbenchPartSite site = fPart.getSite();
+ setGroups(new ActionGroup[] {
+ new NewWizardsActionGroup(site),
+ fNavigateActionGroup= new NavigateActionGroup(fPart),
+// new CCPActionGroup(fPart),
+ new GenerateBuildPathActionGroup(fPart),
+// new GenerateActionGroup(fPart),
+// fRefactorActionGroup= new RefactorActionGroup(fPart),
+// new ImportActionGroup(fPart),
+// new BuildActionGroup(fPart),
+ new RubySearchActionGroup(fPart),
+// new ProjectActionGroup(fPart),
+ fViewActionGroup= new ViewActionGroup(fPart.getRootMode(), workingSetListener, site),
+ fCustomFiltersActionGroup= new CustomFiltersActionGroup(fPart, viewer),
+// new LayoutActionGroup(fPart),
+ // the working set action group must be created after the project action group
+ new WorkingSetActionGroup(fPart)});
+
+
+ fViewActionGroup.fillFilters(viewer);
+
+ PackagesFrameSource frameSource= new PackagesFrameSource(fPart);
+ fFrameList= new FrameList(frameSource);
+ frameSource.connectTo(fFrameList);
+
+ fZoomInAction= new GoIntoAction(fFrameList);
+ fBackAction= new BackAction(fFrameList);
+ fForwardAction= new ForwardAction(fFrameList);
+ fUpAction= new UpAction(fFrameList);
+
+ fGotoTypeAction= new GotoTypeAction(fPart);
+// fGotoPackageAction= new GotoPackageAction(fPart);
+ fGotoResourceAction= new GotoResourceAction(fPart);
+ fCollapseAllAction= new CollapseAllAction(fPart);
+ fToggleLinkingAction = new ToggleLinkingAction(fPart);
+// fGotoRequiredProjectAction= new GotoRequiredProjectAction(fPart);
+ }
+
+ public void dispose() {
+ super.dispose();
+ }
+
+
+ //---- Persistent state -----------------------------------------------------------------------
+
+ /* package */ void restoreFilterAndSorterState(IMemento memento) {
+ fViewActionGroup.restoreState(memento);
+ fCustomFiltersActionGroup.restoreState(memento);
+ }
+
+ /* package */ void saveFilterAndSorterState(IMemento memento) {
+ fViewActionGroup.saveState(memento);
+ fCustomFiltersActionGroup.saveState(memento);
+ }
+
+ //---- Action Bars ----------------------------------------------------------------------------
+
+ public void fillActionBars(IActionBars actionBars) {
+ super.fillActionBars(actionBars);
+ setGlobalActionHandlers(actionBars);
+ fillToolBar(actionBars.getToolBarManager());
+ fillViewMenu(actionBars.getMenuManager());
+ }
+
+ /* package */ void updateActionBars(IActionBars actionBars) {
+ actionBars.getToolBarManager().removeAll();
+ actionBars.getMenuManager().removeAll();
+ fillActionBars(actionBars);
+ actionBars.updateActionBars();
+ fZoomInAction.setEnabled(true);
+ }
+
+ private void setGlobalActionHandlers(IActionBars actionBars) {
+ // Navigate Go Into and Go To actions.
+ actionBars.setGlobalActionHandler(IWorkbenchActionConstants.GO_INTO, fZoomInAction);
+ actionBars.setGlobalActionHandler(ActionFactory.BACK.getId(), fBackAction);
+ actionBars.setGlobalActionHandler(ActionFactory.FORWARD.getId(), fForwardAction);
+ actionBars.setGlobalActionHandler(IWorkbenchActionConstants.UP, fUpAction);
+ actionBars.setGlobalActionHandler(IWorkbenchActionConstants.GO_TO_RESOURCE, fGotoResourceAction);
+// actionBars.setGlobalActionHandler(RdtActionConstants.GOTO_TYPE, fGotoTypeAction);
+// actionBars.setGlobalActionHandler(RdtActionConstants.GOTO_PACKAGE, fGotoPackageAction);
+
+// fRefactorActionGroup.retargetFileMenuActions(actionBars);
+ }
+
+ /* package */ void fillToolBar(IToolBarManager toolBar) {
+ toolBar.add(fBackAction);
+ toolBar.add(fForwardAction);
+ toolBar.add(fUpAction);
+
+ toolBar.add(new Separator());
+ toolBar.add(fCollapseAllAction);
+ toolBar.add(fToggleLinkingAction);
+
+ }
+
+ /* package */ void fillViewMenu(IMenuManager menu) {
+ menu.add(fToggleLinkingAction);
+
+ menu.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));
+ menu.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS+"-end"));//$NON-NLS-1$
+ }
+
+ //---- Context menu -------------------------------------------------------------------------
+
+ public void fillContextMenu(IMenuManager menu) {
+ IStructuredSelection selection= (IStructuredSelection)getContext().getSelection();
+ int size= selection.size();
+ Object element= selection.getFirstElement();
+
+ if (element instanceof LoadPathContainer.RequiredProjectWrapper)
+ menu.appendToGroup(IContextMenuConstants.GROUP_SHOW, fGotoRequiredProjectAction);
+
+ addGotoMenu(menu, element, size);
+
+ addOpenNewWindowAction(menu, element);
+
+ super.fillContextMenu(menu);
+ }
+
+ private void addGotoMenu(IMenuManager menu, Object element, int size) {
+ boolean enabled= size == 1 && fPart.getViewer().isExpandable(element) && (isGoIntoTarget(element) || element instanceof IContainer);
+ fZoomInAction.setEnabled(enabled);
+ if (enabled)
+ menu.appendToGroup(IContextMenuConstants.GROUP_GOTO, fZoomInAction);
+ }
+
+ private boolean isGoIntoTarget(Object element) {
+ if (element == null)
+ return false;
+ if (element instanceof IRubyElement) {
+ int type= ((IRubyElement)element).getElementType();
+ return type == IRubyElement.RUBY_PROJECT ||
+ type == IRubyElement.SOURCE_FOLDER_ROOT ||
+ type == IRubyElement.SOURCE_FOLDER;
+ }
+ if (element instanceof IWorkingSet) {
+ return true;
+ }
+ return false;
+ }
+
+ private void addOpenNewWindowAction(IMenuManager menu, Object element) {
+ if (element instanceof IRubyElement) {
+ element= ((IRubyElement)element).getResource();
+
+ }
+ // fix for 64890 Package explorer out of sync when open/closing projects [package explorer] 64890
+ if (element instanceof IProject && !((IProject)element).isOpen())
+ return;
+
+ if (!(element instanceof IContainer))
+ return;
+ menu.appendToGroup(
+ IContextMenuConstants.GROUP_OPEN,
+ new OpenInNewWindowAction(fPart.getSite().getWorkbenchWindow(), (IContainer)element));
+ }
+
+ //---- Key board and mouse handling ------------------------------------------------------------
+
+ /* package*/ void handleDoubleClick(DoubleClickEvent event) {
+ TreeViewer viewer= fPart.getViewer();
+ IStructuredSelection selection= (IStructuredSelection)event.getSelection();
+ Object element= selection.getFirstElement();
+ if (viewer.isExpandable(element)) {
+ if (doubleClickGoesInto()) {
+ // don't zoom into ruby scripts
+ if (element instanceof IRubyScript)
+ return;
+ if (element instanceof IOpenable || element instanceof IContainer || element instanceof IWorkingSet) {
+ fZoomInAction.run();
+ }
+ } else {
+ IAction openAction= fNavigateActionGroup.getOpenAction();
+ if (openAction != null && openAction.isEnabled() && OpenStrategy.getOpenMethod() == OpenStrategy.DOUBLE_CLICK)
+ return;
+ if (selection instanceof ITreeSelection) {
+ TreePath[] paths= ((ITreeSelection)selection).getPathsFor(element);
+ for (int i= 0; i < paths.length; i++) {
+ viewer.setExpandedState(paths[i], !viewer.getExpandedState(paths[i]));
+ }
+ } else {
+ viewer.setExpandedState(element, !viewer.getExpandedState(element));
+ }
+ }
+ }
+ }
+
+ /* package */ void handleOpen(OpenEvent event) {
+ IAction openAction= fNavigateActionGroup.getOpenAction();
+ if (openAction != null && openAction.isEnabled()) {
+ openAction.run();
+ return;
+ }
+ }
+
+ /* package */ void handleKeyEvent(KeyEvent event) {
+ if (event.stateMask != 0)
+ return;
+
+ if (event.keyCode == SWT.BS) {
+ if (fUpAction != null && fUpAction.isEnabled()) {
+ fUpAction.run();
+ event.doit= false;
+ }
+ }
+ }
+
+ private void doWorkingSetChanged(PropertyChangeEvent event) {
+ if (ViewActionGroup.MODE_CHANGED.equals(event.getProperty())) {
+ fPart.rootModeChanged(((Integer)event.getNewValue()).intValue());
+ Object oldInput= null;
+ Object newInput= null;
+ if (fPart.showProjects()) {
+ oldInput= fPart.getWorkingSetModel();
+ newInput= RubyCore.create(ResourcesPlugin.getWorkspace().getRoot());
+ } else if (fPart.showWorkingSets()) {
+ oldInput= RubyCore.create(ResourcesPlugin.getWorkspace().getRoot());
+ newInput= fPart.getWorkingSetModel();
+ }
+ if (oldInput != null && newInput != null) {
+ Frame frame;
+ for (int i= 0; (frame= fFrameList.getFrame(i)) != null; i++) {
+ if (frame instanceof TreeFrame) {
+ TreeFrame treeFrame= (TreeFrame)frame;
+ if (oldInput.equals(treeFrame.getInput()))
+ treeFrame.setInput(newInput);
+ }
+ }
+ }
+ } else {
+ IWorkingSet workingSet= (IWorkingSet) event.getNewValue();
+
+ String workingSetLabel= null;
+ if (workingSet != null)
+ workingSetLabel= workingSet.getLabel();
+ fPart.setWorkingSetLabel(workingSetLabel);
+ fPart.updateTitle();
+
+ String property= event.getProperty();
+ if (IWorkingSetManager.CHANGE_WORKING_SET_CONTENT_CHANGE.equals(property)) {
+ TreeViewer viewer= fPart.getViewer();
+ viewer.getControl().setRedraw(false);
+ viewer.refresh();
+ viewer.getControl().setRedraw(true);
+ }
+ }
+ }
+
+ private boolean doubleClickGoesInto() {
+ return true;
+// return PreferenceConstants.DOUBLE_CLICK_GOES_INTO.equals(PreferenceConstants.getPreferenceStore().getString(PreferenceConstants.DOUBLE_CLICK));
+ }
+
+ public FrameAction getUpAction() {
+ return fUpAction;
+ }
+
+ public FrameAction getBackAction() {
+ return fBackAction;
+ }
+ public FrameAction getForwardAction() {
+ return fForwardAction;
+ }
+
+ public ViewActionGroup getWorkingSetActionGroup() {
+ return fViewActionGroup;
+ }
+
+ public CustomFiltersActionGroup getCustomFilterActionGroup() {
+ return fCustomFiltersActionGroup;
+ }
+
+ public FrameList getFrameList() {
+ return fFrameList;
+ }
+}
Property changes on: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/packageview/PackageExplorerActionGroup.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/packageview/PackageExplorerContentProvider.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/packageview/PackageExplorerContentProvider.java (rev 0)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/packageview/PackageExplorerContentProvider.java 2007-09-07 13:46:11 UTC (rev 3100)
@@ -0,0 +1,695 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2006 IBM Corporation 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:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.rubypeople.rdt.internal.ui.packageview;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+
+import org.eclipse.core.resources.IFolder;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IResourceDelta;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.jface.viewers.IBasicPropertyConstants;
+import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.ui.IWorkingSet;
+import org.rubypeople.rdt.core.ElementChangedEvent;
+import org.rubypeople.rdt.core.IElementChangedListener;
+import org.rubypeople.rdt.core.ILoadpathEntry;
+import org.rubypeople.rdt.core.IRubyElement;
+import org.rubypeople.rdt.core.IRubyElementDelta;
+import org.rubypeople.rdt.core.IRubyModel;
+import org.rubypeople.rdt.core.IRubyProject;
+import org.rubypeople.rdt.core.IRubyScript;
+import org.rubypeople.rdt.core.ISourceFolder;
+import org.rubypeople.rdt.core.ISourceFolderRoot;
+import org.rubypeople.rdt.core.RubyCore;
+import org.rubypeople.rdt.core.RubyModelException;
+import org.rubypeople.rdt.internal.corext.util.RubyModelUtil;
+import org.rubypeople.rdt.internal.ui.RubyPlugin;
+import org.rubypeople.rdt.internal.ui.workingsets.WorkingSetModel;
+import org.rubypeople.rdt.ui.StandardRubyElementContentProvider;
+
+/**
+ * Content provider for the PackageExplorer.
+ *
+ * <p>
+ * Since 2.1 this content provider can provide the children for flat or hierarchical
+ * layout. The hierarchical layout is done by delegating to the <code>SourceFolderProvider</code>.
+ * </p>
+ *
+ * @see org.eclipse.jdt.ui.StandardRubyElementContentProvider
+ * @see org.eclipse.jdt.internal.ui.packageview.SourceFolderProvider
+ */
+public class PackageExplorerContentProvider extends StandardRubyElementContentProvider implements ITreeContentProvider, IElementChangedListener {
+
+ protected static final int ORIGINAL= 0;
+ protected static final int PARENT= 1 << 0;
+ protected static final int GRANT_PARENT= 1 << 1;
+ protected static final int PROJECT= 1 << 2;
+
+ private TreeViewer fViewer;
+ private Object fInput;
+ private boolean fIsFlatLayout;
+ private SourceFolderProvider fSourceFolderProvider;
+
+ private int fPendingChanges;
+
+ /**
+ * Creates a new content provider for Ruby elements.
+ */
+ public PackageExplorerContentProvider(boolean provideMembers) {
+ super(provideMembers);
+ fSourceFolderProvider= new SourceFolderProvider();
+ }
+
+ /* package */ SourceFolderProvider getSourceFolderProvider() {
+ return fSourceFolderProvider;
+ }
+
+ protected Object getViewerInput() {
+ return fInput;
+ }
+
+ /* (non-Rubydoc)
+ * Method declared on IElementChangedListener.
+ */
+ public void elementChanged(final ElementChangedEvent event) {
+ try {
+ // 58952 delete project does not update Package Explorer [package explorer]
+ // if the input to the viewer is deleted then refresh to avoid the display of stale elements
+ if (inputDeleted())
+ return;
+ processDelta(event.getDelta());
+ } catch(RubyModelException e) {
+ RubyPlugin.log(e);
+ }
+ }
+
+ private boolean inputDeleted() {
+ if (fInput == null)
+ return false;
+ if ((fInput instanceof IRubyElement) && ((IRubyElement) fInput).exists())
+ return false;
+ if ((fInput instanceof IResource) && ((IResource) fInput).exists())
+ return false;
+ if (fInput instanceof WorkingSetModel)
+ return false;
+ if (fInput instanceof IWorkingSet) // see https://bugs.eclipse.org/bugs/show_bug.cgi?id=156239
+ return false;
+ postRefresh(fInput, ORIGINAL, fInput);
+ return true;
+ }
+
+ /* (non-Rubydoc)
+ * Method declared on IContentProvider.
+ */
+ public void dispose() {
+ super.dispose();
+ RubyCore.removeElementChangedListener(this);
+ fSourceFolderProvider.dispose();
+ }
+
+ // ------ Code which delegates to SourceFolderProvider ------
+
+ private boolean needsToDelegateGetChildren(Object element) {
+ int type= -1;
+ if (element instanceof IRubyElement)
+ type= ((IRubyElement)element).getElementType();
+ return (!fIsFlatLayout && (type == IRubyElement.SOURCE_FOLDER || type == IRubyElement.SOURCE_FOLDER_ROOT || type == IRubyElement.RUBY_PROJECT || element instanceof IFolder));
+ }
+
+ public Object[] getChildren(Object parentElement) {
+ Object[] children= NO_CHILDREN;
+ try {
+ if (parentElement instanceof IRubyModel)
+ return concatenate(getRubyProjects((IRubyModel)parentElement), getNonRubyProjects((IRubyModel)parentElement));
+
+ if (parentElement instanceof LoadPathContainer)
+ return getContainerSourceFolderRoots((LoadPathContainer)parentElement);
+
+ if (parentElement instanceof IProject)
+ return ((IProject)parentElement).members();
+
+ if (needsToDelegateGetChildren(parentElement)) {
+ Object[] packageFragments= fSourceFolderProvider.getChildren(parentElement);
+ children= getWithParentsResources(packageFragments, parentElement);
+ } else {
+ children= super.getChildren(parentElement);
+ }
+
+ if (parentElement instanceof IRubyProject) {
+ IRubyProject project= (IRubyProject)parentElement;
+ return rootsAndContainers(project, children);
+ }
+ else
+ return children;
+
+ } catch (CoreException e) {
+ return NO_CHILDREN;
+ }
+ }
+
+ private Object[] rootsAndContainers(IRubyProject project, Object[] roots) throws RubyModelException {
+ List result= new ArrayList(roots.length);
+ Set containers= new HashSet(roots.length);
+ Set containedRoots= new HashSet(roots.length);
+
+ ILoadpathEntry[] entries= project.getRawLoadpath();
+ for (int i= 0; i < entries.length; i++) {
+ ILoadpathEntry entry= entries[i];
+ if (entry != null && entry.getEntryKind() == ILoadpathEntry.CPE_CONTAINER) {
+ ISourceFolderRoot[] roots1= project.findSourceFolderRoots(entry);
+ containedRoots.addAll(Arrays.asList(roots1));
+ containers.add(entry);
+ }
+ }
+ for (int i= 0; i < roots.length; i++) {
+ if (roots[i] instanceof ISourceFolderRoot) {
+ if (!containedRoots.contains(roots[i])) {
+ result.add(roots[i]);
+ }
+ } else {
+ result.add(roots[i]);
+ }
+ }
+ for (Iterator each= containers.iterator(); each.hasNext();) {
+ ILoadpathEntry element= (ILoadpathEntry) each.next();
+ result.add(new LoadPathContainer(project, element));
+ }
+ return result.toArray();
+ }
+
+ private Object[] getContainerSourceFolderRoots(LoadPathContainer container) {
+ return container.getChildren(container);
+ }
+
+ private Object[] getNonRubyProjects(IRubyModel model) throws RubyModelException {
+ return model.getNonRubyResources();
+ }
+
+ public Object getParent(Object child) {
+ if (needsToDelegateGetParent(child)) {
+ return fSourceFolderProvider.getParent(child);
+ } else
+ return super.getParent(child);
+ }
+
+ protected Object internalGetParent(Object element) {
+ // since we insert logical package containers we have to fix
+ // up the parent for package fragment roots so that they refer
+ // to the container and containers refere to the project
+ //
+ if (element instanceof ISourceFolderRoot) {
+ ISourceFolderRoot root= (ISourceFolderRoot)element;
+ IRubyProject project= root.getRubyProject();
+ try {
+ ILoadpathEntry[] entries= project.getRawLoadpath();
+ for (int i= 0; i < entries.length; i++) {
+ ILoadpathEntry entry= entries[i];
+ if (entry.getEntryKind() == ILoadpathEntry.CPE_CONTAINER) {
+ if (LoadPathContainer.contains(project, entry, root))
+ return new LoadPathContainer(project, entry);
+ }
+ }
+ } catch (RubyModelException e) {
+ // fall through
+ }
+ }
+ if (element instanceof LoadPathContainer) {
+ return ((LoadPathContainer)element).getRubyProject();
+ }
+ return super.internalGetParent(element);
+ }
+
+ private boolean needsToDelegateGetParent(Object element) {
+ int type= -1;
+ if (element instanceof IRubyElement)
+ type= ((IRubyElement)element).getElementType();
+ return (!fIsFlatLayout && type == IRubyElement.SOURCE_FOLDER);
+ }
+
+ /**
+ * Returns the given objects with the resources of the parent.
+ */
+ private Object[] getWithParentsResources(Object[] existingObject, Object parent) {
+ Object[] objects= super.getChildren(parent);
+ List list= new ArrayList();
+
+ // Add everything that is not a SourceFolder (Files)
+ for (int i= 0; i < objects.length; i++) {
+ Object object= objects[i];
+ if (!(object instanceof ISourceFolder)) {
+ list.add(object);
+ }
+ }
+ if (existingObject != null)
+ list.addAll(Arrays.asList(existingObject));
+
+ return list.toArray();
+ }
+
+ /* (non-Rubydoc)
+ * Method declared on IContentProvider.
+ */
+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+ super.inputChanged(viewer, oldInput, newInput);
+ fSourceFolderProvider.inputChanged(viewer, oldInput, newInput);
+ fViewer= (TreeViewer)viewer;
+ if (oldInput == null && newInput != null) {
+ RubyCore.addElementChangedListener(this);
+ } else if (oldInput != null && newInput == null) {
+ RubyCore.removeElementChangedListener(this);
+ }
+ fInput= newInput;
+ }
+
+ // ------ delta processing ------
+
+ /**
+ * Processes a delta recursively. When more than two children are affected the
+ * tree is fully refreshed starting at this node. The delta is processed in the
+ * current thread but the viewer updates are posted to the UI thread.
+ */
+ private void processDelta(IRubyElementDelta delta) throws RubyModelException {
+
+ int kind= delta.getKind();
+ int flags= delta.getFlags();
+ IRubyElement element= delta.getElement();
+ int elementType= element.getElementType();
+
+
+ if (elementType != IRubyElement.RUBY_MODEL && elementType != IRubyElement.RUBY_PROJECT) {
+ IRubyProject proj= element.getRubyProject();
+ if (proj == null || !proj.getProject().isOpen()) // TODO: Not needed if parent already did the 'open' check!
+ return;
+ }
+
+ if (!fIsFlatLayout && elementType == IRubyElement.SOURCE_FOLDER) {
+ fSourceFolderProvider.processDelta(delta);
+ if (processResourceDeltas(delta.getResourceDeltas(), element))
+ return;
+ handleAffectedChildren(delta, element);
+ return;
+ }
+
+ if (elementType == IRubyElement.SCRIPT) {
+ IRubyScript cu= (IRubyScript) element;
+ if (!RubyModelUtil.isPrimary(cu)) {
+ return;
+ }
+
+ if (!getProv...
[truncated message content] |
|
From: <caw...@us...> - 2007-09-07 12:27:57
|
Revision: 3099
http://rubyeclipse.svn.sourceforge.net/rubyeclipse/?rev=3099&view=rev
Author: cawilliams
Date: 2007-09-07 05:27:52 -0700 (Fri, 07 Sep 2007)
Log Message:
-----------
fix InstallGemDialog to do a better, more responsive job of filtering the remote gem listings as users type in text in the name field.
Modified Paths:
--------------
trunk/com.aptana.rdt.ui/src/com/aptana/rdt/ui/gems/InstallGemDialog.java
Modified: trunk/com.aptana.rdt.ui/src/com/aptana/rdt/ui/gems/InstallGemDialog.java
===================================================================
--- trunk/com.aptana.rdt.ui/src/com/aptana/rdt/ui/gems/InstallGemDialog.java 2007-09-06 19:59:45 UTC (rev 3098)
+++ trunk/com.aptana.rdt.ui/src/com/aptana/rdt/ui/gems/InstallGemDialog.java 2007-09-07 12:27:52 UTC (rev 3099)
@@ -63,13 +63,15 @@
GridData nameTextData = new GridData();
nameTextData.widthHint = 150;
nameText.setLayoutData(nameTextData);
+ final MyViewerFilter filter = new MyViewerFilter();
nameText.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent e) {
if (filterByText) {
- getShell().getDisplay().syncExec(new Runnable() {
+ getShell().getDisplay().asyncExec(new Runnable() {
public void run() {
+ filter.setText(nameText.getText());
gemViewer.refresh();
}
});
@@ -112,7 +114,7 @@
gemViewer.setContentProvider(contentProvider);
TableViewerSorter.bind(gemViewer);
gemViewer.setInput(AptanaRDTPlugin.getDefault().getGemManager().getRemoteGems());
- gemViewer.addFilter(new MyViewerFilter(nameText));
+ gemViewer.addFilter(filter);
gemViewer.addSelectionChangedListener(new ISelectionChangedListener() {
@@ -158,17 +160,21 @@
private static class MyViewerFilter extends ViewerFilter {
- private Text text;
+ private String value;
- public MyViewerFilter(Text text) {
- this.text = text;
+ public void setText(String value) {
+ if (value == null) {
+ this.value = null;
+ } else {
+ this.value = value.toLowerCase();
+ }
}
@Override
public boolean select(Viewer viewer, Object parentElement, Object element) {
+ if (value == null || value.trim().length() == 0) return true;
Gem gem = (Gem) element;
- // TODO If there's no text show nothing?
- return gem.getName().toLowerCase().startsWith(text.getText().toLowerCase());
+ return gem.getName().toLowerCase().startsWith(value);
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2007-09-06 19:59:47
|
Revision: 3098
http://rubyeclipse.svn.sourceforge.net/rubyeclipse/?rev=3098&view=rev
Author: cawilliams
Date: 2007-09-06 12:59:45 -0700 (Thu, 06 Sep 2007)
Log Message:
-----------
show Errors/Warnings overlays on resources in RubyResourcesView
Modified Paths:
--------------
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/resourcesview/RubyResourcesView.java
Modified: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/resourcesview/RubyResourcesView.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/resourcesview/RubyResourcesView.java 2007-09-06 16:01:12 UTC (rev 3097)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/resourcesview/RubyResourcesView.java 2007-09-06 19:59:45 UTC (rev 3098)
@@ -16,6 +16,7 @@
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.viewers.TreeViewer;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IEditorPart;
@@ -31,6 +32,8 @@
import org.rubypeople.rdt.internal.ui.RubyViewerFilter;
import org.rubypeople.rdt.internal.ui.rubyeditor.ExternalRubyFileEditorInput;
import org.rubypeople.rdt.internal.ui.rubyeditor.IRubyScriptEditorInput;
+import org.rubypeople.rdt.internal.ui.viewsupport.AppearanceAwareLabelProvider;
+import org.rubypeople.rdt.internal.ui.viewsupport.DecoratingRubyLabelProvider;
import org.rubypeople.rdt.ui.RubyUI;
public class RubyResourcesView extends ResourceNavigator implements IShowInTarget {
@@ -173,6 +176,11 @@
return false;
}
+ @Override
+ protected void initLabelProvider(TreeViewer viewer) {
+ viewer.setLabelProvider(new DecoratingRubyLabelProvider(new AppearanceAwareLabelProvider()));
+ }
+
/**
* Returns the element contained in the EditorInput
*/
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|