use of org.talend.designer.core.ui.editor.TalendEditorPaletteFactory.RecentlyUsedComponent in project tdi-studio-se by Talend.
the class TalendEditorPaletteFactoryTest method testSortResultBasedOnRecentlyUsed.
@Test
public void testSortResultBasedOnRecentlyUsed() {
final String component1 = "component1";
final String component2 = "component2";
final String component3 = "component3";
List<RecentlyUsedComponent> recentlyUsedList = new ArrayList<RecentlyUsedComponent>(3);
RecentlyUsedComponent urc = new RecentlyUsedComponent();
GregorianCalendar gregorianCalendar = new GregorianCalendar();
urc.setName(component1);
gregorianCalendar.set(2016, 7, 20);
urc.setTimestamp(gregorianCalendar.getTime());
recentlyUsedList.add(urc);
urc = new RecentlyUsedComponent();
urc.setName(component2);
gregorianCalendar.set(2016, 7, 22);
urc.setTimestamp(gregorianCalendar.getTime());
recentlyUsedList.add(urc);
urc = new RecentlyUsedComponent();
urc.setName(component3);
gregorianCalendar.set(2016, 7, 21);
urc.setTimestamp(gregorianCalendar.getTime());
recentlyUsedList.add(urc);
TalendEditorPaletteFactory.storeRecentlyUsedList(recentlyUsedList);
IComponent comp1 = new DummyComponent(component1, component1 + " long name");
IComponent comp2 = new DummyComponent(component2, component2 + " long name");
IComponent comp3 = new DummyComponent(component3, component3 + " long name");
List<IComponent> componentHits = new ArrayList<IComponent>(3);
componentHits.add(comp1);
componentHits.add(comp2);
componentHits.add(comp3);
TalendEditorPaletteFactory.sortResultsBasedOnRecentlyUsed(componentHits);
assert (componentHits.get(0) == comp2);
assert (componentHits.get(1) == comp3);
assert (componentHits.get(2) == comp1);
}
use of org.talend.designer.core.ui.editor.TalendEditorPaletteFactory.RecentlyUsedComponent in project tdi-studio-se by Talend.
the class TalendPaletteViewer method refreshRecentlyUsedComponentToReference.
protected void refreshRecentlyUsedComponentToReference() {
if (recentlyUsedEditPart == null) {
return;
}
new Thread(new Runnable() {
@Override
public void run() {
if (recentlyUsedEditPart == null) {
return;
}
List children = recentlyUsedEditPart.getModelChildren();
if (children == null) {
return;
}
List<RecentlyUsedComponent> recentlyUsedList = new ArrayList<RecentlyUsedComponent>();
for (Object obj : children) {
TalendCombinedTemplateCreationEntry entryModule = (TalendCombinedTemplateCreationEntry) obj;
RecentlyUsedComponent recentlyUsedComponent = new RecentlyUsedComponent();
recentlyUsedComponent.setName(entryModule.getLabel());
recentlyUsedComponent.setTimestamp(entryModule.getTimestemp());
recentlyUsedList.add(recentlyUsedComponent);
}
TalendEditorPaletteFactory.storeRecentlyUsedList(recentlyUsedList);
}
}).start();
}
use of org.talend.designer.core.ui.editor.TalendEditorPaletteFactory.RecentlyUsedComponent in project tdi-studio-se by Talend.
the class TalendEditorPaletteFactoryTest method storeRecentlyUsed.
private void storeRecentlyUsed() {
List<RecentlyUsedComponent> recentlyUsedList = new ArrayList<RecentlyUsedComponent>(3);
RecentlyUsedComponent urc = new RecentlyUsedComponent();
GregorianCalendar gregorianCalendar = new GregorianCalendar();
urc.setName(TMYSQLROW);
gregorianCalendar.set(2016, 7, 22);
urc.setTimestamp(gregorianCalendar.getTime());
recentlyUsedList.add(urc);
urc = new RecentlyUsedComponent();
urc.setName(TJAVAROW);
gregorianCalendar.set(2016, 7, 21);
urc.setTimestamp(gregorianCalendar.getTime());
recentlyUsedList.add(urc);
TalendEditorPaletteFactory.storeRecentlyUsedList(recentlyUsedList);
}
Aggregations