@Override public JLabel getComponent(final RadRootContainer rootContainer, final IconDescriptor iconDescriptor, final boolean selected, final boolean hasFocus) { if (iconDescriptor != null) { IntroIconProperty.ensureIconLoaded(rootContainer.getModule(), iconDescriptor); } final JLabel component = super.getComponent(rootContainer, iconDescriptor, selected, hasFocus); if (!selected && iconDescriptor != null && iconDescriptor.getIcon() == null) { setForeground(Color.RED); } return component; }
public IconEditor() { myTextField.getTextField().setBorder(null); myTextField.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { final TreeClassChooserFactory factory = TreeClassChooserFactory.getInstance(getModule().getProject()); PsiFile iconFile = null; if (myValue != null) { VirtualFile iconVFile = ResourceFileUtil.findResourceFileInScope(myValue.getIconPath(), getModule().getProject(), getModule() .getModuleWithDependenciesAndLibrariesScope(true)); if (iconVFile != null) { iconFile = PsiManager.getInstance(getModule().getProject()).findFile(iconVFile); } } TreeFileChooser fileChooser = factory.createFileChooser(UIDesignerBundle.message("title.choose.icon.file"), iconFile, null, new ImageFileFilter(getModule()), false, true); fileChooser.showDialog(); PsiFile file = fileChooser.getSelectedFile(); if (file != null) { String resourceName = FormEditingUtil.buildResourceName(file); if (resourceName != null) { IconDescriptor descriptor = new IconDescriptor(resourceName); IntroIconProperty.loadIconFromFile(file.getVirtualFile(), descriptor); myValue = descriptor; myTextField.setText(descriptor.getIconPath()); } } } }); }
public IconDescriptor getValue() throws Exception { if (myTextField.getText().length() == 0) { return null; } final IconDescriptor descriptor = new IconDescriptor(myTextField.getText()); IntroIconProperty.ensureIconLoaded(getModule(), descriptor); return descriptor; }
public void addComponentToContainer(final RadContainer container, final RadComponent component, final int index) { final JTabbedPane tabbedPane = getTabbedPane(); LwTabbedPane.Constraints constraints = null; if (component.getCustomLayoutConstraints() instanceof LwTabbedPane.Constraints) { constraints = ((LwTabbedPane.Constraints)component.getCustomLayoutConstraints()); } component.setCustomLayoutConstraints(null); final HashMap<String, LwTabbedPane.Constraints> id2Constraints = getId2Constraints(RadTabbedPane.this); id2Constraints.put(component.getId(), constraints); final String tabName = calcTabName(constraints == null ? null : constraints.myTitle); String toolTip = null; Icon icon = null; if (constraints != null) { toolTip = getDescriptorText(constraints.myToolTip); if (constraints.myIcon != null) { IntroIconProperty.ensureIconLoaded(getModule(), constraints.myIcon); icon = constraints.myIcon.getIcon(); } } tabbedPane.insertTab(tabName, icon, component.getDelegee(), toolTip, index); if (constraints != null) { if (constraints.myDisabledIcon != null) { IntroIconProperty.ensureIconLoaded(getModule(), constraints.myDisabledIcon); tabbedPane.setDisabledIconAt(index, constraints.myDisabledIcon.getIcon()); } tabbedPane.setEnabledAt(index, constraints.myEnabled); } }