Clean up code, Add minimal target
This commit is contained in:
parent
a309eb0838
commit
08bcf39865
40
eclipse2.target
Normal file
40
eclipse2.target
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||||
|
<?pde version="3.8"?>
|
||||||
|
<target includeMode="feature" name="Minimal">
|
||||||
|
<content>
|
||||||
|
<plugins>
|
||||||
|
</plugins>
|
||||||
|
<features>
|
||||||
|
<feature id="org.eclipse.rcp"/>
|
||||||
|
<feature id="org.eclipse.platform"/>
|
||||||
|
<feature id="org.eclipse.e4.rcp"/>
|
||||||
|
</features>
|
||||||
|
</content>
|
||||||
|
<locations>
|
||||||
|
<location path="${eclipse_home}" type="Directory"/>
|
||||||
|
<location includeDependencyDepth="none" includeDependencyScopes="compile" includeSource="true" missingManifest="generate" type="Maven">
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>me.mrletsplay</groupId>
|
||||||
|
<artifactId>ShareLib</artifactId>
|
||||||
|
<version>1.0-SNAPSHOT</version>
|
||||||
|
<type>jar</type>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.java-websocket</groupId>
|
||||||
|
<artifactId>Java-WebSocket</artifactId>
|
||||||
|
<version>1.5.6</version>
|
||||||
|
<type>jar</type>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
</location>
|
||||||
|
</locations>
|
||||||
|
<includeBundles>
|
||||||
|
<plugin id="wrapped.me.mrletsplay.ShareLib"/>
|
||||||
|
<plugin id="Java-WebSocket"/>
|
||||||
|
<feature id="org.eclipse.e4.rcp"/>
|
||||||
|
<feature id="org.eclipse.rcp"/>
|
||||||
|
<feature id="org.eclipse.platform"/>
|
||||||
|
<plugin id="javax.inject"/>
|
||||||
|
</includeBundles>
|
||||||
|
</target>
|
@ -173,7 +173,6 @@ public class ShareClient extends AbstractUIPlugin implements MessageListener, Di
|
|||||||
@Override
|
@Override
|
||||||
public void onMessage(Message message) {
|
public void onMessage(Message message) {
|
||||||
Display.getDefault().asyncExec(() -> {
|
Display.getDefault().asyncExec(() -> {
|
||||||
System.out.println("Got: " + message);
|
|
||||||
if (message instanceof PeerJoinMessage join) {
|
if (message instanceof PeerJoinMessage join) {
|
||||||
activeSession.getPeers().add(new Peer(join.peerName(), join.peerSiteID()));
|
activeSession.getPeers().add(new Peer(join.peerName(), join.peerSiteID()));
|
||||||
updateView();
|
updateView();
|
||||||
|
@ -39,10 +39,6 @@ public class ShareClientDocumentListener implements IDocumentListener {
|
|||||||
|
|
||||||
if(ignoreChanges) return;
|
if(ignoreChanges) return;
|
||||||
|
|
||||||
System.out.println("UPDATE ON THREAD " + Thread.currentThread());
|
|
||||||
|
|
||||||
// FIXME: bug somewhere here, can cause discrepancies in local editor when editing while changes are coming in
|
|
||||||
|
|
||||||
ShareSession session = ShareClient.getDefault().getActiveSession();
|
ShareSession session = ShareClient.getDefault().getActiveSession();
|
||||||
if(session == null) return;
|
if(session == null) return;
|
||||||
|
|
||||||
|
@ -8,7 +8,6 @@ import org.eclipse.core.resources.IFile;
|
|||||||
import org.eclipse.core.resources.IProject;
|
import org.eclipse.core.resources.IProject;
|
||||||
import org.eclipse.jface.text.IDocument;
|
import org.eclipse.jface.text.IDocument;
|
||||||
import org.eclipse.ui.IEditorInput;
|
import org.eclipse.ui.IEditorInput;
|
||||||
import org.eclipse.ui.IEditorPart;
|
|
||||||
import org.eclipse.ui.IPartListener2;
|
import org.eclipse.ui.IPartListener2;
|
||||||
import org.eclipse.ui.IWorkbenchPart;
|
import org.eclipse.ui.IWorkbenchPart;
|
||||||
import org.eclipse.ui.IWorkbenchPartReference;
|
import org.eclipse.ui.IWorkbenchPartReference;
|
||||||
@ -34,11 +33,9 @@ public class ShareClientPartListener implements IPartListener2 {
|
|||||||
|
|
||||||
public void addDocumentListener(IWorkbenchPartReference partRef) {
|
public void addDocumentListener(IWorkbenchPartReference partRef) {
|
||||||
IWorkbenchPart part = partRef.getPart(false);
|
IWorkbenchPart part = partRef.getPart(false);
|
||||||
if(!(part instanceof IEditorPart)) return;
|
if(!(part instanceof ITextEditor)) return;
|
||||||
IEditorPart editor = (IEditorPart) part;
|
ITextEditor textEditor = (ITextEditor) part;
|
||||||
if(!(editor instanceof ITextEditor)) return;
|
IEditorInput editorInput = textEditor.getEditorInput();
|
||||||
ITextEditor textEditor = (ITextEditor) editor;
|
|
||||||
IEditorInput editorInput = editor.getEditorInput();
|
|
||||||
if(!(editorInput instanceof FileEditorInput)) return;
|
if(!(editorInput instanceof FileEditorInput)) return;
|
||||||
FileEditorInput fileEditorInput = (FileEditorInput) editorInput;
|
FileEditorInput fileEditorInput = (FileEditorInput) editorInput;
|
||||||
IDocument document = textEditor.getDocumentProvider().getDocument(editorInput);
|
IDocument document = textEditor.getDocumentProvider().getDocument(editorInput);
|
||||||
@ -47,10 +44,31 @@ public class ShareClientPartListener implements IPartListener2 {
|
|||||||
IProject project = file.getProject();
|
IProject project = file.getProject();
|
||||||
|
|
||||||
Path filePath = project.getLocation().toPath().relativize(file.getLocation().toPath());
|
Path filePath = project.getLocation().toPath().relativize(file.getLocation().toPath());
|
||||||
// FIXME: this should probably just store an IProject with a relative path
|
|
||||||
ProjectAndPath relPath = new ProjectAndPath(project, filePath.toString());
|
ProjectAndPath relPath = new ProjectAndPath(project, filePath.toString());
|
||||||
System.out.println("Opened editor: " + relPath);
|
|
||||||
document.addDocumentListener(createListener(relPath, document));
|
document.addDocumentListener(createListener(relPath, document));
|
||||||
|
System.out.println("Opened editor: " + relPath);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void removeDocumentListener(IWorkbenchPartReference partRef) {
|
||||||
|
IWorkbenchPart part = partRef.getPart(false);
|
||||||
|
if(!(part instanceof ITextEditor)) return;
|
||||||
|
ITextEditor textEditor = (ITextEditor) part;
|
||||||
|
IEditorInput editorInput = textEditor.getEditorInput();
|
||||||
|
if(!(editorInput instanceof FileEditorInput)) return;
|
||||||
|
FileEditorInput fileEditorInput = (FileEditorInput) editorInput;
|
||||||
|
IDocument document = textEditor.getDocumentProvider().getDocument(editorInput);
|
||||||
|
|
||||||
|
IFile file = fileEditorInput.getFile();
|
||||||
|
IProject project = file.getProject();
|
||||||
|
|
||||||
|
Path filePath = project.getLocation().toPath().relativize(file.getLocation().toPath());
|
||||||
|
ProjectAndPath relPath = new ProjectAndPath(project, filePath.toString());
|
||||||
|
ShareClientDocumentListener listener = getListener(relPath);
|
||||||
|
if(listener == null) return;
|
||||||
|
|
||||||
|
document.removeDocumentListener(listener);
|
||||||
|
listeners.remove(relPath);
|
||||||
|
System.out.println("Closed editor: " + relPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -63,10 +81,19 @@ public class ShareClientPartListener implements IPartListener2 {
|
|||||||
addDocumentListener(partRef);
|
addDocumentListener(partRef);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void partClosed(IWorkbenchPartReference partRef) {
|
||||||
|
removeDocumentListener(partRef);
|
||||||
|
}
|
||||||
|
|
||||||
public Map<ProjectAndPath, ShareClientDocumentListener> getListeners() {
|
public Map<ProjectAndPath, ShareClientDocumentListener> getListeners() {
|
||||||
return listeners;
|
return listeners;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ShareClientDocumentListener getListener(ProjectAndPath path) {
|
||||||
|
return listeners.get(path);
|
||||||
|
}
|
||||||
|
|
||||||
public ShareClientDocumentListener getListener(ProjectRelativePath path) {
|
public ShareClientDocumentListener getListener(ProjectRelativePath path) {
|
||||||
ShareSession session = ShareClient.getDefault().getActiveSession();
|
ShareSession session = ShareClient.getDefault().getActiveSession();
|
||||||
if(session == null) return null;
|
if(session == null) return null;
|
||||||
|
@ -66,7 +66,6 @@ public class ShareView extends ViewPart {
|
|||||||
@Override
|
@Override
|
||||||
public void init(IViewSite site) throws PartInitException {
|
public void init(IViewSite site) throws PartInitException {
|
||||||
super.init(site);
|
super.init(site);
|
||||||
System.out.println(ShareClient.getDefault());
|
|
||||||
ShareClient.getDefault().setView(this);
|
ShareClient.getDefault().setView(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user