use of org.eclipse.gef.palette.CombinedTemplateCreationEntry in project tdi-studio-se by Talend.
the class TalendPaletteViewer method addFavoritesComponent.
public void addFavoritesComponent(CombinedTemplateCreationEntry component) {
if (favoritesEditPart != null) {
List children = favoritesEditPart.getChildren();
int insertIndex = 0;
boolean alreadyExist = false;
if (children != null) {
for (; insertIndex < children.size(); insertIndex++) {
TalendEntryEditPart entryEditPart = (TalendEntryEditPart) children.get(insertIndex);
CombinedTemplateCreationEntry entryModule = (CombinedTemplateCreationEntry) entryEditPart.getModel();
int compareResult = entryModule.getLabel().toLowerCase().compareTo(component.getLabel().toLowerCase());
if (0 == compareResult) {
alreadyExist = true;
break;
}
if (0 < compareResult) {
break;
}
}
}
if (!alreadyExist) {
TalendEditorPaletteFactory.addNewFavoriteIntoPreference(component.getLabel());
CombinedTemplateCreationEntry newFavorite = TalendEditorPaletteFactory.createEntryFrom(component);
newFavorite.setParent(favoritesEditPart.getDrawer());
EditPart child = favoritesEditPart.createChild(newFavorite);
PaletteDrawer paletteDrawer = favoritesEditPart.getDrawer();
if (paletteDrawer != null) {
paletteDrawer.add(insertIndex, newFavorite);
}
// needn't use this, or will cause problem
// favoritesEditPart.addChild(child, insertIndex);
}
}
}
use of org.eclipse.gef.palette.CombinedTemplateCreationEntry in project tdi-studio-se by Talend.
the class TalendPaletteViewer method addRecentlyUsedComponent.
public void addRecentlyUsedComponent(IComponent component) {
EComponentType componentType = component.getComponentType();
if (componentType == EComponentType.JOBLET_INPUT_OUTPUT || componentType == EComponentType.JOBLET_TRIGGER) {
return;
}
if (recentlyUsedEditPart != null) {
List children = recentlyUsedEditPart.getChildren();
int insertIndex = 0;
boolean alreadyExist = false;
if (children != null) {
for (; insertIndex < children.size(); insertIndex++) {
TalendEntryEditPart entryEditPart = (TalendEntryEditPart) children.get(insertIndex);
CombinedTemplateCreationEntry entryModule = (CombinedTemplateCreationEntry) entryEditPart.getModel();
int compareResult = entryModule.getLabel().compareTo(component.getName());
if (0 == compareResult) {
alreadyExist = true;
break;
}
// if (0 < compareResult) {
// break;
// }
}
}
// if already exist, remove first
if (alreadyExist) {
if (0 == insertIndex) {
return;
}
TalendEntryEditPart entryEditPart = (TalendEntryEditPart) children.get(insertIndex);
CombinedTemplateCreationEntry entryModule = (CombinedTemplateCreationEntry) entryEditPart.getModel();
removeRecentlyUsedComponent(entryModule);
}
// if (!alreadyExist) {
TalendCombinedTemplateCreationEntry newRecently = TalendEditorPaletteFactory.createEntryFrom(component);
newRecently.setTimestemp(new Date());
newRecently.setParent(recentlyUsedEditPart.getDrawer());
EditPart child = recentlyUsedEditPart.createChild(newRecently);
PaletteDrawer paletteDrawer = recentlyUsedEditPart.getDrawer();
if (paletteDrawer != null) {
// paletteDrawer.add(insertIndex, newRecently);
paletteDrawer.add(0, newRecently);
}
// reobtain
children = recentlyUsedEditPart.getChildren();
if (children != null) {
int size = children.size();
final int recentlyUsedSize = PaletteSettingsPreferencePage.getPaletteRencentlyUsedListSize();
if (recentlyUsedSize < size) {
TalendEntryEditPart entryEditPart = (TalendEntryEditPart) children.get(recentlyUsedSize);
CombinedTemplateCreationEntry entryModule = (CombinedTemplateCreationEntry) entryEditPart.getModel();
removeRecentlyUsedComponent(entryModule);
}
}
// needn't use this, or will cause problem
// recentlyUsedEditPart.addChild(child, insertIndex);
// }
refreshRecentlyUsedComponentToReference();
}
}
Aggregations