Skip to content

Commit 8396830

Browse files
author
mgricken
committed
Added "Find Again" button in "Find All" panels to repeat the same search.
Refactored some file properties for the external process facility. Added "if", "tmpfile", "input", "project.mode", "project.changed", "project.file", "project.main.class", "project.root" and "project.build.dir" properties. Fixed syntax highlighting in execute external process facility. M src/edu/rice/cs/drjava/config/EagerFileListProperty.java A src/edu/rice/cs/drjava/config/EagerFileProperty.java M src/edu/rice/cs/drjava/ui/MainFrame.java M src/edu/rice/cs/drjava/ui/FindResultsPanel.java M src/edu/rice/cs/drjava/ui/ExecuteExternalDialog.java M src/edu/rice/cs/drjava/ui/FindReplacePanel.java M src/edu/rice/cs/util/StringOps.java git-svn-id: file:///tmp/test-svn/trunk@4424 fe72c1cf-3628-48e9-8b72-1c46755d3cff
1 parent 73b7f0a commit 8396830

7 files changed

Lines changed: 1954 additions & 1628 deletions

File tree

drjava/src/edu/rice/cs/drjava/config/EagerFileListProperty.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@
3636

3737
package edu.rice.cs.drjava.config;
3838

39-
import edu.rice.cs.drjava.model.OpenDefinitionsDocument;
4039
import edu.rice.cs.drjava.DrJava;
4140
import edu.rice.cs.util.FileOps;
4241
import java.util.HashSet;
@@ -85,17 +84,17 @@ public void invalidate() {
8584
}
8685

8786
/** Abstract factory method specifying the list. */
88-
protected abstract List<OpenDefinitionsDocument> getList();
87+
protected abstract List<File> getList();
8988

9089
/** Update the value by concatenating the list of documents. */
9190
public void update() {
92-
List<OpenDefinitionsDocument> l = getList();
91+
List<File> l = getList();
9392
if (l.size()==0) { _value = ""; return; }
9493
StringBuilder sb = new StringBuilder();
95-
for(OpenDefinitionsDocument odd: l) {
94+
for(File fil: l) {
9695
sb.append(_attributes.get("sep"));
9796
try {
98-
File f = FileOps.makeRelativeTo(odd.getRawFile(),
97+
File f = FileOps.makeRelativeTo(fil,
9998
new File(StringOps.unescapeSpacesWith1bHex(StringOps.replaceVariables(_attributes.get("dir"), PropertyMaps.ONLY, PropertyMaps.GET_CURRENT))));
10099
try {
101100
f = f.getCanonicalFile();
Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
/*BEGIN_COPYRIGHT_BLOCK
2+
*
3+
* Copyright (c) 2001-2008, JavaPLT group at Rice University (drjava@rice.edu)
4+
* All rights reserved.
5+
*
6+
* Redistribution and use in source and binary forms, with or without
7+
* modification, are permitted provided that the following conditions are met:
8+
* * Redistributions of source code must retain the above copyright
9+
* notice, this list of conditions and the following disclaimer.
10+
* * Redistributions in binary form must reproduce the above copyright
11+
* notice, this list of conditions and the following disclaimer in the
12+
* documentation and/or other materials provided with the distribution.
13+
* * Neither the names of DrJava, the JavaPLT group, Rice University, nor the
14+
* names of its contributors may be used to endorse or promote products
15+
* derived from this software without specific prior written permission.
16+
*
17+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18+
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19+
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
20+
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
21+
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
22+
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
23+
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
24+
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
25+
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
26+
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
27+
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28+
*
29+
* This software is Open Source Initiative approved Open Source Software.
30+
* Open Source Initative Approved is a trademark of the Open Source Initiative.
31+
*
32+
* This file is part of DrJava. Download the current version of this project
33+
* from http://www.drjava.org/ or http://sourceforge.net/projects/drjava/
34+
*
35+
* END_COPYRIGHT_BLOCK*/
36+
37+
package edu.rice.cs.drjava.config;
38+
39+
import edu.rice.cs.util.Lambda;
40+
import edu.rice.cs.drjava.DrJava;
41+
import edu.rice.cs.util.StringOps;
42+
import edu.rice.cs.util.FileOps;
43+
import java.util.HashSet;
44+
import java.util.Iterator;
45+
import java.io.*;
46+
47+
/** Class representing files that are always up-to-date and that
48+
* can be inserted as variables in external processes.
49+
*
50+
* @version $Id$
51+
*/
52+
public class EagerFileProperty extends DrJavaProperty {
53+
protected Lambda<File,Void> _getFile;
54+
/** Create an eager file property. */
55+
public EagerFileProperty(String name, Lambda<File,Void> getFile) {
56+
super(name);
57+
_getFile = getFile;
58+
resetAttributes();
59+
}
60+
61+
/** Return the value of the property. If it is not current, update first. */
62+
public String getCurrent() {
63+
update();
64+
if (_value==null) { throw new IllegalArgumentException("DrJavaProperty value is null"); }
65+
_isCurrent = true;
66+
return _value;
67+
}
68+
69+
/** Return the value. */
70+
public String toString() {
71+
return getCurrent();
72+
}
73+
74+
/** Return true if the value is current. */
75+
public boolean isCurrent() { return true; }
76+
77+
/** Mark the value as stale. */
78+
public void invalidate() {
79+
// nothing to do, but tell those who are listening
80+
invalidateOthers(new HashSet<DrJavaProperty>());
81+
}
82+
83+
/** @return true if the specified property is equal to this one. */
84+
public boolean equals(Object other) {
85+
if (other == null || other.getClass() != this.getClass()) return false;
86+
EagerProperty o = (EagerProperty)other;
87+
return _name.equals(o._name) && (_isCurrent == o._isCurrent) && _value.equals(o._value);
88+
}
89+
90+
/** @return the hash code. */
91+
public int hashCode() {
92+
int result;
93+
result = _name.hashCode();
94+
result = 31 * result + (_value.hashCode());
95+
result = 31 * result + (_isCurrent?1:0);
96+
return result;
97+
}
98+
99+
public void update() {
100+
try {
101+
File f;
102+
if (_attributes.get("dir").equals("/")) {
103+
f = _getFile.apply(null).getAbsoluteFile();
104+
try {
105+
f = f.getCanonicalFile();
106+
}
107+
catch(IOException ioe) { }
108+
_value = edu.rice.cs.util.StringOps.escapeSpacesWith1bHex(f.toString());
109+
}
110+
else {
111+
f = FileOps.makeRelativeTo(_getFile.apply(null),
112+
new File(StringOps.unescapeSpacesWith1bHex(StringOps.replaceVariables(_attributes.get("dir"), PropertyMaps.ONLY, PropertyMaps.GET_CURRENT))));
113+
_value = edu.rice.cs.util.StringOps.escapeSpacesWith1bHex(f.toString());
114+
}
115+
}
116+
catch(IOException e) { _value = "Error."; }
117+
catch(SecurityException e) { _value = "Error."; }
118+
}
119+
120+
public void resetAttributes() {
121+
_attributes.clear();
122+
_attributes.put("dir", "/");
123+
}
124+
}

0 commit comments

Comments
 (0)