/** @see ch.forthedit.gui.dialog.SettingPage#restore() */ @Override public void restore() { final StringBuilder builder = new StringBuilder(); String[] s; s = GlobalSettings.getInstance().getCompileCommands(); for (int i = 0; i < s.length; ++i) { builder.append(s[i]); if (i < s.length - 1) builder.append(","); } txtCompile.setText(builder.toString()); builder.replace(0, builder.length() - 1, ""); s = GlobalSettings.getInstance().getRunCommands(); for (int i = 0; i < s.length; ++i) { builder.append(s[i]); if (i < s.length - 1) builder.append(","); } txtRun.setText(builder.toString()); }
/** Create the panel. */ private CompileRunPage() { final GridBagLayout gridBagLayout = new GridBagLayout(); gridBagLayout.columnWidths = new int[] {0, 0, 179, 0}; gridBagLayout.rowHeights = new int[] {0, 0, 0, 0, 0}; gridBagLayout.columnWeights = new double[] {0.0, 0.0, 1.0, Double.MIN_VALUE}; gridBagLayout.rowWeights = new double[] {0.0, 0.0, 0.0, 0.0, Double.MIN_VALUE}; setLayout(gridBagLayout); final StringBuilder strBuild = new StringBuilder(); final Component horizontalStrut = Box.createHorizontalStrut(20); final GridBagConstraints gbc_horizontalStrut = new GridBagConstraints(); gbc_horizontalStrut.insets = new Insets(0, 0, 5, 5); gbc_horizontalStrut.gridx = 0; gbc_horizontalStrut.gridy = 1; add(horizontalStrut, gbc_horizontalStrut); final JLabel lableCompile = new JLabel(tr(getClass(), "CompileLable")); final GridBagConstraints gbc_lableCompile = new GridBagConstraints(); gbc_lableCompile.insets = new Insets(0, 0, 5, 5); gbc_lableCompile.gridx = 1; gbc_lableCompile.gridy = 1; add(lableCompile, gbc_lableCompile); for (int i = 0; i < GlobalSettings.getInstance().getCompileCommands().length; ++i) { strBuild.append(GlobalSettings.getInstance().getCompileCommands()[i]); if (i < GlobalSettings.getInstance().getCompileCommands().length - 1) strBuild.append(", "); } txtCompile = new JTextField(); txtCompile.setText(strBuild.toString()); final GridBagConstraints gbc_txtCompile = new GridBagConstraints(); gbc_txtCompile.insets = new Insets(0, 0, 5, 0); gbc_txtCompile.fill = GridBagConstraints.HORIZONTAL; gbc_txtCompile.gridx = 2; gbc_txtCompile.gridy = 1; add(txtCompile, gbc_txtCompile); txtCompile.setColumns(10); final Component horizontalStrut_1 = Box.createHorizontalStrut(20); final GridBagConstraints gbc_horizontalStrut_1 = new GridBagConstraints(); gbc_horizontalStrut_1.insets = new Insets(0, 0, 5, 5); gbc_horizontalStrut_1.gridx = 0; gbc_horizontalStrut_1.gridy = 2; add(horizontalStrut_1, gbc_horizontalStrut_1); final JLabel lableRun = new JLabel(tr(getClass(), "RunLable")); final GridBagConstraints gbc_lableRun = new GridBagConstraints(); gbc_lableRun.anchor = GridBagConstraints.EAST; gbc_lableRun.insets = new Insets(0, 0, 5, 5); gbc_lableRun.gridx = 1; gbc_lableRun.gridy = 2; add(lableRun, gbc_lableRun); strBuild.setLength(0); for (int i = 0; i < GlobalSettings.getInstance().getRunCommands().length; ++i) { strBuild.append(GlobalSettings.getInstance().getRunCommands()[i]); if (i < GlobalSettings.getInstance().getRunCommands().length - 1) strBuild.append(", "); } txtRun = new JTextField(); txtRun.setText(strBuild.toString()); final GridBagConstraints gbc_txtRun = new GridBagConstraints(); gbc_txtRun.insets = new Insets(0, 0, 5, 0); gbc_txtRun.fill = GridBagConstraints.HORIZONTAL; gbc_txtRun.gridx = 2; gbc_txtRun.gridy = 2; add(txtRun, gbc_txtRun); txtRun.setColumns(10); }
/** @see ch.forthedit.gui.dialog.SettingPage#saveGlobal() */ @Override public void saveGlobal() { GlobalSettings.getInstance().setCompileCommands(txtCompile.getText().split(",")); GlobalSettings.getInstance().setRunCommands(txtRun.getText().split(",")); }