Skip to content

Commit

Permalink
New checkstyle to generate warnings using checkstyle.
Browse files Browse the repository at this point in the history
CreateSearchList action is refactored version of SearchHandler and will be used both in showing the search result,
and the friend list as toggleable objects in the list.

Refactor of new formatting style.

Removed ItemActions as they are no longer being used.

New function in mainscreen makes it possible to remove item from main screen by referencing the Parent object.

Extracted methods for the search function from main screen.

New cross for closing the search in mainscreen without having to click away in non reachable places.
  • Loading branch information
miniwolf committed Dec 14, 2016
1 parent 85401b1 commit de3f691
Show file tree
Hide file tree
Showing 27 changed files with 507 additions and 353 deletions.
46 changes: 28 additions & 18 deletions Checkstyle.xml
Original file line number Diff line number Diff line change
@@ -1,24 +1,19 @@
<?xml version="1.0"?>
<!--
~ Copyright (c) 2015. Nicklas 'MiNiWolF' Pingel and Marcus 'Zargess' Haagh.
~ Copyright (c) 2016. Nicklas 'MiNiWolF' Pingel and Marcus 'Zargess' Haagh.
-->

<!DOCTYPE module PUBLIC
"-//Puppy Crawl//DTD Check Configuration 1.3//EN"
"http://www.puppycrawl.com/dtds/configuration_1_3.dtd">

<!--
Checkstyle configuration that checks the Google coding conventions from:
- Google Java Style
https://google-styleguide.googlecode.com/svn-history/r130/trunk/javaguide.html
Checkstyle configuration that checks the Google coding conventions from Google Java Style
that can be found at https://google.github.io/styleguide/javaguide.html.
Checkstyle is very configurable. Be sure to read the documentation at
http://checkstyle.sf.net (or in your downloaded distribution).
Most Checks are configurable, be sure to consult the documentation.
To completely disable a check, just comment it out or delete it from the file.
Authors: Max Vetrenko, Ruslan Diachenko, Roman Ivanov.
-->

<module name = "Checker">
Expand Down Expand Up @@ -107,11 +102,23 @@
<message key="name.invalidPattern"
value="Member name ''{0}'' must match pattern ''{1}''."/>
</module>
<module name="ParameterName">
<property name="format" value="^[a-z]([a-z0-9][a-zA-Z0-9]*)?$"/>
<property name="excludeScope" value="public"/>
<message key="name.invalidPattern"
value="Parameter name ''{0}'' must match pattern ''{1}''."/>
</module>
<module name="ParameterName">
<property name="format" value="^[a-z][a-z0-9][a-zA-Z0-9]*$"/>
<property name="scope" value="public"/>
<message key="name.invalidPattern"
value="Parameter name ''{0}'' must match pattern ''{1}''."/>
</module>
<module name="CatchParameterName">
<property name="format" value="^[a-z][a-z0-9][a-zA-Z0-9]*$"/>
<message key="name.invalidPattern"
value="Catch parameter name ''{0}'' must match pattern ''{1}''."/>
</module>
<module name="LocalVariableName">
<property name="tokens" value="VARIABLE_DEF"/>
<property name="format" value="^[a-z][a-z0-9][a-zA-Z0-9]*$"/>
Expand All @@ -129,12 +136,13 @@
<message key="name.invalidPattern"
value="Method type name ''{0}'' must match pattern ''{1}''."/>
</module>
<module name="InterfaceTypeParameterName">
<property name="format" value="(^[A-Z][0-9]?)$|([A-Z][a-zA-Z0-9]*[T]$)"/>
<message key="name.invalidPattern"
value="Interface type name ''{0}'' must match pattern ''{1}''."/>
</module>
<module name="NoFinalizer"/>
<module name="GenericWhitespace">
<message key="ws.followed"
value="GenericWhitespace ''{0}'' is followed by whitespace."/>
<message key="ws.preceded"
value="GenericWhitespace ''{0}'' is preceded with whitespace."/>
<message key="ws.illegalFollow"
value="GenericWhitespace ''{0}'' should followed by whitespace."/>
<message key="ws.notPreceded"
Expand All @@ -144,8 +152,8 @@
<property name="basicOffset" value="4"/>
<property name="braceAdjustment" value="0"/>
<property name="caseIndent" value="4"/>
<property name="throwsIndent" value="8"/>
<property name="lineWrappingIndentation" value="8"/>
<property name="throwsIndent" value="4"/>
<property name="lineWrappingIndentation" value="4"/>
<property name="arrayInitIndent" value="4"/>
</module>
<module name="AbbreviationAsWordInName">
Expand All @@ -155,14 +163,15 @@
<module name="OverloadMethodsDeclarationOrder"/>
<module name="VariableDeclarationUsageDistance"/>
<module name="CustomImportOrder">
<property name="specialImportsRegExp" value="com.fagi"/>
<property name="sortImportsInGroupAlphabetically" value="true"/>
<property name="customImportOrderRules" value="STATIC###SPECIAL_IMPORTS###THIRD_PARTY_PACKAGE###STANDARD_JAVA_PACKAGE"/>
<property name="separateLineBetweenGroups" value="true"/>
<property name="customImportOrderRules" value="STATIC###THIRD_PARTY_PACKAGE"/>
</module>
<module name="MethodParamPad"/>
<module name="ParenPad"/>
<module name="OperatorWrap">
<property name="option" value="NL"/>
<property name="tokens" value="BAND, BOR, BSR, BXOR, DIV, EQUAL, GE, GT, LAND, LE, LITERAL_INSTANCEOF, LOR, LT, MINUS, MOD, NOT_EQUAL, PLUS, QUESTION, SL, SR, STAR "/>
<property name="tokens" value="BAND, BOR, BSR, BXOR, DIV, EQUAL, GE, GT, LAND, LE, LITERAL_INSTANCEOF, LOR, LT, MINUS, MOD, NOT_EQUAL, PLUS, QUESTION, SL, SR, STAR, METHOD_REF "/>
</module>
<module name="AnnotationLocation">
<property name="tokens" value="CLASS_DEF, INTERFACE_DEF, ENUM_DEF, METHOD_DEF, CTOR_DEF"/>
Expand All @@ -173,7 +182,7 @@
</module>
<module name="NonEmptyAtclauseDescription"/>
<module name="JavadocTagContinuationIndentation"/>
<module name="SummaryJavadocCheck">
<module name="SummaryJavadoc">
<property name="forbiddenSummaryFragments" value="^@return the *|^This method returns |^A [{]@code [a-zA-Z0-9]+[}]( is a )"/>
</module>
<module name="JavadocParagraph"/>
Expand Down Expand Up @@ -201,5 +210,6 @@
<module name="EmptyCatchBlock">
<property name="exceptionVariableName" value="expected"/>
</module>
<module name="CommentsIndentation"/>
</module>
</module>
20 changes: 12 additions & 8 deletions fagiClient/src/com/fagi/action/items/OpenConversation.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,11 @@ public OpenConversation(MainScreen mainScreen, Label username) {
@Override
public void execute() {
Conversation conversation;
Optional<Conversation> optConversation = mainScreen.getConversations().stream().filter(con -> con.getParticipants().size() > 0 && con.getParticipants().contains(username.getText())).findFirst();
if ( optConversation.isPresent() ) {
Optional<Conversation> optConversation = mainScreen.getConversations().stream().filter(
con -> con.getParticipants().size() > 0 && con.getParticipants()
.contains(username.getText()))
.findFirst();
if (optConversation.isPresent()) {
conversation = optConversation.get();
} else {
List<String> participants = new ArrayList<>();
Expand All @@ -40,14 +43,15 @@ public void execute() {

private Conversation waitForConversation() {
Optional<Conversation> optConversation;
while ( !(optConversation = mainScreen.getConversations().stream()
.filter(con -> con.getParticipants().size() > 0
&& con.getParticipants().contains(username.getText()))
.findFirst()).isPresent() ) {
while (!(optConversation = mainScreen.getConversations().stream()
.filter(con -> con.getParticipants().size() > 0
&& con.getParticipants()
.contains(username.getText()))
.findFirst()).isPresent()) {
try {
Thread.sleep(100);
} catch (InterruptedException e) {
e.printStackTrace();
} catch (InterruptedException ie) {
ie.printStackTrace();
}
}
return optConversation.get();
Expand Down
26 changes: 17 additions & 9 deletions fagiClient/src/com/fagi/action/items/OpenConversationFromID.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,30 +29,38 @@ public OpenConversationFromID(MainScreen mainScreen, long id) {
@Override
public void execute() {
Optional<Conversation> optional = mainScreen
.getConversations().stream()
.filter(con -> con.getId() == id)
.findFirst();
.getConversations().stream()
.filter(con -> con.getId() == id)
.findFirst();

if (!optional.isPresent()) {
errorHandling();
return; // NOTE: This is never reached
}

Conversation conversation = optional.get();

if ( conversation.getParticipants().equals(mainScreen.getCurrentConversation().getParticipants()) ) {
if (!optional.isPresent() || conversation.getParticipants()
.equals(mainScreen.getCurrentConversation()
.getParticipants())) {
return;
}

Communication communication = mainScreen.getCommunication();
String username = mainScreen.getUsername();
if ( conversation.getType() == ConversationType.Placeholder ) {
ConversationType type = conversation.getParticipants().size() > 2 ? ConversationType.Multi : ConversationType.Single;
if (conversation.getType() == ConversationType.Placeholder) {
ConversationType type =
conversation.getParticipants().size() > 2 ? ConversationType.Multi
: ConversationType.Single;
conversation.setType(type);
communication.sendObject(new GetAllConversationDataRequest(username, conversation.getId()));
communication
.sendObject(new GetAllConversationDataRequest(username, conversation.getId()));
}

ConversationController controller = new ConversationController(mainScreen.getPrimaryStage(), conversation, communication, username);
FXMLLoader loader = new FXMLLoader(getClass().getResource("/com/fagi/view/conversation/Conversation.fxml"));
ConversationController controller =
new ConversationController(mainScreen, conversation, username);
FXMLLoader loader =
new FXMLLoader(getClass().getResource("/com/fagi/view/conversation/Conversation.fxml"));
loader.setController(controller);
try {
BorderPane conversationBox = loader.load();
Expand Down
7 changes: 1 addition & 6 deletions fagiClient/src/com/fagi/action/items/OpenInvitation.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,18 +32,13 @@ public OpenInvitation(MainScreen mainScreen, Label username) {

@Override
public void execute() {
Communication communication = mainScreen.getCommunication();
String username = this.username.getText();

// TODO: Send invitation and open invitation

SendInvitationController controller = new SendInvitationController(mainScreen);

FXMLLoader loader = new FXMLLoader(getClass().getResource("/com/fagi/view/conversation/Invitation.fxml"));
loader.setController(controller);
try {
BorderPane conversationBox = loader.load();
controller.setUsername(username);
controller.setUsername(username.getText());
mainScreen.addElement(conversationBox);
} catch (IOException e) {
e.printStackTrace();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,10 @@ public OpenReceivedFriendRequest(MainScreen mainScreen, FriendRequest request) {

@Override
public void execute() {
FXMLLoader loader = new FXMLLoader(getClass().getResource("/com/fagi/view/conversation/ReceivedInvitation.fxml"));
ReceivedInvitationController controller = new ReceivedInvitationController(request, mainScreen);
FXMLLoader loader = new FXMLLoader(
getClass().getResource("/com/fagi/view/conversation/ReceivedInvitation.fxml"));
ReceivedInvitationController controller =
new ReceivedInvitationController(request, mainScreen);
loader.setController(controller);
try {
BorderPane conversationBox = loader.load();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
/*
* Copyright (c) 2016. Nicklas 'MiNiWolF' Pingel and Marcus 'Zargess' Haagh.
*/
package com.fagi.action.items.contentList;

import javafx.application.Platform;
import javafx.fxml.FXMLLoader;
import javafx.scene.layout.HBox;
import javafx.scene.layout.VBox;
import com.fagi.action.Action;
import com.fagi.controller.MainScreen;
import com.fagi.controller.SearchContactController;
import com.fagi.controller.contentList.ContentController;

import java.io.IOException;
import java.util.List;

/**
* Created by miniwolf on 14-12-2016.
*/
public class CreateSearchList implements Action {
private MainScreen mainScreen;
private List<String> usernames;

public CreateSearchList(MainScreen mainScreen, List<String> usernames) {
this.mainScreen = mainScreen;
this.usernames = usernames;
}

@Override
public void execute() {
ContentController contentController = new ContentController();
FXMLLoader contentLoader = new FXMLLoader(
mainScreen.getClass().getResource("/com/fagi/view/content/SearchContent.fxml"));
contentLoader.setController(contentController);
VBox searchContent;
try {
searchContent = contentLoader.load();
} catch (IOException ioe) {
ioe.printStackTrace();
return;
}

for (String username : usernames) {
SearchContactController controller = new SearchContactController(false, mainScreen);
FXMLLoader loader = new FXMLLoader(
mainScreen.getClass().getResource("/com/fagi/view/content/SearchContact.fxml"));
loader.setController(controller);
HBox searchContact;
try {
searchContact = loader.load();
controller.setUserName(username);
contentController.addToContentList(searchContact);
} catch (IOException ioe) {
ioe.printStackTrace();
return;
}
}

Platform.runLater(() -> mainScreen
.setScrollPaneContent(mainScreen.getCurrentPaneContent(), searchContent));
}
}
Loading

0 comments on commit de3f691

Please sign in to comment.