Commit a71d6e09 authored by Johannes Roith's avatar Johannes Roith

Add infrastructure for status reporting. Views need this to update their error status correctly,

if any required jobs fail.
parent 6d668158
......@@ -63,6 +63,13 @@ public class Controller {
Debugger.getInstance(editor.getDocument()); // TODO: why is this here?
}
public void notifyObserversOfJobStatus(JobsToDo affectedJob, JobStatus status) {
synchronized (controllerObservers) {
for (IRegisterForControllerChanges observer : controllerObservers)
observer.jobStatusChanged(affectedJob, status);
}
}
private void addJobToDo(JobsToDo job) {
synchronized (jobElements) {
jobElements.add(job);
......
......@@ -129,6 +129,9 @@ public class DocumentDidChangeJob extends Job {
e.printStackTrace();
}
} else {
// TODO: we need to notify listeners THAT/WHY the call failed.
return Status.CANCEL_STATUS;
}
}
......@@ -145,6 +148,9 @@ public class DocumentDidChangeJob extends Job {
* + "because the parser has reported errors."); TODO:
* REMOVE
*/
// TODO: we need to notify listeners THAT/WHY the call failed.
}
} catch (internal_error e) {
e.printStackTrace();
......@@ -162,6 +168,8 @@ public class DocumentDidChangeJob extends Job {
e.printStackTrace();
}
} else {
// TODO: we need to notify listeners THAT/WHY the call failed.
return Status.CANCEL_STATUS;
}
}
......
......@@ -6,6 +6,14 @@ import de.tum.in.www2.cupplugin.controller.Controller.JobsToDo;
public interface IRegisterForControllerChanges {
/**
* Registered controller observers are queried before the job pipeline
* is run and can indicate which jobs they required to be executed.
* Observers who do not depend on the data but simply perform e.g. logging
* activities should return an empty set.
*/
EnumSet<JobsToDo> getRequiredJobs();
void jobStatusChanged(JobsToDo affectedJob, JobStatus status);
}
package de.tum.in.www2.cupplugin.controller;
public class JobStatus {
private boolean failed;
public boolean hasFailed() {
return failed;
}
public JobStatus(boolean failed) {
this.failed = failed;
}
}
......@@ -37,6 +37,7 @@ import de.in.tum.www2.cup.ast.Package;
import de.tum.in.www2.cupplugin.controller.Controller.JobsToDo;
import de.tum.in.www2.cupplugin.controller.Controller;
import de.tum.in.www2.cupplugin.controller.IRegisterForControllerChanges;
import de.tum.in.www2.cupplugin.controller.JobStatus;
import de.tum.in.www2.cupplugin.model.*;
// TODO: try changing to IContentOutlinePage and using a virtual view!
......@@ -563,4 +564,10 @@ public class CupContentOutlinePage extends ContentOutlinePage implements
}
@Override
public void jobStatusChanged(JobsToDo affectedJob, JobStatus status) {
// TODO Auto-generated method stub
}
}
......@@ -45,6 +45,7 @@ import de.in.tum.www2.java.JavaSymbol;
import de.tum.in.www2.cupplugin.PluginUtility;
import de.tum.in.www2.cupplugin.controller.Controller.JobsToDo;
import de.tum.in.www2.cupplugin.controller.IRegisterForControllerChanges;
import de.tum.in.www2.cupplugin.controller.JobStatus;
import de.tum.in.www2.cupplugin.model.ICupParserASTChangeObserver;
import de.tum.in.www2.cupplugin.model.Model;
import de.tum.in.www2.cupplugin.syntax.CupTokenScanner;
......@@ -147,6 +148,11 @@ public class CupSourceViewerConfiguration extends SourceViewerConfiguration {
}
}
@Override
public void jobStatusChanged(JobsToDo affectedJob, JobStatus status) {
// no nothing.
}
}
@Override
......
......@@ -29,6 +29,7 @@ import de.tum.in.www2.cupplugin.PluginUtility;
import de.tum.in.www2.cupplugin.controller.Controller;
import de.tum.in.www2.cupplugin.controller.Controller.JobsToDo;
import de.tum.in.www2.cupplugin.controller.IRegisterForControllerChanges;
import de.tum.in.www2.cupplugin.controller.JobStatus;
import de.tum.in.www2.cupplugin.model.ICupParserASTChangeObserver;
import de.tum.in.www2.cupplugin.model.Model;
......@@ -240,4 +241,9 @@ public class CupTextEditor extends TextEditor
}
}
@Override
public void jobStatusChanged(JobsToDo affectedJob, JobStatus status) {
// do nothing.
}
}
......@@ -19,6 +19,7 @@ import de.in.tum.www2.cup.ast.TypedNonTerminalDeclaration;
import de.in.tum.www2.cup.ast.TypedTerminalDeclaration;
import de.tum.in.www2.cupplugin.controller.Controller.JobsToDo;
import de.tum.in.www2.cupplugin.controller.IRegisterForControllerChanges;
import de.tum.in.www2.cupplugin.controller.JobStatus;
import de.tum.in.www2.cupplugin.model.ICupParserASTChangeObserver;
import de.tum.in.www2.cupplugin.model.Model;
......@@ -97,6 +98,11 @@ public class CupTextHover implements ITextHover,
return EnumSet.of(JobsToDo.parseCode);
}
@Override
public void jobStatusChanged(JobsToDo affectedJob, JobStatus status) {
// do nothing.
}
@Override
public void modelChanged(Model model) {
this.ast = model.getAstModel();
......
......@@ -29,6 +29,7 @@ import de.in.tum.www2.cup.internal.parse_action_table;
import de.tum.in.www2.cupplugin.controller.Controller;
import de.tum.in.www2.cupplugin.controller.Controller.JobsToDo;
import de.tum.in.www2.cupplugin.controller.IRegisterForControllerChanges;
import de.tum.in.www2.cupplugin.controller.JobStatus;
import de.tum.in.www2.cupplugin.editors.CupTextEditor;
import de.tum.in.www2.cupplugin.editors.ICupEditorPageVisibility;
import de.tum.in.www2.cupplugin.editors.Jumper;
......@@ -249,4 +250,10 @@ public class CupActionTableView extends FailableView implements ICupEditorPageVi
}
}
@Override
public void jobStatusChanged(JobsToDo affectedJob, JobStatus status) {
// TODO Auto-generated method stub
}
}
......@@ -75,6 +75,7 @@ import de.tum.in.www2.cupplugin.Colors;
import de.tum.in.www2.cupplugin.controller.Controller;
import de.tum.in.www2.cupplugin.controller.Controller.JobsToDo;
import de.tum.in.www2.cupplugin.controller.IRegisterForControllerChanges;
import de.tum.in.www2.cupplugin.controller.JobStatus;
import de.tum.in.www2.cupplugin.editors.ICupEditorPageVisibility;
import de.tum.in.www2.cupplugin.editors.CupTextEditor;
import de.tum.in.www2.cupplugin.editors.Jumper;
......@@ -819,4 +820,10 @@ public class CupConflictGraphView extends FailableView
return requestedJobs;
}
@Override
public void jobStatusChanged(JobsToDo affectedJob, JobStatus status) {
// TODO Auto-generated method stub
}
}
......@@ -37,6 +37,7 @@ import de.tum.in.www2.cupplugin.Pair;
import de.tum.in.www2.cupplugin.controller.Controller.JobsToDo;
import de.tum.in.www2.cupplugin.controller.Controller;
import de.tum.in.www2.cupplugin.controller.IRegisterForControllerChanges;
import de.tum.in.www2.cupplugin.controller.JobStatus;
import de.tum.in.www2.cupplugin.editors.CupTextEditor;
import de.tum.in.www2.cupplugin.editors.ICupEditorPageVisibility;
import de.tum.in.www2.cupplugin.editors.Jumper;
......@@ -441,4 +442,14 @@ public class CupConflictsView extends FailableView implements ICupEditorPageVisi
return requestedJobs;
}
@Override
public void jobStatusChanged(JobsToDo affectedJob, JobStatus status) {
// TODO: if the job failed, we can show an appropriate error here.
// and update the current status message.
}
}
......@@ -20,6 +20,7 @@ import de.in.tum.www2.cup.ast.ParserResult;
import de.tum.in.www2.cupplugin.controller.Controller.JobsToDo;
import de.tum.in.www2.cupplugin.controller.Controller;
import de.tum.in.www2.cupplugin.controller.IRegisterForControllerChanges;
import de.tum.in.www2.cupplugin.controller.JobStatus;
import de.tum.in.www2.cupplugin.editors.CupTextEditor;
import de.tum.in.www2.cupplugin.editors.ICupEditorPageVisibility;
import de.tum.in.www2.cupplugin.editors.Jumper;
......@@ -204,4 +205,10 @@ public class CupOverviewView extends FailableView implements IRegisterForControl
}
@Override
public void jobStatusChanged(JobsToDo affectedJob, JobStatus status) {
// TODO Auto-generated method stub
}
}
......@@ -83,6 +83,7 @@ import de.tum.in.www2.cupplugin.Colors;
import de.tum.in.www2.cupplugin.controller.Controller.JobsToDo;
import de.tum.in.www2.cupplugin.controller.Controller;
import de.tum.in.www2.cupplugin.controller.IRegisterForControllerChanges;
import de.tum.in.www2.cupplugin.controller.JobStatus;
import de.tum.in.www2.cupplugin.editors.ICupEditorPageVisibility;
import de.tum.in.www2.cupplugin.editors.CupTextEditor;
import de.tum.in.www2.cupplugin.editors.Jumper;
......@@ -1006,4 +1007,10 @@ public class CupReduceGraphView extends FailableView
}
return requestedJobs;
}
@Override
public void jobStatusChanged(JobsToDo affectedJob, JobStatus status) {
// TODO Auto-generated method stub
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment