public void doRFileEvaluate(final IScope scope, final IContainer param) { int size = param.length(scope); // if ( size == 0 ) { throw GamaRuntimeException.error("Missing Parameter Exception", scope); } final String RFile = getPath(); try { // Call R RCaller caller = new RCaller(); String RPath = GamaPreferences.LIB_R.value(scope).getPath(); caller.setRscriptExecutable(RPath); double[] vectorParam = new double[param.length(scope)]; int k = 0; for (Object o : param.iterable(scope)) { vectorParam[k++] = Cast.asFloat(scope, o); } RCode c = new RCode(); // Adding the parameters c.addDoubleArray("vectorParam", vectorParam); // Adding the codes in file List<String> R_statements = new ArrayList<String>(); // tmthai.begin---------------------------------------------------------------------------- String fullPath = FileUtils.constructAbsoluteFilePath(scope, RFile, true); if (DEBUG) { GuiUtils.debug("Stats.R_compute_param.RScript:" + RPath); GuiUtils.debug("Stats.R_compute_param.Param:" + vectorParam.toString()); GuiUtils.debug("Stats.R_compute_param.RFile:" + RFile); GuiUtils.debug("Stats.R_compute_param.fullPath:" + fullPath); } // FileReader fr = new FileReader(RFile); FileReader fr = new FileReader(fullPath); // tmthai.end---------------------------------------------------------------------------- BufferedReader br = new BufferedReader(fr); String statement; while ((statement = br.readLine()) != null) { c.addRCode(statement); R_statements.add(statement); // java.lang.System.out.println(statement); } br.close(); fr.close(); caller.setRCode(c); GamaMap<String, IList> result = GamaMapFactory.create(Types.STRING, Types.LIST); String var = computeVariable(R_statements.get(R_statements.size() - 1).toString()); caller.runAndReturnResult(var); // DEBUG: // java.lang.System.out.println("Name: '" + R_statements.length(scope) + "'"); if (DEBUG) { GuiUtils.debug("Stats.R_compute_param.R_statements.length: '" + R_statements.size() + "'"); } for (String name : caller.getParser().getNames()) { String[] results = null; results = caller.getParser().getAsStringArray(name); // java.lang.System.out.println("Name: '" + name + "'"); if (DEBUG) { GuiUtils.debug( "Stats.R_compute_param.caller.Name: '" + name + "' length: " + results.length + " - Value: " + results.toString()); } result.put(name, GamaListFactory.create(scope, Types.NO_TYPE, results)); } if (DEBUG) { GuiUtils.debug("Stats.R_compute_param.return:" + result.serialize(false)); } setBuffer(result); } catch (Exception ex) { throw GamaRuntimeException.error("RCallerExecutionException " + ex.getMessage(), scope); } }
/** * Transforms the given XML file using the specified XSL file. * * @param origXmlFile The file containg the XML to transform * @param xslString The XML Stylesheet conntaining the transform instructions * @return String representation of the transformation */ public static String transform(File origXmlFile, String xslString) { if (!origXmlFile.exists()) { GuiUtils.showErrorMessage( logger, "Warning, XML file: " + origXmlFile + " doesn't exist", null, null); return null; } try { TransformerFactory tFactory = TransformerFactory.newInstance(); StreamSource xslFileSource = new StreamSource(new StringReader(xslString)); Transformer transformer = tFactory.newTransformer(xslFileSource); StringWriter writer = new StringWriter(); transformer.transform(new StreamSource(origXmlFile), new StreamResult(writer)); return writer.toString(); } catch (Exception e) { GuiUtils.showErrorMessage(logger, "Error when loading the XML file: " + origXmlFile, e, null); return null; } }
public boolean onContextItemSelected(MenuItem item) { AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) item.getMenuInfo(); int menuItemIndex = item.getItemId(); Interes interes = interesesAdapter.getItem(info.position); switch (menuItemIndex) { case R.id.ItemMenuBorrar: OrmLiteSqliteOpenHelper helper = null; try { helper = OpenHelperManager.getHelper(this, DatabaseHelper.class); Dao<Interes, Integer> interesesDao = helper.getDao(Interes.class); interesesDao.delete(interes); interesesAdapter.remove(interes); } catch (Exception e) { Log.e(TAG, "Error al listar los intereses", e); GuiUtils.mostrarToast(this, R.string.operacion_error, null); } finally { try { OpenHelperManager.releaseHelper(); } catch (Exception e2) { } } return true; case R.id.ItemMenuEditar: mostrarDatosInteres(interes); return true; default: return super.onContextItemSelected(item); } }
public SQLHistorySearchCtrl( SQLTextAreaServices sqlTextAreaServices, Session session, ObservableList<SQLHistoryEntry> items) { _sqlTextAreaServices = sqlTextAreaServices; FxmlHelper<SQLHistorySearchView> fxmlHelper = new FxmlHelper<>(SQLHistorySearchView.class); _view = fxmlHelper.getView(); _dialog = new Stage(); _dialog.setTitle( new I18n(getClass()) .t("SQLHistorySearchCtrl.title", session.getMainTabContext().getSessionTabTitle())); _dialog.initModality(Modality.WINDOW_MODAL); _dialog.initOwner(AppState.get().getPrimaryStage()); Region region = fxmlHelper.getRegion(); _dialog.setScene(new Scene(region)); GuiUtils.makeEscapeClosable(region); new StageDimensionSaver( "sqlhistorysearch", _dialog, new Pref(getClass()), region.getPrefWidth(), region.getPrefHeight(), _dialog.getOwner()); _view.cboFilterType.setItems( FXCollections.observableList(Arrays.asList(SqlHistoryFilterType.values()))); _view.cboFilterType.getSelectionModel().selectFirst(); _view.btnApply.setOnAction(e -> onApply()); _view.chkFiltered.setOnAction(e -> onChkFiltered()); _view.split.getItems().add(_tblHistory); _view.split.getItems().add(_txtSqlPreview); _originalTableLoader = new RowObjectTableLoader<>(); _originalTableLoader.initColsByAnnotations(SQLHistoryEntry.class); _originalTableLoader.addRowObjects(items); _currentLoader = _originalTableLoader.cloneLoader(); _currentLoader.load(_tblHistory); _tblHistory .getSelectionModel() .selectedItemProperty() .addListener((observable, oldValue, newValue) -> onTableSelectionChanged()); _tblHistory.setOnMouseClicked(e -> onTblHistoryClicked(e)); _txtSqlPreview.setEditable(false); _dialog.setOnCloseRequest(e -> close()); _view.txtFilter.requestFocus(); _splitPositionSaver.apply(_view.split); _dialog.showAndWait(); }
/** * Checks whether network connection is available. Otherwise shows warning message * * @param silent whether or not to do not show message in case check failure * @return */ public static boolean checkOnline(boolean silent) { boolean result = Utils.isOnline(TroveboxApplication.getContext()) || TEST_CASE; if (!result && !silent) { GuiUtils.alert(R.string.noInternetAccess); } return result; }
public void toggleBreakpoint() { if (isEnabled()) { try { int position = lastClickPoint != null ? viewToModel(lastClickPoint) : getCaretPosition(); lastClickPoint = null; if (position >= 0) { String textToCaret = getDocument().getText(0, position); int lineCount = 0; for (int i = 0; i < textToCaret.length(); i++) { if (textToCaret.charAt(i) == '\n') { lineCount++; } } if (breakpoints.isThereBreakpoint(lineCount)) { breakpoints.removeBreakpoint(lineCount); } else { breakpoints.addBreakpoint(new BreakpointInfo(lineCount)); } } } catch (BadLocationException e) { e.printStackTrace(); } Component parent = GuiUtils.getParentOfType(this, XmlEditorScrollPane.class); if (parent != null) { ((XmlEditorScrollPane) parent).onDocChanged(); } repaint(); } }
public void setSelectedWithoutFire(boolean val) { GuiUtils.throwIfNotOnEDT(); for (Component comp : components) { // seulement les elements concernés par la modif if (comp instanceof AbstractButton == false) continue; AbstractButton btn = (AbstractButton) comp; if (btn != null && btn.isSelected() != val) { GuiUtils.setSelected(btn, val); } } }
/** * Transforms the given XML string using the XSL string. * * @param xmlString The String containg the XML to transform * @param xslString The XML Stylesheet String containing the transform instructions * @return String representation of the transformation */ public static String transform(String xmlString, String xslString) { String shortString = new String(xmlString); if (shortString.length() > 100) shortString = shortString.substring(0, 100) + "..."; try { TransformerFactory tFactory = TransformerFactory.newInstance(); logger.logComment("Transforming string: " + shortString); StreamSource xslFileSource = new StreamSource(new StringReader(xslString)); Transformer transformer = tFactory.newTransformer(xslFileSource); StringWriter writer = new StringWriter(); transformer.transform( new StreamSource(new StringReader(xmlString)), new StreamResult(writer)); String shortResult = writer.toString(); if (shortResult.length() > 100) shortResult = shortResult.substring(0, 100) + "..."; logger.logComment("Result: " + shortResult); return writer.toString(); } catch (TransformerException e) { GuiUtils.showErrorMessage(logger, "Error when transforming the XML: " + shortString, e, null); return null; } }
/** * Checks whether user is logged in * * @param silent * @return */ public static boolean checkLoggedIn(boolean silent) { boolean result = Preferences.isLoggedIn(); if (!result && !silent) { GuiUtils.alert(R.string.errorNotLoggedIn); } return result; }
/** * Format string with params * * @param message * @param params * @return */ public static String format(String message, Object... params) { try { return String.format(Locale.ENGLISH, message, params); } catch (Exception ex) { GuiUtils.noAlertError(TAG, ex); } return null; }
public void setEnabled(boolean val) { GuiUtils.throwIfNotOnEDT(); for (Component comp : components) { if (comp != null && comp.isEnabled() != val) { comp.setEnabled(val); } } }
/** * Write message to the verbose log * * @param TAG * @param message * @param params */ public static void verbose(String TAG, String message, Object... params) { try { if (BuildConfig.DEBUG) { if (params == null || params.length == 0) { Log.v(TAG, message); } else { Log.v(TAG, format(message, params)); } } } catch (Exception ex) { GuiUtils.noAlertError(TAG, ex); } }
/** _more_ */ public void checkPattern() { String pattern = getPatternWidget().getText().trim(); File dir = new File(getFilePathWidget().getText().trim()); File[] list = dir.listFiles( (java.io.FileFilter) new PatternFileFilter(pattern, false, getHiddenWidget().isSelected())); StringBuffer sb = new StringBuffer("<html>"); if ((list == null) || (list.length == 0)) { sb.append("<h3><center><font color=\"red\">No files match the pattern</font></center></h3>"); sb.append("Pattern: " + pattern + "<br>"); list = dir.listFiles(); if (list != null) { for (int i = 0; i < list.length; i++) { if (i == 0) { sb.append("<hr>Example Files:<br>"); } if (i > 20) { sb.append(" ...<br>\n"); break; } sb.append(" " + list[i] + "<br>\n"); } } } else { for (int i = 0; i < list.length; i++) { if (i == 0) { sb.append("<h3><center>Files that match</center></h3>\n"); } if (i > 20) { sb.append(" ...<br>\n"); break; } sb.append(" " + list[i] + "<br>\n"); } } sb.append("</html>"); GuiUtils.showDialog("Sample files", GuiUtils.inset(new JLabel(sb.toString()), 5)); }
/** * Transforms the given XML string using the specified XSL file. * * @param xmlString The String containg the XML to transform * @param xslFile The XML Stylesheet conntaining the transform instructions * @return String representation of the transformation */ public static String transform(String xmlString, File xslFile) { if (!xslFile.exists()) { GuiUtils.showErrorMessage( logger, "Warning, XSL file: " + xslFile + " doesn't exist", null, null); return null; } String shortString = new String(xmlString); if (shortString.length() > 100) shortString = shortString.substring(0, 100) + "..."; try { logger.logComment("The xslFile is " + xslFile.getAbsolutePath() + " *************"); TransformerFactory tFactory = TransformerFactory.newInstance(); logger.logComment("Transforming string: " + shortString); StreamSource xslFileSource = new StreamSource(xslFile); Transformer transformer = tFactory.newTransformer(xslFileSource); StringWriter writer = new StringWriter(); transformer.transform( new StreamSource(new StringReader(xmlString)), new StreamResult(writer)); String shortResult = writer.toString(); if (shortResult.length() > 100) shortResult = shortResult.substring(0, 100) + "..."; logger.logComment("Result: " + shortResult); return writer.toString(); } catch (TransformerException e) { GuiUtils.showErrorMessage(logger, "Error when transforming the XML: " + shortString, e, null); return null; } }
/** Gets current text values and reassigns them to the GUI components. */ private void reassignTexts() { setTitle(Language.getText("welcome.welcome") + " - " + Consts.APPLICATION_NAME); welcomeLabel.setText(Language.getText("welcome.welcome") + '!'); firstRunLabel.setText(Language.getText("welcome.firstRun", Consts.APPLICATION_NAME + "â„¢")); chooseLabel.setText(Language.getText("welcome.selectLanguage")); thankYouLabel.setText(Language.getText("welcome.thankYou", Consts.APPLICATION_NAME + "â„¢")); languageLabel.setText(Language.getText("welcome.language")); voiceLabel.setText(Language.getText("welcome.voice")); languageLabel.setPreferredSize(null); voiceLabel.setPreferredSize(null); final int maxWidth = Math.max(languageLabel.getPreferredSize().width, voiceLabel.getPreferredSize().width); languageLabel.setPreferredSize( new Dimension(maxWidth, languageLabel.getPreferredSize().height)); voiceLabel.setPreferredSize(new Dimension(maxWidth, voiceLabel.getPreferredSize().height)); GuiUtils.updateButtonText(okButton, "button.ok"); GuiUtils.updateButtonText(cancelButton, "button.cancel"); pack(); SharedUtils.centerWindow(this); }
// Gets the specified XML Schema doc if one is mentioned in the file public static File getSchemaFile(File xmlDoc) { /** @todo Must be an easier way of doing this... */ logger.logComment("Getting schema file for: " + xmlDoc); try { // File xslFile = null; DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); DocumentBuilder db = dbf.newDocumentBuilder(); Document doc = db.parse(xmlDoc); return getSchemaFile(doc); } catch (Exception e) { GuiUtils.showErrorMessage(logger, "Error when looking at the XML file: " + xmlDoc, e, null); return null; } }
private void cargarListadoIntereses() { OrmLiteSqliteOpenHelper helper = null; try { helper = OpenHelperManager.getHelper(this, DatabaseHelper.class); Dao<Interes, Integer> interesDao = helper.getDao(Interes.class); List<Interes> intereses = interesDao.queryForAll(); interesesAdapter = new ArrayAdapter<Interes>(this, android.R.layout.simple_list_item_1, intereses); listViewIntereses.setAdapter(interesesAdapter); } catch (Exception e) { Log.e(TAG, "Error al cargar los clientes", e); GuiUtils.mostrarToast(this, R.string.operacion_error, null); } finally { try { OpenHelperManager.releaseHelper(); } catch (Exception e2) { Log.e(TAG, "Error en el release", e2); } } }
/** * Updates progress bar progress line every time a progress event has been received. * * @param event the <tt>FileTransferProgressEvent</tt> that notified us */ public void progressChanged(FileTransferProgressEvent event) { progressBar.setValue((int) event.getProgress()); long transferredBytes = event.getFileTransfer().getTransferedBytes(); long progressTimestamp = event.getTimestamp(); ByteFormat format = new ByteFormat(); String bytesString = format.format(transferredBytes); if ((progressTimestamp - lastSpeedTimestamp) >= SPEED_CALCULATE_DELAY) { lastProgressSpeed = Math.round(calculateProgressSpeed(transferredBytes)); this.lastSpeedTimestamp = progressTimestamp; this.lastTransferredBytes = transferredBytes; } if ((progressTimestamp - lastEstimatedTimeTimestamp) >= SPEED_CALCULATE_DELAY && lastProgressSpeed > 0) { lastEstimatedTime = Math.round( calculateEstimatedTransferTime( lastProgressSpeed, transferredFileSize - transferredBytes)); lastEstimatedTimeTimestamp = progressTimestamp; } progressBar.setString(getProgressLabel(bytesString)); if (lastProgressSpeed > 0) { progressSpeedLabel.setText( resources.getI18NString("service.gui.SPEED") + format.format(lastProgressSpeed) + "/sec"); progressSpeedLabel.setVisible(true); } if (lastEstimatedTime > 0) { estimatedTimeLabel.setText( resources.getI18NString("service.gui.ESTIMATED_TIME") + GuiUtils.formatSeconds(lastEstimatedTime * 1000)); estimatedTimeLabel.setVisible(true); } }
void jButtonOK_actionPerformed(ActionEvent e) { logger.logComment("OK button pressed"); cancelled = false; double threshold; try { threshold = Double.parseDouble(jTextFieldThreshold.getText()); } catch (NumberFormatException ex) { GuiUtils.showErrorMessage( logger, "Please enter a number (usually -50 -> 0) for the millivolt value of the firing threshold", ex, this); return; } mySynProps.setThreshold(threshold); String selectedSynapse = (String) jComboBoxSynapseType.getSelectedItem(); mySynProps.setSynapseType(selectedSynapse); this.dispose(); }
/** Creates a new WelcomeFrame and makes it visible. */ public WelcomeFrame() { setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); addWindowListener( new WindowAdapter() { public void windowClosing(final WindowEvent event) { cancel(); }; }); setIconImage(Icons.SC2GEARS.getImage()); final Box box = Box.createVerticalBox(); box.add(Box.createVerticalStrut(5)); box.add(GuiUtils.wrapInPanel(SharedUtils.createAnimatedLogoLabel())); box.add(Box.createVerticalStrut(10)); GuiUtils.changeFontToBold(welcomeLabel); box.add(Box.createVerticalStrut(15)); box.add(GuiUtils.wrapInPanel(welcomeLabel)); box.add(Box.createVerticalStrut(15)); box.add(GuiUtils.wrapInPanel(firstRunLabel)); box.add(GuiUtils.wrapInPanel(chooseLabel)); box.add(Box.createVerticalStrut(15)); box.add(GuiUtils.wrapInPanel(thankYouLabel)); box.add(Box.createVerticalStrut(15)); final JPanel languagePanel = new JPanel(new FlowLayout(FlowLayout.CENTER, 0, 1)); languagePanel.add(languageLabel); final JComboBox<String> languagesComboBox = new JComboBox<>(Language.getAvailableLanguages()); languagesComboBox.setMaximumRowCount( languagesComboBox.getModel().getSize()); // Display all languages languagesComboBox.setRenderer( new BaseLabelListCellRenderer<String>() { @Override public Icon getIcon(final String value) { return Icons.getLanguageIcon(value); } }); languagesComboBox.addActionListener( new ActionListener() { @Override public void actionPerformed(final ActionEvent event) { final String language = (String) languagesComboBox.getSelectedItem(); Language.loadAndActivateLanguage(language); reassignTexts(); } }); languagePanel.add(languagesComboBox); box.add(languagePanel); final JPanel voicePanel = new JPanel(new FlowLayout(FlowLayout.CENTER, 0, 1)); voicePanel.add(voiceLabel); final JComboBox<VoiceDescription> voiceComboBox = new JComboBox<>(Sounds.VOICE_DESCRIPTIONS); voiceComboBox.setMaximumRowCount(15); // Not too many languages, display them all voiceComboBox.setRenderer( new BaseLabelListCellRenderer<VoiceDescription>() { @Override public Icon getIcon(final VoiceDescription value) { return Icons.getLanguageIcon(value.language); } }); voiceComboBox.addActionListener( new ActionListener() { @Override public void actionPerformed(final ActionEvent event) { final VoiceDescription voiceDescription = (VoiceDescription) voiceComboBox.getSelectedItem(); Settings.set(Settings.KEY_SETTINGS_VOICE, voiceDescription.name); Sounds.playSoundSample(Sounds.SAMPLE_WELCOME, false); } }); voicePanel.add(voiceComboBox); box.add(voicePanel); int maxWidth = Math.max( languagesComboBox.getPreferredSize().width, voiceComboBox.getPreferredSize().width); maxWidth += 5; languagesComboBox.setPreferredSize( new Dimension(maxWidth, languagesComboBox.getPreferredSize().height)); voiceComboBox.setPreferredSize( new Dimension(maxWidth, voiceComboBox.getPreferredSize().height)); box.add(Box.createVerticalStrut(15)); final JPanel buttonsPanel = new JPanel(); okButton.addActionListener( new ActionListener() { @Override public void actionPerformed(final ActionEvent event) { dispose(); Settings.set( Settings.KEY_SETTINGS_LANGUAGE, (String) languagesComboBox.getSelectedItem()); Settings.saveProperties(); synchronized (WelcomeFrame.this) { Sounds.playSoundSample(Sounds.SAMPLE_THANK_YOU, false); WelcomeFrame.this .notify(); // Notify the main thread to continue starting the application } } }); buttonsPanel.add(okButton); cancelButton.addActionListener( new ActionListener() { @Override public void actionPerformed(final ActionEvent event) { cancel(); } }); buttonsPanel.add(cancelButton); box.add(buttonsPanel); box.add(Box.createVerticalStrut(15)); final JPanel panel = new JPanel(); panel.add(Box.createHorizontalStrut(15)); panel.add(box); panel.add(Box.createHorizontalStrut(15)); getContentPane().add(panel); setResizable(false); reassignTexts(); setVisible(true); okButton.requestFocusInWindow(); Sounds.playSoundSample(Sounds.SAMPLE_WELCOME, false); }
/** * _more_ * * @param comps _more_ * @param includeName _more_ * @param includeFileCount _more_ */ public void getPropertyComponents(List comps, boolean includeName, boolean includeFileCount) { JButton directoryBtn = new JButton("Select"); boolean isFile = false; if (getFile() != null) { File f = new File(getFile()); isFile = f.isFile(); } GuiUtils.setupFileChooser(directoryBtn, getFilePathWidget(), !isFile); if (isFile) { comps.add(GuiUtils.rLabel("File: ")); } else { comps.add(GuiUtils.rLabel("Directory: ")); } comps.add( GuiUtils.left( GuiUtils.centerRight( GuiUtils.wrap(getFilePathWidget()), GuiUtils.inset(directoryBtn, new Insets(0, 5, 0, 0))))); if (includeName) { comps.add(GuiUtils.rLabel("Name: ")); comps.add(GuiUtils.left(getNameWidget())); } comps.add(GuiUtils.rLabel("File Pattern:")); comps.add( GuiUtils.left( GuiUtils.hbox( GuiUtils.wrap(GuiUtils.hbox(getPatternWidget(), getHiddenWidget())), GuiUtils.makeButton("Verify", this, "checkPattern")))); if (includeFileCount) { ActionListener actionListener = new ActionListener() { public void actionPerformed(ActionEvent ae) { checkModeEnabled(); } }; comps.add(GuiUtils.rLabel("Files:")); fileCountButton = new JRadioButton("", mode == MODE_COUNT); dateRangeButton = new JRadioButton("All files in last:", mode == MODE_ABSDATERANGE); fileCountButton.addActionListener(actionListener); dateRangeButton.addActionListener(actionListener); ButtonGroup bg = GuiUtils.buttonGroup(fileCountButton, dateRangeButton); List modeComps = new ArrayList(); modeComps.add(fileCountButton); modeComps.add(getFileCountWidget()); modeComps.add(new JLabel(" ")); modeComps.add(dateRangeButton); modeComps.add(getDateRangeWidget()); modeComps.add(new JLabel(" minutes")); checkModeEnabled(); comps.add(GuiUtils.left(GuiUtils.hbox(modeComps))); } comps.add(GuiUtils.rLabel("Polling:")); comps.add( GuiUtils.left( GuiUtils.hbox( getActiveWidget(), GuiUtils.lLabel(" Check every: "), GuiUtils.wrap(getIntervalWidget()), GuiUtils.lLabel(" minutes")))); }
public static boolean transform( File origXmlFileOrDir, File xslFile, File targetDir, String extension) { logger.logComment( "Going to transform " + origXmlFileOrDir + " into dir " + targetDir + " using: " + xslFile, true); if (!origXmlFileOrDir.exists()) { GuiUtils.showErrorMessage( logger, "Warning, XML file/directory: " + origXmlFileOrDir + " doesn't exist", null, null); return false; } if (!xslFile.exists()) { GuiUtils.showErrorMessage( logger, "Warning, XSL file: " + xslFile + " doesn't exist", null, null); return false; } if (!targetDir.exists()) { GuiUtils.showErrorMessage( logger, "Warning, target directory: " + targetDir + " doesn't exist", null, null); return false; } if (origXmlFileOrDir.isDirectory()) { logger.logComment("That file is a directory. Converting all of the XML files in it"); File[] files = origXmlFileOrDir.listFiles(); boolean totalSuccess = true; for (int i = 0; i < files.length; i++) { if (!files[i].isDirectory() && (files[i].getName().endsWith(".xml") || files[i].getName().endsWith(".XML"))) { boolean partialSuccess = transform(files[i], xslFile, targetDir, extension); totalSuccess = totalSuccess || partialSuccess; } else if (files[i].isDirectory() && !GeneralUtils.isVersionControlDir(files[i])) { File newFolder = new File(targetDir, files[i].getName()); newFolder.mkdir(); logger.logComment( "Found a sub folder. Going to convert all there into: " + newFolder + "..."); transform(files[i], xslFile, newFolder, extension); } } return totalSuccess; } String result = transform(origXmlFileOrDir, xslFile); String newName = origXmlFileOrDir.getName(); if (newName.endsWith(".xml") || newName.endsWith(".XML")) { newName = newName.substring(0, newName.length() - 4) + extension; } File targetFile = new File(targetDir, newName); try { FileWriter fw = new FileWriter(targetFile); fw.write(result); fw.close(); } catch (IOException ex) { GuiUtils.showErrorMessage(logger, "Exception writing to file: " + targetFile, ex, null); return false; } logger.logComment("The result is in " + targetFile + " *************"); return result != null; }
public LibraryBundlingEditorComponent(@NotNull Project project) { myProject = project; GuiUtils.replaceJSplitPaneWithIDEASplitter(myMainPanel); ((JBSplitter) myMainPanel.getComponent(0)).setProportion(0.4f); myRulesPanel.add( ToolbarDecorator.createDecorator(myRulesList) .setAddAction( new AnActionButtonRunnable() { @Override public void run(AnActionButton button) { updateCurrentRule(); myRulesModel.add(new LibraryBundlificationRule()); myRulesList.setSelectedIndex(myRulesModel.getSize() - 1); updateFields(); } }) .setRemoveAction( new AnActionButtonRunnable() { @Override public void run(AnActionButton button) { myLastSelected = -1; if (myRulesModel.getSize() == 1) { myRulesModel.setElementAt(new LibraryBundlificationRule(), 0); myRulesList.setSelectedIndex(0); } else { int index = myRulesList.getSelectedIndex(); myRulesModel.remove(index); myRulesList.setSelectedIndex(index > 0 ? index - 1 : 0); } updateFields(); } }) .setMoveUpAction( new AnActionButtonRunnable() { @Override public void run(AnActionButton button) { updateCurrentRule(); myLastSelected = -1; ListUtil.moveSelectedItemsUp(myRulesList); updateFields(); } }) .setMoveDownAction( new AnActionButtonRunnable() { @Override public void run(AnActionButton button) { updateCurrentRule(); myLastSelected = -1; ListUtil.moveSelectedItemsDown(myRulesList); updateFields(); } }) .addExtraAction( new AnActionButton("Copy", PlatformIcons.COPY_ICON) { @Override public void actionPerformed(AnActionEvent e) { updateCurrentRule(); int index = myRulesList.getSelectedIndex(); if (index >= 0) { myRulesModel.add(myRulesModel.getElementAt(index).copy()); myRulesList.setSelectedIndex(myRulesModel.getSize() - 1); updateFields(); } } @Override public boolean isEnabled() { return myRulesList.getSelectedIndex() >= 0; } }) .createPanel(), BorderLayout.CENTER); myRulesModel = new CollectionListModel<>(); //noinspection unchecked myRulesList.setModel(myRulesModel); myRulesList.addListSelectionListener( new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent e) { updateCurrentRule(); updateFields(); } }); }
/** Initialise the GUI elements to display the given item. */ private void initGui() { this.setResizable(true); this.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE); JPanel unmodifiableAttributesPanel = skinsFactory.createSkinnedJPanel("ObjectStaticAttributesPanel"); unmodifiableAttributesPanel.setLayout(new GridBagLayout()); JPanel metadataContainer = skinsFactory.createSkinnedJPanel("ObjectPropertiesMetadataPanel"); metadataContainer.setLayout(new GridBagLayout()); metadataButtonsContainer = skinsFactory.createSkinnedJPanel("ObjectPropertiesMetadataButtonsPanel"); metadataButtonsContainer.setLayout(new GridBagLayout()); // Fields to display unmodifiable object details. JLabel objectKeyLabel = skinsFactory.createSkinnedJHtmlLabel("ObjectKeyLabel"); objectKeyLabel.setText("Object key:"); objectKeyTextField = skinsFactory.createSkinnedJTextField("ObjectKeyTextField"); objectKeyTextField.setEditable(false); JLabel objectContentLengthLabel = skinsFactory.createSkinnedJHtmlLabel("ObjectContentLengthLabel"); objectContentLengthLabel.setText("Size:"); objectContentLengthTextField = skinsFactory.createSkinnedJTextField("ObjectContentLengthTextField"); objectContentLengthTextField.setEditable(false); JLabel objectLastModifiedLabel = skinsFactory.createSkinnedJHtmlLabel("ObjectLastModifiedLabel"); objectLastModifiedLabel.setText("Last modified:"); objectLastModifiedTextField = skinsFactory.createSkinnedJTextField("ObjectLastModifiedTextField"); objectLastModifiedTextField.setEditable(false); JLabel objectETagLabel = skinsFactory.createSkinnedJHtmlLabel("ObjectETagLabel"); objectETagLabel.setText("ETag:"); objectETagTextField = skinsFactory.createSkinnedJTextField("ObjectETagTextField"); objectETagTextField.setEditable(false); JLabel bucketNameLabel = skinsFactory.createSkinnedJHtmlLabel("BucketNameLabel"); bucketNameLabel.setText("Bucket:"); bucketLocationTextField = skinsFactory.createSkinnedJTextField("BucketLocationTextField"); bucketLocationTextField.setEditable(false); ownerNameLabel = skinsFactory.createSkinnedJHtmlLabel("OwnerNameLabel"); ownerNameLabel.setText("Owner name:"); ownerNameTextField = skinsFactory.createSkinnedJTextField("OwnerNameTextField"); ownerNameTextField.setEditable(false); ownerIdLabel = skinsFactory.createSkinnedJHtmlLabel("OwnerIdLabel"); ownerIdLabel.setText("Owner ID:"); ownerIdTextField = skinsFactory.createSkinnedJTextField("OwnerIdTextField"); ownerIdTextField.setEditable(false); int row = 0; unmodifiableAttributesPanel.add( objectKeyLabel, new GridBagConstraints( 0, row, 1, 1, 0, 0, GridBagConstraints.EAST, GridBagConstraints.NONE, insetsDefault, 0, 0)); unmodifiableAttributesPanel.add( objectKeyTextField, new GridBagConstraints( 1, row, 1, 1, 1, 0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, insetsDefault, 0, 0)); row++; unmodifiableAttributesPanel.add( objectContentLengthLabel, new GridBagConstraints( 0, row, 1, 1, 0, 0, GridBagConstraints.EAST, GridBagConstraints.NONE, insetsDefault, 0, 0)); unmodifiableAttributesPanel.add( objectContentLengthTextField, new GridBagConstraints( 1, row, 1, 1, 1, 0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, insetsDefault, 0, 0)); row++; unmodifiableAttributesPanel.add( objectLastModifiedLabel, new GridBagConstraints( 0, row, 1, 1, 0, 0, GridBagConstraints.EAST, GridBagConstraints.NONE, insetsDefault, 0, 0)); unmodifiableAttributesPanel.add( objectLastModifiedTextField, new GridBagConstraints( 1, row, 1, 1, 1, 0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, insetsDefault, 0, 0)); row++; unmodifiableAttributesPanel.add( objectETagLabel, new GridBagConstraints( 0, row, 1, 1, 0, 0, GridBagConstraints.EAST, GridBagConstraints.NONE, insetsDefault, 0, 0)); unmodifiableAttributesPanel.add( objectETagTextField, new GridBagConstraints( 1, row, 1, 1, 1, 0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, insetsDefault, 0, 0)); row++; unmodifiableAttributesPanel.add( ownerNameLabel, new GridBagConstraints( 0, row, 1, 1, 0, 0, GridBagConstraints.EAST, GridBagConstraints.NONE, insetsDefault, 0, 0)); unmodifiableAttributesPanel.add( ownerNameTextField, new GridBagConstraints( 1, row, 1, 1, 1, 0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, insetsDefault, 0, 0)); row++; unmodifiableAttributesPanel.add( ownerIdLabel, new GridBagConstraints( 0, row, 1, 1, 0, 0, GridBagConstraints.EAST, GridBagConstraints.NONE, insetsDefault, 0, 0)); unmodifiableAttributesPanel.add( ownerIdTextField, new GridBagConstraints( 1, row, 1, 1, 1, 0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, insetsDefault, 0, 0)); row++; unmodifiableAttributesPanel.add( bucketNameLabel, new GridBagConstraints( 0, row, 1, 1, 0, 0, GridBagConstraints.EAST, GridBagConstraints.NONE, insetsDefault, 0, 0)); unmodifiableAttributesPanel.add( bucketLocationTextField, new GridBagConstraints( 1, row, 1, 1, 1, 0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, insetsDefault, 0, 0)); // Build metadata table. objectMetadataTableModel = new DefaultTableModel(new Object[] {"Name", "Value"}, 0) { private static final long serialVersionUID = -3762866886166776851L; public boolean isCellEditable(int row, int column) { return isModifyMode(); } }; metadataTableSorter = new TableSorter(objectMetadataTableModel); metadataTable = skinsFactory.createSkinnedJTable("MetadataTable"); metadataTable.setModel(metadataTableSorter); metadataTable .getSelectionModel() .addListSelectionListener( new ListSelectionListener() { public void valueChanged(ListSelectionEvent e) { if (!e.getValueIsAdjusting() && removeMetadataItemButton != null) { int row = metadataTable.getSelectedRow(); removeMetadataItemButton.setEnabled(row >= 0); } } }); metadataTableSorter.setTableHeader(metadataTable.getTableHeader()); metadataTableSorter.setSortingStatus(0, TableSorter.ASCENDING); metadataContainer.add( new JScrollPane(metadataTable), new GridBagConstraints( 0, 0, 1, 1, 1, 1, GridBagConstraints.CENTER, GridBagConstraints.BOTH, insetsHorizontalSpace, 0, 0)); // Add/remove buttons for metadata table. removeMetadataItemButton = skinsFactory.createSkinnedJButton("ObjectPropertiesAddMetadataButton"); removeMetadataItemButton.setEnabled(false); removeMetadataItemButton.setToolTipText("Remove the selected metadata item(s)"); guiUtils.applyIcon(removeMetadataItemButton, "/images/nuvola/16x16/actions/viewmag-.png"); removeMetadataItemButton.addActionListener(this); removeMetadataItemButton.setActionCommand("removeMetadataItem"); addMetadataItemButton = skinsFactory.createSkinnedJButton("ObjectPropertiesAddMetadataButton"); addMetadataItemButton.setToolTipText("Add a new metadata item"); guiUtils.applyIcon(addMetadataItemButton, "/images/nuvola/16x16/actions/viewmag+.png"); addMetadataItemButton.setActionCommand("addMetadataItem"); addMetadataItemButton.addActionListener(this); metadataButtonsContainer.add( removeMetadataItemButton, new GridBagConstraints( 0, 0, 1, 1, 0, 0, GridBagConstraints.CENTER, GridBagConstraints.NONE, insetsZero, 0, 0)); metadataButtonsContainer.add( addMetadataItemButton, new GridBagConstraints( 1, 0, 1, 1, 0, 0, GridBagConstraints.CENTER, GridBagConstraints.NONE, insetsZero, 0, 0)); metadataContainer.add( metadataButtonsContainer, new GridBagConstraints( 0, 1, 1, 1, 1, 0, GridBagConstraints.EAST, GridBagConstraints.NONE, insetsHorizontalSpace, 0, 0)); metadataButtonsContainer.setVisible(false); // OK Button. okButton = skinsFactory.createSkinnedJButton("ObjectPropertiesOKButton"); okButton.setText("OK"); okButton.setActionCommand("OK"); okButton.addActionListener(this); // Cancel Button. cancelButton = null; cancelButton = skinsFactory.createSkinnedJButton("ObjectPropertiesCancelButton"); cancelButton.setText("Cancel"); cancelButton.setActionCommand("Cancel"); cancelButton.addActionListener(this); cancelButton.setVisible(false); // Recognize and handle ENTER, ESCAPE, PAGE_UP, and PAGE_DOWN key presses. this.getRootPane().setDefaultButton(okButton); this.getRootPane() .getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW) .put(KeyStroke.getKeyStroke("ESCAPE"), "ESCAPE"); this.getRootPane() .getActionMap() .put( "ESCAPE", new AbstractAction() { private static final long serialVersionUID = -7768790936535999307L; public void actionPerformed(ActionEvent actionEvent) { setVisible(false); } }); this.getRootPane() .getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW) .put(KeyStroke.getKeyStroke("PAGE_UP"), "PAGE_UP"); this.getRootPane() .getActionMap() .put( "PAGE_UP", new AbstractAction() { private static final long serialVersionUID = -6324229423705756219L; public void actionPerformed(ActionEvent actionEvent) { previousObjectButton.doClick(); } }); this.getRootPane() .getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW) .put(KeyStroke.getKeyStroke("PAGE_DOWN"), "PAGE_DOWN"); this.getRootPane() .getActionMap() .put( "PAGE_DOWN", new AbstractAction() { private static final long serialVersionUID = -5808972377672449421L; public void actionPerformed(ActionEvent actionEvent) { nextObjectButton.doClick(); } }); // Put it all together. row = 0; JPanel container = skinsFactory.createSkinnedJPanel("ObjectPropertiesPanel"); container.setLayout(new GridBagLayout()); container.add( unmodifiableAttributesPanel, new GridBagConstraints( 0, row++, 1, 1, 1, 0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, insetsZero, 0, 0)); // Object previous and next buttons, if we have multiple objects. previousObjectButton = skinsFactory.createSkinnedJButton("ObjectPropertiesPreviousButton"); guiUtils.applyIcon(previousObjectButton, "/images/nuvola/16x16/actions/1leftarrow.png"); previousObjectButton.addActionListener(this); previousObjectButton.setEnabled(false); nextObjectButton = skinsFactory.createSkinnedJButton("ObjectPropertiesNextButton"); guiUtils.applyIcon(nextObjectButton, "/images/nuvola/16x16/actions/1rightarrow.png"); nextObjectButton.addActionListener(this); nextObjectButton.setEnabled(false); currentObjectLabel = skinsFactory.createSkinnedJHtmlLabel("ObjectPropertiesCurrentObjectLabel"); currentObjectLabel.setHorizontalAlignment(JLabel.CENTER); nextPreviousPanel = skinsFactory.createSkinnedJPanel("ObjectPropertiesNextPreviousPanel"); nextPreviousPanel.setLayout(new GridBagLayout()); nextPreviousPanel.add( previousObjectButton, new GridBagConstraints( 0, 0, 1, 1, 1, 0, GridBagConstraints.EAST, GridBagConstraints.NONE, insetsZero, 0, 0)); nextPreviousPanel.add( currentObjectLabel, new GridBagConstraints( 1, 0, 1, 1, 0, 0, GridBagConstraints.CENTER, GridBagConstraints.NONE, insetsHorizontalSpace, 0, 0)); nextPreviousPanel.add( nextObjectButton, new GridBagConstraints( 2, 0, 1, 1, 1, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, insetsZero, 0, 0)); container.add( nextPreviousPanel, new GridBagConstraints( 0, row, 1, 1, 1, 0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, insetsZero, 0, 0)); nextPreviousPanel.setVisible(false); row++; JHtmlLabel metadataLabel = skinsFactory.createSkinnedJHtmlLabel("MetadataLabel"); metadataLabel.setText("<html><b>Metadata Attributes</b></html>"); metadataLabel.setHorizontalAlignment(JLabel.CENTER); container.add( metadataLabel, new GridBagConstraints( 0, row++, 1, 1, 1, 0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, insetsVerticalSpace, 0, 0)); container.add( metadataContainer, new GridBagConstraints( 0, row++, 1, 1, 1, 1, GridBagConstraints.CENTER, GridBagConstraints.BOTH, insetsZero, 0, 0)); // Destination Access Control List setting. destinationPanel = skinsFactory.createSkinnedJPanel("DestinationPanel"); destinationPanel.setLayout(new GridBagLayout()); JPanel actionButtonsPanel = skinsFactory.createSkinnedJPanel("ObjectPropertiesActionButtonsPanel"); actionButtonsPanel.setLayout(new GridBagLayout()); actionButtonsPanel.add( cancelButton, new GridBagConstraints( 0, 0, 1, 1, 1, 0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, insetsZero, 0, 0)); actionButtonsPanel.add( okButton, new GridBagConstraints( 1, 0, 1, 1, 1, 0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, insetsZero, 0, 0)); cancelButton.setVisible(false); container.add( actionButtonsPanel, new GridBagConstraints( 0, row++, 3, 1, 0, 0, GridBagConstraints.CENTER, GridBagConstraints.NONE, insetsDefault, 0, 0)); this.getContentPane().add(container); this.pack(); this.setSize(new Dimension(450, 500)); this.setLocationRelativeTo(this.getOwner()); }
protected void reInitWholePanelIfNeeded() { if (!myToReInitWholePanel) return; myWholePanel = new JPanel(new BorderLayout()) { public void addNotify() { super.addNotify(); MasterDetailsComponent.this.addNotify(); TreeModel m = myTree.getModel(); if (m instanceof DefaultTreeModel) { DefaultTreeModel model = (DefaultTreeModel) m; for (int eachRow = 0; eachRow < myTree.getRowCount(); eachRow++) { TreePath eachPath = myTree.getPathForRow(eachRow); Object component = eachPath.getLastPathComponent(); if (component instanceof TreeNode) { model.nodeChanged((TreeNode) component); } } } } }; mySplitter.setHonorComponentsMinimumSize(true); myWholePanel.add(mySplitter, BorderLayout.CENTER); JPanel left = new JPanel(new BorderLayout()) { public Dimension getMinimumSize() { final Dimension original = super.getMinimumSize(); return new Dimension(Math.max(original.width, 100), original.height); } }; if (isNewProjectSettings()) { ToolbarDecorator decorator = ToolbarDecorator.createDecorator(myTree); DefaultActionGroup group = createToolbarActionGroup(); if (group != null) { decorator.setActionGroup(group); } // left.add(myNorthPanel, BorderLayout.NORTH); myMaster = decorator.setAsUsualTopToolbar().setPanelBorder(JBUI.Borders.empty()).createPanel(); myNorthPanel.setVisible(false); } else { left.add(myNorthPanel, BorderLayout.NORTH); myMaster = ScrollPaneFactory.createScrollPane(myTree); } left.add(myMaster, BorderLayout.CENTER); mySplitter.setFirstComponent(left); final JPanel right = new JPanel(new BorderLayout()); right.add(myDetails.getComponent(), BorderLayout.CENTER); if (!isNewProjectSettings()) { myWholePanel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); } mySplitter.setSecondComponent(right); GuiUtils.replaceJSplitPaneWithIDEASplitter(myWholePanel); myToReInitWholePanel = false; }
public void doRFileEvaluate(final IScope scope) { final String RFile = getPath(); try { // Call R RCaller caller = new RCaller(); String RPath = GamaPreferences.LIB_R.value(scope).getPath(); caller.setRscriptExecutable(RPath); // caller.setRscriptExecutable("\"" + RPath + "\""); // if(java.lang.System.getProperty("os.name").startsWith("Mac")) // { // caller.setRscriptExecutable(RPath); // } RCode c = new RCode(); List<String> R_statements = new ArrayList<String>(); // tmthai.begin---------------------------------------------------------------------------- String fullPath = FileUtils.constructAbsoluteFilePath(scope, RFile, true); if (DEBUG) { GuiUtils.debug("Stats.R_compute.RScript:" + RPath); GuiUtils.debug("Stats.R_compute.RFile:" + RFile); GuiUtils.debug("Stats.R_compute.fullPath:" + fullPath); } // FileReader fr = new FileReader(RFile); FileReader fr = new FileReader(fullPath); // tmthai.end---------------------------------------------------------------------------- BufferedReader br = new BufferedReader(fr); String statement; while ((statement = br.readLine()) != null) { c.addRCode(statement); R_statements.add(statement); // java.lang.System.out.println(statement); if (DEBUG) { GuiUtils.debug("Stats.R_compute.statement:" + statement); } } fr.close(); br.close(); caller.setRCode(c); GamaMap<String, IList> result = GamaMapFactory.create(Types.STRING, Types.LIST); String var = computeVariable(R_statements.get(R_statements.size() - 1).toString()); caller.runAndReturnResult(var); for (String name : caller.getParser().getNames()) { Object[] results = null; results = caller.getParser().getAsStringArray(name); // for (int i = 0; i < results.length; i++) { // java.lang.System.out.println(results[i]); // } if (DEBUG) { GuiUtils.debug( "Stats.R_compute_param.caller.Name: '" + name + "' length: " + results.length + " - Value: " + results.toString()); } result.put(name, GamaListFactory.createWithoutCasting(Types.NO_TYPE, results)); } if (DEBUG) { GuiUtils.debug("Stats.R_compute.return:" + result.serialize(false)); } // return result; setBuffer(result); } catch (Exception ex) { throw GamaRuntimeException.error("RCallerExecutionException " + ex.getMessage(), scope); } }
/** Constructor - creates layout. */ public HelpFrame() { setTitle("Web-Harvest Help"); setIconImage(((ImageIcon) ResourceManager.HELP32_ICON).getImage()); this.topNode = new DefaultMutableTreeNode(); this.treeModel = new DefaultTreeModel(this.topNode); try { String helpContent = CommonUtil.readStringFromUrl(ResourceManager.getHelpContentUrl()); XmlNode xmlNode = XmlParser.parse(new InputSource(new StringReader(helpContent))); createNodes(topNode, xmlNode); } catch (Exception e) { e.printStackTrace(); GuiUtils.showErrorMessage("Error reading help content!"); } tree = new JTree(topNode); tree.setRootVisible(false); tree.setShowsRootHandles(true); tree.setBorder(new EmptyBorder(5, 5, 5, 5)); tree.setCellRenderer( new DefaultTreeCellRenderer() { public Component getTreeCellRendererComponent( JTree tree, Object value, boolean sel, boolean expanded, boolean leaf, int row, boolean hasFocus) { DefaultTreeCellRenderer renderer = (DefaultTreeCellRenderer) super.getTreeCellRendererComponent( tree, value, sel, expanded, leaf, row, hasFocus); if (value instanceof DefaultMutableTreeNode) { DefaultMutableTreeNode defaultMutableTreeNode = (DefaultMutableTreeNode) value; Object userObject = defaultMutableTreeNode.getUserObject(); if (userObject instanceof TopicInfo) { TopicInfo topicInfo = (TopicInfo) userObject; renderer.setIcon( topicInfo.subtopicCount == 0 ? ResourceManager.HELPTOPIC_ICON : ResourceManager.HELPDIR_ICON); } } return renderer; } }); tree.addTreeSelectionListener(this); htmlPane = new JEditorPane(); htmlPane.setEditable(false); htmlPane.setContentType("text/html"); htmlPane.setEditorKit(new HTMLEditorKit()); htmlPane.setBorder(new EmptyBorder(5, 5, 5, 5)); JSplitPane splitPane = new ProportionalSplitPane(JSplitPane.HORIZONTAL_SPLIT); splitPane.setResizeWeight(0.0d); splitPane.setBorder(null); JScrollPane treeScrollPane = new WHScrollPane(tree); treeScrollPane.getViewport().setBackground(Color.white); treeScrollPane.setBackground(Color.white); splitPane.setLeftComponent(treeScrollPane); splitPane.setRightComponent(new WHScrollPane(htmlPane)); splitPane.setDividerLocation(0.3d); Container contentPane = getContentPane(); contentPane.setLayout(new BorderLayout()); contentPane.add(splitPane, BorderLayout.CENTER); pack(); }