use of org.netxms.ui.eclipse.imagelibrary.dialogs.ImagePropertiesDialog in project netxms by netxms.
the class ImageLibrary method createActions.
/**
* Create actions
*/
private void createActions() {
actionNew = new Action(Messages.get().ImageLibrary_ActionUpload) {
@Override
public void run() {
final ImagePropertiesDialog dialog = new ImagePropertiesDialog(getSite().getShell(), knownCategories, imageLibrary, false);
final GalleryItem[] selection = gallery.getSelection();
if (selection.length > 0) {
LibraryImage image = (LibraryImage) selection[0].getData();
dialog.setDefaultCategory(image.getCategory());
}
if (dialog.open() == Dialog.OK) {
uploadNewImage(dialog.getName(), dialog.getCategory(), dialog.getFileName());
}
}
};
actionNew.setImageDescriptor(SharedIcons.ADD_OBJECT);
actionEdit = new Action(Messages.get().ImageLibrary_ActionEdit) {
@Override
public void run() {
final GalleryItem[] selection = gallery.getSelection();
if (selection.length == 1) {
final ImagePropertiesDialog dialog = new ImagePropertiesDialog(getSite().getShell(), knownCategories, imageLibrary, true);
LibraryImage image = (LibraryImage) selection[0].getData();
dialog.setName(image.getName());
dialog.setDefaultCategory(image.getCategory());
if (dialog.open() == Dialog.OK) {
editImage(selection[0], dialog.getName(), dialog.getCategory(), dialog.getFileName());
}
}
}
};
actionEdit.setImageDescriptor(SharedIcons.EDIT);
actionDelete = new Action(Messages.get().ImageLibrary_ActionDelete) {
@Override
public void run() {
deleteImage();
}
};
actionDelete.setImageDescriptor(SharedIcons.DELETE_OBJECT);
actionRefresh = new RefreshAction(this) {
@Override
public void run() {
try {
refreshImages();
} catch (Exception e) {
// $NON-NLS-1$
Activator.logError("ImageLibrary view: Exception in refresh action", e);
}
}
};
actionZoomIn = new Action(Messages.get().ImageLibrary_ActionZoomIn) {
@Override
public void run() {
final DefaultGalleryGroupRenderer groupRenderer = (DefaultGalleryGroupRenderer) gallery.getGroupRenderer();
if (currentIconSize < MAX_GRID_ICON_SIZE) {
currentIconSize += 16;
groupRenderer.setItemHeight(currentIconSize);
groupRenderer.setItemWidth(currentIconSize);
}
}
};
actionZoomIn.setImageDescriptor(SharedIcons.ZOOM_IN);
actionZoomOut = new Action(Messages.get().ImageLibrary_ActionZoomOut) {
@Override
public void run() {
final DefaultGalleryGroupRenderer groupRenderer = (DefaultGalleryGroupRenderer) gallery.getGroupRenderer();
if (currentIconSize > MIN_GRID_ICON_SIZE) {
currentIconSize -= 16;
groupRenderer.setItemHeight(currentIconSize);
groupRenderer.setItemWidth(currentIconSize);
}
}
};
actionZoomOut.setImageDescriptor(SharedIcons.ZOOM_OUT);
}
Aggregations