-
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
rxdps93
committed
Apr 11, 2019
1 parent
5e32d29
commit e5459e3
Showing
5 changed files
with
119 additions
and
24 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
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
80 changes: 80 additions & 0 deletions
80
src/main/java/com/dom/freeman/components/users/dialog/ViewUserSummaryDialog.java
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,80 @@ | ||
package com.dom.freeman.components.users.dialog; | ||
|
||
import com.dom.freeman.obj.User; | ||
import com.dom.freeman.obj.UserPermission; | ||
import com.googlecode.lanterna.SGR; | ||
import com.googlecode.lanterna.TerminalSize; | ||
import com.googlecode.lanterna.gui2.Borders; | ||
import com.googlecode.lanterna.gui2.Button; | ||
import com.googlecode.lanterna.gui2.EmptySpace; | ||
import com.googlecode.lanterna.gui2.GridLayout; | ||
import com.googlecode.lanterna.gui2.Label; | ||
import com.googlecode.lanterna.gui2.LocalizedString; | ||
import com.googlecode.lanterna.gui2.Panel; | ||
import com.googlecode.lanterna.gui2.GridLayout.Alignment; | ||
import com.googlecode.lanterna.gui2.dialogs.DialogWindow; | ||
import com.googlecode.lanterna.gui2.table.Table; | ||
|
||
public class ViewUserSummaryDialog extends DialogWindow { | ||
|
||
public ViewUserSummaryDialog(String title, User user) { | ||
super(title); | ||
this.configureContent(user); | ||
} | ||
|
||
private void configureContent(User user) { | ||
|
||
Panel mainPanel = new Panel(new GridLayout(2)); | ||
|
||
// Description | ||
mainPanel.addComponent(new Label("Summary for selected user").setLayoutData( | ||
GridLayout.createLayoutData(Alignment.BEGINNING, Alignment.CENTER, | ||
false, false, 2, 1))); | ||
|
||
// User details | ||
mainPanel.addComponent(this.dialogSpacer()); | ||
|
||
mainPanel.addComponent(new Label("First Name").addStyle(SGR.BOLD)); | ||
mainPanel.addComponent(new Label(user.getFirstName())); | ||
|
||
mainPanel.addComponent(new Label("Last Name").addStyle(SGR.BOLD)); | ||
mainPanel.addComponent(new Label(user.getLastName())); | ||
|
||
mainPanel.addComponent(new Label("Display Name").addStyle(SGR.BOLD)); | ||
mainPanel.addComponent(new Label(user.getDisplayName())); | ||
|
||
// User Permissions | ||
mainPanel.addComponent(this.dialogSpacer()); | ||
if (user.getUserPermissions().size() == 0) { | ||
mainPanel.addComponent(new Label("This user has no permissions.").setLayoutData( | ||
GridLayout.createLayoutData(Alignment.CENTER, Alignment.CENTER, | ||
false, false, 2, 1))); | ||
} else { | ||
Table<String> permissions = new Table<String>("PERMISSION", "DESCRIPTION"); | ||
permissions.setEnabled(false); | ||
for (UserPermission permission : user.getUserPermissions()) { | ||
permissions.getTableModel().addRow( | ||
permission.toString(), permission.getDescription()); | ||
} | ||
permissions.setLayoutData(GridLayout.createLayoutData( | ||
Alignment.FILL, Alignment.FILL, true, true, 2, 1)); | ||
mainPanel.addComponent(permissions.withBorder(Borders.singleLine("Permissions"))); | ||
} | ||
|
||
// Buttons | ||
mainPanel.addComponent(this.dialogSpacer()); | ||
mainPanel.addComponent(new EmptySpace(TerminalSize.ONE)); | ||
mainPanel.addComponent(new Button(LocalizedString.OK.toString(), new Runnable() { | ||
@Override | ||
public void run() { | ||
close(); | ||
} | ||
})); | ||
|
||
this.setComponent(mainPanel); | ||
} | ||
|
||
private EmptySpace dialogSpacer() { | ||
return new EmptySpace().setLayoutData(GridLayout.createHorizontallyFilledLayoutData(2)); | ||
} | ||
} |
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
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,3 +1,4 @@ | ||
"Donald","Trump","GEOTUS","3d1e48ce-a651-48b6-bd8f-e540fe8db73b","" | ||
"Richard","Stallman","rms.sexy","bfff8b19-b48f-41d7-b000-942646135f45","" | ||
"Terry","Davis","temple","0a85af4c-18cb-401f-bace-efcc42de11c7","" | ||
Theodore,Roosevelt,teddy,08a53765-46d8-4326-b302-b4d419a4be85, |