1 19 20 package org.netbeans.modules.apisupport.project.ui.customizer; 21 22 import java.awt.Image ; 23 import java.awt.Rectangle ; 24 import java.beans.PropertyChangeEvent ; 25 import java.beans.PropertyChangeListener ; 26 import java.io.File ; 27 import java.net.MalformedURLException ; 28 import java.net.URL ; 29 import java.text.ParseException ; 30 import java.util.Locale ; 31 import javax.swing.JFileChooser ; 32 import javax.swing.JFormattedTextField ; 33 import javax.swing.event.ChangeEvent ; 34 import javax.swing.event.ChangeListener ; 35 import javax.swing.event.DocumentEvent ; 36 import org.netbeans.modules.apisupport.project.ui.UIUtil; 37 import org.netbeans.spi.project.ui.support.ProjectCustomizer; 38 import org.openide.ErrorManager; 39 import org.openide.util.NbBundle; 40 41 46 public class SuiteCustomizerSplashBranding extends NbPropertyPanel.Suite { 47 48 private SplashComponentPreview splashImage; 49 private JFormattedTextField fontSize; 50 private JFormattedTextField runningTextBounds; 51 private JFormattedTextField progressBarBounds; 52 private SplashUISupport.ColorComboBox textColor; 53 private SplashUISupport.ColorComboBox barColor; 54 private SplashUISupport.ColorComboBox edgeColor; 55 private SplashUISupport.ColorComboBox cornerColor; 56 57 private URL splashSource; 58 private ProjectCustomizer.Category cat; 59 62 public SuiteCustomizerSplashBranding(final SuiteProperties suiteProps, final ProjectCustomizer.Category cat) { 63 super(suiteProps, SuiteCustomizerSplashBranding.class); 64 this.cat = cat; 65 BasicBrandingModel branding = getBrandingModel(); 66 branding.addChangeListener(new ChangeListener () { 67 public void stateChanged(ChangeEvent e) { 68 enableDisableComponents(); 69 } 70 }); 71 72 splashImage =new SplashComponentPreview(); 73 fontSize = SplashUISupport.getIntegerField(); 74 runningTextBounds = SplashUISupport.getBoundsField(); 75 progressBarBounds = SplashUISupport.getBoundsField(); 76 textColor = SplashUISupport.getColorComboBox(); 77 barColor = SplashUISupport.getColorComboBox(); 78 edgeColor = SplashUISupport.getColorComboBox(); 79 cornerColor = SplashUISupport.getColorComboBox(); 80 splashImage.setDropHandletForProgress(new DragManager.DropHandler(){ 81 public void dragAccepted(Rectangle original, Rectangle afterDrag) { 82 progressBarBounds.setValue(afterDrag); 83 } 84 }); 85 86 splashImage.setDropHandletForText(new DragManager.DropHandler(){ 87 public void dragAccepted(Rectangle original, Rectangle afterDrag) { 88 runningTextBounds.setValue(afterDrag); 89 double ratio = ((double)afterDrag.height)/original.height; 90 int size = (int)((((Number )fontSize.getValue()).intValue()*ratio)); 91 size = (size > 0) ? size : 3; 92 fontSize.setValue(new Integer (size)); 93 } 94 }); 95 96 initComponents(); 97 refresh(); 98 99 PropertyChangeListener pL = new PropertyChangeListener () { 100 public void propertyChange(PropertyChangeEvent evt) { 101 if (evt.getPropertyName() != SplashUISupport.ColorComboBox.PROP_COLOR) { 102 return; 103 } 104 resetSplashPreview(); 105 } 106 }; 107 textColor.addPropertyChangeListener(pL); 108 barColor.addPropertyChangeListener(pL); 109 edgeColor.addPropertyChangeListener(pL); 110 cornerColor.addPropertyChangeListener(pL); 111 112 fontSize.getDocument().addDocumentListener(new UIUtil.DocumentAdapter() { 113 114 public void insertUpdate(DocumentEvent e) { 115 if (e != null || fontSize.isFocusOwner()) { 116 try { 117 fontSize.commitEdit(); 118 ((Number ) fontSize.getValue()).intValue(); 119 cat.setErrorMessage(null); 120 cat.setValid(true); 121 resetSplashPreview(); 122 } catch (ParseException ex) { 123 cat.setErrorMessage(NbBundle.getMessage(SuiteCustomizerSplashBranding.class, "ERR_InvalidFontSize")); 125 cat.setValid(false); 126 } 127 } 128 } 129 }); 130 131 runningTextBounds.getDocument().addDocumentListener(new UIUtil.DocumentAdapter() { 132 public void insertUpdate(DocumentEvent e) { 133 if (e != null || runningTextBounds.isFocusOwner()) { 134 try { 135 runningTextBounds.commitEdit(); 136 cat.setErrorMessage(null); 137 cat.setValid(true); 138 resetSplashPreview(); 139 } catch (ParseException ex) { 140 cat.setErrorMessage(NbBundle.getMessage(SuiteCustomizerSplashBranding.class, "ERR_InvalidTextBounds")); 142 cat.setValid(false); 143 } 144 } 145 } 146 }); 147 148 progressBarBounds.getDocument().addDocumentListener(new UIUtil.DocumentAdapter() { 149 public void insertUpdate(DocumentEvent e) { 150 if (e != null || progressBarBounds.isFocusOwner()) { 151 try { 152 progressBarBounds.commitEdit(); 153 cat.setErrorMessage(null); 154 cat.setValid(true); 155 resetSplashPreview(); 156 } catch (ParseException ex) { 157 cat.setErrorMessage(NbBundle.getMessage(SuiteCustomizerSplashBranding.class, "ERR_InvalidProgressBarBounds")); 159 cat.setValid(false); 160 } 161 } 162 } 163 }); 164 165 } 166 167 168 public void store() { 169 BasicBrandingModel branding = getBrandingModel(); 170 171 branding.getSplashRunningTextFontSize().setValue(SplashUISupport.integerToString(((Number )fontSize.getValue()).intValue())); 172 branding.getSplashRunningTextBounds().setValue(SplashUISupport.boundsToString((Rectangle )runningTextBounds.getValue())); 173 branding.getSplashProgressBarBounds().setValue(SplashUISupport.boundsToString((Rectangle )progressBarBounds.getValue())); 174 branding.getSplashRunningTextColor().setValue(SplashUISupport.colorToString(textColor.getColor())); 175 branding.getSplashProgressBarColor().setValue(SplashUISupport.colorToString(barColor.getColor())); 176 181 branding.getSplashShowProgressBar().setValue(Boolean.toString(progressBarEnabled.isSelected())); 182 branding.getSplash().setBrandingSource(splashSource); 183 184 branding.getSplashWidth().setValue(Integer.toString(splashImage.image.getWidth(null),10)); 185 branding.getSplashHeight().setValue(Integer.toString(splashImage.image.getHeight(null),10)); 186 } 187 188 189 void refresh() { 190 BasicBrandingModel branding = getBrandingModel(); 191 192 fontSize.setValue(new Integer (SplashUISupport.stringToInteger(branding.getSplashRunningTextFontSize().getValue()))); 193 runningTextBounds.setValue(SplashUISupport.stringToBounds(branding.getSplashRunningTextBounds().getValue())); 194 progressBarBounds.setValue(SplashUISupport.stringToBounds(branding.getSplashProgressBarBounds().getValue())); 195 textColor.setColor(SplashUISupport.stringToColor(branding.getSplashRunningTextColor().getValue())); 196 barColor.setColor(SplashUISupport.stringToColor(branding.getSplashProgressBarColor().getValue())); edgeColor.setColor(SplashUISupport.stringToColor(branding.getSplashProgressBarEdgeColor().getValue())); 198 cornerColor.setColor(SplashUISupport.stringToColor(branding.getSplashProgressBarCornerColor().getValue())); 199 progressBarEnabled.setSelected(getBrandingModel().getSplashShowProgressBar().getValue().trim().toLowerCase(Locale.ENGLISH).equals("true")); 201 splashSource = getBrandingModel().getSplash().getBrandingSource(); 202 resetSplashPreview(); 203 204 splashImage.setMaxSteps(10); 205 splashImage.resetSteps(); 207 splashImage.setText(NbBundle.getMessage(getClass(),"TEXT_SplashSample")); 208 209 enableDisableComponents(); 210 211 } 212 213 private void enableDisableComponents() { 214 final BasicBrandingModel branding = getBrandingModel(); 215 jLabel1.setEnabled(branding.isBrandingEnabled()); 216 jLabel2.setEnabled(branding.isBrandingEnabled()); 217 fontSize.setEnabled(branding.isBrandingEnabled()); 218 runningTextBounds.setEnabled(branding.isBrandingEnabled()); 219 progressBarBounds.setEnabled(branding.isBrandingEnabled()); 220 textColor.setEnabled(branding.isBrandingEnabled()); 221 barColor.setEnabled(branding.isBrandingEnabled()); 222 edgeColor.setEnabled(branding.isBrandingEnabled()); 223 cornerColor.setEnabled(branding.isBrandingEnabled()); 224 progressBarEnabled.setEnabled(branding.isBrandingEnabled()); 225 splashImage.setEnabled(branding.isBrandingEnabled()); 226 barBoundsLabel.setEnabled(branding.isBrandingEnabled()); 227 barColorLabel.setEnabled(branding.isBrandingEnabled()); 228 browse.setEnabled(branding.isBrandingEnabled()); 229 splashLabel.setEnabled(branding.isBrandingEnabled()); 230 splashPreview.setEnabled(branding.isBrandingEnabled()); 231 textBoundsLabel.setEnabled(branding.isBrandingEnabled()); 232 textColorLabel.setEnabled(branding.isBrandingEnabled()); 233 textFontSizeLabel.setEnabled(branding.isBrandingEnabled()); 234 splashImage.setEnabled(branding.isBrandingEnabled()); 235 } 236 237 private void resetSplashPreview() throws NumberFormatException { 238 splashImage.setSplashImageIcon(splashSource); 239 Rectangle tRectangle = (Rectangle )runningTextBounds.getValue(); 240 Rectangle pRectangle = (Rectangle )progressBarBounds.getValue(); 241 splashImage.setTextColor(textColor.getColor()); 242 splashImage.setColorBar(barColor.getColor()); 243 splashImage.setColorEdge(edgeColor.getColor()); 244 splashImage.setColorEdge(cornerColor.getColor()); 245 splashImage.setFontSize(((Number )fontSize.getValue()).intValue()); 246 splashImage.setRunningTextBounds(tRectangle); 247 splashImage.setProgressBarBounds(pRectangle); 248 splashImage.setProgressBarEnabled(progressBarEnabled.isSelected()); 249 splashImage.resetSteps(); 250 splashImage.setText(NbBundle.getMessage(getClass(),"TEXT_SplashSample")); 251 } 252 253 258 private void initComponents() { 260 javax.swing.JComboBox barColor; 261 javax.swing.JTextField fontSize; 262 java.awt.GridBagConstraints gridBagConstraints; 263 javax.swing.JTextField jTextField1; 264 javax.swing.JTextField jTextField4; 265 javax.swing.JComboBox textColor; 266 267 barColor = this.barColor; 268 jTextField1 = this.progressBarBounds; 269 barColorLabel = new javax.swing.JLabel (); 270 barBoundsLabel = new javax.swing.JLabel (); 271 textColorLabel = new javax.swing.JLabel (); 272 textColor = this.textColor; 273 jTextField4 = this.runningTextBounds; 274 fontSize = this.fontSize; 275 progressBarEnabled = new javax.swing.JCheckBox (); 276 textFontSizeLabel = new javax.swing.JLabel (); 277 textBoundsLabel = new javax.swing.JLabel (); 278 jLabel1 = new javax.swing.JLabel (); 279 jLabel2 = new javax.swing.JLabel (); 280 jPanel1 = new javax.swing.JPanel (); 281 splashLabel = new javax.swing.JLabel (); 282 jScrollPane1 = new javax.swing.JScrollPane (); 283 splashPreview = splashImage; 284 browse = new javax.swing.JButton (); 285 286 setLayout(new java.awt.GridBagLayout ()); 287 288 gridBagConstraints = new java.awt.GridBagConstraints (); 289 gridBagConstraints.gridx = 3; 290 gridBagConstraints.gridy = 1; 291 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 292 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 293 gridBagConstraints.weightx = 1.0; 294 gridBagConstraints.insets = new java.awt.Insets (6, 0, 0, 12); 295 add(barColor, gridBagConstraints); 296 297 jTextField1.setInputVerifier(jTextField1.getInputVerifier()); 298 jTextField1.setVerifyInputWhenFocusTarget(false); 299 gridBagConstraints = new java.awt.GridBagConstraints (); 300 gridBagConstraints.gridx = 5; 301 gridBagConstraints.gridy = 1; 302 gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; 303 gridBagConstraints.ipadx = 10; 304 gridBagConstraints.weightx = 1.0; 305 gridBagConstraints.insets = new java.awt.Insets (6, 0, 0, 0); 306 add(jTextField1, gridBagConstraints); 307 308 barColorLabel.setLabelFor(barColor); 309 org.openide.awt.Mnemonics.setLocalizedText(barColorLabel, java.util.ResourceBundle.getBundle("org/netbeans/modules/apisupport/project/ui/customizer/Bundle").getString("LBL_BarColor")); 310 gridBagConstraints = new java.awt.GridBagConstraints (); 311 gridBagConstraints.gridx = 2; 312 gridBagConstraints.gridy = 1; 313 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 314 gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST; 315 gridBagConstraints.insets = new java.awt.Insets (6, 0, 0, 12); 316 add(barColorLabel, gridBagConstraints); 317 barColorLabel.getAccessibleContext().setAccessibleDescription(java.util.ResourceBundle.getBundle("org/netbeans/modules/apisupport/project/ui/customizer/Bundle").getString("ACS_BarColor")); 318 319 barBoundsLabel.setLabelFor(jTextField1); 320 org.openide.awt.Mnemonics.setLocalizedText(barBoundsLabel, java.util.ResourceBundle.getBundle("org/netbeans/modules/apisupport/project/ui/customizer/Bundle").getString("LBL_BarBounds")); 321 gridBagConstraints = new java.awt.GridBagConstraints (); 322 gridBagConstraints.gridx = 4; 323 gridBagConstraints.gridy = 1; 324 gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST; 325 gridBagConstraints.insets = new java.awt.Insets (6, 0, 0, 12); 326 add(barBoundsLabel, gridBagConstraints); 327 barBoundsLabel.getAccessibleContext().setAccessibleDescription(java.util.ResourceBundle.getBundle("org/netbeans/modules/apisupport/project/ui/customizer/Bundle").getString("ACS_BarBounds")); 328 329 textColorLabel.setLabelFor(textColor); 330 org.openide.awt.Mnemonics.setLocalizedText(textColorLabel, java.util.ResourceBundle.getBundle("org/netbeans/modules/apisupport/project/ui/customizer/Bundle").getString("LBL_TextColor")); 331 gridBagConstraints = new java.awt.GridBagConstraints (); 332 gridBagConstraints.gridx = 2; 333 gridBagConstraints.gridy = 3; 334 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 335 gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST; 336 gridBagConstraints.insets = new java.awt.Insets (6, 0, 0, 12); 337 add(textColorLabel, gridBagConstraints); 338 textColorLabel.getAccessibleContext().setAccessibleDescription(java.util.ResourceBundle.getBundle("org/netbeans/modules/apisupport/project/ui/customizer/Bundle").getString("ACS_TextColor")); 339 340 gridBagConstraints = new java.awt.GridBagConstraints (); 341 gridBagConstraints.gridx = 3; 342 gridBagConstraints.gridy = 3; 343 gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; 344 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 345 gridBagConstraints.weightx = 1.0; 346 gridBagConstraints.insets = new java.awt.Insets (6, 0, 0, 12); 347 add(textColor, gridBagConstraints); 348 349 jTextField4.setInputVerifier(jTextField1.getInputVerifier()); 350 jTextField4.setVerifyInputWhenFocusTarget(false); 351 gridBagConstraints = new java.awt.GridBagConstraints (); 352 gridBagConstraints.gridx = 5; 353 gridBagConstraints.gridy = 3; 354 gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; 355 gridBagConstraints.ipadx = 10; 356 gridBagConstraints.weightx = 1.0; 357 gridBagConstraints.insets = new java.awt.Insets (6, 0, 0, 0); 358 add(jTextField4, gridBagConstraints); 359 360 fontSize.setInputVerifier(jTextField1.getInputVerifier()); 361 gridBagConstraints = new java.awt.GridBagConstraints (); 362 gridBagConstraints.gridx = 1; 363 gridBagConstraints.gridy = 3; 364 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 365 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 366 gridBagConstraints.insets = new java.awt.Insets (5, 0, 0, 12); 367 add(fontSize, gridBagConstraints); 368 369 org.openide.awt.Mnemonics.setLocalizedText(progressBarEnabled, java.util.ResourceBundle.getBundle("org/netbeans/modules/apisupport/project/ui/customizer/Bundle").getString("LBL_ProgressBarEnabled")); 370 progressBarEnabled.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0)); 371 progressBarEnabled.setMargin(new java.awt.Insets (0, 0, 0, 0)); 372 progressBarEnabled.addActionListener(new java.awt.event.ActionListener () { 373 public void actionPerformed(java.awt.event.ActionEvent evt) { 374 progressBarEnabledActionPerformed(evt); 375 } 376 }); 377 378 gridBagConstraints = new java.awt.GridBagConstraints (); 379 gridBagConstraints.gridx = 0; 380 gridBagConstraints.gridy = 1; 381 gridBagConstraints.gridwidth = 2; 382 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 383 gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST; 384 gridBagConstraints.weightx = 1.0; 385 gridBagConstraints.insets = new java.awt.Insets (6, 1, 0, 12); 386 add(progressBarEnabled, gridBagConstraints); 387 progressBarEnabled.getAccessibleContext().setAccessibleDescription(java.util.ResourceBundle.getBundle("org/netbeans/modules/apisupport/project/ui/customizer/Bundle").getString("ACS_ProgressEnabled")); 388 389 textFontSizeLabel.setLabelFor(fontSize); 390 org.openide.awt.Mnemonics.setLocalizedText(textFontSizeLabel, java.util.ResourceBundle.getBundle("org/netbeans/modules/apisupport/project/ui/customizer/Bundle").getString("LBL_TextFontSize")); 391 gridBagConstraints = new java.awt.GridBagConstraints (); 392 gridBagConstraints.gridx = 0; 393 gridBagConstraints.gridy = 3; 394 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 395 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 396 gridBagConstraints.insets = new java.awt.Insets (6, 0, 0, 12); 397 add(textFontSizeLabel, gridBagConstraints); 398 textFontSizeLabel.getAccessibleContext().setAccessibleDescription(java.util.ResourceBundle.getBundle("org/netbeans/modules/apisupport/project/ui/customizer/Bundle").getString("ACS_FontSize")); 399 400 textBoundsLabel.setLabelFor(jTextField4); 401 org.openide.awt.Mnemonics.setLocalizedText(textBoundsLabel, java.util.ResourceBundle.getBundle("org/netbeans/modules/apisupport/project/ui/customizer/Bundle").getString("LBL_TextBounds")); 402 gridBagConstraints = new java.awt.GridBagConstraints (); 403 gridBagConstraints.gridx = 4; 404 gridBagConstraints.gridy = 3; 405 gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST; 406 gridBagConstraints.insets = new java.awt.Insets (6, 0, 0, 12); 407 add(textBoundsLabel, gridBagConstraints); 408 textBoundsLabel.getAccessibleContext().setAccessibleDescription(java.util.ResourceBundle.getBundle("org/netbeans/modules/apisupport/project/ui/customizer/Bundle").getString("ACS_TextBounds")); 409 410 org.openide.awt.Mnemonics.setLocalizedText(jLabel1, java.util.ResourceBundle.getBundle("org/netbeans/modules/apisupport/project/ui/customizer/Bundle").getString("LBL_ProgressBar")); 411 gridBagConstraints = new java.awt.GridBagConstraints (); 412 gridBagConstraints.gridx = 0; 413 gridBagConstraints.gridy = 0; 414 gridBagConstraints.gridwidth = 6; 415 gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; 416 gridBagConstraints.anchor = java.awt.GridBagConstraints.SOUTHWEST; 417 gridBagConstraints.weightx = 1.0; 418 add(jLabel1, gridBagConstraints); 419 420 org.openide.awt.Mnemonics.setLocalizedText(jLabel2, java.util.ResourceBundle.getBundle("org/netbeans/modules/apisupport/project/ui/customizer/Bundle").getString("LBL_RunningText")); 421 gridBagConstraints = new java.awt.GridBagConstraints (); 422 gridBagConstraints.gridx = 0; 423 gridBagConstraints.gridy = 2; 424 gridBagConstraints.gridwidth = 6; 425 gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; 426 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 427 gridBagConstraints.weightx = 1.0; 428 gridBagConstraints.insets = new java.awt.Insets (6, 0, 0, 0); 429 add(jLabel2, gridBagConstraints); 430 431 jPanel1.setLayout(new java.awt.GridBagLayout ()); 432 433 org.openide.awt.Mnemonics.setLocalizedText(splashLabel, java.util.ResourceBundle.getBundle("org/netbeans/modules/apisupport/project/ui/customizer/Bundle").getString("LBL_Splash")); 434 gridBagConstraints = new java.awt.GridBagConstraints (); 435 gridBagConstraints.gridx = 0; 436 gridBagConstraints.gridy = 0; 437 gridBagConstraints.gridwidth = 2; 438 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 439 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 440 gridBagConstraints.weightx = 1.0; 441 gridBagConstraints.insets = new java.awt.Insets (6, 0, 0, 12); 442 jPanel1.add(splashLabel, gridBagConstraints); 443 444 jScrollPane1.setBorder(null); 445 jScrollPane1.setViewportView(splashPreview); 446 447 gridBagConstraints = new java.awt.GridBagConstraints (); 448 gridBagConstraints.gridx = 0; 449 gridBagConstraints.gridy = 1; 450 gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; 451 gridBagConstraints.ipadx = 20; 452 gridBagConstraints.weightx = 1.0; 453 gridBagConstraints.weighty = 1.0; 454 gridBagConstraints.insets = new java.awt.Insets (6, 0, 0, 12); 455 jPanel1.add(jScrollPane1, gridBagConstraints); 456 457 org.openide.awt.Mnemonics.setLocalizedText(browse, java.util.ResourceBundle.getBundle("org/netbeans/modules/apisupport/project/ui/customizer/Bundle").getString("LBL_Browse")); 458 browse.addActionListener(new java.awt.event.ActionListener () { 459 public void actionPerformed(java.awt.event.ActionEvent evt) { 460 browseActionPerformed(evt); 461 } 462 }); 463 464 gridBagConstraints = new java.awt.GridBagConstraints (); 465 gridBagConstraints.gridx = 1; 466 gridBagConstraints.gridy = 1; 467 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 468 gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHEAST; 469 gridBagConstraints.insets = new java.awt.Insets (6, 0, 0, 0); 470 jPanel1.add(browse, gridBagConstraints); 471 browse.getAccessibleContext().setAccessibleDescription(java.util.ResourceBundle.getBundle("org/netbeans/modules/apisupport/project/ui/customizer/Bundle").getString("ACS_SplashBrowse")); 472 473 gridBagConstraints = new java.awt.GridBagConstraints (); 474 gridBagConstraints.gridx = 0; 475 gridBagConstraints.gridy = 4; 476 gridBagConstraints.gridwidth = 6; 477 gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; 478 gridBagConstraints.weightx = 1.0; 479 gridBagConstraints.weighty = 1.0; 480 gridBagConstraints.insets = new java.awt.Insets (6, 0, 0, 0); 481 add(jPanel1, gridBagConstraints); 482 483 } 485 private void browseActionPerformed(java.awt.event.ActionEvent evt) { JFileChooser chooser = UIUtil.getIconFileChooser(); 487 int ret = chooser.showDialog(this, NbBundle.getMessage(getClass(), "LBL_Select")); if (ret == JFileChooser.APPROVE_OPTION) { 489 File file = chooser.getSelectedFile(); 490 try { 491 splashSource = file.toURI().toURL(); 492 Image oldImage = splashImage.image; 493 splashImage.setSplashImageIcon(splashSource); 494 Image newImage = splashImage.image; 495 int newWidth = newImage.getWidth(null); 496 int newHeight = newImage.getHeight(null); 497 int oldWidth = oldImage.getWidth(null); 498 int oldHeight = oldImage.getHeight(null); 499 if (newWidth != oldWidth || newHeight != oldHeight) { 500 double xRatio = newWidth / ((double) oldWidth); 501 double yRatio = newHeight / ((double) oldHeight); 502 Rectangle tRectangle = (Rectangle )runningTextBounds.getValue(); 503 Rectangle pRectangle = (Rectangle )progressBarBounds.getValue(); 504 505 int x = ((int)(tRectangle.x*xRatio)); 506 int y = ((int)(tRectangle.y*yRatio)); 507 int width = ((int)(tRectangle.width*xRatio)); 508 int height = ((int)(tRectangle.height*xRatio)); 509 width = (width <= 0) ? 2 : width; 510 height = (height <= 0) ? 2 : height; 511 tRectangle.setBounds(x,y,width,height); 512 513 x = ((int)(pRectangle.x*xRatio)); 514 y = ((int)(pRectangle.y*yRatio)); 515 width = ((int)(pRectangle.width*xRatio)); 516 height = ((int)(pRectangle.height*xRatio)); 517 width = (width <= 6) ? 6 : width; 518 height = (height <= 6) ? 6 : height; 519 pRectangle.setBounds(x,y,width,height); 520 521 runningTextBounds.setValue(tRectangle); 522 progressBarBounds.setValue(pRectangle); 523 int size = (int)((((Number )fontSize.getValue()).intValue()*yRatio)); 524 size = (size <= 6) ? 6 : size; 525 fontSize.setValue(new Integer (size)); 526 } else { 527 resetSplashPreview(); 528 } 529 530 } catch (MalformedURLException ex) { 531 ErrorManager.getDefault().notify(ex); 532 } 533 534 } 535 536 } 538 private void progressBarEnabledActionPerformed(java.awt.event.ActionEvent evt) { resetSplashPreview(); 540 } 542 543 private javax.swing.JLabel barBoundsLabel; 545 private javax.swing.JLabel barColorLabel; 546 private javax.swing.JButton browse; 547 private javax.swing.JLabel jLabel1; 548 private javax.swing.JLabel jLabel2; 549 private javax.swing.JPanel jPanel1; 550 private javax.swing.JScrollPane jScrollPane1; 551 private javax.swing.JCheckBox progressBarEnabled; 552 private javax.swing.JLabel splashLabel; 553 private javax.swing.JLabel splashPreview; 554 private javax.swing.JLabel textBoundsLabel; 555 private javax.swing.JLabel textColorLabel; 556 private javax.swing.JLabel textFontSizeLabel; 557 559 private BasicBrandingModel getBrandingModel() { 560 return getProperties().getBrandingModel(); 561 } 562 } 563 | Popular Tags |