Java Code Examples for org.openide.util.NbBundle.getMessage()

The following are Jave code examples for showing how to use getMessage() of the org.openide.util.NbBundle class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: incubator-netbeans   File: ThisInAnonymous.java   View Source Code Vote up 6 votes
@TriggerPattern(value="synchronized ($this) { $stmts$; }")
public static ErrorDescription hint(HintContext ctx) {
    TreePath thisVariable = ctx.getVariables().get("$this");
    if (thisVariable.getLeaf().getKind() != Kind.IDENTIFIER || !((IdentifierTree) thisVariable.getLeaf()).getName().contentEquals(THIS_KEYWORD)) {
        return null;
    }
    
    TreePath anonClassTP = getParentClass(ctx.getPath());
    Element annonClass = ctx.getInfo().getTrees().getElement(anonClassTP);
    String key = getKey(annonClass);
    if (key != null) {
        Element parent = ctx.getInfo().getTrees().getElement(getParentClass(anonClassTP.getParentPath()));

        if (parent == null || (!parent.getKind().isClass() && !parent.getKind().isInterface())) {
            return null;
        }
        
        Fix fix = new FixImpl(TreePathHandle.create(thisVariable, ctx.getInfo()),
                     ElementHandle.create((TypeElement) parent)).toEditorFix();

        String displayName = NbBundle.getMessage(ThisInAnonymous.class, key);
        return ErrorDescriptionFactory.forName(ctx, thisVariable, displayName, fix);
    }

    return null;
}
 
Example 2
Project: incubator-netbeans   File: OverriddenAbsMethodFinder.java   View Source Code Vote up 6 votes
@Override
public void run(CompilationController javac) throws Exception {
    for (ElementHandle<ExecutableElement> method : allMethods) {
        ExecutableElement el = method.resolve(javac);
        Collection<ExecutableElement> overriddenMethods = JavaRefactoringUtils.getOverriddenMethods(el, javac);
        for (ExecutableElement overriddenMethod : overriddenMethods) {
            ElementHandle<ExecutableElement> handle = ElementHandle.create(overriddenMethod);
            if(!allMethods.contains(handle)) {
                TypeElement type1 = javac.getElementUtilities().enclosingTypeElement(el);
                TypeElement type2 = javac.getElementUtilities().enclosingTypeElement(overriddenMethod);
                Problem prob = new Problem(false, NbBundle.getMessage(OverriddenAbsMethodFinder.class, "WRN_Implements", overriddenMethod.getSimpleName(), type1.getQualifiedName(), type2.getQualifiedName()));
                problem = JavaPluginUtils.chainProblems(problem, prob);
            }
        }
    }
}
 
Example 3
Project: incubator-netbeans   File: SQLStatementExecutor.java   View Source Code Vote up 6 votes
protected void commitOrRollback(String cmdName) {
    if (!error && commit(conn)) {
        long executionTime = System.currentTimeMillis() - startTime;
        String execTimeStr = SQLExecutionHelper.millisecondsToSeconds(executionTime);
        String infoMsg = cmdName + " " + NbBundle.getMessage(SQLStatementExecutor.class, "MSG_execution_success", execTimeStr);
        dataView.setInfoStatusText(infoMsg);
        executeOnSucess(); // delegate 
    } else {
        rollback(conn);
        reinstateToolbar();

        String msg = cmdName + " " + NbBundle.getMessage(SQLStatementExecutor.class, "MSG_failed");
        if (ex == null) {
            errorMsg = msg + " " + errorMsg;
        } else {
            errorMsg = msg;
        }

        ex = new DBException(errorMsg, ex);
        dataView.setErrorStatusText(conn, null, ex);

        NotifyDescriptor nd = new NotifyDescriptor.Message(ex.getMessage(), NotifyDescriptor.ERROR_MESSAGE);
        DialogDisplayer.getDefault().notify(nd);
    }
}
 
Example 4
Project: incubator-netbeans   File: UnitCategoryTableModel.java   View Source Code Vote up 6 votes
private String getTooltipForCheckBox(int row) {
    String key0 = null;
    switch (getType()) {
        case INSTALLED:
            key0 = "UnitTab_TooltipCheckBox_INSTALLED"; //NOI18N
            break;
        case UPDATE:
            key0 = "UnitTab_TooltipCheckBox_UPDATE"; //NOI18N
            break;
        case AVAILABLE:
            key0 = "UnitTab_TooltipCheckBox_AVAILABLE"; //NOI18N
            break;
        case LOCAL:
            key0 = "UnitTab_TooltipCheckBox_LOCAL"; //NOI18N
            break;
    }
    return (key0 != null) ? NbBundle.getMessage (UnitCategoryTableModel.class, key0, (String)getValueAt (row, 1)) : null;
}
 
Example 5
Project: incubator-netbeans   File: CheckoutPaths.java   View Source Code Vote up 6 votes
boolean show() {
    panel.cbUpdateIndex.addActionListener(this);
    okButton = new JButton(NbBundle.getMessage(CheckoutPaths.class, "LBL_CheckoutPaths.OKButton.text")); //NOI18N
    org.openide.awt.Mnemonics.setLocalizedText(okButton, okButton.getText());
    dd = new DialogDescriptor(panel, NbBundle.getMessage(CheckoutPaths.class, "LBL_CheckoutPaths.title"), true,  //NOI18N
            new Object[] { okButton, DialogDescriptor.CANCEL_OPTION }, okButton, DialogDescriptor.DEFAULT_ALIGN, new HelpCtx(CheckoutPaths.class), null);
    enableRevisionPanel();
    revisionPicker.addPropertyChangeListener(new PropertyChangeListener() {
        @Override
        public void propertyChange (PropertyChangeEvent evt) {
            if (evt.getPropertyName() == RevisionDialogController.PROP_VALID) {
                setValid(Boolean.TRUE.equals(evt.getNewValue()));
            }
        }
    });
    Dialog d = DialogDisplayer.getDefault().createDialog(dd);
    d.setVisible(true);
    return okButton == dd.getValue();
}
 
Example 6
Project: incubator-netbeans   File: StableCompoundEdit.java   View Source Code Vote up 6 votes
@Override
   public String getUndoPresentationName() {
UndoableEdit last = lastEdit();
if (last != null) {
    return last.getUndoPresentationName();
} else {
           String name = getPresentationName();
           if (!"".equals(name)) {
               name = NbBundle.getMessage(ContentEdit.class, "AbstractUndoableEdit.undoText.param", name); // NOI18N
           } else {
               name = NbBundle.getMessage(ContentEdit.class, "AbstractUndoableEdit.undoText"); // NOI18N
           }

           return name;
}
   }
 
Example 7
Project: incubator-netbeans   File: JFXDownloadModePanel.java   View Source Code Vote up 5 votes
@Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
    String strValue = "";   //NOI18N
    String toolTip = null;
    Icon icon = null;
    if (value instanceof Boolean) {
        strValue = NbBundle.getMessage(JFXDownloadModePanel.class, value == Boolean.TRUE ? "TXT_LAZY":"TXT_EAGER"); //NOI18N
    } else if (value instanceof File) {
        final File f = (File)value;
        strValue = f.getName();
        toolTip = f.getAbsolutePath();
        icon = JAR_ICON;
    }
    final Component c = super.getTableCellRendererComponent(
            table,
            strValue, //NOI18N
            isSelected,
            hasFocus,
            row,
            column);
    if (c instanceof JLabel) {
        JLabel label = (JLabel) c;
        label.setToolTipText (toolTip);
        label.setIcon(icon);
    }
    return c;
}
 
Example 8
Project: incubator-netbeans   File: OptionsExportModel.java   View Source Code Vote up 5 votes
/** Sets state of all categories according to given value.
 * @param state new state
 */
void setState(State state) {
    String passwords = NbBundle.getMessage(OptionsChooserPanel.class, "OptionsChooserPanel.export.passwords.category.displayName");
    for (OptionsExportModel.Category category : getCategories()) {
        if (category.isApplicable()) {
            if (state.equals(State.ENABLED)) {
                if (category.getDisplayName() != null && !category.getDisplayName().equals(passwords)) {
                    category.setState(state);
                }
            } else {
                category.setState(state);
            }
        }
    }
}
 
Example 9
Project: incubator-netbeans   File: JavaDataLoader.java   View Source Code Vote up 5 votes
@Override
public FileObject createFromTemplate(FileObject f, String name) throws IOException {
    if (getFile().getAttribute(/* ScriptingCreateFromTemplateHandler.SCRIPT_ENGINE_ATTR */"javax.script.ScriptEngine") == null) {
        Logger.getLogger(JavaDataLoader.class.getName()).log(Level.WARNING, "Please replace template {0} with the new scripting support. See http://bits.netbeans.org/7.1/javadoc/org-openide-loaders/apichanges.html#scripting", getFile().getPath());
    }
    if (name == null) {
        // special case: name is null (unspecified or from one-parameter createFromTemplate)
        name = FileUtil.findFreeFileName(f, f.getName(), "java"); // NOI18N
    } else if (!PACKAGE_INFO.equals(name) && !Utilities.isJavaIdentifier(name)) {
        throw new IOException(NbBundle.getMessage(JavaDataObject.class, "FMT_Not_Valid_FileName", name));
    }
    
    this.initializeIndentEngine();
    FileObject fo = super.createFromTemplate(f, name);
    
    ClassPath cp = ClassPath.getClassPath(fo, ClassPath.SOURCE);
    String pkgName;
    if (cp != null) {
        pkgName = cp.getResourceName(f, '.', false);
        if (pkgName == null) {
            Logger.getLogger(JavaDataLoader.class.getName()).log(Level.WARNING, "{0} is not on its own source path", FileUtil.getFileDisplayName(fo));
            pkgName = "";
        }
    } else {
        pkgName = "";   //NOI18N
    }
    JavaDataObject.renameFO(fo, pkgName, name, getFile().getName());
    
    // unfortunately JavaDataObject.renameFO creates JavaDataObject but it is too soon
    // in this stage. Loaders reusing this FileEntry will create further files.
    destroyDataObject(fo);
    
    return fo;
}
 
Example 10
Project: incubator-netbeans   File: ClassMemberPanelUI.java   View Source Code Vote up 5 votes
/** Creates new form ClassMemberPanelUi */
public ClassMemberPanelUI(final Language language) {
    
    initComponents();
    
    // Tree view of the elements
    elementView = createBeanTreeView();        
    add(elementView, BorderLayout.CENTER);
           
    filters = new ClassMemberFilters( this );
    filters.getInstance().hookChangeListener(this);

    // See http://www.netbeans.org/issues/show_bug.cgi?id=186407
    // Making the calls to getStructure() out of AWT EDT
    RP.post(new UpdateFilterState(language));
    
                        // filters
                        filtersPanel = new TapPanel();
                        filtersLbl = new JLabel(NbBundle.getMessage(ClassMemberPanelUI.class, "LBL_Filter")); //NOI18N
                        filtersLbl.setBorder(new EmptyBorder(0, 5, 5, 0));
                        filtersPanel.add(filtersLbl);
                        filtersPanel.setOrientation(TapPanel.DOWN);
                        // tooltip
                        KeyStroke toggleKey = KeyStroke.getKeyStroke(KeyEvent.VK_T,
                                Toolkit.getDefaultToolkit().getMenuShortcutKeyMask());
                        String keyText = Utilities.keyToString(toggleKey);
                        filtersPanel.setToolTipText(NbBundle.getMessage(ClassMemberPanelUI.class, "TIP_TapPanel", keyText));
                        filtersPanel.add(filters.getComponent());
                        add(filtersPanel, BorderLayout.SOUTH);  
    manager.setRootContext(ElementNode.getWaitNode());
    
    lookup = ExplorerUtils.createLookup(manager, getActionMap());       
}
 
Example 11
Project: incubator-netbeans   File: CPRenameRefactoringUI.java   View Source Code Vote up 5 votes
@Override
   public CustomRefactoringPanel getPanel(ChangeListener parent) {
if (panel == null) {
    panel = new RenamePanel(context.getElementName(), parent, NbBundle.getMessage(RenamePanel.class, "LBL_Rename"), true, true); //NOI18N
}

return panel;
   }
 
Example 12
Project: incubator-netbeans   File: AnnotationHolder.java   View Source Code Vote up 4 votes
public String getValue(final JTextComponent component, final Document document, Object attributeKey, final int startOffset, final int endOffset) {
    return resolveWarnings(document, startOffset, endOffset) + NbBundle.getMessage(AnnotationHolder.class, "LBL_shortcut_promotion");
}
 
Example 13
Project: incubator-netbeans   File: ClasspathNavigatorProviderImpl.java   View Source Code Vote up 4 votes
public String getDisplayHint() {
    return NbBundle.getMessage(ClasspathNavigatorProviderImpl.class, "SD_Classpath");
}
 
Example 14
Project: incubator-netbeans   File: CPRenameRefactoringUI.java   View Source Code Vote up 4 votes
@Override
   public String getName() {
return NbBundle.getMessage(CPRenameRefactoringUI.class, "LBL_Rename"); //NOI18N
   }
 
Example 15
Project: incubator-netbeans   File: QueryTopComponent.java   View Source Code Vote up 4 votes
private static String getBundleText(String key) {
    return NbBundle.getMessage(QueryTopComponent.class, key);
}
 
Example 16
Project: incubator-netbeans   File: GitHookImpl.java   View Source Code Vote up 4 votes
public GitHookImpl() {
    this.name = NbBundle.getMessage(GitHookImpl.class, "LBL_VCSHook");       // NOI18N
    VCSHooksConfig config = VCSHooksConfig.getInstance(VCSHooksConfig.HookType.GIT);
    delegate = new HookImpl(config, SUPPORTED_ISSUE_INFO_VARIABLES, SUPPORTED_REVISION_VARIABLES);
}
 
Example 17
Project: incubator-netbeans   File: MercurialAnnotator.java   View Source Code Vote up 4 votes
private Image addToolTip (Image icon, VCSContext context) {
    if (!VersioningSupport.getPreferences().getBoolean(VersioningSupport.PREF_BOOLEAN_TEXT_ANNOTATIONS_VISIBLE, false)) {
        return icon;
    }
    File root = null;
    File repository = null;
    for (File f : context.getRootFiles()) {
        File repo = Mercurial.getInstance().getRepositoryRoot(f);
        if (repo != null) {
            if (repository == null) {
                repository = repo;
                root = f;
            } else if (!repository.equals(repo)) {
                // root files are from different repositories, do not annotate icon
                return icon;
            }
        }
    }
    if (repository != null) {
        WorkingCopyInfo info = WorkingCopyInfo.getInstance(repository);
        addFileWithRepositoryAnnotation(info, root);
        HgLogMessage[] parents = info.getWorkingCopyParents();
        String label = null;
        if (parents.length == 1) {
            HgLogMessage parent = parents[0];
            String branchName = null;
            for (String b : parent.getBranches()) {
                branchName = b;
            }
            if (branchName != null) {
                label = NbBundle.getMessage(MercurialAnnotator.class, "LBL_Annotator.currentBranch.toolTip", branchName); //NOI18N
            }
        } else if (parents.length > 1) {
            String b1 = parents[0].getBranches().length == 0 ? HgBranch.DEFAULT_NAME : parents[0].getBranches()[0];
            String b2 = parents[1].getBranches().length == 0 ? HgBranch.DEFAULT_NAME : parents[1].getBranches()[0];
            if (b1.equals(b2)) {
                label = NbBundle.getMessage(MercurialAnnotator.class, "LBL_Annotator.mergeNeeded.oneBranch.toolTip", new Object[] { //NOI18N
                    parents[0].getCSetShortID().substring(0, Math.min(7, parents[0].getCSetShortID().length())), 
                    parents[1].getCSetShortID().substring(0, Math.min(7, parents[1].getCSetShortID().length())), 
                    b1
                });
            } else {
                label = NbBundle.getMessage(MercurialAnnotator.class, "LBL_Annotator.mergeNeeded.twoBranches.toolTip", new Object[] { b1, b2 }); //NOI18N
            }
        }
        if (label != null) {
            icon = ImageUtilities.addToolTipToImage(icon, label.toString());
        }
    }
    return icon;
}
 
Example 18
Project: incubator-netbeans   File: ReplaceConstructorWithBuilderUI.java   View Source Code Vote up 4 votes
@Override
public String getDescription() {
    return NbBundle.getMessage(ReplaceConstructorWithBuilderUI.class, "ReplaceConstructorWithBuilderDescription", name ,builderFQN);    
}
 
Example 19
Project: incubator-netbeans   File: Actions.java   View Source Code Vote up 4 votes
public NotificationQueryAction(QueryNode... queryNodes) {
    super(NbBundle.getMessage(Actions.class, "CTL_Notification"), queryNodes); //NOI18N
}
 
Example 20
Project: openjdk-jdk10   File: FilterAction.java   View Source Code Vote up 4 votes
public FilterAction() {
    super(NbBundle.getMessage(FilterAction.class, "CTL_FilterAction"));
}