Search in sources :

Example 1 with ImagePropertiesDialog

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);
}
Also used : RefreshAction(org.netxms.ui.eclipse.actions.RefreshAction) Action(org.eclipse.jface.action.Action) RefreshAction(org.netxms.ui.eclipse.actions.RefreshAction) DefaultGalleryGroupRenderer(org.netxms.nebula.widgets.gallery.DefaultGalleryGroupRenderer) ImagePropertiesDialog(org.netxms.ui.eclipse.imagelibrary.dialogs.ImagePropertiesDialog) LibraryImage(org.netxms.client.LibraryImage) SWTException(org.eclipse.swt.SWTException) IOException(java.io.IOException) NXCException(org.netxms.client.NXCException)

Aggregations

IOException (java.io.IOException)1 Action (org.eclipse.jface.action.Action)1 SWTException (org.eclipse.swt.SWTException)1 LibraryImage (org.netxms.client.LibraryImage)1 NXCException (org.netxms.client.NXCException)1 DefaultGalleryGroupRenderer (org.netxms.nebula.widgets.gallery.DefaultGalleryGroupRenderer)1 RefreshAction (org.netxms.ui.eclipse.actions.RefreshAction)1 ImagePropertiesDialog (org.netxms.ui.eclipse.imagelibrary.dialogs.ImagePropertiesDialog)1