Skip to content

Commit 520bb81

Browse files
committed
feat: improving UX by utilizing ColumnLabelProvider
1 parent 83fe2ea commit 520bb81

File tree

2 files changed

+85
-32
lines changed

2 files changed

+85
-32
lines changed

bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/nvs/dialog/NvsCsvEditorPage.java

Lines changed: 81 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,10 @@ public boolean getSaveAction()
276276
*/
277277
public void markDirty()
278278
{
279+
@SuppressWarnings("unchecked")
280+
List<NvsTableBean> beansToSave = (List<NvsTableBean>) tableViewer.getInput();
281+
validateBeansBeforeSaving(beansToSave);
282+
updateErrorMessage();
279283
dirtyStateListener.accept(true);
280284
}
281285

@@ -534,6 +538,17 @@ public String getColumnText(NvsTableBean bean)
534538
{
535539
return bean.getKey();
536540
}
541+
542+
@Override
543+
public String getToolTipText(Object element)
544+
{
545+
if (tableViewer.getElementAt(0).equals(element))
546+
{
547+
548+
return Messages.NvsEditorDialog_FirstRowIsFixedInfoMsg;
549+
}
550+
return super.getToolTipText(element);
551+
}
537552
});
538553
colKey.setEditingSupport(new EditingSupport(tableViewer)
539554
{
@@ -577,6 +592,28 @@ public String getColumnText(NvsTableBean bean)
577592
{
578593
return bean.getType();
579594
}
595+
596+
@Override
597+
public String getToolTipText(Object element)
598+
{
599+
if (tableViewer.getElementAt(0).equals(element))
600+
{
601+
602+
return Messages.NvsEditorDialog_FirstRowIsFixedInfoMsg;
603+
}
604+
return super.getToolTipText(element);
605+
}
606+
607+
@Override
608+
public Color getBackground(Object element)
609+
{
610+
if (tableViewer.getElementAt(0).equals(element))
611+
{
612+
return Display.getCurrent().getSystemColor(SWT.COLOR_WIDGET_LIGHT_SHADOW);
613+
}
614+
return null;
615+
}
616+
580617
});
581618
colType.setEditingSupport(new EditingSupport(tableViewer)
582619
{
@@ -587,11 +624,6 @@ protected CellEditor getCellEditor(Object element)
587624

588625
protected boolean canEdit(Object element)
589626
{
590-
if (tableViewer.getElementAt(0).equals(element))
591-
{
592-
setMessage(Messages.NvsEditorDialog_FirstRowIsFixedInfoMsg, IMessageProvider.INFORMATION);
593-
return false;
594-
}
595627
return true;
596628
}
597629

@@ -646,6 +678,27 @@ public String getColumnText(NvsTableBean bean)
646678
{
647679
return bean.getEncoding();
648680
}
681+
682+
@Override
683+
public String getToolTipText(Object element)
684+
{
685+
if (tableViewer.getElementAt(0).equals(element))
686+
{
687+
688+
return Messages.NvsEditorDialog_FirstRowIsFixedInfoMsg;
689+
}
690+
return super.getToolTipText(element);
691+
}
692+
693+
@Override
694+
public Color getBackground(Object element)
695+
{
696+
if (tableViewer.getElementAt(0).equals(element))
697+
{
698+
return Display.getCurrent().getSystemColor(SWT.COLOR_WIDGET_LIGHT_SHADOW);
699+
}
700+
return null;
701+
}
649702
});
650703
colEncoding.setEditingSupport(new EditingSupport(tableViewer)
651704
{
@@ -658,18 +711,7 @@ protected CellEditor getCellEditor(Object element)
658711

659712
protected boolean canEdit(Object element)
660713
{
661-
if (tableViewer.getElementAt(0).equals(element))
662-
{
663-
setMessage(Messages.NvsEditorDialog_FirstRowIsFixedInfoMsg, IMessageProvider.INFORMATION);
664-
return false;
665-
}
666-
NvsTableBean bean = (NvsTableBean) element;
667-
boolean isCellEditable = !bean.getType().contentEquals("namespace"); //$NON-NLS-1$
668-
if (!isCellEditable)
669-
{
670-
setMessage(Messages.NvsEditorDialog_NamespaceEditLimitationInfoMsg, IMessageProvider.INFORMATION);
671-
}
672-
return isCellEditable;
714+
return true;
673715
}
674716

675717
protected Object getValue(Object element)
@@ -715,6 +757,27 @@ public String getColumnText(NvsTableBean bean)
715757
{
716758
return bean.getValue();
717759
}
760+
761+
@Override
762+
public String getToolTipText(Object element)
763+
{
764+
if (tableViewer.getElementAt(0).equals(element))
765+
{
766+
767+
return Messages.NvsEditorDialog_FirstRowIsFixedInfoMsg;
768+
}
769+
return super.getToolTipText(element);
770+
}
771+
772+
@Override
773+
public Color getBackground(Object element)
774+
{
775+
if (tableViewer.getElementAt(0).equals(element))
776+
{
777+
return Display.getCurrent().getSystemColor(SWT.COLOR_WIDGET_LIGHT_SHADOW);
778+
}
779+
return null;
780+
}
718781
});
719782
colValue.setEditingSupport(new EditingSupport(tableViewer)
720783
{
@@ -725,18 +788,7 @@ protected CellEditor getCellEditor(Object element)
725788

726789
protected boolean canEdit(Object element)
727790
{
728-
if (tableViewer.getElementAt(0).equals(element))
729-
{
730-
setMessage(Messages.NvsEditorDialog_FirstRowIsFixedInfoMsg, IMessageProvider.INFORMATION);
731-
return false;
732-
}
733-
NvsTableBean bean = (NvsTableBean) element;
734-
boolean isCellEditable = !bean.getType().contentEquals("namespace"); //$NON-NLS-1$
735-
if (!isCellEditable)
736-
{
737-
setMessage(Messages.NvsEditorDialog_NamespaceEditLimitationInfoMsg, IMessageProvider.INFORMATION);
738-
}
739-
return isCellEditable;
791+
return true;
740792
}
741793

742794
protected Object getValue(Object element)

bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/nvs/dialog/NvsTableEditorLabelProvider.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
22

33
import org.eclipse.jface.dialogs.Dialog;
44
import org.eclipse.jface.resource.JFaceResources;
5-
import org.eclipse.jface.viewers.CellLabelProvider;
5+
import org.eclipse.jface.viewers.ColumnLabelProvider;
66
import org.eclipse.jface.viewers.ViewerCell;
77
import org.eclipse.swt.SWT;
88
import org.eclipse.swt.widgets.Display;
99

1010
import com.espressif.idf.core.build.NvsTableBean;
1111
import com.espressif.idf.core.util.NvsBeanValidator;
1212

13-
public abstract class NvsTableEditorLabelProvider extends CellLabelProvider
13+
public abstract class NvsTableEditorLabelProvider extends ColumnLabelProvider
1414
{
1515

1616
protected NvsBeanValidator validator = new NvsBeanValidator();
@@ -45,7 +45,8 @@ public void update(ViewerCell cell)
4545
cell.setForeground(null);
4646
cell.setImage(null);
4747
}
48-
cell.setBackground(null);
48+
49+
cell.setBackground(getBackground(bean));
4950
}
5051

5152
/**

0 commit comments

Comments
 (0)