Skip to content

Commit

Permalink
updated by feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
baslo2 committed Jul 26, 2024
1 parent c201655 commit aaf94ab
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,13 @@
import org.eclipse.jface.viewers.TableViewerColumn;
import org.eclipse.jface.window.ApplicationWindow;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.SashForm;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.MessageBox;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.ToolBar;
import org.eclipse.swt.widgets.ToolItem;
Expand Down Expand Up @@ -93,25 +95,27 @@ protected Point getInitialSize() {
@Override
protected Control createContents(Composite parent) {
Composite contentComposite = new Composite(parent, SWT.NONE);
contentComposite.setLayout(new GridLayout(2, false));
contentComposite.setLayout(new GridLayout());

Composite journalsComposite = new Composite(contentComposite, SWT.NONE);
journalsComposite.setLayoutData(new GridData(SWT.LEFT, SWT.FILL, false, true));
journalsComposite.setLayout(new GridLayout());

ToolItem b = new ToolItem(new ToolBar(journalsComposite, SWT.HORIZONTAL), SWT.PUSH);
b.setImage(ImageUtils.getImage(Images.FOLDER));
b.setToolTipText(resourceBundle.getString("open_dir"));
b.addListener(SWT.Selection, event -> {
ToolBar toolBar = new ToolBar(contentComposite, SWT.HORIZONTAL);
ToolItem openDirToolItem = new ToolItem(toolBar, SWT.PUSH);
openDirToolItem.setImage(ImageUtils.getImage(Images.FOLDER));
openDirToolItem.setToolTipText(resourceBundle.getString("open_dir"));
openDirToolItem.addListener(SWT.Selection, event -> {
File file = new File(Settings.getInstance().getBlocksJournalPath());
try {
Desktop.getDesktop().open(file);
} catch (IOException ex) {
ex.printStackTrace();
} catch (Exception ex) {
MessageBox m = new MessageBox(getShell(), SWT.ICON_ERROR);
m.setMessage(ex.getLocalizedMessage());
m.open();
}
});

filesTable = new TableViewer(journalsComposite, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL);
SashForm sashForm = new SashForm(contentComposite, SWT.HORIZONTAL);
sashForm.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));

filesTable = new TableViewer(sashForm, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL);
filesTable.getTable().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
filesTable.getTable().setHeaderVisible(true);
TableViewerColumn column = new TableViewerColumn(filesTable, SWT.NONE);
Expand All @@ -122,7 +126,7 @@ protected Control createContents(Composite parent) {
filesTable.setInput(journalFiles);
filesTable.addSelectionChangedListener(this::filesTableSelectionChanged);

Composite processesContentContainer = new Composite(contentComposite, SWT.NONE);
Composite processesContentContainer = new Composite(sashForm, SWT.BORDER);
processesContentContainer.setLayout(new GridLayout());
processesContentContainer.setLayoutData(new GridData(SWT.RIGHT, SWT.FILL, true, true));

Expand All @@ -144,6 +148,7 @@ protected Control createContents(Composite parent) {
processInfoView.hideToolBar();
processInfoView.hide();

sashForm.setWeights(25, 75);
getJournalFilesFromJournalsDir();

return super.createContents(parent);
Expand All @@ -170,7 +175,12 @@ private void getJournalFilesFromJournalsDir() {
Path blocksJournalsDirPath = PathBuilder.getInstance().getBlocksJournalsDir();
File[] files = blocksJournalsDirPath.toFile().listFiles();
if (files != null) {
List<File> filesList = Arrays.asList(files);
List<File> filesList = new ArrayList<>();;
for (File f : files) {
if (f.getName().endsWith(".xml")) {
filesList.add(f);
}
}
filesList.sort(Comparator.comparingLong(File::lastModified));
this.journalFiles.addAll(filesList);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -473,26 +473,35 @@ public void dbBlocksJournalDidCloseProcesses(List<DBBlocksJournalProcess> proces
}

private void saveBlockedProcessesToFile(List<DBBlocksJournalProcess> processes, boolean isOpenProcess) {

DBBlocksXmlStore store = getXmlStore();
List<DBBlocksJournalProcess> oldProcesses = store.readObjects();
// FIXME doesn't work with procLimit != 0
List<DBBlocksJournalProcess> result = new ArrayList<>();
if (isOpenProcess) {
processes = processes.stream()
.filter(e -> !oldProcesses.contains(e))
.collect(Collectors.toList());
if(processes.isEmpty()) {
return;
result.addAll(oldProcesses);
for (DBBlocksJournalProcess p : processes) {
if (!oldProcesses.contains(p)) {
result.add(p);
}
}
}
oldProcesses.addAll(processes);
} else {
for (DBBlocksJournalProcess p : oldProcesses) {
if (!processes.contains(p)) {
result.add(p);
}
}
result.addAll(processes);
}

if (procLimit != 0) {
for (List<DBBlocksJournalProcess> subList : chopped(oldProcesses, procLimit)) {
for (List<DBBlocksJournalProcess> subList : chopped(result, procLimit)) {
getXmlStore().writeObjects(subList);
part++;
}
part--;
} else {
store.writeObjects(oldProcesses);
store.writeObjects(result);
}
}

Expand Down

0 comments on commit aaf94ab

Please sign in to comment.