Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Truncate long titles, implement line wrap #38

Merged
merged 1 commit into from
Nov 19, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,24 @@ public class TaskCard extends JPanel {
* Create the panel.
*/
public TaskCard(String nameData, String dateData, String userNameData) {
setBorder(new LineBorder(Color.black));
setLayout(new MigLayout("", "[grow,fill]", "[grow][bottom]"));
this.setBorder(new LineBorder(Color.black));
this.setLayout(new MigLayout("", "[grow,fill]", "[grow][bottom]"));


taskName.setText(nameData);
taskName.setFont(new Font("Tahoma", Font.BOLD, 14));
taskName.setEditable(false);
taskName.setBackground(UIManager.getColor("Button.background"));
add(taskName, "cell 0 0,alignx center,aligny center");
// truncates the displayed task title if it's longer than 25 characters. if
if (nameData.length() > 45) {
this.taskName.setToolTipText(nameData);
nameData = nameData.substring(0, 45).concat("...");
}

this.taskName.setText(nameData);
this.taskName.setFont(new Font("Tahoma", Font.BOLD, 14));
this.taskName.setEditable(false);
this.taskName.setBackground(UIManager.getColor("Button.background"));
this.add(this.taskName, "cell 0 0,alignx center,aligny center");

JPanel infoPanel = new JPanel();
add(infoPanel, "cell 0 1,grow");
this.add(infoPanel, "cell 0 1,grow");
infoPanel.setLayout(new MigLayout("", "[grow][grow]", "[grow]"));

JLabel date = new JLabel(dateData);
Expand All @@ -54,7 +60,7 @@ public TaskCard(String nameData, String dateData, String userNameData) {
}

public Task getTaskObj() {
return taskObj;
return this.taskObj;
}

public void setTaskObj(Task taskObj) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,11 @@ public class TaskStatusView extends JPanel {
*/
public TaskStatusView(String title, String statusType) {

initialized = false;
this.initialized = false;
this.title = title;

setLayout(new MigLayout("", "[236px,grow]", "[26px][200px,grow 500]"));
taskStatusObj = new TaskStatus(statusType);
this.setLayout(new MigLayout("", "[236px,grow]", "[26px][200px,grow 500]"));
this.taskStatusObj = new TaskStatus(statusType);

JScrollPane scrollPane = new JScrollPane();
scrollPane.setViewportBorder(null);
Expand All @@ -85,10 +85,10 @@ public TaskStatusView(String title, String statusType) {
txtpnTitle.setFont(txtpnTitle.getFont().deriveFont(20f));
txtpnTitle.setText(this.title);
this.add(txtpnTitle, "cell 0 0,alignx center,aligny center");
panel.setBackground(Color.WHITE);
this.panel.setBackground(Color.WHITE);

scrollPane.setViewportView(panel);
panel.setLayout(new MigLayout("", "[grow,fill]", "[]"));
scrollPane.setViewportView(this.panel);
this.panel.setLayout(new MigLayout("", "[236px,grow,fill]", "[]"));
}


Expand All @@ -101,24 +101,25 @@ public void requestTasksFromDb() {
}

public void fillTaskList(Task[] taskArray) {
taskStatusObj.setTaskList(new ArrayList<Task>());
this.taskStatusObj.setTaskList(new ArrayList<Task>());
for (Task t : taskArray) {
if (t.getStatus() != null && taskStatusObj.getName().equals(t.getStatus().getName())) {
taskStatusObj.addTask(t);
if (t.getStatus() != null
&& this.taskStatusObj.getName().equals(t.getStatus().getName())) {
this.taskStatusObj.addTask(t);
}
}
populateTaskStatusViewCards();
this.populateTaskStatusViewCards();
}

public void populateTaskStatusViewCards() {
List<Task> taskList = taskStatusObj.getTaskList();
panel.removeAll();
List<Task> taskList = this.taskStatusObj.getTaskList();
this.panel.removeAll();
for (Task t : taskList) {
String dateString = formateDate(t);
String dateString = this.formateDate(t);
TaskCard card = new TaskCard(t.getTitle(), dateString, t.getUserForTaskCard());
panel.add(card, "newline");
this.panel.add(card, "newline");
}
revalidate();
this.revalidate();
}


Expand All @@ -139,9 +140,9 @@ private String formateDate(Task t) {

@Override
public void paintComponent(Graphics g) {
if (!initialized) {
requestTasksFromDb();
initialized = true;
if (!this.initialized) {
this.requestTasksFromDb();
this.initialized = true;
}
super.paintComponent(g);
}
Expand Down