Skip to content

Commit

Permalink
task assigning: UI improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
ge0ffrey committed Apr 27, 2016
1 parent 9ca1b85 commit aee4f8f
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 12 deletions.
Expand Up @@ -128,8 +128,16 @@ public Integer getEndTime() {
return startTime + getDuration();
}

public String getCode() {
return taskType + "-" + indexInTaskType;
}

public String getTitle() {
return taskType.getTitle();
}

public String getLabel() {
return taskType.getCode() + "-" + indexInTaskType + ": " + taskType.getTitle();
return getCode() + ": " + taskType.getTitle();
}

public String getToolText() {
Expand All @@ -146,7 +154,7 @@ public String getToolText() {

@Override
public String toString() {
return taskType + "-" + indexInTaskType;
return getCode();
}

}
Expand Up @@ -102,8 +102,8 @@ public class TaskAssigningGenerator extends LoggingMain {
"Research");
private static final StringDataGenerator customerNameGenerator = StringDataGenerator.build1kCompanyNames();
private static final StringDataGenerator employeeNameGenerator = StringDataGenerator.build10kFullNames();
private static final int BASE_DURATION_MINIMUM = 10;
private static final int BASE_DURATION_MAXIMUM = 60;
private static final int BASE_DURATION_MINIMUM = 20;
private static final int BASE_DURATION_MAXIMUM = 120;
private static final int SKILL_SET_SIZE_MINIMUM = 2;
private static final int SKILL_SET_SIZE_MAXIMUM = 7;

Expand All @@ -123,6 +123,8 @@ public TaskAssigningGenerator() {
public void generate() {
writeTaskAssigningSolution(50, 5);
writeTaskAssigningSolution(100, 5);
writeTaskAssigningSolution(500, 20);
writeTaskAssigningSolution(1000, 20);
}

private void writeTaskAssigningSolution(int taskListSize, int employeeListSize) {
Expand Down
Expand Up @@ -20,6 +20,7 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.swing.BorderFactory;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.SwingConstants;
Expand All @@ -34,7 +35,7 @@
public class TaskOverviewPanel extends JPanel {

public static final int HEADER_COLUMN_WIDTH = 150;
public static final int ROW_HEIGHT = 20;
public static final int ROW_HEIGHT = 40;

public TaskOverviewPanel() {
setLayout(null);
Expand All @@ -53,16 +54,16 @@ public void resetPanel(TaskAssigningSolution taskAssigningSolution) {
employeeLabel.setToolTipText(employee.getToolText());
employeeLabel.setLocation(0, employeeIndex * ROW_HEIGHT);
employeeLabel.setSize(HEADER_COLUMN_WIDTH, ROW_HEIGHT);
employeeLabel.setBorder(BorderFactory.createLineBorder(Color.black, 1));
add(employeeLabel);
employeeIndexMap.put(employee, employeeIndex);
employeeIndex++;
}
int unassignedIndex = employeeList.size();
for (Task task : taskAssigningSolution.getTaskList()) {
JLabel taskLabel = new JLabel(task.getLabel(), SwingConstants.CENTER);
taskLabel.setOpaque(true);
taskLabel.setToolTipText(task.getToolText());
taskLabel.setBackground(tangoColorFactory.pickColor(task));
TaskPanel taskPanel = new TaskPanel(task);
taskPanel.setToolTipText(task.getToolText());
taskPanel.setBackground(tangoColorFactory.pickColor(task.getTaskType()));
int x;
int y;
if (task.getEmployee() != null) {
Expand All @@ -73,11 +74,30 @@ public void resetPanel(TaskAssigningSolution taskAssigningSolution) {
y = unassignedIndex * ROW_HEIGHT;
unassignedIndex++;
}
taskLabel.setLocation(x, y);
taskLabel.setSize(task.getDuration(), ROW_HEIGHT);
add(taskLabel);
taskPanel.setLocation(x, y);
add(taskPanel);
}
repaint();
}

private class TaskPanel extends JPanel {

private final Task task;

public TaskPanel(Task task) {
this.task = task;
setLayout(null);
setSize(task.getDuration(), ROW_HEIGHT);
JLabel codeLabel = new JLabel(task.getCode(), SwingConstants.CENTER);
codeLabel.setLocation(0, 0);
codeLabel.setSize(task.getDuration(), ROW_HEIGHT / 2);
add(codeLabel);
JLabel titleLabel = new JLabel(task.getTitle(), SwingConstants.CENTER);
titleLabel.setLocation(0, ROW_HEIGHT / 2);
titleLabel.setSize(task.getDuration(), ROW_HEIGHT / 2);
add(titleLabel);
}

}

}

0 comments on commit aee4f8f

Please sign in to comment.