Search in sources :

Example 1 with ImageRegistry

use of org.eclipse.jface.resource.ImageRegistry in project translationstudio8 by heartsome.

the class DefaultTableHeaderRenderer method getImageRegistry.

private ImageRegistry getImageRegistry() {
    if (_imageRegistry == null) {
        _imageRegistry = new ImageRegistry();
        ImageDescriptor imgDesc = new LocalResourceImageDescriptor("/de/jaret/util/ui/table/resource/smallarrow_down.gif");
        _imageRegistry.put(DOWN, imgDesc.createImage());
        imgDesc = new LocalResourceImageDescriptor("/de/jaret/util/ui/table/resource/smallarrow_up.gif");
        _imageRegistry.put(UP, imgDesc.createImage());
    }
    return _imageRegistry;
}
Also used : ImageRegistry(org.eclipse.jface.resource.ImageRegistry) ImageDescriptor(org.eclipse.jface.resource.ImageDescriptor)

Example 2 with ImageRegistry

use of org.eclipse.jface.resource.ImageRegistry in project translationstudio8 by heartsome.

the class BooleanCellRenderer method getImageRegistry.

/**
     * Retrieve the image registry used by the renderer (lazy initializing).
     * 
     * @return initialized image regsitry containing the resources
     */
private ImageRegistry getImageRegistry() {
    if (_imageRegistry == null) {
        _imageRegistry = new ImageRegistry();
        ImageDescriptor imgDesc = new ResourceImageDescriptor(_checkedRscName, this.getClass());
        _imageRegistry.put(CHECKED, imgDesc.createImage());
        imgDesc = new ResourceImageDescriptor(_uncheckedRscName, this.getClass());
        _imageRegistry.put(UNCHECKED, imgDesc.createImage());
    }
    return _imageRegistry;
}
Also used : ImageRegistry(org.eclipse.jface.resource.ImageRegistry) ResourceImageDescriptor(de.jaret.util.ui.ResourceImageDescriptor) ImageDescriptor(org.eclipse.jface.resource.ImageDescriptor) ResourceImageDescriptor(de.jaret.util.ui.ResourceImageDescriptor)

Example 3 with ImageRegistry

use of org.eclipse.jface.resource.ImageRegistry in project translationstudio8 by heartsome.

the class MultiLineListExample method getImageRegistry.

public static ImageRegistry getImageRegistry() {
    if (_imageRegistry == null) {
        _imageRegistry = new ImageRegistry();
        ImageDescriptor imgDesc = new ResourceImageDescriptor("/de/jaret/examples/table/mllist/icon.gif");
        _imageRegistry.put("icon", imgDesc);
        imgDesc = new ResourceImageDescriptor("/de/jaret/examples/table/keyboard.png");
        _imageRegistry.put("keyboard", imgDesc);
    }
    return _imageRegistry;
}
Also used : ImageRegistry(org.eclipse.jface.resource.ImageRegistry) ResourceImageDescriptor(de.jaret.util.ui.ResourceImageDescriptor) ImageDescriptor(org.eclipse.jface.resource.ImageDescriptor) ResourceImageDescriptor(de.jaret.util.ui.ResourceImageDescriptor)

Example 4 with ImageRegistry

use of org.eclipse.jface.resource.ImageRegistry in project archi by archimatetool.

the class ColoursFontsPreferencePage method performColoursDefaults.

private void performColoursDefaults() {
    fDeriveElementLineColorsButton.setSelection(getPreferenceStore().getDefaultBoolean(DERIVE_ELEMENT_LINE_COLOR));
    fPersistUserDefaultColors.setSelection(getPreferenceStore().getDefaultBoolean(SAVE_USER_DEFAULT_COLOR));
    fShowUserDefaultFillColorsInApplication.setSelection(getPreferenceStore().getDefaultBoolean(SHOW_FILL_COLORS_IN_GUI));
    fElementLineColorContrastSpinner.setSelection(getPreferenceStore().getDefaultInt(DERIVE_ELEMENT_LINE_COLOR_FACTOR));
    // Set color cache to inbuilt defaults
    resetColorsCache(true);
    // Clear tree image registry
    fImageRegistry.dispose();
    fImageRegistry = new ImageRegistry();
    // Update tree
    for (Entry<Object, Color> entry : fColorsCache.entrySet()) {
        fTreeViewer.update(entry.getKey(), null);
    }
}
Also used : ImageRegistry(org.eclipse.jface.resource.ImageRegistry) Color(org.eclipse.swt.graphics.Color)

Example 5 with ImageRegistry

use of org.eclipse.jface.resource.ImageRegistry in project archi by archimatetool.

the class ColoursFontsPreferencePage method createColoursTab.

private void createColoursTab() {
    // Reset everything
    resetColorsCache(false);
    fImageRegistry = new ImageRegistry();
    Composite client = new Composite(fTabfolder, SWT.NULL);
    client.setLayout(new GridLayout(2, false));
    TabItem item = new TabItem(fTabfolder, SWT.NONE);
    item.setText(Messages.ColoursFontsPreferencePage_23);
    item.setControl(client);
    Label label = new Label(client, SWT.NULL);
    label.setText(Messages.ColoursFontsPreferencePage_0);
    GridData gd = new GridData(GridData.FILL_HORIZONTAL);
    gd.horizontalSpan = 2;
    label.setLayoutData(gd);
    // Tree
    fTreeViewer = new TreeViewer(client);
    gd = new GridData(GridData.FILL_BOTH);
    // need this to set a smaller height
    gd.heightHint = 80;
    fTreeViewer.getTree().setLayoutData(gd);
    // Tree Double-click listener
    fTreeViewer.addDoubleClickListener(new IDoubleClickListener() {

        @Override
        public void doubleClick(DoubleClickEvent event) {
            Object[] selected = ((IStructuredSelection) fTreeViewer.getSelection()).toArray();
            if (isValidTreeSelection(selected)) {
                RGB newRGB = openColorDialog(selected[0]);
                if (newRGB != null) {
                    for (Object object : selected) {
                        setColor(object, newRGB);
                    }
                }
            }
        }
    });
    // Tree Selection Changed Listener
    fTreeViewer.addSelectionChangedListener(new ISelectionChangedListener() {

        @Override
        public void selectionChanged(SelectionChangedEvent event) {
            Object[] selected = ((IStructuredSelection) event.getSelection()).toArray();
            fEditFillColorButton.setEnabled(isValidTreeSelection(selected));
            fResetFillColorButton.setEnabled(isValidTreeSelection(selected));
        }
    });
    // Tree Content Provider
    fTreeViewer.setContentProvider(new ITreeContentProvider() {

        @Override
        public void dispose() {
        }

        @Override
        public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
        }

        @Override
        public Object[] getElements(Object inputElement) {
            if (inputElement instanceof String) {
                return new Object[] { new TreeGrouping(Messages.ColoursFontsPreferencePage_32, ArchimateModelUtils.getStrategyClasses()), new TreeGrouping(Messages.ColoursFontsPreferencePage_7, ArchimateModelUtils.getBusinessClasses()), new TreeGrouping(Messages.ColoursFontsPreferencePage_8, ArchimateModelUtils.getApplicationClasses()), new TreeGrouping(Messages.ColoursFontsPreferencePage_9, ArchimateModelUtils.getTechnologyClasses()), new TreeGrouping(Messages.ColoursFontsPreferencePage_33, ArchimateModelUtils.getPhysicalClasses()), new TreeGrouping(Messages.ColoursFontsPreferencePage_10, ArchimateModelUtils.getMotivationClasses()), new TreeGrouping(Messages.ColoursFontsPreferencePage_11, ArchimateModelUtils.getImplementationMigrationClasses()), new TreeGrouping(Messages.ColoursFontsPreferencePage_17, ArchimateModelUtils.getOtherClasses()), new TreeGrouping(Messages.ColoursFontsPreferencePage_34, new Object[] { IArchimatePackage.eINSTANCE.getDiagramModelNote(), IArchimatePackage.eINSTANCE.getDiagramModelGroup() }), DEFAULT_ELEMENT_LINE_COLOR, DEFAULT_CONNECTION_LINE_COLOR };
            }
            return null;
        }

        @Override
        public Object[] getChildren(Object parentElement) {
            if (parentElement instanceof TreeGrouping) {
                return ((TreeGrouping) parentElement).children;
            }
            return null;
        }

        @Override
        public Object getParent(Object element) {
            return null;
        }

        @Override
        public boolean hasChildren(Object element) {
            return element instanceof TreeGrouping;
        }
    });
    // Tree Label Provider
    fTreeViewer.setLabelProvider(new LabelProvider() {

        @Override
        public String getText(Object element) {
            if (element instanceof EClass) {
                return ArchiLabelProvider.INSTANCE.getDefaultName((EClass) element);
            }
            if (element instanceof TreeGrouping) {
                return ((TreeGrouping) element).title;
            }
            if (element instanceof String) {
                String s = (String) element;
                if (s.equals(DEFAULT_ELEMENT_LINE_COLOR)) {
                    return Messages.ColoursFontsPreferencePage_12;
                }
                if (s.equals(DEFAULT_CONNECTION_LINE_COLOR)) {
                    return Messages.ColoursFontsPreferencePage_18;
                }
            }
            return null;
        }

        @Override
        public Image getImage(Object element) {
            if (element instanceof TreeGrouping) {
                return IArchiImages.ImageFactory.getImage(IArchiImages.ECLIPSE_IMAGE_FOLDER);
            }
            return getColorSwatch(element);
        }

        // Create a coloured image based on colour and add to the image registry
        private Image getColorSwatch(Object object) {
            String key = getColorKey(object);
            Image image = fImageRegistry.get(key);
            if (image == null) {
                image = new Image(Display.getCurrent(), 16, 16);
                GC gc = new GC(image);
                SWTGraphics graphics = new SWTGraphics(gc);
                graphics.setBackgroundColor(fColorsCache.get(object));
                graphics.fillRectangle(0, 0, 15, 15);
                graphics.drawRectangle(0, 0, 15, 15);
                gc.dispose();
                graphics.dispose();
                fImageRegistry.put(key, image);
            }
            return image;
        }
    });
    // fTreeViewer.setAutoExpandLevel(2);
    // Set Content in Tree
    // $NON-NLS-1$
    fTreeViewer.setInput("");
    // Buttons
    Composite buttonClient = new Composite(client, SWT.NULL);
    gd = new GridData(SWT.TOP, SWT.TOP, false, false);
    buttonClient.setLayoutData(gd);
    buttonClient.setLayout(new GridLayout());
    // Edit...
    fEditFillColorButton = new Button(buttonClient, SWT.PUSH);
    fEditFillColorButton.setText(Messages.ColoursFontsPreferencePage_13);
    fEditFillColorButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    fEditFillColorButton.setEnabled(false);
    fEditFillColorButton.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent event) {
            Object[] selected = ((IStructuredSelection) fTreeViewer.getSelection()).toArray();
            if (isValidTreeSelection(selected)) {
                RGB newRGB = openColorDialog(selected[0]);
                if (newRGB != null) {
                    for (Object object : selected) {
                        setColor(object, newRGB);
                    }
                }
            }
        }
    });
    // Reset
    fResetFillColorButton = new Button(buttonClient, SWT.PUSH);
    fResetFillColorButton.setText(Messages.ColoursFontsPreferencePage_14);
    fResetFillColorButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    fResetFillColorButton.setEnabled(false);
    fResetFillColorButton.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent event) {
            Object[] selected = ((IStructuredSelection) fTreeViewer.getSelection()).toArray();
            if (isValidTreeSelection(selected)) {
                for (Object object : selected) {
                    resetColorToInbuiltDefault(object);
                }
            }
        }
    });
    // Import Scheme
    Button importButton = new Button(buttonClient, SWT.PUSH);
    importButton.setText(Messages.ColoursFontsPreferencePage_2);
    importButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    importButton.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            try {
                importUserColors();
            } catch (IOException ex) {
                ex.printStackTrace();
            }
        }
    });
    // Export Scheme
    Button exportButton = new Button(buttonClient, SWT.PUSH);
    exportButton.setText(Messages.ColoursFontsPreferencePage_3);
    exportButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    exportButton.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            try {
                exportUserColors();
            } catch (IOException ex) {
                ex.printStackTrace();
            }
        }
    });
    Group elementColorGroup = new Group(client, SWT.NULL);
    elementColorGroup.setLayout(new GridLayout(2, false));
    elementColorGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    elementColorGroup.setText(Messages.ColoursFontsPreferencePage_20);
    // Derive element line colours
    fDeriveElementLineColorsButton = new Button(elementColorGroup, SWT.CHECK);
    fDeriveElementLineColorsButton.setText(Messages.ColoursFontsPreferencePage_19);
    gd = new GridData(GridData.FILL_HORIZONTAL);
    gd.horizontalSpan = 2;
    fDeriveElementLineColorsButton.setLayoutData(gd);
    fDeriveElementLineColorsButton.setSelection(getPreferenceStore().getBoolean(DERIVE_ELEMENT_LINE_COLOR));
    fDeriveElementLineColorsButton.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            fElementLineColorContrastSpinner.setEnabled(fDeriveElementLineColorsButton.getSelection());
            fContrastFactorLabel.setEnabled(fDeriveElementLineColorsButton.getSelection());
        }
    });
    fContrastFactorLabel = new Label(elementColorGroup, SWT.NULL);
    fContrastFactorLabel.setText(Messages.ColoursFontsPreferencePage_21);
    fElementLineColorContrastSpinner = new Spinner(elementColorGroup, SWT.BORDER);
    fElementLineColorContrastSpinner.setMinimum(1);
    fElementLineColorContrastSpinner.setMaximum(10);
    fElementLineColorContrastSpinner.setSelection(getPreferenceStore().getInt(DERIVE_ELEMENT_LINE_COLOR_FACTOR));
    label = new Label(elementColorGroup, SWT.NULL);
    label.setText(Messages.ColoursFontsPreferencePage_22);
    gd = new GridData(GridData.FILL_HORIZONTAL);
    gd.horizontalSpan = 2;
    // Persist user default colours
    fPersistUserDefaultColors = new Button(client, SWT.CHECK);
    fPersistUserDefaultColors.setText(Messages.ColoursFontsPreferencePage_1);
    fPersistUserDefaultColors.setLayoutData(gd);
    fPersistUserDefaultColors.setSelection(getPreferenceStore().getBoolean(SAVE_USER_DEFAULT_COLOR));
    // Use colours in application
    fShowUserDefaultFillColorsInApplication = new Button(client, SWT.CHECK);
    fShowUserDefaultFillColorsInApplication.setText(Messages.ColoursFontsPreferencePage_6);
    fShowUserDefaultFillColorsInApplication.setLayoutData(gd);
    fShowUserDefaultFillColorsInApplication.setSelection(getPreferenceStore().getBoolean(SHOW_FILL_COLORS_IN_GUI));
}
Also used : ITreeContentProvider(org.eclipse.jface.viewers.ITreeContentProvider) Group(org.eclipse.swt.widgets.Group) TreeViewer(org.eclipse.jface.viewers.TreeViewer) Spinner(org.eclipse.swt.widgets.Spinner) CLabel(org.eclipse.swt.custom.CLabel) Label(org.eclipse.swt.widgets.Label) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) TreeViewer(org.eclipse.jface.viewers.TreeViewer) Viewer(org.eclipse.jface.viewers.Viewer) Image(org.eclipse.swt.graphics.Image) GridLayout(org.eclipse.swt.layout.GridLayout) EClass(org.eclipse.emf.ecore.EClass) Button(org.eclipse.swt.widgets.Button) IDoubleClickListener(org.eclipse.jface.viewers.IDoubleClickListener) SelectionEvent(org.eclipse.swt.events.SelectionEvent) GC(org.eclipse.swt.graphics.GC) Composite(org.eclipse.swt.widgets.Composite) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) DoubleClickEvent(org.eclipse.jface.viewers.DoubleClickEvent) IOException(java.io.IOException) RGB(org.eclipse.swt.graphics.RGB) TabItem(org.eclipse.swt.widgets.TabItem) SWTGraphics(org.eclipse.draw2d.SWTGraphics) ImageRegistry(org.eclipse.jface.resource.ImageRegistry) GridData(org.eclipse.swt.layout.GridData) ArchiLabelProvider(com.archimatetool.editor.ui.ArchiLabelProvider) LabelProvider(org.eclipse.jface.viewers.LabelProvider)

Aggregations

ImageRegistry (org.eclipse.jface.resource.ImageRegistry)63 ImageDescriptor (org.eclipse.jface.resource.ImageDescriptor)25 Image (org.eclipse.swt.graphics.Image)22 URL (java.net.URL)4 ResourceBundle (java.util.ResourceBundle)4 Before (org.junit.Before)4 CoreRuntimePlugin (org.talend.core.runtime.CoreRuntimePlugin)4 CompositeMultiImageDescriptor (com.archimatetool.editor.ui.components.CompositeMultiImageDescriptor)3 ResourceImageDescriptor (de.jaret.util.ui.ResourceImageDescriptor)3 CompositeImageDescriptor (org.eclipse.jface.resource.CompositeImageDescriptor)3 Label (org.eclipse.swt.widgets.Label)3 RepositoryContext (org.talend.core.context.RepositoryContext)3 Project (org.talend.core.model.general.Project)3 User (org.talend.core.model.properties.User)3 IRepositoryFactory (org.talend.core.repository.model.IRepositoryFactory)3 ProxyRepositoryFactory (org.talend.core.repository.model.ProxyRepositoryFactory)3 XmiResourceManager (org.talend.core.repository.utils.XmiResourceManager)3 IRepositoryNodeConfiguration (org.talend.mdm.repository.core.IRepositoryNodeConfiguration)3 IRepositoryNodeResourceProvider (org.talend.mdm.repository.core.IRepositoryNodeResourceProvider)3 RecycleBinNodeConfiguration (org.talend.mdm.repository.core.impl.recyclebin.RecycleBinNodeConfiguration)3