Author: scabanovich
Date: 2012-10-17 12:56:48 -0400 (Wed, 17 Oct 2012)
New Revision: 44559
Added:
trunk/common/plugins/org.jboss.tools.common.ui/src/org/jboss/tools/common/ui/CommonUIImages.java
Removed:
trunk/common/plugins/org.jboss.tools.common.ui/src/org/jboss/tools/common/ui/ModelUIImages.java
Modified:
trunk/common/plugins/org.jboss.tools.common.ui/src/org/jboss/tools/common/ui/wizard/service/NewServiceWizardPage.java
trunk/common/plugins/org.jboss.tools.common.ui/src/org/jboss/tools/common/ui/wizard/service/RegisterAsServiceDialog.java
Log:
JBIDE-12866
https://issues.jboss.org/browse/JBIDE-12866
CommonUIImages modified.
Copied:
trunk/common/plugins/org.jboss.tools.common.ui/src/org/jboss/tools/common/ui/CommonUIImages.java
(from rev 44556,
trunk/common/plugins/org.jboss.tools.common.ui/src/org/jboss/tools/common/ui/ModelUIImages.java)
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.ui/src/org/jboss/tools/common/ui/CommonUIImages.java
(rev 0)
+++
trunk/common/plugins/org.jboss.tools.common.ui/src/org/jboss/tools/common/ui/CommonUIImages.java 2012-10-17
16:56:48 UTC (rev 44559)
@@ -0,0 +1,109 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.common.ui;
+
+import java.net.MalformedURLException;
+import java.net.URL;
+
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.resource.ImageRegistry;
+import org.eclipse.swt.graphics.Image;
+import org.jboss.tools.common.ui.CommonUIPlugin;
+
+public class CommonUIImages {
+ private static CommonUIImages INSTANCE;
+
+ static {
+ try {
+ INSTANCE = new CommonUIImages(new
URL(CommonUIPlugin.getDefault().getBundle().getEntry("/"), "icons/"));
//$NON-NLS-1$ //$NON-NLS-2$
+ } catch (MalformedURLException e) {
+ CommonUIPlugin.getDefault().logError(e);
+ }
+ }
+
+ public static final String JAVA_SERVICE_PROVIDER_IMAGE =
"wizard/JavaServiceProviderWizBan.png"; //$NON-NLS-1$
+ public static final String NEW_JAVA_SERVICE_PROVIDER_IMAGE =
"wizard/NewJavaServiceProviderWizBan.png"; //$NON-NLS-1$
+
+ public final static Image getImage(ImageDescriptor descriptor) {
+ return CommonUIPlugin.getImageDescriptorRegistry().get(descriptor);
+ }
+
+ public static void setImageDescriptors(IAction action, String iconName) {
+ action.setImageDescriptor(getInstance().getOrCreateImageDescriptor(iconName));
+ }
+
+ public static CommonUIImages getInstance() {
+ return INSTANCE;
+ }
+
+ protected URL baseUrl;
+ protected CommonUIImages parentRegistry;
+
+ protected CommonUIImages(URL registryUrl, CommonUIImages parent){
+ if(registryUrl == null) throw new
IllegalArgumentException(CommonUIMessages.IMAGESBASE_URL_FOR_IMAGE_REGISTRY_CANNOT_BE_NULL);
+ baseUrl = registryUrl;
+ parentRegistry = parent;
+ }
+
+ protected CommonUIImages(URL url){
+ this(url,null);
+ }
+
+ protected ImageRegistry getImageRegistry() {
+ return CommonUIPlugin.getDefault().getImageRegistry();
+ }
+
+ public final ImageDescriptor getOrCreateImageDescriptor(String key) {
+ ImageDescriptor result = null;
+ ImageRegistry registry = getImageRegistry();
+ synchronized(registry) {
+ result = registry.getDescriptor(key);
+ }
+ if(result == null) {
+ result = createImageDescriptor(key);
+ if(result != null) {
+ synchronized (registry) {
+ registry.remove(key);
+ registry.put(key, result);
+ }
+ }
+ }
+ return result;
+ }
+
+ public final Image getOrCreateImage(String key) {
+ getOrCreateImageDescriptor(key);
+ return getImageRegistry().get(key);
+ }
+
+ public final Image getImageByFileName(String key) {
+ return getOrCreateImage(key);
+ }
+
+ public final ImageDescriptor createImageDescriptor(String key) {
+ try {
+ return ImageDescriptor.createFromURL(makeIconFileURL(key));
+ } catch (MalformedURLException e) {
+ if(parentRegistry == null) {
+ return ImageDescriptor.getMissingImageDescriptor();
+ } else {
+ return parentRegistry.createImageDescriptor(key);
+ }
+ }
+ }
+
+ private URL makeIconFileURL(String name) throws MalformedURLException {
+ if (name == null) throw new
MalformedURLException(CommonUIMessages.IMAGESIMAGE_NAME_CANNOT_BE_NULL);
+ return new URL(baseUrl, name);
+ }
+
+}
Property changes on:
trunk/common/plugins/org.jboss.tools.common.ui/src/org/jboss/tools/common/ui/CommonUIImages.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Deleted:
trunk/common/plugins/org.jboss.tools.common.ui/src/org/jboss/tools/common/ui/ModelUIImages.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.ui/src/org/jboss/tools/common/ui/ModelUIImages.java 2012-10-17
16:08:14 UTC (rev 44558)
+++
trunk/common/plugins/org.jboss.tools.common.ui/src/org/jboss/tools/common/ui/ModelUIImages.java 2012-10-17
16:56:48 UTC (rev 44559)
@@ -1,90 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2011 Red Hat, Inc.
- * Distributed under license by Red Hat, Inc. All rights reserved.
- * This program is made available under the terms of the
- * Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at
http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
-package org.jboss.tools.common.ui;
-
-import java.net.MalformedURLException;
-import java.net.URL;
-
-import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.swt.graphics.Image;
-import org.jboss.tools.common.ui.CommonUIPlugin;
-
-public class ModelUIImages {
-
- private static ModelUIImages INSTANCE;
-
- static {
- try {
- INSTANCE = new ModelUIImages(new
URL(CommonUIPlugin.getDefault().getBundle().getEntry("/"), "icons/"));
//$NON-NLS-1$ //$NON-NLS-2$
- } catch (MalformedURLException e) {
- CommonUIPlugin.getDefault().logError(e);
- }
- }
-
- public static final String JAVA_SERVICE_PROVIDER_IMAGE =
"wizard/JavaServiceProviderWizBan.png"; //$NON-NLS-1$
- public static final String NEW_JAVA_SERVICE_PROVIDER_IMAGE =
"wizard/NewJavaServiceProviderWizBan.png"; //$NON-NLS-1$
-
- public static Image getImage(ImageDescriptor descriptor) {
- return CommonUIPlugin.getImageDescriptorRegistry().get(descriptor);
- }
-
- public static Image getImage(String key) {
- return INSTANCE.createImageDescriptor(key).createImage();
- }
-
- public static ImageDescriptor getImageDescriptor(String key) {
- return INSTANCE.createImageDescriptor(key);
- }
-
- public static void setImageDescriptors(IAction action, String iconName) {
- action.setImageDescriptor(INSTANCE.createImageDescriptor(iconName));
- }
-
- public static ModelUIImages getInstance() {
- return INSTANCE;
- }
-
- private URL baseUrl;
- private ModelUIImages parentRegistry;
-
- protected ModelUIImages(URL registryUrl, ModelUIImages parent){
- if(registryUrl == null) throw new
IllegalArgumentException(CommonUIMessages.IMAGESBASE_URL_FOR_IMAGE_REGISTRY_CANNOT_BE_NULL);
- baseUrl = registryUrl;
- parentRegistry = parent;
- }
-
- protected ModelUIImages(URL url){
- this(url,null);
- }
-
- public Image getImageByFileName(String key) {
- return createImageDescriptor(key).createImage();
- }
-
- public ImageDescriptor createImageDescriptor(String key) {
- try {
- return ImageDescriptor.createFromURL(makeIconFileURL(key));
- } catch (MalformedURLException e) {
- if(parentRegistry == null) {
- return ImageDescriptor.getMissingImageDescriptor();
- } else {
- return parentRegistry.createImageDescriptor(key);
- }
- }
- }
-
- private URL makeIconFileURL(String name) throws MalformedURLException {
- if (name == null) throw new
MalformedURLException(CommonUIMessages.IMAGESIMAGE_NAME_CANNOT_BE_NULL);
- return new URL(baseUrl, name);
- }
-
-}
\ No newline at end of file
Modified:
trunk/common/plugins/org.jboss.tools.common.ui/src/org/jboss/tools/common/ui/wizard/service/NewServiceWizardPage.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.ui/src/org/jboss/tools/common/ui/wizard/service/NewServiceWizardPage.java 2012-10-17
16:08:14 UTC (rev 44558)
+++
trunk/common/plugins/org.jboss.tools.common.ui/src/org/jboss/tools/common/ui/wizard/service/NewServiceWizardPage.java 2012-10-17
16:56:48 UTC (rev 44559)
@@ -47,7 +47,7 @@
import org.jboss.tools.common.ui.CommonUIMessages;
import org.jboss.tools.common.ui.CommonUIPlugin;
import org.jboss.tools.common.ui.IValidator;
-import org.jboss.tools.common.ui.ModelUIImages;
+import org.jboss.tools.common.ui.CommonUIImages;
import org.jboss.tools.common.ui.widget.editor.ButtonFieldEditor.ButtonPressedAction;
import org.jboss.tools.common.ui.widget.editor.IFieldEditor;
import org.jboss.tools.common.ui.widget.editor.SwtFieldEditorFactory;
@@ -68,7 +68,7 @@
public NewServiceWizardPage() {
setTitle(CommonUIMessages.NEW_SERVICE_WIZARD_PAGE_NAME);
setDescription(CommonUIMessages.NEW_SERVICE_WIZARD_DESCRIPTION);
- setImageDescriptor(ModelUIImages.getImageDescriptor(ModelUIImages.NEW_JAVA_SERVICE_PROVIDER_IMAGE));
+ setImageDescriptor(CommonUIImages.getInstance().getOrCreateImageDescriptor(CommonUIImages.NEW_JAVA_SERVICE_PROVIDER_IMAGE));
}
public void init(IStructuredSelection selection) {
Modified:
trunk/common/plugins/org.jboss.tools.common.ui/src/org/jboss/tools/common/ui/wizard/service/RegisterAsServiceDialog.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.ui/src/org/jboss/tools/common/ui/wizard/service/RegisterAsServiceDialog.java 2012-10-17
16:08:14 UTC (rev 44558)
+++
trunk/common/plugins/org.jboss.tools.common.ui/src/org/jboss/tools/common/ui/wizard/service/RegisterAsServiceDialog.java 2012-10-17
16:56:48 UTC (rev 44559)
@@ -29,7 +29,7 @@
import org.jboss.tools.common.java.ParametedTypeFactory;
import org.jboss.tools.common.ui.CommonUIMessages;
import org.jboss.tools.common.ui.CommonUIPlugin;
-import org.jboss.tools.common.ui.ModelUIImages;
+import org.jboss.tools.common.ui.CommonUIImages;
import org.jboss.tools.common.ui.widget.editor.IFieldEditor;
import org.jboss.tools.common.ui.widget.editor.IFieldEditorFactory;
@@ -72,7 +72,7 @@
protected Control createDialogArea(Composite parent) {
getShell().setText(CommonUIMessages.REGISTER_AS_SERVICE_TITLE);
setTitle(NLS.bind(CommonUIMessages.REGISTER_AS_SERVICE_SUB_TITLE,
type.getFullyQualifiedName()));
- setTitleImage(ModelUIImages.getImage(ModelUIImages.JAVA_SERVICE_PROVIDER_IMAGE)); //
image is managed by registry
+ setTitleImage(CommonUIImages.getInstance().getOrCreateImage(CommonUIImages.JAVA_SERVICE_PROVIDER_IMAGE));
// image is managed by registry
setMessage(CommonUIMessages.REGISTER_AS_SERVICE_MESSAGE);
if(types.isEmpty()) {
setErrorMessage(CommonUIMessages.REGISTER_AS_SERVICE_NO_TYPES_MESSAGE);