-
Notifications
You must be signed in to change notification settings - Fork 382
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
jarek/7057: %classpath add results as HTML widget (#7212)
- Loading branch information
1 parent
7408e60
commit dc76805
Showing
20 changed files
with
363 additions
and
130 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/* | ||
* Copyright 2017 TWO SIGMA OPEN SOURCE, LLC | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
const widgets = require('./widgets'); | ||
|
||
class BxHTMLModel extends widgets.HTMLModel { | ||
defaults() { | ||
return { | ||
...super.defaults(), | ||
_view_name: "BxHTMLView", | ||
_model_name: "BxHTMLModel", | ||
_model_module: 'beakerx', | ||
_view_module: 'beakerx', | ||
_model_module_version: BEAKERX_MODULE_VERSION, | ||
_view_module_version: BEAKERX_MODULE_VERSION | ||
}; | ||
} | ||
} | ||
|
||
class BxHTMLView extends widgets.HTMLView { | ||
render() { | ||
super.render(); | ||
this.content.style.lineHeight = "20px"; | ||
this.content.style.fontSize = "14px"; | ||
} | ||
} | ||
|
||
export default { | ||
BxHTMLModel, | ||
BxHTMLView | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
66 changes: 0 additions & 66 deletions
66
kernel/base/src/main/java/com/twosigma/beakerx/kernel/handler/MagicCommandExecutor.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
81 changes: 81 additions & 0 deletions
81
...c/main/java/com/twosigma/beakerx/kernel/magic/command/outcome/MagicCommandOutputHTML.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
/* | ||
* Copyright 2018 TWO SIGMA OPEN SOURCE, LLC | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package com.twosigma.beakerx.kernel.magic.command.outcome; | ||
|
||
import com.twosigma.beakerx.TryResult; | ||
import com.twosigma.beakerx.jvm.object.SimpleEvaluationObject; | ||
import com.twosigma.beakerx.kernel.KernelFunctionality; | ||
import com.twosigma.beakerx.kernel.msg.MessageCreator; | ||
import com.twosigma.beakerx.message.Message; | ||
import com.twosigma.beakerx.mimetype.MIMEContainer; | ||
import com.twosigma.beakerx.widget.BxHTML; | ||
|
||
import java.util.Optional; | ||
|
||
import static com.twosigma.beakerx.util.Preconditions.checkNotNull; | ||
|
||
public class MagicCommandOutputHTML implements MagicCommandOutcomeItem { | ||
|
||
private final MIMEContainer mineContainer; | ||
private MagicCommandOutput.Status status; | ||
|
||
public MagicCommandOutputHTML(MagicCommandOutput.Status status, String text) { | ||
this.mineContainer = MIMEContainer.HTML(checkNotNull(text)); | ||
this.status = checkNotNull(status); | ||
} | ||
|
||
@Override | ||
public Optional<MIMEContainer> getMIMEContainer() { | ||
return Optional.of(this.mineContainer); | ||
} | ||
|
||
@Override | ||
public Status getStatus() { | ||
return this.status; | ||
} | ||
|
||
@Override | ||
public TryResult getResult() { | ||
return null; | ||
} | ||
|
||
@Override | ||
public SimpleEvaluationObject getSimpleEvaluationObject() { | ||
return null; | ||
} | ||
|
||
@Override | ||
public void sendRepliesWithStatus(KernelFunctionality kernel, Message message, int executionCount) { | ||
if (getStatus().equals(MagicCommandOutcomeItem.Status.OK)) { | ||
sendHTML(message); | ||
kernel.send(MessageCreator.buildReplyWithOkStatus(message, executionCount)); | ||
} else { | ||
sendHTML(message); | ||
kernel.send(MessageCreator.buildReplyWithErrorStatus(message, executionCount)); | ||
} | ||
} | ||
|
||
private void sendHTML(Message message) { | ||
BxHTML value = new BxHTML(message); | ||
value.setValue(getMIMEContainer().get().getData()); | ||
value.display(); | ||
} | ||
|
||
@Override | ||
public void sendMagicCommandOutcome(KernelFunctionality kernel, Message message, int executionCount) { | ||
sendHTML(message); | ||
} | ||
} |
Oops, something went wrong.