Merge remote-tracking branch 'origin/master'

This commit is contained in:
Anna Kozlova
2014-08-22 15:36:48 +04:00
10 changed files with 57 additions and 44 deletions
@@ -51,7 +51,6 @@ import java.util.TreeSet;
*/
@SuppressWarnings({"CallToPrintStackTrace", "SynchronizeOnThis"})
public class TraverseUIStarter extends ApplicationStarterEx {
private String OUTPUT_PATH;
@NonNls private static final String OPTIONS = "options";
@NonNls private static final String CONFIGURABLE = "configurable";
@NonNls private static final String ID = "id";
@@ -61,9 +60,11 @@ public class TraverseUIStarter extends ApplicationStarterEx {
@NonNls private static final String PATH = "path";
@NonNls private static final String HIT = "hit";
private String OUTPUT_PATH;
@Override
public boolean isHeadless() {
return false;
return true;
}
@Override
@@ -55,7 +55,7 @@ final class OldStreamProviderAdapter extends StreamProvider implements CurrentUs
}
@Override
public void deleteFile(@NotNull String fileSpec, @NotNull RoamingType roamingType) {
public void delete(@NotNull String fileSpec, @NotNull RoamingType roamingType) {
if (myRoamingType == roamingType) {
myProvider.deleteFile(fileSpec, roamingType);
}
@@ -615,11 +615,11 @@ public abstract class StateStorageManagerImpl implements StateStorageManager, Di
}
@Override
public void deleteFile(@NotNull String fileSpec, @NotNull RoamingType roamingType) {
public void delete(@NotNull String fileSpec, @NotNull RoamingType roamingType) {
for (StreamProvider streamProvider : myStreamProviders) {
try {
if (streamProvider.isEnabled() && streamProvider.isApplicable(fileSpec, roamingType)) {
streamProvider.deleteFile(fileSpec, roamingType);
streamProvider.delete(fileSpec, roamingType);
}
}
catch (Exception e) {
@@ -245,6 +245,7 @@ public class StorageUtil {
}
}
@NotNull
public static BufferExposingByteArrayOutputStream documentToBytes(@NotNull Document document, boolean useSystemLineSeparator) throws IOException {
BufferExposingByteArrayOutputStream out = new BufferExposingByteArrayOutputStream(512);
OutputStreamWriter writer = new OutputStreamWriter(out, CharsetToolkit.UTF8_CHARSET);
@@ -271,9 +272,9 @@ public class StorageUtil {
}
}
public static void deleteContent(@NotNull StreamProvider provider, @NotNull String fileSpec, @NotNull RoamingType type) {
public static void delete(@NotNull StreamProvider provider, @NotNull String fileSpec, @NotNull RoamingType type) {
if (provider.isApplicable(fileSpec, type)) {
provider.deleteFile(fileSpec, type);
provider.delete(fileSpec, type);
}
}
@@ -47,5 +47,8 @@ public abstract class StreamProvider {
return Collections.emptyList();
}
public abstract void deleteFile(@NotNull String fileSpec, @NotNull RoamingType roamingType);
/**
* Delete file or directory
*/
public abstract void delete(@NotNull String fileSpec, @NotNull RoamingType roamingType);
}
@@ -34,6 +34,7 @@ import com.intellij.openapi.vfs.VirtualFileAdapter;
import com.intellij.openapi.vfs.VirtualFileEvent;
import com.intellij.openapi.vfs.newvfs.NewVirtualFile;
import com.intellij.util.Alarm;
import com.intellij.util.SmartList;
import com.intellij.util.UniqueFileNamesProvider;
import com.intellij.util.containers.HashSet;
import com.intellij.util.text.UniqueNameGenerator;
@@ -292,12 +293,13 @@ public class SchemesManagerImpl<T extends Scheme, E extends ExternalizableScheme
}
}
@NotNull
private Collection<E> readSchemesFromProviders() {
Collection<E> result = new ArrayList<E>();
if (myProvider == null || !myProvider.isEnabled()) {
return result;
return Collections.emptyList();
}
Collection<E> result = new SmartList<E>();
for (String subPath : myProvider.listSubFiles(myFileSpec, myRoamingType)) {
if (!subPath.equals(DELETED_XML)) {
try {
@@ -305,6 +307,7 @@ public class SchemesManagerImpl<T extends Scheme, E extends ExternalizableScheme
if (subDocument != null) {
E scheme = readScheme(subDocument);
boolean fileRenamed = false;
assert scheme != null;
T existing = findSchemeByName(scheme.getName());
if (existing != null && existing instanceof ExternalizableScheme) {
String currentFileName = ((ExternalizableScheme)existing).getExternalInfo().getCurrentFileName();
@@ -315,7 +318,6 @@ public class SchemesManagerImpl<T extends Scheme, E extends ExternalizableScheme
}
}
String fileName = checkFileNameIsFree(subPath, scheme.getName());
if (!fileRenamed && !fileName.equals(subPath)) {
deleteServerFiles(subPath);
}
@@ -325,7 +327,7 @@ public class SchemesManagerImpl<T extends Scheme, E extends ExternalizableScheme
}
}
catch (Exception e) {
LOG.info("Cannot load data from IDEAServer: " + e.getLocalizedMessage());
LOG.info("Cannot load data from stream provider: " + e.getLocalizedMessage());
}
}
}
@@ -347,21 +349,22 @@ public class SchemesManagerImpl<T extends Scheme, E extends ExternalizableScheme
});
}
private String checkFileNameIsFree(final String subPath, final String schemeName) {
@NotNull
private String checkFileNameIsFree(@NotNull String subPath, @NotNull String schemeName) {
for (Scheme scheme : mySchemes) {
if (scheme instanceof ExternalizableScheme) {
ExternalInfo externalInfo = ((ExternalizableScheme)scheme).getExternalInfo();
String name = externalInfo.getCurrentFileName();
if (name != null) {
String fileName = name + mySchemeExtension;
if (fileName.equals(subPath) && !Comparing.equal(schemeName, scheme.getName())) {
return createUniqueFileName(collectAllFileNames(), UniqueFileNamesProvider.convertName(schemeName));
String name = ((ExternalizableScheme)scheme).getExternalInfo().getCurrentFileName();
if (name != null &&
!schemeName.equals(scheme.getName()) &&
subPath.length() == (name.length() + mySchemeExtension.length()) &&
subPath.startsWith(name) &&
subPath.endsWith(mySchemeExtension)) {
return UniqueNameGenerator.generateUniqueName(UniqueFileNamesProvider.convertName(schemeName), collectAllFileNames());
/*VirtualFile oldFile = myVFSBaseDir.findChild(subPath);
if (oldFile != null) {
oldFile.copy(this, myVFSBaseDir, uniqueFileName + EXT);
}
externalInfo.setCurrentFileName(uniqueFileName);*/
}
}
}
}
@@ -369,8 +372,9 @@ public class SchemesManagerImpl<T extends Scheme, E extends ExternalizableScheme
return subPath;
}
@NotNull
private Collection<String> collectAllFileNames() {
HashSet<String> result = new HashSet<String>();
Set<String> result = new THashSet<String>();
for (T scheme : mySchemes) {
if (scheme instanceof ExternalizableScheme) {
ExternalInfo externalInfo = ((ExternalizableScheme)scheme).getExternalInfo();
@@ -382,10 +386,6 @@ public class SchemesManagerImpl<T extends Scheme, E extends ExternalizableScheme
return result;
}
private static String createUniqueFileName(final Collection<String> strings, final String schemeName) {
return UniqueNameGenerator.generateUniqueName(schemeName, strings);
}
private void loadScheme(final E scheme, boolean forceAdd, final String name) {
if (scheme != null && (!myDeletedNames.contains(scheme.getName()) || forceAdd)) {
T existing = findSchemeByName(scheme.getName());
@@ -469,13 +469,6 @@ public class SchemesManagerImpl<T extends Scheme, E extends ExternalizableScheme
}
final E scheme = readScheme(document);
if (scheme != null) {
if (scheme.getName() == null) {
String suggestedName = FileUtil.getNameWithoutExtension(file.getName());
if (!"_".equals(suggestedName)) {
scheme.setName(suggestedName);
}
}
loadScheme(scheme, forceAdd, file.getName());
result.add(scheme);
}
@@ -653,8 +646,7 @@ public class SchemesManagerImpl<T extends Scheme, E extends ExternalizableScheme
result = new SharedSchemeData(original, name, user, description);
}
else {
Document original = subDocument;
result = new SharedSchemeData(original, name, null, null);
result = new SharedSchemeData(subDocument, name, null, null);
}
return result;
}
@@ -673,8 +665,8 @@ public class SchemesManagerImpl<T extends Scheme, E extends ExternalizableScheme
return false;
}
private String getFileFullPath(final String subPath) {
return myFileSpec + "/" + subPath;
private String getFileFullPath(@NotNull String subPath) {
return myFileSpec + '/' + subPath;
}
@Override
@@ -843,9 +835,9 @@ public class SchemesManagerImpl<T extends Scheme, E extends ExternalizableScheme
deleteServerFiles(fileName);
}
private void deleteServerFiles(final String fileName) {
private void deleteServerFiles(@NotNull String path) {
if (myProvider != null && myProvider.isEnabled()) {
StorageUtil.deleteContent(myProvider, getFileFullPath(fileName), myRoamingType);
StorageUtil.delete(myProvider, getFileFullPath(path), myRoamingType);
}
}
@@ -150,7 +150,7 @@ public class CompoundShelfFileProcessor {
if (stream != null) {
File file = new File(myShelfPath + "/" + newName);
copyFileToStream(stream, file);
serverStreamProvider.deleteFile(oldFilePath, RoamingType.PER_USER);
serverStreamProvider.delete(oldFilePath, RoamingType.PER_USER);
copyFileContentToProviders(newFilePath, serverStreamProvider, file);
}
}
@@ -221,7 +221,7 @@ public class CompoundShelfFileProcessor {
public void delete(final String name) {
FileUtil.delete(new File(getBaseIODir(), name));
if (myServerStreamProvider != null && myServerStreamProvider.isEnabled()) {
StorageUtil.deleteContent(myServerStreamProvider, FILE_SPEC + name, RoamingType.PER_USER);
StorageUtil.delete(myServerStreamProvider, FILE_SPEC + name, RoamingType.PER_USER);
}
}
}
@@ -122,6 +122,13 @@ public class XBreakpointActionsPanel<B extends XBreakpointBase<?,?,?>> extends X
}
}
JComponent getDefaultFocusComponent() {
if (myLogExpressionComboBox != null && myLogExpressionComboBox.getComboBox().isEnabled()) {
return myLogExpressionComboBox.getEditorComponent();
}
return null;
}
public void dispose() {
}
}
@@ -180,8 +180,15 @@ public class XLightBreakpointPropertiesPanel<B extends XBreakpointBase<?,?,?>> i
myMainPanel.addFocusListener(new FocusAdapter() {
@Override
public void focusGained(FocusEvent event) {
if (myConditionComboBox != null) {
IdeFocusManager.findInstance().requestFocus(myConditionComboBox.getEditorComponent(), false);
JComponent compToFocus;
if (myConditionComboBox != null && myConditionComboBox.getComboBox().isEnabled()) {
compToFocus = myConditionComboBox.getEditorComponent();
}
else {
compToFocus = myActionsPanel.getDefaultFocusComponent();
}
if (compToFocus != null) {
IdeFocusManager.findInstance().requestFocus(compToFocus, false);
}
}
});
@@ -97,7 +97,8 @@ public abstract class XVariablesViewBase extends XDebugView {
public void selectionChanged(SelectionEvent e) {
final String text = editor.getDocument().getText(e.getNewRange());
final XDebuggerEvaluator evaluator = stackFrame.getEvaluator();
if (evaluator != null && !StringUtil.isEmpty(text)) {
if (evaluator != null && !StringUtil.isEmpty(text)
&& !(text.contains("exec(") || text.contains("++") || text.contains("--") || text.contains("="))) {
evaluator.evaluate(text, new XEvaluationCallbackBase() {
@Override
public void evaluated(@NotNull XValue result) {
@@ -111,7 +112,8 @@ public abstract class XVariablesViewBase extends XDebugView {
SimpleColoredComponent component = HintUtil.createInformationComponent();
text.appendToComponent(component);
String str = text.toString();
if ("undefined".equals(str) || str.startsWith("Cannot find local variable") || str.startsWith("Invalid expression")) {
if ("undefined".equals(str) || str.startsWith("Cannot find local variable")
|| str.startsWith("Invalid expression")) {
return; //todo[kb] this is temporary solution
}
HintManager.getInstance().hideAllHints();