public TaskRow(final ControllerInterface controller,
			final EDITED_TaskScrollPanel taskScrollPanel, Task ta) {
		super();
		t = ta;
		// this.controller = controller;
		this.taskScrollPanel = taskScrollPanel;

		// TODO setlenient su sdf, rimosso

		// TODO layout has to be fixed a lot! I didnt mind about it now
		// this.setLayout(new FlowLayout(FlowLayout.LEFT,
		// GlobalValues.TASKROW_ELEMENT_SPACING_X,
		// GlobalValues.TASKROW_ELEMENT_SPACING_Y));

		this.setLayout(new GridBagLayout());

		// preferences
		// this.setBorder(BorderFactory.createLineBorder(Color.BLACK, ));

		// Now add my components: done Button
		lang = controller.getLanguageBundle();

		doneBut = new JButton();
		// doneBut.setText(lang.getString("mainFrame.middlePanel.taskScrollPanel.taskRow.button.done.name"));
		doneBut.setText("");

		doneBut.setIcon(new ImageIcon(controller
				.getResource("assets/Icons/donetask.png")));

		doneBut.addMouseListener(new MouseAdapter() {
			public void mousePressed(MouseEvent me) {
				t.setCompleted(!t.getCompleted());

				// TODO
				// This button will notify the parent (scrollpanel component)
				// that this TaskRow has to be moved to completed or pending
				// section.

				JOptionPane
						.showMessageDialog(
								null,
								"This button will edit task status: completed/pending\nMaybe it should inform scrollpanel.. TODO");
			}
		});
		GridBagConstraints con = new GridBagConstraints();
		con.gridx = 0;
		con.gridy = 0;
		con.weightx = 1.0;
		// con.insets = new Insets(0, 100, 0, 0);
		con.anchor = GridBagConstraints.LINE_START;
		// con.anchor = GridBagConstraints.LINE_END;

		add(doneBut, con);

		nameField = new JTextField(t.getName());
		// nameField.setHorizontalAlignment(JTextField.TRAILING);
		nameField.setEnabled(false);
		// nameField.setBackground(Color.LIGHT_GRAY);
		nameField.setFont(new Font(null, Font.BOLD, 30));
		// nameArea.setDisabledTextColor(Color.BLACK);
		// nameField.setBorder(null);
		con = new GridBagConstraints();
		con.gridx = 1;
		con.gridy = 0;
		con.weightx = 1.0;
		// con.fill = GridBagConstraints.WEST;
		// con.insets = new Insets(0, 0, 0, 100);
		// con.insets = Insets.WEST_INSETS : EAST_INSETS;

		con.anchor = GridBagConstraints.LINE_START;
		add(nameField, con);

		// date format
		// TODO anche controlli su data qui
		// dateField = new JTextField(sdf.format(t.getDate()));
		dateField = new JTextField(controller.getDateFormat().format(
				t.getDate()));

		dateField.setEnabled(false);
		// dateField.setBackground(Color.GREEN);
		// dateField.setDisabledTextColor(Color.BLACK);
		// dateField.setBorder(null);
		con = new GridBagConstraints();
		con.gridx = 2;
		con.gridy = 0;
		// con.insets = new Insets(0, 0, 0, 300);
		// con.anchor = GridBagConstraints.LINE_START;
		add(dateField, con);

		// now build category ComboBox

		// TODO: Kadir suggests special combobox, our component wich extends
		// combobox
		// TODO: Kadir suggests special combobox, our component wich extends
		// combobox
		// TODO: Kadir suggests special combobox, our component wich extends
		// combobox
		// TODO: Kadir suggests special combobox, our component wich extends
		// combobox
		// TODO: Kadir suggests special combobox, our component wich extends
		// combobox
		// TODO: Kadir suggests special combobox, our component wich extends
		// combobox
		// maybe is better a button? Then simple dialog with colorpicker???
		categoryBox = new JComboBox<String>();
		for (Category c : controller.getCategories().values()) {
			categoryBox.addItem(c.getName());
		}

		// Add this special value for adding a task, will register listener

		categoryBox.addItem(lang
				.getString("shared_actions.newcategoryaction.text"));

		categoryBox.addActionListener(new ActionListener() {

			// If last "special item" is selected, open add category dialog
			// will be an action, because also NewTaskDialog will use this
			public void actionPerformed(ActionEvent e) {
				JComboBox<String> source = ((JComboBox<String>) e.getSource());

				// Note: this method fails is another category is called
				// "New Category..."
				// because it returns an index wich is not the last one
				// TODO how do i prevent this problem? Check on values?
				if (source.getSelectedIndex() == (source.getItemCount() - 1)) {

					// TODO open add category dialog
					// modify through controller
					// view will be updated by observer call
					// System.out.println("ultimo!");

					// TODO
					controller.getAction(ControllerInterface.ActionName.NEWCAT)
							.actionPerformed(null);
					// new AddCategoryDialog(controller);
				}

			}
		});

		// Select actual category
		categoryBox.setSelectedItem(t.getCategory().getName());
		categoryBox.setEnabled(false);

		// categoryBox.setEditable(true);
		// patternList.addActionListener(this);

		con = new GridBagConstraints();
		con.gridx = 3;
		con.gridy = 0;
		// con.insets = new Insets(0, 0, 0, 300);
		// con.anchor = GridBagConstraints.LINE_START;
		add(categoryBox, con);

		// And set my background color!
		setBackground(t.getCategory().getColor());

		// ------------------------------------------------------
		// TODO change this

		// priorityField = new JTextField(t.getPrio().toString());
		// priorityArea.addMouseListener(my);
		// priorityField.setEnabled(false);
		// priorityField.setBackground(Color.GREEN);
		// priorityField.setDisabledTextColor(Color.BLACK);
		// priorityField.setBorder(null);
		// con.insets = new Insets(0, 0, 0, 300);
		// con.anchor = GridBagConstraints.LINE_START;

		// add(priorityField, con);

		// PriorityBar pb = new PriorityBar(name, name, name, name, name, name,
		// name, name, name, name);
		bar = new PriorityBar("assets/def.png", "assets/hover1.png",
				"assets/pressed1.png", "assets/pressed1.png",
				"assets/hover2.png", "assets/pressed2.png",
				"assets/pressed2.png", "assets/hover3.png",
				"assets/pressed3.png", "assets/pressed3.png", t.getPrio());
		bar.setEnabled(false);

		con = new GridBagConstraints();
		con.gridx = 4;
		con.gridy = 0;

		add(bar, con);

		// ------------------------------------------------------

		descriptionArea = new JTextArea(t.getDescription(),
				GlobalValues.TASKROW_DESC_ROWS, GlobalValues.TASKROW_DESC_COLS);

		// descriptionArea = new JTextArea(t.getDescription());
		// descriptionArea.setBounds( 0, 0, 200, 200 );
		// descriptionArea.addMouseListener(my);
		descriptionArea.setEnabled(false);
		// descriptionArea.setBackground(Color.GREEN);
		// descriptionArea.setDisabledTextColor(Color.BLACK);
		descriptionArea.setLineWrap(true);
		descriptionArea.setWrapStyleWord(true);

		descriptionArea.setAlignmentX(CENTER_ALIGNMENT); // TODO not sure it
															// works.. once
															// again check
															// layout

		descriptionPane = new JScrollPane(descriptionArea);
		descriptionPane.setVisible(false);
		con = new GridBagConstraints();
		con.gridx = 5;
		con.gridy = 0;
		if (!descriptionArea.getText().isEmpty())
			descriptionPane.setVisible(true);

		add(descriptionPane, con);

		// Now the edit button
		editBut = new JButton();
		// editBut = new
		// JButton(lang.getString("mainFrame.middlePanel.taskScrollPanel.taskRow.button.edit.name"));

		editBut.setIcon(new ImageIcon(controller
				.getResource("assets/Icons/edittask.png")));

		editBut.addMouseListener(new MouseAdapter() {
			public void mousePressed(MouseEvent me) {

				// if (editBut.getActionCommand().equals(
				// lang.getString("mainFrame.middlePanel.taskScrollPanel.taskRow.button.edit.name")))
				// {
				if (!editBut.getIcon().toString().contains("stop")) {

					// nameField.setBackground(Color.GREEN);
					// dateField.setBackground(Color.GREEN);
					// categoryField.setBackground(Color.GREEN);
					// priorityField.setBackground(Color.GREEN);
					// descriptionArea.setBackground(Color.GREEN);

					// editBut.setText("Stop editing");

					// editBut.setIcon(defaultIcon)
					editBut.setIcon(new ImageIcon(controller
							.getResource("assets/Icons/stopedittask.png")));

				} else { // call edit task method

					// TODO
					// priority will be a radiobutton, for the moment it's just
					// some text
					// did this for quick prototype
					String name = nameField.getText();

					String date = dateField.getText();
					// TODO change priorty to drop down list

					// String priority = priorityField.getText();

					Task.Priority priority = bar.getPriority();
					// TODO: non meglio che categoryBox contenga direttamente
					// Category???
					// non stringhe!
					String categoryName = (String) categoryBox
							.getSelectedItem();
					String description = descriptionArea.getText();

					try {
						controller.editTask(t, name,
								controller.getDateFormat(), date, priority,
								t.getCompleted(), categoryName, description);
					} catch (InvalidCategoryException e) {
						JOptionPane.showMessageDialog(null, e.getMessage(),
								"Category Problem", JOptionPane.WARNING_MESSAGE);

					} catch (InvalidDateException e) {
						JOptionPane.showMessageDialog(null, e.getMessage(),
								"Date problem", JOptionPane.WARNING_MESSAGE);

						dateField.setText(controller.getDateFormat().format(
								t.getDate()));
					}
					nameField.setBackground(Color.WHITE);
					dateField.setBackground(Color.WHITE);
					categoryBox.setBackground(Color.WHITE);
					// bar.setBackground(Color.WHITE);
					descriptionArea.setBackground(Color.WHITE);

					setBackground(t.getCategory().getColor());

					editBut.setIcon(new ImageIcon(controller
							.getResource("assets/Icons/edittask.png")));
					//
					// editBut.setText(
					// lang.getString("mainFrame.middlePanel.taskScrollPanel.taskRow.button.edit.name"));
				}

				nameField.setEnabled(!nameField.isEnabled());
				dateField.setEnabled(!dateField.isEnabled());
				categoryBox.setEnabled(!categoryBox.isEnabled());
				// priorityField.setEnabled(!priorityField.isEnabled());
				bar.setEnabled(!bar.isEnabled());

				descriptionArea.setEnabled(!descriptionArea.isEnabled());
			}
		});

		editBut.setVisible(false);
		con = new GridBagConstraints();
		con.gridx = 6;
		con.gridy = 0;
		con.weightx = 1.0;
		con.anchor = GridBagConstraints.LINE_END;
		add(editBut, con);

		// Delete button apre un popup di conferma
		deleteBut = new JButton();
		// deleteBut = new JButton(
		// lang.getString("mainFrame.middlePanel.taskScrollPanel.taskRow.button.delete.name"));
		deleteBut.setIcon(new ImageIcon(controller
				.getResource("assets/Icons/deletetask.png")));

		deleteBut.addMouseListener(new MouseAdapter() {
			public void mousePressed(MouseEvent me) {

				// Display a dialog for confirmation and read answer
				// if yes, delete (call to parent, he knows already we r
				// focused)
				if (JOptionPane.showOptionDialog(null,
						"Are you sure you want to delete \"" + t.getName()
								+ "\"", "Confirm task deletion",
						JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE,
						null, null, null) == JOptionPane.YES_OPTION) {

					taskScrollPanel.deleteTask(); // TODO changed
					// controller.deleteTask(t);
				}
			}

		});
		deleteBut.setVisible(false);
		con = new GridBagConstraints();
		// con.gridx = 7;
		// con.gridy = 0;
		add(deleteBut, con);

		// Finally add panel listeners
		addMouseListener(new MouseAdapter() {
			// public void mousePressed(MouseEvent me) {

			// XXX: to be discussed with team, do we really need a
			// fixed focus when someone clicks? I feel that the onfocus
			// event is enough!
			// }

			public void mouseEntered(MouseEvent e) {

				if (!isSelected) {
					setBorder(BorderFactory
							.createBevelBorder(BevelBorder.LOWERED));

					setSelected(true);
				}

			}

			public void mouseExited(MouseEvent e) {
				if (!isSelected) {
					setBorder(BorderFactory
							.createBevelBorder(BevelBorder.RAISED));

					setSelected(false);
				}
			}
		});

		// setBorder(BorderFactory.createEmptyBorder(0, 10, 10, 10));
		// setBorder(BorderFactory.createLineBorder(Color.black, 50));
		setBorder(BorderFactory.createBevelBorder(BevelBorder.RAISED));
	}