/** * Adds specified <code>item</code> to the palette. * * @param item item to be added * @throws IllegalArgumentException if an item for the same class * is already exists in the palette */ public void addItem(@NotNull final GroupItem group, @NotNull final ComponentItem item) { // class -> item final String componentClassName = item.getClassName(); if (getItem(componentClassName) != null) { Messages.showMessageDialog( UIDesignerBundle.message("error.item.already.added", componentClassName), ApplicationNamesInfo.getInstance().getFullProductName(), Messages.getErrorIcon() ); return; } myClassName2Item.put(componentClassName, item); // group -> items group.addItem(item); // Process special predefined item for JPanel if ("javax.swing.JPanel".equals(item.getClassName())) { myPanelItem = item; } }
public void actionPerformed(AnActionEvent e) { Project project = e.getData(CommonDataKeys.PROJECT); GroupItem groupToBeRemoved = e.getData(GroupItem.DATA_KEY); if (groupToBeRemoved == null || project == null) return; if(!Palette.isRemovable(groupToBeRemoved)){ Messages.showInfoMessage( project, UIDesignerBundle.message("error.cannot.remove.default.group"), CommonBundle.getErrorTitle() ); return; } Palette palette = Palette.getInstance(project); ArrayList<GroupItem> groups = new ArrayList<GroupItem>(palette.getGroups()); groups.remove(groupToBeRemoved); palette.setGroups(groups); }
public void actionPerformed(AnActionEvent e) { Project project = e.getData(CommonDataKeys.PROJECT); ComponentItem selectedItem = e.getData(ComponentItem.DATA_KEY); GroupItem groupItem = e.getData(GroupItem.DATA_KEY); if (project == null || selectedItem == null || groupItem == null) return; if(!selectedItem.isRemovable()){ Messages.showInfoMessage( project, UIDesignerBundle.message("error.cannot.remove.default.palette"), CommonBundle.getErrorTitle() ); return; } int rc = Messages.showYesNoDialog(project, UIDesignerBundle.message("delete.component.prompt", selectedItem.getClassShortName()), UIDesignerBundle.message("delete.component.title"), Messages.getQuestionIcon()); if (rc != Messages.YES) return; final Palette palette = Palette.getInstance(project); palette.removeItem(groupItem, selectedItem); palette.fireGroupsChanged(); }
public LightBulbComponentImpl(@NotNull final QuickFixManager manager, @NotNull final Icon icon) { myManager = manager; myIcon = icon; setPreferredSize(new Dimension(icon.getIconWidth(), icon.getIconHeight())); final String acceleratorsText = KeymapUtil.getFirstKeyboardShortcutText( ActionManager.getInstance().getAction(IdeActions.ACTION_SHOW_INTENTION_ACTIONS)); if (acceleratorsText.length() > 0) { setToolTipText(UIDesignerBundle.message("tooltip.press.accelerator", acceleratorsText)); } new ClickListener() { @Override public boolean onClick(@NotNull MouseEvent e, int clickCount) { myManager.showIntentionPopup(); return true; } }.installOn(this); }
public void run() { final PsiFile psiFile = myField.getContainingFile(); if (psiFile == null) return; if (!FileModificationService.getInstance().preparePsiElementForWrite(psiFile)) return; ApplicationManager.getApplication().runWriteAction(new Runnable() { public void run() { CommandProcessor.getInstance().executeCommand(myField.getProject(), new Runnable() { public void run() { try { final PsiManager manager = myField.getManager(); myField.getTypeElement().replace(JavaPsiFacade.getInstance(manager.getProject()).getElementFactory().createTypeElement(myNewType)); } catch (final IncorrectOperationException e) { ApplicationManager.getApplication().invokeLater(new Runnable() { public void run() { Messages.showErrorDialog(myEditor, UIDesignerBundle.message("error.cannot.change.field.type", myField.getName(), e.getMessage()), CommonBundle.getErrorTitle()); } }); } } }, getName(), null); } }); }
public Component getTableCellEditorComponent(final JTable table, @NotNull final Object value, final boolean isSelected, final int row, final int column){ final Property property=(Property)value; try { //noinspection unchecked final JComponent c = myEditor.getComponent(mySelection.get(0), getSelectionValue(property), null); if (c instanceof JComboBox) { c.putClientProperty("JComboBox.isTableCellEditor", Boolean.TRUE); } else if (c instanceof JCheckBox) { c.putClientProperty( "JComponent.sizeVariant", UIUtil.isUnderAquaLookAndFeel() ? "small" : null); } return c; } catch(Exception ex) { LOG.debug(ex); SimpleColoredComponent errComponent = new SimpleColoredComponent(); errComponent.append(UIDesignerBundle.message("error.getting.value", ex.getMessage()), SimpleTextAttributes.ERROR_ATTRIBUTES); return errComponent; } }
private static Collection<PsiReference> findPropertyReferences(final Property pproperty, final Module module) { final Collection<PsiReference> references = Collections.synchronizedList(new ArrayList<PsiReference>()); ProgressManager.getInstance().runProcessWithProgressSynchronously( new Runnable() { public void run() { ReferencesSearch.search(pproperty).forEach(new Processor<PsiReference>() { public boolean process(final PsiReference psiReference) { PsiMethod method = PsiTreeUtil.getParentOfType(psiReference.getElement(), PsiMethod.class); if (method == null || !AsmCodeGenerator.SETUP_METHOD_NAME.equals(method.getName())) { references.add(psiReference); } return true; } }); } }, UIDesignerBundle.message("edit.text.searching.references"), false, module.getProject() ); return references; }
public static boolean saveCreatedProperty(final PropertiesFile bundle, final String name, final String value, final PsiFile formFile) { final ReadonlyStatusHandler.OperationStatus operationStatus = ReadonlyStatusHandler.getInstance(bundle.getProject()).ensureFilesWritable(bundle.getVirtualFile()); if (operationStatus.hasReadonlyFiles()) { return false; } CommandProcessor.getInstance().executeCommand( bundle.getProject(), new Runnable() { public void run() { UndoUtil.markPsiFileForUndo(formFile); ApplicationManager.getApplication().runWriteAction(new Runnable() { public void run() { try { bundle.addProperty(name, value); } catch (IncorrectOperationException e1) { LOG.error(e1); } } }); } }, UIDesignerBundle.message("command.create.property"), null); return true; }
public T getValue() throws Exception { final Matcher matcher = myPattern.matcher(myTf.getText()); if (!matcher.matches()) { throw new Exception("Incorrect dimension format"); } Class[] paramTypes = new Class[myMinValues.length]; Integer[] params = new Integer[myMinValues.length]; for(int i=0; i<myMinValues.length; i++) { paramTypes [i] = int.class; final int value = Integer.parseInt(matcher.group(i + 1)); if (value < myMinValues [i]) { throw new RuntimeException(UIDesignerBundle.message("error.value.should.not.be.less", myMinValues [i])); } params [i] = value; } return myValueClass.getConstructor(paramTypes).newInstance(params); }
public void run() { if (!myEditor.ensureEditable()) { return; } Runnable runnable = new Runnable() { public void run() { final Palette palette = Palette.getInstance(myEditor.getProject()); IntrospectedProperty[] props = palette.getIntrospectedProperties(myLabel); boolean modified = false; for(IntrospectedProperty prop: props) { if (prop.getName().equals(SwingProperties.LABEL_FOR) && prop instanceof IntroComponentProperty) { IntroComponentProperty icp = (IntroComponentProperty) prop; icp.setValueEx(myLabel, myComponent.getId()); modified = true; break; } } if (modified) myEditor.refreshAndSave(false); } }; CommandProcessor.getInstance().executeCommand(myEditor.getProject(), runnable, UIDesignerBundle.message("inspection.no.label.for.command"), null); }
@Override protected void initToolWindow() { myToolWindow = ToolWindowManager.getInstance(myProject).registerToolWindow(UIDesignerBundle.message("toolwindow.ui.designer.name"), false, getAnchor(), myProject, true); myToolWindow.setIcon(UIDesignerIcons.ToolWindowUIDesigner); if (!ApplicationManager.getApplication().isHeadlessEnvironment()) { myToolWindow.getComponent().putClientProperty(ToolWindowContentUi.HIDE_ID_LABEL, "true"); } initGearActions(); ContentManager contentManager = myToolWindow.getContentManager(); Content content = contentManager.getFactory() .createContent(myToolWindowPanel.getToolWindowPanel(), UIDesignerBundle.message("toolwindow.ui.designer.title"), false); content.setCloseable(false); content.setPreferredFocusableComponent(myToolWindowPanel.getComponentTree()); contentManager.addContent(content); contentManager.setSelectedContent(content, true); myToolWindow.setAvailable(false, null); }
protected String createFormBody(@Nullable String fqn, @NonNls String formName, String layoutManager) throws IncorrectOperationException { String s; try { s = FileUtil.loadTextAndClose(getClass().getResourceAsStream(formName)); } catch (IOException e) { throw new IncorrectOperationException(UIDesignerBundle.message("error.cannot.read", formName), (Throwable)e); } if (fqn != null) { s = StringUtil.replace(s, "$CLASS$", fqn); } else { s = StringUtil.replace(s, "bind-to-class=\"$CLASS$\"", ""); } s = StringUtil.replace(s, "$LAYOUT$", layoutManager); return StringUtil.convertLineSeparators(s); }
protected void actionPerformed(final GuiEditor editor, final List<RadComponent> selection, final AnActionEvent e) { Processor<ComponentItem> processor = new Processor<ComponentItem>() { public boolean process(final ComponentItem selectedValue) { if (selectedValue != null) { myLastCreatedComponent = selectedValue; editor.getMainProcessor().startInsertProcessor(selectedValue, getCreateLocation(editor, selection)); } return true; } }; PaletteListPopupStep step = new PaletteListPopupStep(editor, myLastCreatedComponent, processor, UIDesignerBundle.message("create.component.title")); final ListPopup listPopup = JBPopupFactory.getInstance().createListPopup(step); if (selection.size() > 0) { FormEditingUtil.showPopupUnderComponent(listPopup, selection.get(0)); } else { listPopup.showInCenterOf(editor.getRootContainer().getDelegee()); } }
private void doPaste(final ComponentDropLocation location) { if (location.canDrop(myPastedComponentList) && myEditor.ensureEditable()) { final RadComponent[] componentsToPaste = myComponentsToPaste.toArray(new RadComponent[myComponentsToPaste.size()]); CommandProcessor.getInstance().executeCommand( myEditor.getProject(), new Runnable() { public void run() { location.processDrop(myEditor, componentsToPaste, null, myPastedComponentList); for(RadComponent c: componentsToPaste) { FormEditingUtil.iterate(c, new FormEditingUtil.ComponentVisitor() { public boolean visit(final IComponent component) { if (component.getBinding() != null) { InsertComponentProcessor.createBindingField(myEditor, (RadComponent) component); } return true; } }); } FormEditingUtil.selectComponents(myEditor, myComponentsToPaste); myEditor.refreshAndSave(true); } }, UIDesignerBundle.message("command.paste"), null); endPaste(); } }
private String getInsertFeedbackTooltip() { StringBuilder result = new StringBuilder(myContainer.getDisplayName()); result.append(" ("); if (myXPart == 1 && myYPart == 1) { result.append(UIDesignerBundle.message("insert.feedback.fill")); } else { if (myYPart == 0) { result.append(UIDesignerBundle.message("insert.feedback.top")); } else if (myYPart == 2) { result.append(UIDesignerBundle.message("insert.feedback.bottom")); } if (myYPart != 1 && myXPart != 1) { result.append(" "); } if (myXPart == 0) { result.append(UIDesignerBundle.message("insert.feedback.left")); } else if (myXPart == 2) { result.append(UIDesignerBundle.message("insert.feedback.right")); } } result.append(")"); return result.toString(); }
protected void customizeCellRenderer( final JList list, final Object value, final int index, final boolean selected, final boolean hasFocus ) { final BeanProperty property = (BeanProperty)value; if(property == null){ append(UIDesignerBundle.message("property.not.defined"), myAttrs2); } else{ append(property.myName, myAttrs1); append(" ", myAttrs1); append(property.myType, myAttrs2); } }
public void _commit(boolean finishChosen) throws CommitStepException { // Stop editing if any final TableCellEditor cellEditor = myTable.getCellEditor(); if(cellEditor != null){ cellEditor.stopCellEditing(); } // Check that all included fields are bound to valid bean properties final PsiNameHelper nameHelper = PsiNameHelper.getInstance(myData.myProject); for(int i = 0; i <myData.myBindings.length; i++){ final FormProperty2BeanProperty binding = myData.myBindings[i]; if(binding.myBeanProperty == null){ continue; } if (!nameHelper.isIdentifier(binding.myBeanProperty.myName)){ throw new CommitStepException( UIDesignerBundle.message("error.X.is.not.a.valid.property.name", binding.myBeanProperty.myName) ); } } myData.myGenerateIsModified = myChkIsModified.isSelected(); }
@Override public void actionPerformed(AnActionEvent e) { Project project = e.getData(CommonDataKeys.PROJECT); if (project == null) return; // Ask group name final String groupName = Messages.showInputDialog( project, UIDesignerBundle.message("message.enter.group.name"), UIDesignerBundle.message("title.add.group"), Messages.getQuestionIcon() ); if (groupName == null) { return; } Palette palette = Palette.getInstance(project); // Check that name of the group is unique List<GroupItem> groups = palette.getGroups(); for (int i = groups.size() - 1; i >= 0; i--) { if (groupName.equals(groups.get(i).getName())) { Messages.showErrorDialog(project, UIDesignerBundle.message("error.group.name.unique"), CommonBundle.getErrorTitle()); return; } } final GroupItem groupToBeAdded = new GroupItem(groupName); ArrayList<GroupItem> newGroups = new ArrayList<GroupItem>(groups); newGroups.add(groupToBeAdded); palette.setGroups(newGroups); }
public void actionPerformed(AnActionEvent e) { Project project = e.getData(CommonDataKeys.PROJECT); ComponentItem selectedItem = e.getData(ComponentItem.DATA_KEY); if (project == null || selectedItem == null || selectedItem.isAnyComponent() || selectedItem.isSpacer()) { return; } final ComponentItem itemToBeEdited = selectedItem.clone(); /*"Cancel" should work, so we need edit copy*/ Window parentWindow = WindowManager.getInstance().suggestParentWindow(project); final ComponentItemDialog dialog = new ComponentItemDialog(project, parentWindow, itemToBeEdited, false); dialog.setTitle(UIDesignerBundle.message("title.edit.component")); if (!dialog.showAndGet()) { return; } GroupItem groupItem = null; Palette palette = Palette.getInstance(project); // If the itemToBeAdded is already in palette do nothing for (GroupItem group : palette.getGroups()) { if (group.containsItemCopy(selectedItem, itemToBeEdited.getClassName())) { return; } if (group.containsItemClass(selectedItem.getClassName())) { groupItem = group; } } LOG.assertTrue(groupItem != null); palette.replaceItem(groupItem, selectedItem, itemToBeEdited); palette.fireGroupsChanged(); }
private boolean saveNestedForm() { VirtualFile formFile = ResourceFileUtil.findResourceFileInProject(myProject, myTfNestedForm.getText()); if (formFile == null) { Messages.showErrorDialog(getWindow(), UIDesignerBundle.message("add.component.cannot.load.form", myTfNestedForm.getText()), CommonBundle.getErrorTitle()); return false; } LwRootContainer lwRootContainer; try { lwRootContainer = Utils.getRootContainer(formFile.getInputStream(), null); } catch (Exception e) { Messages.showErrorDialog(getWindow(), e.getMessage(), CommonBundle.getErrorTitle()); return false; } if (lwRootContainer.getClassToBind() == null) { Messages.showErrorDialog(getWindow(), UIDesignerBundle.message("add.component.form.not.bound"), CommonBundle.getErrorTitle()); return false; } if (lwRootContainer.getComponent(0).getBinding() == null) { Messages.showErrorDialog(getWindow(), UIDesignerBundle.message("add.component.root.not.bound"), CommonBundle.getErrorTitle()); return false; } PsiClass psiClass = JavaPsiFacade.getInstance(myProject).findClass(lwRootContainer.getClassToBind(), GlobalSearchScope.projectScope(myProject)); if (psiClass != null) { myItemToBeEdited.setClassName(getClassOrInnerName(psiClass)); } else { myItemToBeEdited.setClassName(lwRootContainer.getClassToBind()); } return true; }
private boolean isOKEnabled() { myErrorLabel.setText(" "); if (myClassRadioButton.isSelected()) { if (myDocument == null) { // why? return false; } if (!PsiNameHelper.getInstance(myProject).isQualifiedName(myDocument.getText())) { if (myDocument.getTextLength() > 0) { myErrorLabel.setText(UIDesignerBundle.message("add.component.error.qualified.name.required")); } return false; } final JavaPsiFacade javaPsiFacade = JavaPsiFacade.getInstance(myProject); PsiClass psiClass = javaPsiFacade.findClass(myDocument.getText(), ProjectScope.getAllScope(myProject)); PsiClass componentClass = javaPsiFacade.findClass(JComponent.class.getName(), ProjectScope.getAllScope(myProject)); if (psiClass != null && componentClass != null && !InheritanceUtil.isInheritorOrSelf(psiClass, componentClass, true)) { myErrorLabel.setText(UIDesignerBundle.message("add.component.error.component.required")); return false; } } else { if (myTfNestedForm.getText().length() == 0) { return false; } } if (myGroupComboBox.isVisible() && myGroupComboBox.getSelectedItem() == null) { return false; } return true; }
@Override public void actionPerformed(final ActionEvent e) { final TreeClassChooserFactory factory = TreeClassChooserFactory.getInstance(myProject); final TreeClassChooser chooser = factory.createInheritanceClassChooser(UIDesignerBundle.message("title.choose.component.class"), GlobalSearchScope.allScope(myProject), JavaPsiFacade.getInstance(myProject).findClass( JComponent.class.getName(), GlobalSearchScope.allScope(myProject)), true, true, null); chooser.showDialog(); final PsiClass result = chooser.getSelected(); if (result != null) { setEditorText(result.getQualifiedName()); } }
@Override public void actionPerformed(AnActionEvent e) { Project project = CommonDataKeys.PROJECT.getData(e.getDataContext()); GroupItem groupToBeEdited = GroupItem.DATA_KEY.getData(e.getDataContext()); if (groupToBeEdited == null || project == null) return; // Ask group name final String groupName = Messages.showInputDialog( project, UIDesignerBundle.message("edit.enter.group.name"), UIDesignerBundle.message("title.edit.group"), Messages.getQuestionIcon(), groupToBeEdited.getName(), null ); if (groupName == null || groupName.equals(groupToBeEdited.getName())) { return; } Palette palette = Palette.getInstance(project); List<GroupItem> groups = palette.getGroups(); for (int i = groups.size() - 1; i >= 0; i--) { if (groupName.equals(groups.get(i).getName())) { Messages.showErrorDialog(project, UIDesignerBundle.message("error.group.name.unique"), CommonBundle.getErrorTitle()); return; } } groupToBeEdited.setName(groupName); palette.fireGroupsChanged(); }
public void customizeCellRenderer(ColoredListCellRenderer cellRenderer, boolean selected, boolean hasFocus) { cellRenderer.setIcon(getSmallIcon()); if (myAnyComponent) { cellRenderer.append(UIDesignerBundle.message("palette.non.palette.component"), SimpleTextAttributes.REGULAR_ATTRIBUTES); cellRenderer.setToolTipText(UIDesignerBundle.message("palette.non.palette.component.tooltip")); } else { cellRenderer.append(getClassShortName(), SimpleTextAttributes.REGULAR_ATTRIBUTES); cellRenderer.setToolTipText(getToolTipText()); } }
private void buildSuppressFixes(final ErrorInfo errorInfo, final ArrayList<ErrorWithFix> suppressList, boolean named) { final String suppressName = named ? UIDesignerBundle.message("action.suppress.named.for.component", errorInfo.myDescription) : UIDesignerBundle.message("action.suppress.for.component"); final String suppressAllName = named ? UIDesignerBundle.message("action.suppress.named.for.all.components", errorInfo.myDescription) : UIDesignerBundle.message("action.suppress.for.all.components"); final SuppressFix suppressFix = new SuppressFix(myEditor, suppressName, errorInfo.getInspectionId(), errorInfo.getComponent()); final SuppressFix suppressAllFix = new SuppressFix(myEditor, suppressAllName, errorInfo.getInspectionId(), null); suppressList.add(new ErrorWithFix(errorInfo, suppressFix)); suppressList.add(new ErrorWithFix(errorInfo, suppressAllFix)); }
@Override @Nullable public String getCellResizeTooltip(RadContainer container, boolean isRow, int cell, int newSize) { final String size = getUpdatedSize(container, isRow, cell, newSize).toString(); return isRow ? UIDesignerBundle.message("tooltip.resize.row", cell+getCellIndexBase(), size) : UIDesignerBundle.message("tooltip.resize.column", cell+getCellIndexBase(), size); }
public CreateFieldFix( final GuiEditor editor, @NotNull final PsiClass aClass, @NotNull final String fieldClass, @NotNull final String fieldName ) { super(editor, UIDesignerBundle.message("action.create.field", fieldName), null); myClass = aClass; myFieldClassName = fieldClass; myFieldName = fieldName; }
private String getInsertFeedbackTooltip() { String pos; if (getSplitPane().getOrientation() == JSplitPane.VERTICAL_SPLIT) { pos = myLeft ? UIDesignerBundle.message("insert.feedback.top") : UIDesignerBundle.message("insert.feedback.bottom"); } else { pos = myLeft ? UIDesignerBundle.message("insert.feedback.left") : UIDesignerBundle.message("insert.feedback.right"); } return getDisplayName() + " (" + pos + ")"; }
private static String composeText(final List<PsiFile> formFiles) { @NonNls StringBuilder result = new StringBuilder("<html><body>"); result.append(UIDesignerBundle.message("ui.is.bound.header")); @NonNls String sep = ""; for (PsiFile file: formFiles) { result.append(sep); sep = "<br>"; result.append(" "); result.append(file.getName()); } result.append("</body></html>"); return result.toString(); }
private static void showInvalidInput(final Exception exc) { final Throwable cause = exc.getCause(); String message; if(cause != null){ message = cause.getMessage(); } else{ message = exc.getMessage(); } if (message == null || message.length() == 0) { message = UIDesignerBundle.message("error.no.message"); } Messages.showMessageDialog(UIDesignerBundle.message("error.setting.value", message), UIDesignerBundle.message("title.invalid.input"), Messages.getErrorIcon()); }
private static boolean setPropValue(final Property property, final RadComponent c, final Object newValue) { try { //noinspection unchecked property.setValue(c, newValue); } catch (Throwable e) { LOG.debug(e); if(e instanceof InvocationTargetException){ // special handling of warapped exceptions e = ((InvocationTargetException)e).getTargetException(); } Messages.showMessageDialog(e.getMessage(), UIDesignerBundle.message("title.invalid.input"), Messages.getErrorIcon()); return false; } return true; }
boolean setValueAtRow(final int row, final Object newValue) { final Property property=myProperties.get(row); // Optimization: do nothing if value doesn't change final Object oldValue=getSelectionValue(property); boolean retVal = true; if(!Comparing.equal(oldValue,newValue)){ final GuiEditor editor = myEditor; if (!editor.ensureEditable()) { return false; } final Ref<Boolean> result = new Ref<Boolean>(Boolean.FALSE); CommandProcessor.getInstance().executeCommand(myProject, new Runnable() { public void run() { result.set(setSelectionValue(property, newValue)); editor.refreshAndSave(false); } }, UIDesignerBundle.message("command.set.property.value"), null); retVal = result.get().booleanValue(); } if (property.needRefreshPropertyList() && retVal) { synchWithTree(true); } return retVal; }
protected void setValueImpl(final RadComponent component, final String value) throws Exception { if (Comparing.strEqual(value, component.getBinding(), true)) { return; } if (value.length() > 0 && !PsiNameHelper.getInstance(component.getProject()).isIdentifier(value)) { throw new Exception("Value '" + value + "' is not a valid identifier"); } final RadRootContainer root = (RadRootContainer) FormEditingUtil.getRoot(component); final String oldBinding = getValue(component); // Check that binding remains unique if (value.length() > 0) { if (!FormEditingUtil.isBindingUnique(component, value, root)) { throw new Exception(UIDesignerBundle.message("error.binding.not.unique")); } component.setBinding(value); component.setDefaultBinding(false); } else { if (component.isCustomCreateRequired()) { throw new Exception(UIDesignerBundle.message("error.custom.create.binding.required")); } component.setBinding(null); component.setCustomCreate(false); } // Set new value or rename old one. It means that previous binding exists // and the new one doesn't exist we need to ask user to create new field // or rename old one. updateBoundFieldName(root, oldBinding, value, component.getComponentClassName()); }
public static void checkRemoveUnusedField(final RadRootContainer rootContainer, final String fieldName, final Object undoGroupId) { final PsiField oldBindingField = findBoundField(rootContainer, fieldName); if (oldBindingField == null) { return; } final Project project = oldBindingField.getProject(); final PsiClass aClass = oldBindingField.getContainingClass(); if (isFieldUnreferenced(oldBindingField)) { if (!CommonRefactoringUtil.checkReadOnlyStatus(project, aClass)) { return; } ApplicationManager.getApplication().runWriteAction( new Runnable() { public void run() { CommandProcessor.getInstance().executeCommand( project, new Runnable() { public void run() { try { oldBindingField.delete(); } catch (IncorrectOperationException e) { Messages.showErrorDialog(project, UIDesignerBundle.message("error.cannot.delete.unused.field", e.getMessage()), CommonBundle.getErrorTitle()); } } }, UIDesignerBundle.message("command.delete.unused.field"), undoGroupId ); } } ); } }
public static String descriptorToString(final FontDescriptor value) { if (value == null) { return ""; } if (value.getSwingFont() != null) { return value.getSwingFont(); } StringBuilder builder = new StringBuilder(); if (value.getFontName() != null) { builder.append(value.getFontName()); } if (value.getFontSize() >= 0) { builder.append(' ').append(value.getFontSize()).append(" pt"); } if (value.getFontStyle() >= 0) { if (value.getFontStyle() == 0) { builder.append(' ').append(UIDesignerBundle.message("font.chooser.regular")); } else { if ((value.getFontStyle() & Font.BOLD) != 0) { builder.append(' ').append(UIDesignerBundle.message("font.chooser.bold")); } if ((value.getFontStyle() & Font.ITALIC) != 0) { builder.append(" ").append(UIDesignerBundle.message("font.chooser.italic")); } } } String result = builder.toString().trim(); if (result.length() > 0) { return result; } return UIDesignerBundle.message("font.default"); }
public MyPropertyEditor() { myCbx.setRenderer(new ListCellRendererWrapper<RadButtonGroup>() { @Override public void customize(JList list, RadButtonGroup value, int index, boolean selected, boolean hasFocus) { if (value == null) { setText(UIDesignerBundle.message("button.group.none")); } else if (value == RadButtonGroup.NEW_GROUP) { setText(UIDesignerBundle.message("button.group.new")); } else { setText(value.getName()); } } }); myCbx.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED && e.getItem() == RadButtonGroup.NEW_GROUP) { String newGroupName = myRootContainer.suggestGroupName(); newGroupName = (String)JOptionPane.showInputDialog(myCbx, UIDesignerBundle.message("button.group.name.prompt"), UIDesignerBundle.message("button.group.name.title"), JOptionPane.QUESTION_MESSAGE, null, null, newGroupName); if (newGroupName != null) { RadButtonGroup group = myRootContainer.createGroup(newGroupName); myRootContainer.setGroupForComponent(myComponent, group); updateModel(); } } } }); }
private IntEnumEditor.Pair[] getPairs() { return new IntEnumEditor.Pair[] { new IntEnumEditor.Pair(GridConstraints.ALIGN_LEFT, myHorizontal ? UIDesignerBundle.message("property.left") : UIDesignerBundle.message("property.top")), new IntEnumEditor.Pair(GridConstraints.ALIGN_CENTER, UIDesignerBundle.message("property.center")), new IntEnumEditor.Pair(GridConstraints.ALIGN_RIGHT, myHorizontal ? UIDesignerBundle.message("property.right") : UIDesignerBundle.message("property.bottom")), new IntEnumEditor.Pair(GridConstraints.ALIGN_FILL, UIDesignerBundle.message("property.fill")) }; }
public void customize(final String value){ final String className = PsiNameHelper.getShortClassName(value); if(value.length() == className.length()){ // class in default package setText(className); } else{ final String packageName = value.substring(0, value.length() - className.length() - 1); setText(UIDesignerBundle.message("class.in.package", className, packageName)); } }
public JComponent getComponent(final RadRootContainer rootContainer, String value, boolean selected, boolean hasFocus) { clear(); setBackground(selected ? UIUtil.getTableSelectionBackground() : UIUtil.getTableBackground()); if (value != null && value.length() > 0) { RadComponent target = (RadComponent)FormEditingUtil.findComponent(rootContainer, value); if (target != null) { renderComponent(target, selected); } else { append(UIDesignerBundle.message("component.not.found"), SimpleTextAttributes.ERROR_ATTRIBUTES); } } return this; }
private void initPairs() { if (myPairs == null) { myPairs = new IntEnumEditor.Pair[] { new IntEnumEditor.Pair(FlowLayout.CENTER, UIDesignerBundle.message("property.center")), new IntEnumEditor.Pair(FlowLayout.LEFT, UIDesignerBundle.message("property.left")), new IntEnumEditor.Pair(FlowLayout.RIGHT, UIDesignerBundle.message("property.right")), new IntEnumEditor.Pair(FlowLayout.LEADING, UIDesignerBundle.message("property.leading")), new IntEnumEditor.Pair(FlowLayout.TRAILING, UIDesignerBundle.message("property.trailing")) }; } }