use of org.netxms.nebula.widgets.gallery.GalleryItem in project netxms by netxms.
the class GalleryViewerRow method getRowBelow.
protected ViewerRow getRowBelow() {
if (item.getParentItem() == null) {
int index = item.getParent().indexOf(item) + 1;
if (index < item.getParent().getItemCount()) {
GalleryItem tmp = item.getParent().getItem(index);
if (tmp != null) {
return new GalleryViewerRow(tmp);
}
}
} else {
GalleryItem parentItem = item.getParentItem();
int index = parentItem.indexOf(item) + 1;
if (index < parentItem.getItemCount()) {
GalleryItem tmp = parentItem.getItem(index);
if (tmp != null) {
return new GalleryViewerRow(tmp);
}
}
}
return null;
}
use of org.netxms.nebula.widgets.gallery.GalleryItem in project netxms by netxms.
the class ImageLibrary method refreshUI.
/**
* Refresh UI after retrieving imaqe library from server
*/
private void refreshUI(List<LibraryImage> imageLibrary) {
Map<String, List<LibraryImage>> categories = new HashMap<String, List<LibraryImage>>();
for (LibraryImage image : imageLibrary) {
final String category = image.getCategory();
if (!categories.containsKey(category)) {
categories.put(category, new ArrayList<LibraryImage>());
}
categories.get(category).add(image);
}
this.knownCategories = categories.keySet();
gallery.removeAll();
for (String category : categories.keySet()) {
final GalleryItem categoryItem = new GalleryItem(gallery, SWT.NONE);
categoryItem.setText(category);
final List<LibraryImage> categoryImages = categories.get(category);
for (final LibraryImage image : categoryImages) {
final GalleryItem imageItem = new GalleryItem(categoryItem, SWT.NONE);
imageItem.setText(image.getName());
final byte[] binaryData = image.getBinaryData();
if (binaryData != null) {
final ByteArrayInputStream stream = new ByteArrayInputStream(binaryData);
try {
imageItem.setImage(new Image(getSite().getShell().getDisplay(), stream));
} catch (SWTException e) {
// $NON-NLS-1$
Activator.logError("Exception in ImageLibrary.refreshUI()", e);
// show as "missing"
imageItem.setImage(ImageProvider.getInstance(getSite().getShell().getDisplay()).getImage(null));
}
} else {
// show as "missing"
imageItem.setImage(ImageProvider.getInstance(getSite().getShell().getDisplay()).getImage(null));
}
imageItem.setData(image);
}
}
gallery.redraw();
}
use of org.netxms.nebula.widgets.gallery.GalleryItem in project netxms by netxms.
the class ImageLibrary method deleteImage.
/**
*/
protected void deleteImage() {
final GalleryItem[] selection = gallery.getSelection();
for (GalleryItem item : selection) {
try {
session.deleteImage((LibraryImage) item.getData());
final GalleryItem category = item.getParentItem();
gallery.remove(item);
if (category != null) {
if (category.getItemCount() == 0) {
gallery.remove(category);
}
}
} catch (NXCException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
}
use of org.netxms.nebula.widgets.gallery.GalleryItem in project netxms by netxms.
the class GalleryTreeViewer method editElement.
public void editElement(Object element, int column) {
if (element instanceof TreePath) {
setSelection(new TreeSelection((TreePath) element));
GalleryItem[] items = gallery.getSelection();
if (items.length == 1) {
ViewerRow row = getViewerRowFromItem(items[0]);
if (row != null) {
ViewerCell cell = row.getCell(column);
if (cell != null) {
getControl().setRedraw(false);
triggerEditorActivationEvent(new ColumnViewerEditorActivationEvent(cell));
getControl().setRedraw(true);
}
}
}
} else {
super.editElement(element, column);
}
}
Aggregations