@@ -54,7 +54,8 @@ public void run() {
5454 if (texPreview == null ) {
5555 texPreview = new TexturePreview (manager );
5656 }
57- texPreview .requestPreview (stripQuotes (textureName ), "" , 80 , 25 , texturePreview , null );
57+ final String [] textureNameComponents = textureName .split (" " );
58+ texPreview .requestPreview (stripQuotes (textureNameComponents [textureNameComponents .length - 1 ]), "" , 80 , 25 , texturePreview , null );
5859 } catch (AssetNotFoundException a ) {
5960 Logger .getLogger (MaterialEditorTopComponent .class .getName ()).log (Level .WARNING , "Could not load texture {0}" , textureName );
6061 }
@@ -68,19 +69,21 @@ private String stripQuotes(String s) {
6869 }
6970
7071 private void updateFlipRepeat () {
71- if (flip && repeat ) {
72- property .setValue ("Flip Repeat " + textureName );
73- texturePreview .setToolTipText ("Flip Repeat " + textureName );
74- } else if (flip ) {
75- property .setValue ("Flip " + textureName );
76- texturePreview .setToolTipText ("Flip " + textureName );
77- } else if (repeat ) {
78- property .setValue ("Repeat " + textureName );
79- texturePreview .setToolTipText ("Repeat " + textureName );
80- } else {
81- property .setValue (textureName );
82- texturePreview .setToolTipText (textureName );
72+ String propertyValue = property .getValue ();
73+ propertyValue = propertyValue .replaceFirst (textureName , "" );
74+ if (flip && !propertyValue .contains ("Flip " )) {
75+ propertyValue += "Flip " ;
76+ } else if (!flip ) {
77+ propertyValue = propertyValue .replaceFirst ("Flip " , "" );
8378 }
79+ if (repeat && !propertyValue .contains ("Repeat " )) {
80+ propertyValue += "Repeat " ;
81+ } else if (!repeat ) {
82+ propertyValue = propertyValue .replaceFirst ("Repeat " , "" );
83+ }
84+ propertyValue += textureName ;
85+ property .setValue (propertyValue );
86+ texturePreview .setToolTipText (propertyValue );
8487 }
8588
8689 private static BufferedImage resizeImage (BufferedImage originalImage ) {
@@ -277,33 +280,26 @@ private void texturePreviewMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FI
277280
278281 @ Override
279282 protected void readProperty () {
280- java .awt .EventQueue .invokeLater (new Runnable () {
281-
282- @ Override
283- public void run () {
284- if (property .getValue ().startsWith ("Flip Repeat " )) {
285- flip = true ;
286- repeat = true ;
287- textureName = property .getValue ().replaceFirst ("Flip Repeat " , "" ).trim ();
288- } else if (property .getValue ().startsWith ("Flip " )) {
289- flip = true ;
290- textureName = property .getValue ().replaceFirst ("Flip " , "" ).trim ();
291- } else if (property .getValue ().startsWith ("Repeat " )) {
292- repeat = true ;
293- textureName = property .getValue ().replaceFirst ("Repeat " , "" ).trim ();
294- } else {
295- textureName = property .getValue ();
296- }
297- jLabel1 .setText (property .getName ());
298- jLabel1 .setToolTipText (property .getName ());
299- displayPreview ();
300- texturePreview .setToolTipText (property .getValue ());
301- MaterialProperty prop = property ;
302- property = null ;
303- jCheckBox1 .setSelected (flip );
304- jCheckBox2 .setSelected (repeat );
305- property = prop ;
283+ java .awt .EventQueue .invokeLater (() -> {
284+ textureName = property .getValue ();
285+ if (textureName .contains ("Flip " )) {
286+ flip = true ;
287+ textureName = textureName .replaceFirst ("Flip " , "" ).trim ();
288+ }
289+ if (textureName .contains ("Repeat " )) {
290+ repeat = true ;
291+ textureName = textureName .replaceFirst ("Repeat " , "" ).trim ();
306292 }
293+ property .setValue (textureName );
294+ jLabel1 .setText (property .getName ());
295+ jLabel1 .setToolTipText (property .getName ());
296+ displayPreview ();
297+ texturePreview .setToolTipText (property .getValue ());
298+ MaterialProperty prop = property ;
299+ property = null ;
300+ jCheckBox1 .setSelected (flip );
301+ jCheckBox2 .setSelected (repeat );
302+ property = prop ;
307303 });
308304 }
309305
0 commit comments