[PT-#150740880] File listener and project listeners mechanics

Refactor project finder into project manager

Update annotation index based on project changes

Missing comments
This commit is contained in:
BoykoAlex
2017-10-10 12:15:55 -04:00
parent 825db31d88
commit 423c6bcaef
40 changed files with 1177 additions and 359 deletions

View File

@@ -0,0 +1,69 @@
/*******************************************************************************
* Copyright (c) 2017 Pivotal, Inc.
* 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:
* Pivotal, Inc. - initial API and implementation
*******************************************************************************/
package org.springframework.ide.vscode.commons.util;
/**
* Basic implementation of File Observer interface
*
* @author Alex Boyko
*
*/
public class BasicFileObserver implements FileObserver {
private ListenerList<FileListener> listeners = new ListenerList<>();
@Override
public void addListener(FileListener listener) {
listeners.add(listener);
}
@Override
public void removeListener(FileListener listener) {
listeners.remove(listener);
}
public void notifyFileChanged(String uri) {
listeners.forEach(l -> {
try {
if (l.accept(uri)) {
l.changed(uri);
}
} catch (Throwable t) {
Log.log(t);
}
});
}
public void notifyFileCreated(String uri) {
listeners.forEach(l -> {
try {
if (l.accept(uri)) {
l.created(uri);
}
} catch (Throwable t) {
Log.log(t);
}
});
}
public void notifyFileDeleted(String uri) {
listeners.forEach(l -> {
try {
if (l.accept(uri)) {
l.deleted(uri);
}
} catch (Throwable t) {
Log.log(t);
}
});
}
}

View File

@@ -0,0 +1,32 @@
/*******************************************************************************
* Copyright (c) 2017 Pivotal, Inc.
* 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:
* Pivotal, Inc. - initial API and implementation
*******************************************************************************/
package org.springframework.ide.vscode.commons.util;
/**
* Object able to add/remove {@link FileListener} objects and fire events via these listeners
*
* @author Alex Boyko
*
*/
public interface FileObserver {
public interface FileListener {
boolean accept(String uri);
void changed(String uri);
void deleted(String uri);
void created(String uri);
}
void addListener(FileListener listener);
void removeListener(FileListener listener);
}