How to make the CVS items in VCS menu disappear if CVS is not the active VCS?

Is there a way that I missed to remove completely these?
Right now the Tools/]]> is getting pretty long for no reason.

Jacques

13 comments

I've complained about this for some time, and even filed a defect against it.
When we are close to release, I will file a defect against any outstanding
issues here. In the mean time, I put code in my own VCS implementation to do just that:
I simply remove the actions that CVS is showing all the time, and wrap the CVS main-menu item so it
is only visible when CVS is active.

Jacques Morel wrote:

Is there a way that I missed to remove completely these?
Right now the Tools/<VCS plugin name> is getting pretty long for no reason.

Jacques


--

Erb

==============================================================
"Most of you are familiar with the virtues of a programmer.
There are three, of course: laziness, impatience, and hubris."
- Larry Wall
==============================================================

0

Perforce plug-in had this same bug, and I just went in and fixed it in the
Perforce plug-in. Not sure if you have the CVS code, but all you have to do
is check that the AbstractVcs you get from the project is instanceof CVSVcs
or whatever the class is called. If it's not, then call
Action.setHidden(true);

do this in every action that they have and it'll fix the problem...

-harpstein

"Jacques Morel" <jacmorel@yahoo.com> wrote in message
news:2046316.1066951973134.JavaMail.itn@is.intellij.net...

Is there a way that I missed to remove completely these?
Right now the Tools/<VCS plugin name> is getting pretty long for no

reason.
>

Jacques



0

As I thought... ;-(
Could you extract this out to a reusable library? if you do not have the time could you just send me the code and I will try to make something that everybody can use.

Thanks

Jacques

0

Well, I've been holding off until the plugin stabilized. You think they're done yet?

Jacques Morel wrote:

As I thought... ;-(
Could you extract this out to a reusable library? if you do not have the time could you just send me the code and I will try to make something that everybody can use.

Thanks

Jacques


--

Erb

==============================================================
"Most of you are familiar with the virtues of a programmer.
There are three, of course: laziness, impatience, and hubris."
- Larry Wall
==============================================================

0

I would not be sure of that. However I just want this piece only not the overall VCS plugin infrastructure that I am sure we can expend upon. I look at this, this way: I am going to do it anyway. I am going to live through upgrades and do the necessary changes. If you have done it already and we share it, I save time right now. Later, if an upgrade impacts this, one of us can migrate it for the benefit of everybody.
Everybody wins at the price of some minor delay for the others.

Jacques

0
  • Step 1:


This goes in an ApplicationComponent:

private static final String CVS_MAIN_MENU = "CvsGlobalActions";
public void initComponent() {
ActionManager aManager = ActionManager.getInstance();

// Defer this until init finished. Too bad StartupManager
// does not support post-app init.
SwingUtilities.invokeLater(new Runnable() {
public void run() {
// Wrap CVS main menu to show only for CVS.
ActionManager aManager = ActionManager.getInstance();
DefaultActionGroup cvsMenu = (DefaultActionGroup)aManager.getAction(CVS_MAIN_MENU);
DefaultActionGroup mainMenu = (DefaultActionGroup)aManager.getAction("MainMenu");
mainMenu.getChildren(null);
mainMenu.add(new CvsMenuWrapper(cvsMenu), new Constraints(Anchor.AFTER, CVS_MAIN_MENU));
mainMenu.remove(cvsMenu);
}
});
}

  • it uses this class:


class CvsMenuWrapper extends DefaultActionGroup {

private ActionGroup _inner;

public CvsMenuWrapper(ActionGroup inner) {
_inner = inner;
copyFrom(_inner);
setPopup(_inner.isPopup());
setEnabledInModalContext(_inner.isEnabledInModalContext());

AnAction[] kids = _inner.getChildren(null);
for(int i = 0, n = kids.length; i < n; i++) {
add(kids+);
}
}

public void update(AnActionEvent e) {
// Show only if CVS.
Project project = (Project)e.getDataContext().getData(DataConstants.PROJECT);
AbstractVcs vcs = (project == null ? null : VcsManager.getInstance(project).getActiveVcs());
boolean isCvs = (vcs != null && getVcsClassName(vcs).indexOf("cvs") >= 0);
if (isCvs == false) {
e.getPresentation().setVisible(false);
}
else {
_inner.update(e);
}
}

private static String getVcsClassName(AbstractVcs vcs) {
return vcs.getClass().getName().toLowerCase();
}
}

  • Step 2: this is called from you AbstractVcs, the FIRST time start() is called:


private static void killCVS() {
ActionManager manager = ActionManager.getInstance();
// Temporary fix until they fix the plugin:
DefaultActionGroup parent = (DefaultActionGroup)manager.getAction("FileMenu");
if (parent != null) {
parent.getChildren(null);
AnAction cvs = manager.getAction("Cvs.CheckoutProject");
if (cvs != null) {
parent.remove(cvs);
}
}
parent = (DefaultActionGroup)manager.getAction("VersionControlsGroup");
if (parent != null) {
parent.getChildren(null);
AnAction cvs = manager.getAction("Cvs.BrowseCVSRepository");
if (cvs != null) {
parent.remove(cvs);
}
cvs = manager.getAction("Cvs.Import");
if (cvs != null) {
parent.remove(cvs);
}
}
}




Jacques Morel wrote:

I would not be sure of that. However I just want this piece only not the overall VCS plugin infrastructure that I am sure we can expend upon. I look at this, this way: I am going to do it anyway. I am going to live through upgrades and do the necessary changes. If you have done it already and we share it, I save time right now. Later, if an upgrade impacts this, one of us can migrate it for the benefit of everybody.
Everybody wins at the price of some minor delay for the others.

Jacques


--

Erb

==============================================================
"Most of you are familiar with the virtues of a programmer.
There are three, of course: laziness, impatience, and hubris."
- Larry Wall
==============================================================

0

Note, by the way, that the actions removed are still accessible from the CVS main menu.

Erb wrote:

  • Step 1:


This goes in an ApplicationComponent:


--

Erb

==============================================================
"Most of you are familiar with the virtues of a programmer.
There are three, of course: laziness, impatience, and hubris."
- Larry Wall
==============================================================

0

Fixed in the 961 (CVS-specific menu items (in Tools->VCS) will be invisible
if CVS is inactive)
--
Best regards,
Olesya Smirnova
JetBrains, Inc / IntelliJ Software
http://www.intellij.com
"Develop with pleasure!"


"Jacques Morel" <jacmorel@yahoo.com> wrote in message
news:2046316.1066951973134.JavaMail.itn@is.intellij.net...

Is there a way that I missed to remove completely these?
Right now the Tools/<VCS plugin name> is getting pretty long for no

reason.
>

Jacques



0

Thanks Olesya! Great turn around as usual.

Jacques

0

And the CVS menu too, I hope?

Olesya Smirnova (JetBrains) wrote:

Fixed in the 961 (CVS-specific menu items (in Tools->VCS) will be invisible
if CVS is inactive)


--

Erb

==============================================================
"Most of you are familiar with the virtues of a programmer.
There are three, of course: laziness, impatience, and hubris."
- Larry Wall
==============================================================

0

Checkout and Import menu items will be (at least they should be) accessible
from "File" menu only, if cvs is inactive.
To avoid this you can remove cvs from plugins...
--
Best regards,
Olesya Smirnova
JetBrains, Inc / IntelliJ Software
http://www.intellij.com
"Develop with pleasure!"


"Erb" <dont@evenbother.com> wrote in message
news:bnlva5$328$1@is.intellij.net...

And the CVS menu too, I hope?

>

Olesya Smirnova (JetBrains) wrote:

>

Fixed in the 961 (CVS-specific menu items (in Tools->VCS) will be

invisible

if CVS is inactive)

>

--

>

Erb

>

==============================================================
"Most of you are familiar with the virtues of a programmer.
There are three, of course: laziness, impatience, and hubris."
- Larry Wall
==============================================================

>


0

Again, what if you need CVS for one project but another Vcs for another project?
This is easily fixed and should be.

Olesya Smirnova (JetBrains) wrote:

Checkout and Import menu items will be (at least they should be) accessible
from "File" menu only, if cvs is inactive.
To avoid this you can remove cvs from plugins...


--

Erb

==============================================================
"Most of you are familiar with the virtues of a programmer.
There are three, of course: laziness, impatience, and hubris."
- Larry Wall
==============================================================

0

Ok we have already discussed this before and did not come to a consensus.
Why is CVS so special? Are you going to have the equivalent menus for starteam and vss as well?
Let's be consistent.
Will your position change once IDEA migrates to Perforce or some more advanced VCS than CVS?
In addition are these menus are only to create project level configuration (Main modules). What about secondary modules when they are using a mix set of VCS. What if I use Clearcase for some and CVS for others but I have all modules in one project? I am under the assumption that it is still going to be available right?

Jacques

0

Please sign in to leave a comment.