Skip to content

Tab-Menu doesn't open files with only different extension (with solution) [imported] #191

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
cmaglie opened this issue Nov 15, 2012 · 0 comments

Comments

@cmaglie
Copy link
Member

cmaglie commented Nov 15, 2012

This is Issue 191 moved from a Google Code project.
Added by 2010-01-25T15:35:08.000Z by qist...@gmail.com.
Please review that bug for more context and additional comments, but update this bug.
Closed (Fixed).

Original labels: Type-Defect, Priority-Medium, Component-IDE, OpSys-All, Milestone-0019

Original description

What steps will reproduce the problem?

  1. Start a new Sketch
  2. Add a file "test.cpp" to the Sketch
  3. Add a file "test.h" to the Sketch
  4. Open the tab menu and select the first "test" (the test.cpp opens)
  5. Open the tab menu and select the second "test" (the test.cpp opens again)

What is the expected output? What do you see instead?
Only one of the files (alphabetically first seemingly) can be opened from
the tab-menu if there are multiple files with the same name, and only a
different extension.

What version of the Arduino software are you using?
Arduino 0017 and Arduino 0018 running on Windows Vista.

Please provide any additional information below.
The solution is quite simple.
Sketch.setCurrentCode(String fileName) already checks for file name as well
as 'pretty name'.
The jumpListener in SketchHeader already uses the action command to get the
filename (which is the button text if none is set, and thus the pretty name).
Setting the action command specifically allows the tab menu to function
properly.

Old code
for (SketchCode code : sketch.getCode()) {
item = new JMenuItem(code.getPrettyName());
item.addActionListener(jumpListener);
menu.add(item);
}

New code
for (SketchCode code : sketch.getCode()) {
item = new JMenuItem(code.getPrettyName());
item.setActionCommand(code.getFileName());
item.addActionListener(jumpListener);
menu.add(item);
}

For more clarity it's maybe a good idea to also show the extension in the
tab menu. The easiest way to do this would be:
for (SketchCode code : sketch.getCode()) {
item = new JMenuItem(code.getFileName());
item.addActionListener(jumpListener);
menu.add(item);
}

@cmaglie cmaglie closed this as completed Nov 15, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant