Skip to content

Commit

Permalink
add a refresh action to the navigation
Browse files Browse the repository at this point in the history
(just in case...)
  • Loading branch information
msrocka committed Jun 11, 2021
1 parent cf894e9 commit 28c2037
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 39 deletions.
3 changes: 1 addition & 2 deletions src/app/navi/NaviSync.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@ public void run() {
continue;
sync(node, elem);
}
Navigator.refreshFolders();
Navigator.refreshViewer();
Navigator.refreshAll();
}

private void sync(Node node, NavigationElement parent) {
Expand Down
77 changes: 41 additions & 36 deletions src/app/navi/NavigationMenu.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,35 +47,40 @@ public void fillActionBars(IActionBars actionBars) {

if (actionBars == null || menuAdded)
return;
IMenuManager menu = actionBars.getMenuManager();
var menu = actionBars.getMenuManager();
if (menu == null)
return;

Action collapseAll = Actions.create(
"Collapse all", Icon.COLLAPSE.des(), () -> {
CommonViewer viewer = Navigator.getViewer();
if (viewer != null) {
viewer.collapseAll();
}
});
var collapseAll = Actions.create(
"Collapse all", Icon.COLLAPSE.des(), () -> {
CommonViewer viewer = Navigator.getViewer();
if (viewer != null) {
viewer.collapseAll();
}
});
menu.add(collapseAll);

Action expandAll = Actions.create(
"Expand all", Icon.EXPAND.des(), () -> {
CommonViewer viewer = Navigator.getViewer();
if (viewer != null) {
viewer.expandAll();
}
});
var expandAll = Actions.create(
"Expand all", Icon.EXPAND.des(), () -> {
CommonViewer viewer = Navigator.getViewer();
if (viewer != null) {
viewer.expandAll();
}
});
menu.add(expandAll);

var refresh = Actions.create(
"Refresh", Icon.RELOAD.des(), Navigator::refreshAll);
menu.add(refresh);

menuAdded = true;
}

@Override
public void fillContextMenu(IMenuManager menu) {
ActionContext con = getContext();
IStructuredSelection s = (IStructuredSelection) con
.getSelection();
.getSelection();
List<NavigationElement> elements = Viewers.getAll(s);
if (elements.isEmpty())
return;
Expand Down Expand Up @@ -108,7 +113,7 @@ public void fillContextMenu(IMenuManager menu) {
if (first instanceof ProfileElement) {
ProfileElement pe = (ProfileElement) first;
menu.add(Actions.create(M.Open, Icon.OPEN.des(),
() -> ProfileEditor.open(pe.profile)));
() -> ProfileEditor.open(pe.profile)));
menu.add(new ProfileExportAction(pe.profile));
menu.add(new ProfileDeleteAction(pe.profile));
}
Expand All @@ -121,23 +126,23 @@ public void fillContextMenu(IMenuManager menu) {
if (first instanceof ConnectionElement) {
ConnectionElement e = (ConnectionElement) first;
menu.add(Actions.create(M.Open, Icon.OPEN.des(),
() -> ConnectionEditor.open(e.con)));
() -> ConnectionEditor.open(e.con)));
menu.add(Actions.create(M.DownloadEPDProfiles,
Icon.DOWNLOAD.des(), () -> {
EpdProfileDownload.runInUI(e.con.url);
}));
Icon.DOWNLOAD.des(), () -> {
EpdProfileDownload.runInUI(e.con.url);
}));
menu.add(new ConnectionDeleteAction(e));
}
}

private void forRef(RefElement e, IMenuManager menu) {
menu.add(Actions.create(M.Open, Icon.OPEN.des(),
() -> Editors.open(e.ref)));
() -> Editors.open(e.ref)));
menu.add(Actions.create(M.Validate, Icon.OK.des(),
() -> ValidationDialog.open(e.ref)));
() -> ValidationDialog.open(e.ref)));
menu.add(new DuplicateAction(e));
menu.add(Actions.create(M.Export, Icon.EXPORT.des(),
() -> ExportDialog.open(e.ref)));
() -> ExportDialog.open(e.ref)));
menu.add(new RefDeleteAction(e));
}

Expand All @@ -155,7 +160,7 @@ private void forFile(FileElement e, IMenuManager menu) {

private void categorySync(IMenuManager menu, String systemName) {
MenuManager syncMenu = new MenuManager(M.Update,
Icon.DOWNLOAD.des(), "UpdateClassifications");
Icon.DOWNLOAD.des(), "UpdateClassifications");
menu.add(syncMenu);
for (SodaConnection con : Connections.get()) {
syncMenu.add(new ClassificationSync(con, systemName));
Expand All @@ -167,17 +172,17 @@ private void open(FileElement e, IMenuManager menu) {
return;
Runnable fn = null;
switch (e.getType()) {
case CLASSIFICATION:
fn = () -> ClassificationEditor.open(e.file);
break;
case LOCATION:
fn = () -> LocationEditor.open(e.file);
break;
case DOC:
fn = () -> UI.open(e.file);
break;
default:
break;
case CLASSIFICATION:
fn = () -> ClassificationEditor.open(e.file);
break;
case LOCATION:
fn = () -> LocationEditor.open(e.file);
break;
case DOC:
fn = () -> UI.open(e.file);
break;
default:
break;
}
if (fn == null)
return;
Expand Down
2 changes: 1 addition & 1 deletion src/app/rcp/ActionBar.java
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ protected void fillMenuBar(IMenuManager menuBar) {
}

private MenuManager extrasMenu() {
MenuManager m = new MenuManager(M.Extras,
var m = new MenuManager(M.Extras,
IWorkbenchActionConstants.M_EDIT);
m.add(Actions.create(M.Settings,
Icon.SETTINGS.des(), SettingsPage::open));
Expand Down

0 comments on commit 28c2037

Please sign in to comment.