forked from nroduit/Weasis
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Dicomizer: Limit the number of characters in metadata table according…
… to the DICOM attributes nroduit#564
- Loading branch information
Showing
5 changed files
with
74 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
weasis-core/src/main/java/org/weasis/core/ui/util/LimitedTextField.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/* | ||
* Copyright (c) 2024 Weasis Team and other contributors. | ||
* | ||
* This program and the accompanying materials are made available under the terms of the Eclipse | ||
* Public License 2.0 which is available at https://www.eclipse.org/legal/epl-2.0, or the Apache | ||
* License, Version 2.0 which is available at https://www.apache.org/licenses/LICENSE-2.0. | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 | ||
*/ | ||
package org.weasis.core.ui.util; | ||
|
||
import javax.swing.*; | ||
import javax.swing.text.*; | ||
|
||
public class LimitedTextField extends JTextField { | ||
public LimitedTextField(int limit) { | ||
super(); | ||
setDocument(new LimitedDocument(limit)); | ||
} | ||
|
||
private static class LimitedDocument extends PlainDocument { | ||
private final int limit; | ||
|
||
LimitedDocument(int limit) { | ||
this.limit = limit; | ||
} | ||
|
||
@Override | ||
public void insertString(int offset, String str, AttributeSet attr) | ||
throws BadLocationException { | ||
if (str == null) { | ||
return; | ||
} | ||
|
||
if ((getLength() + str.length()) <= limit) { | ||
super.insertString(offset, str, attr); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters