-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e06189c
commit 32e0b64
Showing
13 changed files
with
155 additions
and
85 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 |
---|---|---|
@@ -1,5 +1,5 @@ | ||
/* | ||
Copyright 2012-2023 Michael Pozhidaev <[email protected]> | ||
Copyright 2012-2024 Michael Pozhidaev <[email protected]> | ||
This file is part of LUWRAIN. | ||
|
@@ -29,6 +29,7 @@ public final class App extends AppBase<Strings> implements MonoApp | |
|
||
private Hooks hooks = null; | ||
private MailStoring storing = null; | ||
private Data data = null; | ||
private Conv conv = null; | ||
private MainLayout mainLayout = null; | ||
private StartingLayout startingLayout = null; | ||
|
@@ -41,15 +42,24 @@ public App() | |
@Override protected AreaLayout onAppInit() | ||
{ | ||
this.hooks = new Hooks(getLuwrain()); | ||
Log.debug(LOG_COMPONENT, "before data"); | ||
this.data = new Data(); | ||
Log.debug(LOG_COMPONENT, "after data"); | ||
this.storing = org.luwrain.pim.Connections.getMailStoring(getLuwrain(), true); | ||
/* | ||
if (storing == null) | ||
return null; | ||
*/ | ||
this.conv = new Conv(this); | ||
this.mainLayout = new MainLayout(this); | ||
Log.debug("proba", "before main layout "); | ||
this.mainLayout = new MainLayout(this, data); | ||
Log.debug("proba", "after main layout"); | ||
this.startingLayout = new StartingLayout(this); | ||
setAppName(getStrings().appName()); | ||
/* | ||
if (storing.getAccounts().load().length == 0) | ||
return startingLayout.getAreaLayout(); | ||
*/ | ||
return mainLayout.getAreaLayout(); | ||
} | ||
|
||
|
@@ -82,6 +92,7 @@ Layouts layouts() | |
MailStoring getStoring() { return this.storing; } | ||
Hooks getHooks() { return this.hooks; } | ||
Conv getConv() { return conv; } | ||
public Data getData() { return data; } | ||
|
||
interface Layouts | ||
{ | ||
|
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 |
---|---|---|
@@ -1,5 +1,5 @@ | ||
/* | ||
Copyright 2012-2022 Michael Pozhidaev <[email protected]> | ||
Copyright 2012-2024 Michael Pozhidaev <[email protected]> | ||
This file is part of LUWRAIN. | ||
|
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,72 @@ | ||
/* | ||
Copyright 2012-2024 Michael Pozhidaev <[email protected]> | ||
This file is part of LUWRAIN. | ||
LUWRAIN is free software; you can redistribute it and/or | ||
modify it under the terms of the GNU General Public | ||
License as published by the Free Software Foundation; either | ||
version 3 of the License, or (at your option) any later version. | ||
LUWRAIN is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
General Public License for more details. | ||
*/ | ||
|
||
package org.luwrain.app.mail; | ||
|
||
import java.util.*; | ||
|
||
import org.luwrain.core.*; | ||
import org.luwrain.pim.mail2.persistence.dao.*; | ||
import org.luwrain.pim.mail2.persistence.model.*; | ||
import org.luwrain.pim.mail2.persistence.*; | ||
|
||
import static org.luwrain.pim.mail2.FolderProperties.*; | ||
|
||
public final class Data | ||
{ | ||
public final FolderDAO folderDAO = MailPersistence.getFolderDAO(); | ||
public final MessageDAO messageDAO = MailPersistence.getMessageDAO(); | ||
public final AccountDAO accountDAO = MailPersistence.getAccountDAO(); | ||
|
||
Data() | ||
{ | ||
if (folderDAO.getRoot() == null) | ||
createInitialFolders(); | ||
} | ||
|
||
private void createInitialFolders() | ||
{ | ||
final var t = "true"; | ||
final var root = new Folder(); | ||
root.setName("Почтовые группы"); | ||
folderDAO.add(root); | ||
folderDAO.setRoot(root); | ||
var f = new Folder(); | ||
f.setName("Входящие"); | ||
f.getProperties().setProperty(DEFAULT_INCOMING, t); | ||
f.setParentFolderId(root.getId()); | ||
folderDAO.add(f); | ||
f = new Folder(); | ||
f.setName("Рассылки"); | ||
f.getProperties().setProperty(DEFAULT_MAILING_LISTS, t); | ||
f.setParentFolderId(root.getId()); | ||
folderDAO.add(f); | ||
f = new Folder(); | ||
f.setName("Исходящие"); | ||
f.getProperties().setProperty(DEFAULT_OUTGOING, t); | ||
f.setParentFolderId(root.getId()); | ||
folderDAO.add(f); | ||
f = new Folder(); | ||
f.setName("Отправленные"); | ||
f.getProperties().setProperty(DEFAULT_SENT, t); | ||
f.setParentFolderId(root.getId()); | ||
folderDAO.add(f); | ||
f = new Folder(); | ||
f.setName("Черновики"); | ||
f.setParentFolderId(root.getId()); | ||
folderDAO.add(f); | ||
} | ||
} |
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 |
---|---|---|
@@ -1,5 +1,5 @@ | ||
/* | ||
Copyright 2012-2023 Michael Pozhidaev <[email protected]> | ||
Copyright 2012-2024 Michael Pozhidaev <[email protected]> | ||
This file is part of LUWRAIN. | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
/* | ||
Copyright 2012-2022 Michael Pozhidaev <[email protected]> | ||
Copyright 2012-2024 Michael Pozhidaev <[email protected]> | ||
This file is part of LUWRAIN. | ||
|
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 |
---|---|---|
@@ -1,5 +1,5 @@ | ||
/* | ||
Copyright 2012-2023 Michael Pozhidaev <[email protected]> | ||
Copyright 2012-2024 Michael Pozhidaev <[email protected]> | ||
This file is part of LUWRAIN. | ||
|
@@ -30,39 +30,45 @@ | |
import org.luwrain.pim.mail.script.*; | ||
import org.luwrain.app.base.*; | ||
|
||
import org.luwrain.pim.mail2.persistence.model.*; | ||
import org.luwrain.app.mail.layouts.*; | ||
|
||
|
||
import static org.luwrain.script.ScriptUtils.*; | ||
import static org.luwrain.core.DefaultEventResponse.*; | ||
|
||
import static org.luwrain.app.mail.App.*; | ||
import static org.luwrain.app.mail.Utils.*; | ||
import static org.luwrain.core.DefaultEventResponse.*; | ||
|
||
final class MainLayout extends LayoutBase implements TreeListArea.LeafClickHandler<MailFolder>, ClickHandler<SummaryItem> | ||
final class MainLayout extends LayoutBase implements TreeListArea.LeafClickHandler<Folder>, ClickHandler<SummaryItem> | ||
{ | ||
static private final InputEvent | ||
HOT_KEY_REPLY = new InputEvent('r', EnumSet.of(InputEvent.Modifiers.ALT)); | ||
|
||
final App app; | ||
final TreeListArea<MailFolder> foldersArea; | ||
final TreeListArea<Folder> foldersArea; | ||
final ListArea<SummaryItem> summaryArea; | ||
final ReaderArea messageArea; | ||
|
||
private final Data data; | ||
private final List<SummaryItem> summaryItems = new ArrayList<>(); | ||
private boolean showDeleted = false; | ||
private MailFolder folder = null; | ||
private Folder folder = null; | ||
private MailMessage message = null; | ||
|
||
MainLayout(App app) | ||
MainLayout(App app, Data data) | ||
{ | ||
super(app); | ||
this.app = app; | ||
this.data = data; | ||
|
||
final TreeListArea.Params<MailFolder> treeParams = new TreeListArea.Params<>(); | ||
final TreeListArea.Params<Folder> treeParams = new TreeListArea.Params<>(); | ||
treeParams.context = getControlContext(); | ||
treeParams.name = app.getStrings().foldersAreaName(); | ||
treeParams.model = new FoldersModel(app); | ||
treeParams.model = new FoldersModel(); | ||
treeParams.leafClickHandler = this; | ||
this.foldersArea = new TreeListArea<MailFolder>(treeParams) { | ||
this.foldersArea = new TreeListArea<>(treeParams) { | ||
@Override public boolean onSystemEvent(SystemEvent event) | ||
{ | ||
if (event.getType() == SystemEvent.Type.REGULAR) | ||
|
@@ -167,7 +173,7 @@ void updateSummary() | |
summaryArea.refresh(); | ||
} | ||
|
||
@Override public boolean onLeafClick(TreeListArea<MailFolder> area, MailFolder folder) | ||
@Override public boolean onLeafClick(TreeListArea<Folder> area, Folder folder) | ||
{ | ||
this.folder = folder; | ||
updateSummary(); | ||
|
@@ -178,6 +184,7 @@ void updateSummary() | |
|
||
private boolean actNewFolder() | ||
{ | ||
/* | ||
final MailFolder opened = foldersArea.opened(); | ||
if (opened == null) | ||
return false; | ||
|
@@ -190,11 +197,13 @@ private boolean actNewFolder() | |
app.getStoring().getFolders().save(opened, newFolder, Math.max(selectedIndex, 0)); | ||
foldersArea.requery(); | ||
foldersArea.refresh(); | ||
*/ | ||
return true; | ||
} | ||
|
||
private boolean actRemoveFolder() | ||
{ | ||
/* | ||
final MailFolder opened = foldersArea.opened(); | ||
if (opened == null) | ||
return false; | ||
|
@@ -206,6 +215,7 @@ private boolean actRemoveFolder() | |
app.getStoring().getFolders().remove(opened, selectedIndex); | ||
foldersArea.requery(); | ||
foldersArea.refresh(); | ||
*/ | ||
return true; | ||
} | ||
|
||
|
@@ -359,4 +369,15 @@ boolean saveAttachment(String fileName) | |
*/ | ||
return true; | ||
} | ||
|
||
final class FoldersModel implements TreeListArea.Model<Folder> | ||
{ | ||
@Override public boolean getItems(Folder folder, TreeListArea.Collector<Folder> collector) | ||
{ | ||
collector.collect(data.folderDAO.getChildFolders(folder)); | ||
return true; | ||
} | ||
@Override public Folder getRoot() { return data.folderDAO.getRoot(); } | ||
@Override public boolean isLeaf(Folder folder) { return data.folderDAO.getChildFolders(folder).size() != 0; } | ||
} | ||
} |
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 |
---|---|---|
@@ -1,5 +1,5 @@ | ||
/* | ||
Copyright 2012-2022 Michael Pozhidaev <[email protected]> | ||
Copyright 2012-2024 Michael Pozhidaev <[email protected]> | ||
Copyright 2015-2016 Roman Volovodov <[email protected]> | ||
This file is part of LUWRAIN. | ||
|
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 |
---|---|---|
@@ -1,5 +1,5 @@ | ||
/* | ||
Copyright 2012-2023 Michael Pozhidaev <[email protected]> | ||
Copyright 2012-2024 Michael Pozhidaev <[email protected]> | ||
i This file is part of LUWRAIN. | ||
|
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 |
---|---|---|
@@ -1,5 +1,5 @@ | ||
/* | ||
Copyright 2012-2022 Michael Pozhidaev <[email protected]> | ||
Copyright 2012-2024 Michael Pozhidaev <[email protected]> | ||
This file is part of LUWRAIN. | ||
|
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 |
---|---|---|
@@ -1,5 +1,5 @@ | ||
/* | ||
Copyright 2012-2022 Michael Pozhidaev <[email protected]> | ||
Copyright 2012-2024 Michael Pozhidaev <[email protected]> | ||
This file is part of LUWRAIN. | ||
|
Oops, something went wrong.