Skip to content

Commit

Permalink
Indentation fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
marigostra committed Apr 9, 2021
1 parent 7b4c369 commit 765fb42
Show file tree
Hide file tree
Showing 2 changed files with 72 additions and 73 deletions.
16 changes: 8 additions & 8 deletions src/main/java/org/luwrain/app/contacts/Conversations.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ String newFolderName()

ContactValue.Type newContactValueType()
{
final String mailTitle = "Электронная почта";
final String mailTitle = "Электронная почта";
final String phoneTitle = "Телефон";
final String addressTitle = "Адрес";
final String birthdayTitle = "Дата рождения";
Expand All @@ -59,12 +59,12 @@ ContactValue.Type newContactValueType()
final ContactValue.Type type;
if (res == mailTitle)
return ContactValue.Type.MAIL;
if (res == addressTitle)
return ContactValue.Type.ADDRESS;
if (res == birthdayTitle)
return ContactValue.Type.BIRTHDAY;
if (res == skypeTitle)
return ContactValue.Type.SKYPE;
return null;//Should never happen
if (res == addressTitle)
return ContactValue.Type.ADDRESS;
if (res == birthdayTitle)
return ContactValue.Type.BIRTHDAY;
if (res == skypeTitle)
return ContactValue.Type.SKYPE;
return null;//Should never happen
}
}
129 changes: 64 additions & 65 deletions src/main/java/org/luwrain/app/contacts/MainLayout.java
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ final class MainLayout extends LayoutBase implements ListArea.ClickHandler
this.valuesArea = new FormArea(new DefaultControlContext(app.getLuwrain()), app.getStrings().valuesAreaName());
valuesActions = actions(
action("new-value", "Добавить новое значение", new InputEvent(InputEvent.Special.INSERT), this::actNewValue)
);
);
}

final Actions notesActions;
Expand All @@ -90,9 +90,9 @@ final class MainLayout extends LayoutBase implements ListArea.ClickHandler
if (obj == null || !(obj instanceof Contact))
return false;
ensureEverythingSaved();
this.openedContact = (Contact)obj;
fillValuesArea(valuesArea);
fillNotesArea(notesArea);
this.openedContact = (Contact)obj;
fillValuesArea(valuesArea);
fillNotesArea(notesArea);
setActiveArea(valuesArea);
return true;
}
Expand All @@ -109,10 +109,10 @@ private boolean actNewFolder()
return true;
}

private boolean actNewContact()
private boolean actNewContact()
{
final String name = app.getConv().newContactName();
if (name == null || name.trim().isEmpty())
if (name == null || name.trim().isEmpty())
return true;
final Contact c = new Contact();
c.setTitle(name);
Expand All @@ -134,8 +134,8 @@ private boolean actNewValue()
final ContactValue[] newValues = Arrays.copyOf(oldValues, oldValues.length + 1);
newValues[newValues.length - 1] = newValue;
openedContact.setValues(newValues);
return true;
}
return true;
}

private void updateItems()
{
Expand Down Expand Up @@ -180,76 +180,75 @@ private void saveForm(FormArea area)
if (obj == null || !(obj instanceof ContactValue))
continue;
final ContactValue value = (ContactValue)obj;
value.setValue(area.getEnteredText(i));
value.setValue(area.getEnteredText(i));
if (!value.getValue().trim().isEmpty())
values.add(value);
}
openedContact.setValues(values.toArray(new ContactValue[values.size()]));
return;
}

private boolean fillNotesArea(EditArea area)
{
String value;
value = openedContact.getNotes();
area.setLines(value.split("\n", -1));
return true;
}

private boolean saveNotes(EditArea area)
{
if (openedContact == null)
return true;
final StringBuilder b = new StringBuilder();
final int count = area.getLineCount();
if (count > 0)
private boolean fillNotesArea(EditArea area)
{
b.append(area.getLine(0));
for(int i = 1;i < count;++i)
b.append("\n" + area.getLine(i));
String value;
value = openedContact.getNotes();
area.setLines(value.split("\n", -1));
return true;
}
openedContact.setNotes(b.toString());
return true;
}

private boolean deleteFolder(ContactsFolder folder)
{
if (folder.isRoot())
private boolean saveNotes(EditArea area)
{
app.getLuwrain().message("Корневая группа контактов не может быть удалена", Luwrain.MessageType.ERROR);
return false;
if (openedContact == null)
return true;
final StringBuilder b = new StringBuilder();
final int count = area.getLineCount();
if (count > 0)
{
b.append(area.getLine(0));
for(int i = 1;i < count;++i)
b.append("\n" + area.getLine(i));
}
openedContact.setNotes(b.toString());
return true;
}
final Contact[] contacts = app.getStoring().getContacts().load(folder);
final ContactsFolder[] subfolders = app.getStoring().getFolders().load(folder);
if (contacts != null && contacts.length > 0)

private boolean deleteFolder(ContactsFolder folder)
{
app.getLuwrain().message("Выделенная группа содержит контакты и не может быть удалена", Luwrain.MessageType.ERROR);
return false;
if (folder.isRoot())
{
app.getLuwrain().message("Корневая группа контактов не может быть удалена", Luwrain.MessageType.ERROR);
return false;
}
final Contact[] contacts = app.getStoring().getContacts().load(folder);
final ContactsFolder[] subfolders = app.getStoring().getFolders().load(folder);
if (contacts != null && contacts.length > 0)
{
app.getLuwrain().message("Выделенная группа содержит контакты и не может быть удалена", Luwrain.MessageType.ERROR);
return false;
}
if (subfolders != null && subfolders.length > 0)
{
app.getLuwrain().message("Выделенная группа содержит вложенные группы и не может быть удалена", Luwrain.MessageType.ERROR);
return false;
}
final YesNoPopup popup = new YesNoPopup(app.getLuwrain(), "Удаление группы контактов", "Вы действительно хотите удалить группу контактов \"" + folder.getTitle() + "\"?", false, Popups.DEFAULT_POPUP_FLAGS);
app.getLuwrain().popup(popup);
if (popup.wasCancelled() || !popup.result())
return false;
app.getStoring().getFolders().delete(folder);
return true;
}
if (subfolders != null && subfolders.length > 0)

private boolean deleteContact(Contact contact)
{
app.getLuwrain().message("Выделенная группа содержит вложенные группы и не может быть удалена", Luwrain.MessageType.ERROR);
return false;
final YesNoPopup popup = new YesNoPopup(app.getLuwrain(), "Удаление группы контактов", "Вы действительно хотите удалить контакт \"" + contact.getTitle() + "\"?", false, Popups.DEFAULT_POPUP_FLAGS);
app.getLuwrain().popup(popup);
if (popup.wasCancelled() || !popup.result())
return false;
app.getStoring().getContacts().delete(contact);
openedContact = null;//FIXME:maybe only if currentContact == contact
return true;
}
final YesNoPopup popup = new YesNoPopup(app.getLuwrain(), "Удаление группы контактов", "Вы действительно хотите удалить группу контактов \"" + folder.getTitle() + "\"?", false, Popups.DEFAULT_POPUP_FLAGS);
app.getLuwrain().popup(popup);
if (popup.wasCancelled() || !popup.result())
return false;
app.getStoring().getFolders().delete(folder);
return true;
}

private boolean deleteContact(Contact contact)
{
final YesNoPopup popup = new YesNoPopup(app.getLuwrain(), "Удаление группы контактов", "Вы действительно хотите удалить контакт \"" + contact.getTitle() + "\"?", false, Popups.DEFAULT_POPUP_FLAGS);
app.getLuwrain().popup(popup);
if (popup.wasCancelled() || !popup.result())
return false;
app.getStoring().getContacts().delete(contact);
openedContact = null;//FIXME:maybe only if currentContact == contact
return true;
}


/*
//Returns false if the area must issue an error beep
Expand All @@ -267,11 +266,11 @@ boolean insertValue(FormArea valuesArea)
}
*/

void ensureEverythingSaved()
void ensureEverythingSaved()
{
if (openedContact == null)
return;
saveForm(valuesArea);
saveNotes(notesArea);
saveForm(valuesArea);
saveNotes(notesArea);
}
}

0 comments on commit 765fb42

Please sign in to comment.