Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion gui/browserv7/src/RBrowsableSysFile.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ std::unique_ptr<RLevelIter> SysFileElement::GetChildsIter()

std::string SysFileElement::GetContent(const std::string &kind)
{
if ((kind == "text"s) && (RSysDirLevelIter::GetFileIcon(GetName()) == "sap-icon://document-text"s)) {
if ((kind == "text"s) && ((RSysDirLevelIter::GetFileIcon(GetName()) == "sap-icon://document-text"s) || RSysDirLevelIter::GetFileIcon(GetName()) == "sap-icon://document"s)) {
std::ifstream t(GetFullName());
return std::string(std::istreambuf_iterator<char>(t), std::istreambuf_iterator<char>());
}
Expand Down
81 changes: 66 additions & 15 deletions ui5/browser/controller/Browser.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ sap.ui.define(['sap/ui/core/Component',
"sap/ui/core/Fragment",
"sap/m/Link",
"sap/ui/codeeditor/CodeEditor",
"sap/m/TabContainerItem"
"sap/m/TabContainerItem",
],function(Component, Controller, CoreControl, CoreIcon, XMLView, mText, mCheckBox, MessageBox, MessageToast, TabContainerItem,
Splitter, ResizeHandler, HorizontalLayout, tableColumn, File, JSONModel, BrowserModel, Fragment, Link, CodeEditor) {

Expand Down Expand Up @@ -161,6 +161,12 @@ sap.ui.define(['sap/ui/core/Component',
modified: false
}));

let splitterUpperContent = this.getView().byId("defaultCodeEditor").getContent()[0].mAggregations.contentAreas[0].getContent();
splitterUpperContent[0].attachChange(this.onChangeFile, this);
splitterUpperContent[1].attachPress(this.onSaveAs, this);
splitterUpperContent[2].attachPress(this.onSaveFile, this);
splitterUpperContent[3].attachPress(this.onRunMacro, this);

defaultCodeEditor.attachChange( function() {
this.getModel().setProperty("/modified", true);
});
Expand Down Expand Up @@ -239,7 +245,7 @@ sap.ui.define(['sap/ui/core/Component',

/** @brief Handle the "Browse..." button press event */
onChangeFile: function(oEvent) {
var oEditor = this.getView().byId("aCodeEditor");
var oEditor = this.getSelectedCodeEditorTab();
var oModel = oEditor.getModel();
var oReader = new FileReader();
oReader.onload = function() {
Expand Down Expand Up @@ -525,6 +531,7 @@ sap.ui.define(['sap/ui/core/Component',
if (prop && prop.fullpath) {
fullpath = prop.fullpath.substr(1, prop.fullpath.length-2);
var dirname = fullpath.substr(0, fullpath.lastIndexOf('/'));

if (dirname.endsWith(".root")) {
let split = fullpath.split("/");
let model = row.getModel().mainModel;
Expand All @@ -550,13 +557,24 @@ sap.ui.define(['sap/ui/core/Component',
}

return this.websocket.Send('DBLCLK: ["' + fullpath + '","' + drawingOptions + '"]' );
} else if ( fullpath.endsWith(".png") ||
fullpath.endsWith(".jpg") ||
fullpath.endsWith(".bmp") ||
fullpath.endsWith(".gif") ||
fullpath.endsWith(".ico") ||
// fullpath.endsWith(".svg") ||
fullpath.endsWith(".webp")) {
let oTab = this.getSelectedImageViewer();
if (oTab !== -1) {
oTab.setAdditionalText(fullpath);
return this.websocket.Send('DBLCLK:' + fullpath);
}
}
}

let codeEditor = this.getSelectedCodeEditorTab();
if(codeEditor !== -1) {
var oModel = codeEditor.getModel();
console.log(oModel);
oModel.setProperty("/fullpath", fullpath);
this.getSaveButtonFromCodeEditor(codeEditor).setEnabled(true);
var filename = fullpath.substr(fullpath.lastIndexOf('/') + 1);
Expand Down Expand Up @@ -597,17 +615,7 @@ sap.ui.define(['sap/ui/core/Component',
getSelectedCodeEditorTab: function() {
let oTabItemString = this.getView().byId("myTabContainer").getSelectedItem();

// console.log(oTabItemString);
// if(oTabItemString.indexOf("__item") !== -1) {
// oTabItemString = oTabItemString.substr(6);
// oTabItemString = parseInt(oTabItemString);
// oTabItemString++;
// oTabItemString = "__item" + oTabItemString;
// }
// console.log(oTabItemString);

let oTabItem = sap.ui.getCore().byId(oTabItemString);
console.log(oTabItem);
if(oTabItem) {
let oTabItemContent = oTabItem.getContent();
for (let i=0; i<oTabItemContent[0].mAggregations.contentAreas.length; i++) {
Expand All @@ -621,6 +629,19 @@ sap.ui.define(['sap/ui/core/Component',
return -1;
},

getSelectedImageViewer: function() {
let oTabItemString = this.getView().byId("myTabContainer").getSelectedItem();

let oTabItem = sap.ui.getCore().byId(oTabItemString);

if (oTabItem.getName() === "Image Viewer") {
return oTabItem;
}

MessageToast.show("Sorry, you need to select an image viewer tab", {duration: 1500});
return -1;
},

getSaveButtonFromCodeEditor: function(oCodeEditor) {
let oSplitter = oCodeEditor.getParent();
let oToolBar = oSplitter.mAggregations.contentAreas[0];
Expand Down Expand Up @@ -665,7 +686,13 @@ sap.ui.define(['sap/ui/core/Component',
}
break;
case "FIMG": // image file read
console.log("Got image " + msg.substr(0,50) + "...");
let oTab = this.getSelectedImageViewer();
if(oTab !== -1) {
let oContent = sap.ui.getCore().byId(this.getView().byId("myTabContainer").getSelectedItem());
let oImage = oContent.getContent()[0].getItems()[0];

oImage.setSrc(msg);
}
break;
case "CANVS": // canvas created by server, need to establish connection
var arr = JSON.parse(msg);
Expand Down Expand Up @@ -814,6 +841,7 @@ sap.ui.define(['sap/ui/core/Component',
sap.ui.getCore().byId("NewTabR6").attachPress(this, this.newRootXCanvas);
sap.ui.getCore().byId("NewTabR7").attachPress(this, this.newRootXCanvas);
sap.ui.getCore().byId("NewTabCE").attachPress(this, this.newCodeEditor);
sap.ui.getCore().byId("NewTabIV").attachPress(this, this.newImageViewer);
}
this._actionSheet.openBy(oButton);
},
Expand All @@ -838,7 +866,6 @@ sap.ui.define(['sap/ui/core/Component',

// TODO: use proper openui5 methods to get aggregation
let editor = oFragment.mAggregations.contentAreas[1];
console.log(oFragment);

editor.setModel(new JSONModel({
code: "",
Expand All @@ -856,9 +883,33 @@ sap.ui.define(['sap/ui/core/Component',

oTabContainer.addItem(tabContainerItem);

let splitterUpperContent = tabContainerItem.getContent()[0].mAggregations.contentAreas[0].getContent();
splitterUpperContent[0].attachChange(myThis.onChangeFile, myThis);
splitterUpperContent[1].attachPress(myThis.onSaveAs, myThis);
splitterUpperContent[2].attachPress(myThis.onSaveFile, myThis);
splitterUpperContent[3].attachPress(myThis.onRunMacro, myThis);

oTabContainer.setSelectedItem(tabContainerItem);
},

newImageViewer: async function(oEvent, myThis) {
let oTabContainer = myThis.getView().byId("myTabContainer");

let tabContainerItem = new TabContainerItem({
icon: "sap-icon://background",
name:"Image Viewer",
additionalText: "untitled"
});

await Fragment.load({name: "rootui5.browser.view.imageviewer"}).then(function (oFragment) {
tabContainerItem.removeAllContent();
tabContainerItem.addContent(oFragment);
});

oTabContainer.addItem(tabContainerItem);
oTabContainer.setSelectedItem(tabContainerItem);
},

/** process initial message, now it is list of existing canvases */
processInitMsg: function(msg) {
this.websocket.Send('GETWORKDIR:'); // Update the breadcrumbs
Expand Down
5 changes: 5 additions & 0 deletions ui5/browser/view/imageviewer.fragment.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<core:FragmentDefinition xmlns="sap.m" xmlns:core="sap.ui.core" xmlns:l="sap.ui.layout" xmlns:e="sap.ui.codeeditor" xmlns:u="sap.ui.unified">
<HBox alignContent="Center" alignItems="Center" justifyContent="Center" height="100%" width="100%">
<Image src="" densityAware="false" />
</HBox>
</core:FragmentDefinition>