Sometimes, especially when dealing with variations of factory pattern, single method (namely factory()) can return objects of different types, so NetBeans is unable to guess the exact type of returned instance and as such cannot auto-complete. Indeed, you can setup return type using phpDoc syntax:

/**
 * @return Some_Base_Abstract_Class_Name
 */
public function factory($adapter)

but that doesn’t work if returned objects are specifications of more general abstract class (exactly the case with factory).

As it turned out, you can easily resolve this issue – just document your variable with @var, before calling factory() method:

/**
 * @var Some_Specific_Class $foo
 */
$foo = Magic::factory('adapterName');
$foo-> // and NetBeans opens pop-up list with available attributes and methods

The good news, you can use this method in any scope – it just works :) I love NetBeans!!

UPD: Well, actually NetBeans seems to be picky of scope – as reported by others (and confirmed by myself).

UPD1: Actually NetBeans handles this quite well, just use vdoc (review this and this for details)

,

It’s been several days that I am relying solely on NetBeans for my PHP and Java coding. So far, it’s beyond my wildest expectations – I am totally satisfied with that great IDE. Today, I have searched for shortcut that would allow me to duplicate a given line, and (fortunately!) came by a great post – Top 10 NetBeans IDE Keyboard Shortcuts. Not only I found the line-duplication thing, I discovered several other pearls which due to unavailability in my previous IDEs, I even didn’t consider to look for.

So, I decided to compile my own list of shortcuts that save me a lot of time during code-sessions.

Shift + Esc Toggle Work-space Maximize/Minimize

Like the original post author, I really like to have as much work-space available for code itself as possible. And when I occasionally need to see one of the supplementary panels (like Files, Project, Navigator etc), I rely mostly on short-cuts, w/o toggling back. So, if I need to view some docking panel I hit one of the following:

Ctrl+1 – Project Window
Ctrl+2 – Files Window
Ctrl+3 – Favorite Window
Ctrl+4 – Output Window
Ctrl+5 – Services window
Ctrl+6 – Tasks Window

and when I am done, Ctrl+0 to get me back to editor. Try for yourself, I am pretty sure, you’d be amazed how much time this saves you, while making coding area less cluttered.

Alt+Enter View fix suggestions

NetBeans makes your life a lot easier, its Java code analyzer does a really solid job. Most of errors are filtered even before compilation – should you see the light bulb on the left of your code, you can review fix suggestions by either clicking on it or (time-saver again!) by just hitting Alt+Enter. I personally enjoy this one, as I prefer to see why IDE is complaining w/o releasing my hands of the keyboard.

Ctrl+F12 Navigate to Member

If your class is too big, then Members View in Navigator (Ctrl+7 remember?) might not be the best option. Just hit Ctrl+F12 and you’d be able to navigate more easily, as it has filter that would eliminate non-matching members while you are typing.

Alt+Insert Generate code

That’s one of my favorites – code generators for getters/setters/constructors are just too sexy to ignore. This shortcut makes them even more usefull.

Ctrl+Shift+ArrowDown Duplicate Line

Duplicating lines never been easier :) If you want a new duplicate to be inserted before the current line, use ArrowUp instead of ArrowDown.

Ctrl+W Close Current Window

Firefox honors this short-cut, as well as Konqueror. So, I even configured my console to use this by default. In no time you’d be accustomed to hit this combination instead of Ctrl+F4.

Ctrl+PgUp and Ctrl+PgDn Navigate through Windows (previous/next)

Again, got used to it from Firefox. Makes it a swift to loop through open documents.

Ctrl+P Display method’s arguments

Within method’s braces hit this combination to see what parameters are there. Comes where handy when reviewing the code.

Ctrl+; Add semicolon to the end of the line w/o leaving current cursor position

If you are working on some code line and NetBeans underlines it red (due to [yet] non-existent semicolon at the end of the line) hitting Ctrl + ; (Ctrl + semicolon) is enough to close the statement, while you are still positioned at the very same place on line. First saw this on dzone.com blog, and really liked using it.

Ctrl+K and Ctrl+L Auto complete with previous/next matched word

I use this combination even more often than Ctrl+Space to auto complete. Listing all items with Ctrl+Space might be slow, but hitting Ctrl+K is instant. More than often the variable name you are typing is already typed somewhere in the current file, thus matching it with Ctrl+K or Ctrl+L is probably most obvious thing to do.

Ctrl+E Delete current line

Ctrl+Del and Ctrl+BackSpace Delete next/previous word

I generally use Ctrl+BackSpace, but on some occasions Ctrl+Del also proved userful.

That’s more than enough to get you going. In some time, I plan to write more extensive list  of esoteric shortcuts you rarely use, because you rarely know about them.

And what shortcuts save your time?

,

После того как на developer.com были подведенны итоги голосования за лучший продукт года, стало ясно, что с NetBeans и рядом ничего не стояло :) На самом деле, я сам перебрался на NB около двух недель назад, конфигурировал свою Слаку так и эдак, и при попытке найти толковый Java-редактор, в который раз наткнулся на NetBeans (до этого руки как-то не доходили до номального тестирования). Система мне понравилась настолько, что я и с PHP теперь работаю исключительно из NetBeans.

В целом, NetBeans ни в чем не уступает Zend Studio (разве что нормального саппорта ftp пока нет, но во-1, я думаю, скоро появится; во-2, для меня это не критично, т.к. FileZilla мне удобнее, да и проекты мои переведенны на Subversion,  так что заливкой через ftp не занимаюсь). Более того, во многом ее превосходит: рефакторинг, работа с базами данных, возможность работы с другими языками (я пробывал работать на Java, C++, PHP – впечатления только положительные!).

Кроме того, NetBeans – это Open Source проект, и уже поэтому, хотя бы на линуксе, Zend Studio должен быть задвинут – они так долго завышали цену за свою IDE, что мне даже нравится неизбежное падение продаж Zend Studio.

И в заключинии, список номинаций в которых NetBeans признан продуктом года:

  • Development tool
  • Development utilities
  • Wireless/mobile (вот тут даже странно!)
  • Java tool
  • Open Source

Таким образом из 12 номинаций NetBeans покорились 5! Прекрасный результат, надеюсь, что дальнейшая разработка будет настолько же успешной.

,

Если кто не знает NetBeans это кросс-платформенный IDE с поддержкой кучи языков (меня интересуют только PHP, Java, C/C++, но там заявленна поддержка также Ruby, Python и много чего еще по мелочи, как то XML, JS и пр. пр.). Если сравнивать с Zend Studio на которой я очень долго писал код для PHP, NetBeans ничем не уступает, а во многом даже превосходит – учитывая что текущая версия ZS построенна поверх Eclipse и в данный момент жутко тормозит, NetBeans выглядит наиболее подходящей альтернативой.

В общем, всем кто не пробывал – вперед!

Сегодня захотел подключить MySQL, но соединение никак не создавалось, вроде все ввожу правильно (да и где там можно ошибиться?), но не работает! Полазил по нету, нашел вот этот пост. В общем, нужно в файле конфигурации (у меня он храниться как /etc/my.cnf) закоментировать строку skip-networking и все должно зароботать. Я так и сделал, перезапустил БД-сервер:

/etc/rc.d/rc.mysqld restart

Сервер рестартанулся, соединиться через jdbc в NetBeans опять не получилось. Потратив (бесполезно) час, решил глянуть на сам скрипт rc.mysqd, и нашел там такую прелесть:

# To allow outside connections to the database comment out the next line.
# If you don't need incoming network connections, then leave the line
# uncommented to improve system security.
SKIP="--skip-networking"

Как только я это дело закоментил, все (как и ожидалось) заработало!

,