Skip to content

Commit

Permalink
Editor file name broken by putting dots for long names. Fix #21
Browse files Browse the repository at this point in the history
  • Loading branch information
jordeu committed Feb 11, 2013
1 parent 79e1895 commit b9cf202
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,6 @@ public void run(IProgressMonitor monitor) {
editor.setName(analysis.getTitle() + "." + FileSuffixes.COMBINATION);
else
editor.setName(editorPanel.deriveName(currentEditor.getName(), ext, "", FileSuffixes.COMBINATION));
editor.abbreviateName(Settings.getDefault().getEditorTabLength());

SwingUtilities.invokeLater(new Runnable() {
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,6 @@ public void run(IProgressMonitor monitor) {
editor.setName(analysis.getTitle() + "."+FileSuffixes.CORRELATIONS);
else
editor.setName(editorPanel.deriveName(currentEditor.getName(), ext, "", FileSuffixes.CORRELATIONS));
editor.abbreviateName(Settings.getDefault().getEditorTabLength());

SwingUtilities.invokeLater(new Runnable() {
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,6 @@ public void run(IProgressMonitor monitor) {
editor.setName(analysis.getTitle() + "." + FileSuffixes.GROUP_COMPARISON);
else
editor.setName(editorPanel.deriveName(currentEditor.getName(), ext, "", FileSuffixes.GROUP_COMPARISON));
editor.abbreviateName(Settings.getDefault().getEditorTabLength());


SwingUtilities.invokeLater(new Runnable() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,6 @@ public void run(IProgressMonitor monitor) {
editor.setName(analysis.getTitle() + "."+FileSuffixes.OVERLAPPING);
else
editor.setName(editorPanel.deriveName(currentEditor.getName(), ext, "", FileSuffixes.OVERLAPPING));
editor.abbreviateName(Settings.getDefault().getEditorTabLength());

SwingUtilities.invokeLater(new Runnable() {
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,6 @@ else if (mime.equals(MimeTypes.GROUPCOMPARISON_ANALYSIS))
editor = new GroupComparisonAnalysisEditor((GroupComparisonAnalysis) analysis);

editor.setName(file.getName());
editor.abbreviateName(Settings.getDefault().getEditorTabLength());

final AbstractEditor newEditor = editor;
SwingUtilities.invokeLater(new Runnable() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ public void execute(IProgressMonitor monitor) throws CommandException {
final HeatmapEditor editor = new HeatmapEditor(figure);

editor.setName(PersistenceUtils.getFileName(file.getName()));
editor.abbreviateName(Settings.getDefault().getEditorTabLength());

SwingUtilities.invokeLater(new Runnable() {
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
*/
package org.gitools.ui.platform.component;

import org.apache.commons.lang.StringUtils;
import org.gitools.ui.platform.editor.AbstractEditor;
import org.gitools.ui.platform.editor.EditorsPanel;
import org.gitools.ui.platform.editor.IEditor;
Expand All @@ -23,6 +24,8 @@
*/
public class EditorTabComponent extends JPanel {

public static final int DEFAULT_EDITOR_TAB_LENGTH = 20;

private final EditorsPanel editorPanel;
private final AbstractEditor editor;

Expand Down Expand Up @@ -79,7 +82,20 @@ private void updateLabel() {


String name = editor.getName();
label.setText(name);
String extension = "";
String filename = name;
String newname;

int i = name.lastIndexOf('.');
if (i > 0) {
extension = "." + name.substring(i+1);
filename = name.substring(0, name.lastIndexOf('.'));
}

//TODO allow the default editor tab length to be configurable
newname = StringUtils.abbreviate(filename, DEFAULT_EDITOR_TAB_LENGTH) + extension;

label.setText(newname);
label.setIcon(editor.getIcon());
label.setIconTextGap(3);
label.setHorizontalTextPosition(SwingConstants.RIGHT);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,24 +55,6 @@ public void setName(String name) {
}
}

public void abbreviateName(int maxLength) {

String extension = "";
String filename = getName();
String name = getName();
String newname;

int i = name.lastIndexOf('.');
if (i > 0) {
extension = "." + name.substring(i+1);
filename = name.substring(0, name.lastIndexOf('.'));
}

newname = StringUtils.abbreviate(filename, maxLength) + extension;

setName(newname);
}

public File getFile() {
return file;
}
Expand Down

2 comments on commit b9cf202

@mpschr
Copy link
Member

@mpschr mpschr commented on b9cf202 Feb 11, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did the setting editor_tab_length get obsolete?

@jordeu
Copy link
Member Author

@jordeu jordeu commented on b9cf202 Feb 11, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll reconsider it when implementing the user interface to customize the default config values. See issue #37.

Please sign in to comment.