<arguments>
</arguments>
</buildCommand>
+ <buildCommand>
+ <name>net.sf.eclipsecs.core.CheckstyleBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
<buildCommand>
<name>org.eclipse.m2e.core.maven2Builder</name>
<arguments>
<nature>org.eclipse.m2e.core.maven2Nature</nature>
<nature>org.eclipse.pde.PluginNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
+ <nature>net.sf.eclipsecs.core.CheckstyleNature</nature>
</natures>
</projectDescription>
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IResource;
-
+import org.eclipse.core.runtime.IStatus;
import org.opendaylight.yangide.core.IOpenable;
+import org.opendaylight.yangide.core.YangCorePlugin;
import org.opendaylight.yangide.core.model.YangElement;
/**
public class BufferManager {
protected static BufferManager DEFAULT_BUFFER_MANAGER;
- protected static boolean VERBOSE;
+ protected static boolean VERBOSE = false;
/**
* LRU cache of buffers. The key and value for an entry in the table is the identical buffer.
public void addBuffer(IBuffer buffer) {
if (VERBOSE) {
String owner = ((YangElement) buffer.getOwner()).toStringWithAncestors();
- System.out.println("Adding buffer for " + owner); //$NON-NLS-1$
+ YangCorePlugin.log(IStatus.INFO, "Adding buffer for " + owner);
}
synchronized (this.openBuffers) {
this.openBuffers.put(buffer.getOwner(), buffer);
// close buffers that were removed from the cache if space was needed
this.openBuffers.closeBuffers();
if (VERBOSE) {
- System.out
- .println("-> Buffer cache filling ratio = " + NumberFormat.getInstance().format(this.openBuffers.fillingRatio()) + "%"); //$NON-NLS-1$//$NON-NLS-2$
+ YangCorePlugin.log(IStatus.INFO, "-> Buffer cache filling ratio = " + NumberFormat.getInstance().format(this.openBuffers.fillingRatio()) + "%"); //$NON-NLS-1$//$NON-NLS-2$
}
}
import java.io.IOException;
import java.util.HashSet;
+import java.util.Set;
import java.util.jar.JarFile;
import java.util.zip.ZipEntry;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.IResourceProxy;
-import org.eclipse.core.resources.IResourceProxyVisitor;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
import org.eclipse.jdt.core.IClasspathEntry;
import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jdt.core.IPackageFragmentRoot;
@Override
public boolean execute(IProgressMonitor progressMonitor) {
- System.err.println("[I] Project: " + project.getName());
+ YangCorePlugin.log(IStatus.INFO, "[I] Project: " + project.getName());
if (this.isCancelled || progressMonitor != null && progressMonitor.isCanceled()) {
return true;
if (!this.project.isAccessible()) {
return true;
}
- final HashSet<IPath> ignoredPath = new HashSet<IPath>();
- final HashSet<IPath> externalJarsPath = new HashSet<IPath>();
+ final Set<IPath> ignoredPath = new HashSet<>();
+ final Set<IPath> externalJarsPath = new HashSet<>();
try {
JavaProject proj = (JavaProject) JavaCore.create(project);
- final HashSet<String> projectScope = new HashSet<>();
+ final Set<String> projectScope = new HashSet<>();
projectScope.add(project.getName());
if (proj != null) {
IClasspathEntry[] classpath = proj.getResolvedClasspath();
- for (int i = 0, length = classpath.length; i < length; i++) {
- IClasspathEntry entry = classpath[i];
+ for (IClasspathEntry entry : classpath) {
IPath entryPath = entry.getPath();
IPath output = entry.getOutputLocation();
if (output != null && !entryPath.equals(output)) {
}
}
IPackageFragmentRoot[] roots = proj.getAllPackageFragmentRoots();
- for (int i = 0, length = roots.length; i < length; i++) {
- IPath entryPath = roots[i].getPath();
+ for (IPackageFragmentRoot root : roots) {
+ IPath entryPath = root.getPath();
if (entryPath != null && entryPath.toFile().exists()
&& entryPath.lastSegment().toLowerCase().endsWith(".jar")) {
externalJarsPath.add(entryPath);
YangProjectInfo yangProjectInfo = (YangProjectInfo) YangCorePlugin.create(project).getElementInfo(null);
yangProjectInfo.setProjectScope(projectScope);
// fill indirect scope
- HashSet<String> indirectScope = new HashSet<String>();
+ Set<String> indirectScope = new HashSet<>();
indirectScope.add(project.getName());
for (IJavaProject jproj : JavaCore.create(ResourcesPlugin.getWorkspace().getRoot()).getJavaProjects()) {
if (jproj != proj) {
}
}
try {
- final HashSet<IFile> indexedFiles = new HashSet<IFile>();
- project.accept(new IResourceProxyVisitor() {
- @Override
- public boolean visit(IResourceProxy proxy) {
- if (IndexAllProject.this.isCancelled) {
- return false;
- }
- if (!ignoredPath.isEmpty() && ignoredPath.contains(proxy.requestFullPath())) {
- return false;
- }
- if (proxy.getType() == IResource.FILE) {
- if (CoreUtil.isYangLikeFileName(proxy.getName())) {
- IFile file = (IFile) proxy.requestResource();
- indexedFiles.add(file);
- }
- return false;
+ final HashSet<IFile> indexedFiles = new HashSet<>();
+ project.accept(proxy -> {
+ if (IndexAllProject.this.isCancelled) {
+ return false;
+ }
+ if (!ignoredPath.isEmpty() && ignoredPath.contains(proxy.requestFullPath())) {
+ return false;
+ }
+ if (proxy.getType() == IResource.FILE) {
+ if (CoreUtil.isYangLikeFileName(proxy.getName())) {
+ IFile file = (IFile) proxy.requestResource();
+ indexedFiles.add(file);
}
- return true;
+ return false;
}
+ return true;
}, IResource.NONE);
for (IFile iFile : indexedFiles) {
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Path;
import org.mapdb.DB;
import org.mapdb.DBMaker;
if (this.db != null) {
this.db.close();
}
- File[] files = indexFile.getParentFile().listFiles(new FilenameFilter() {
-
- @Override
- public boolean accept(File dir, String name) {
- return name.startsWith("index") && (cleanAll || !name.startsWith("index_" + INDEX_VERSION));
- }
- });
+ File[] files = indexFile.getParentFile().listFiles((FilenameFilter) (dir, name) -> name.startsWith("index") && (cleanAll || !name.startsWith("index_" + INDEX_VERSION)));
if (files != null) {
for (File file : files) {
file.delete();
Iterable<Long> it = Fun.filter(idxResources, file.getProject().getName(), file.getFullPath().toString());
for (Long modStamp : it) {
if (modStamp == file.getModificationStamp()) {
- System.err.println("[x] " + file);
+ YangCorePlugin.log(IStatus.INFO, "[x] " + file);
return;
}
}
Iterable<Long> it = Fun.filter(idxResources, project.getName(), file.toString());
for (Long modStamp : it) {
if (modStamp == file.toFile().lastModified()) {
- System.err.println("[x] " + file);
+ YangCorePlugin.log(IStatus.INFO, "[x] " + file);
return;
}
}
}
public synchronized void addElementIndexInfo(ElementIndexInfo info) {
- System.err.println("[I] " + info.getModule() + "@" + info.getRevision() + " - " + info.getName() + " - "
- + info.getType());
- idxKeywords.add(Fun.t6(info.getModule(), info.getRevision(), info.getName(), info.getType(), info.getPath(),
- info));
+ YangCorePlugin.log(IStatus.INFO,
+ "[I] " + info.getModule() + "@" + info.getRevision() + " - " + info.getName() + " - " + info.getType());
+ idxKeywords.add(Fun.t6(info.getModule(), info.getRevision(), info.getName(), info.getType(), info.getPath(), info));
}
public synchronized void addElementIndexReferenceInfo(ElementIndexReferenceInfo info) {
- System.err.println("[IR] " + info.getReference() + " : " + info.getType() + " - " + info.getProject() + "@"
- + info.getPath());
+ YangCorePlugin.log(IStatus.INFO,
+ "[IR] " + info.getReference() + " : " + info.getType() + " - " + info.getProject() + "@" + info.getPath());
idxReferences.add(Fun.t4(info.getReference(), info.getType(), info.getPath(), info));
}
}
String nameWithoutPrefix = name;
- int colonIndex = nameWithoutPrefix != null ? nameWithoutPrefix.indexOf(':') : -1;
+ int colonIndex = nameWithoutPrefix != null ? nameWithoutPrefix.indexOf(':') : -1;
if (colonIndex != -1) {
nameWithoutPrefix = nameWithoutPrefix.substring(colonIndex + 1);
}
-
+
for (Tuple6<String, String, String, ElementIndexType, String, ElementIndexInfo> entry : idxKeywords) {
if (module != null && module.length() > 0 && !module.equals(entry.a)) {
continue;
}
if (infos == null) {
- infos = new ArrayList<ElementIndexInfo>();
+ infos = new ArrayList<>();
}
infos.add(entry.f);
}
}
String nameWithoutPrefix = reference.getName();
- int colonIndex = nameWithoutPrefix != null ? nameWithoutPrefix.indexOf(':') : -1;
+ int colonIndex = nameWithoutPrefix != null ? nameWithoutPrefix.indexOf(':') : -1;
if (colonIndex != -1) {
nameWithoutPrefix = nameWithoutPrefix.substring(colonIndex + 1);
}
}
if (infos == null) {
- infos = new ArrayList<ElementIndexReferenceInfo>();
+ infos = new ArrayList<>();
}
if (!infos.contains(entry.d)) {
public static void log(IStatus status) {
getDefault().getLog().log(status);
}
+
+ /**
+ * Reports log to Error Log view.
+ *
+ * @param statusErrorID plugin related error ID
+ * @param message error message
+ */
+ public static void log(int statusErrorID, String message) {
+ log(new Status(statusErrorID, PLUGIN_ID, message));
+ }
}
package org.opendaylight.yangide.ext.model.editor.editors;
import org.eclipse.core.resources.IFile;
+import org.eclipse.core.runtime.IStatus;
import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.EAttribute;
import org.opendaylight.yangide.ext.model.ModelPackage;
import org.opendaylight.yangide.ext.model.Module;
import org.opendaylight.yangide.ext.model.Node;
+import org.opendaylight.yangide.ext.model.editor.Activator;
import org.opendaylight.yangide.ext.model.editor.diagram.EditorFeatureProvider;
import org.opendaylight.yangide.ext.model.editor.util.DiagramImportSupport;
import org.opendaylight.yangide.ext.model.editor.util.LayoutUtil;
@Override
public void nodeRemoved(Node node) {
- System.out.println("Removed " + node);
+ if (Activator.getDefault().isDebugging()) {
+ Activator.log(IStatus.INFO, "Removed " + node);
+ }
PictogramElement[] elements = getDiagramTypeProvider().getFeatureProvider()
.getAllPictogramElementsForBusinessObject(node);
for (PictogramElement element : elements) {
@Override
public void nodeChanged(Node node, EObject object, Object newValue) {
- System.out.println("Changed " + node);
+ if (Activator.getDefault().isDebugging()) {
+ Activator.log(IStatus.INFO, "Changed " + node);
+ }
if (object instanceof EAttribute) {
PictogramElement pe = YangModelUIUtil.getBusinessObjectPropShape(
getDiagramTypeProvider().getFeatureProvider(), node, (EAttribute) object);
@Override
public void nodeAdded(Node parent, Node child, int position) {
- System.out.println("Added " + child);
+ if (Activator.getDefault().isDebugging()) {
+ Activator.log(IStatus.INFO, "Added " + child);
+ }
if (null == YangModelUIUtil.getBusinessObjectShape(getDiagramTypeProvider().getFeatureProvider(), child)) {
Point p = null;
if (parent instanceof Module) {
super.initializeGraphicalViewer();
GraphicalViewer graphicalViewer = getGraphicalViewer();
if (graphicalViewer != null) {
- graphicalViewer.addSelectionChangedListener(new ISelectionChangedListener() {
- @Override
- public void selectionChanged(SelectionChangedEvent event) {
- ((YangDiagramBehavior) getDiagramBehavior()).getYangPaletteBehavior()
- .updateSelection(event.getSelection());
- }
- });
+ graphicalViewer.addSelectionChangedListener(event -> ((YangDiagramBehavior) getDiagramBehavior()).getYangPaletteBehavior()
+ .updateSelection(event.getSelection()));
}
sourceSelectionUpdater = new SourceSelectionUpdater();
}
.getConnectionReferenceSubjectClass(notification.getNotifier());
if (null != type) {
getDiagramBehavior().getEditingDomain().getCommandStack()
- .execute(new RecordingCommand(getDiagramBehavior().getEditingDomain()) {
+ .execute(new RecordingCommand(getDiagramBehavior().getEditingDomain()) {
@Override
protected void doExecute() {
public void setSourceModelManager(ISourceModelManager sourceModelManager) {
((EditorFeatureProvider) getDiagramTypeProvider().getFeatureProvider())
- .setSourceModelManager(sourceModelManager);
+ .setSourceModelManager(sourceModelManager);
this.sourceModelManager = sourceModelManager;
}
*/
public void startSourceSelectionUpdater() {
GraphicalViewer graphicalViewer = getGraphicalViewer();
- if (graphicalViewer != null)
+ if (graphicalViewer != null) {
graphicalViewer.addSelectionChangedListener(sourceSelectionUpdater);
+ }
}
/**
*/
public void stopSourceSelectionUpdater() {
GraphicalViewer graphicalViewer = getGraphicalViewer();
- if (graphicalViewer != null)
+ if (graphicalViewer != null) {
graphicalViewer.removeSelectionChangedListener(sourceSelectionUpdater);
+ }
}
private class SourceSelectionUpdater implements ISelectionChangedListener {
IStructuredSelection selection = (IStructuredSelection) event.getSelection();
Object object = selection.getFirstElement();
if (object instanceof GraphitiShapeEditPart) {
- PictogramElement element = (PictogramElement) ((GraphitiShapeEditPart) object).getPictogramElement();
+ PictogramElement element = ((GraphitiShapeEditPart) object).getPictogramElement();
EObject node = Graphiti.getLinkService().getBusinessObjectForLinkedPictogramElement(element);
ASTNode moduleNode = sourceModelManager.getModuleNode((Node) node);
IRegion region = YangEditor.getSelectionRegion(moduleNode);
<arguments>
</arguments>
</buildCommand>
+ <buildCommand>
+ <name>net.sf.eclipsecs.core.CheckstyleBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
<buildCommand>
<name>org.eclipse.m2e.core.maven2Builder</name>
<arguments>
<nature>org.eclipse.m2e.core.maven2Nature</nature>
<nature>org.eclipse.pde.PluginNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
+ <nature>net.sf.eclipsecs.core.CheckstyleNature</nature>
</natures>
</projectDescription>
<arguments>
</arguments>
</buildCommand>
+ <buildCommand>
+ <name>net.sf.eclipsecs.core.CheckstyleBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
<buildCommand>
<name>org.eclipse.m2e.core.maven2Builder</name>
<arguments>
<nature>org.eclipse.m2e.core.maven2Nature</nature>
<nature>org.eclipse.pde.PluginNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
+ <nature>net.sf.eclipsecs.core.CheckstyleNature</nature>
</natures>
</projectDescription>
<arguments>
</arguments>
</buildCommand>
+ <buildCommand>
+ <name>net.sf.eclipsecs.core.CheckstyleBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
<buildCommand>
<name>org.eclipse.m2e.core.maven2Builder</name>
<arguments>
<nature>org.eclipse.m2e.core.maven2Nature</nature>
<nature>org.eclipse.pde.PluginNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
+ <nature>net.sf.eclipsecs.core.CheckstyleNature</nature>
</natures>
</projectDescription>
<projects>
</projects>
<buildSpec>
+ <buildCommand>
+ <name>net.sf.eclipsecs.core.CheckstyleBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
<buildCommand>
<name>org.eclipse.m2e.core.maven2Builder</name>
<arguments>
</buildSpec>
<natures>
<nature>org.eclipse.m2e.core.maven2Nature</nature>
+ <nature>net.sf.eclipsecs.core.CheckstyleNature</nature>
</natures>
</projectDescription>