r2038 - in trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing: . editor/config
Author: tchemit Date: 2010-08-26 13:24:28 +0200 (Thu, 26 Aug 2010) New Revision: 2038 Url: http://nuiton.org/repositories/revision/jaxx/2038 Log: remove old api Removed: trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/application/ trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/ConfigUIBuilder.java Deleted: trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/ConfigUIBuilder.java =================================================================== --- trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/ConfigUIBuilder.java 2010-08-11 14:46:18 UTC (rev 2037) +++ trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/ConfigUIBuilder.java 2010-08-26 11:24:28 UTC (rev 2038) @@ -1,306 +0,0 @@ -/* - * #%L - * JAXX :: Widgets - * - * $Id$ - * $HeadURL$ - * %% - * Copyright (C) 2008 - 2010 CodeLutin - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Lesser Public License for more details. - * - * You should have received a copy of the GNU General Lesser Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/lgpl-3.0.html>. - * #L% - */ - -package jaxx.runtime.swing.editor.config; - -import jaxx.runtime.JAXXContext; -import jaxx.runtime.context.JAXXInitialContext; -import jaxx.runtime.swing.editor.config.model.ConfigUIModel; - -import java.awt.*; - -/** - * La classe pour construire l'ui - * - * @author tchemit <chemit@codelutin.com> - * @deprecated since 2.0.2, do not use any more, prefer use the {@link ConfigUIHelper} api. - */ -@Deprecated -public class ConfigUIBuilder { - - private static final String CALLBACKS_WITH_OPTIONS = "callbacksWithOptions"; - - private static final String CALLBACKS = "callbacks"; - - /** - * Construire l'ui de configuration (sous forme de panel) - * - * @param parentContext le context applicatif - * @param model le modele de l'ui de configuration - * @param defaultCategory la categorie a selectionner - * @return l'ui instanciate - */ - public static ConfigUI newConfigUI(JAXXContext parentContext, - ConfigUIModel model, - String defaultCategory) { - JAXXContext tx = new JAXXInitialContext().add(parentContext).add(model); - - ConfigUI ui = new ConfigUI(tx); - - ui.init(defaultCategory); - return ui; -// JButton quitButton = ui.getQuit(); -// -// // prepare quit action -// Action quitAction = new AbstractAction(quitButton.getText(), -// quitButton.getIcon()) { -// -// private static final long serialVersionUID = 1L; -// -// @Override -// public void actionPerformed(ActionEvent e) { -// if (!canQuitCategory(ui)) { -// return; -// } -// -// final Window parentWindow = ui.getParentContainer(Window.class); -// -// if (!model.isSaved() || model.isStandalone()) { -// -// // just quit, no callBack can be apply here -// -// ui.destroy(); -// -// // close the configu ui -// parentWindow.dispose(); -// return; -// } -// -// Map<CallBackEntry, List<OptionModel>> forSaved; -// forSaved = model.getCallBacksForSaved(); -// -// if (forSaved.isEmpty()) { -// // just quit, no callBack to call -// -// ui.destroy(); -// -// // close the configu ui -// parentWindow.dispose(); -// return; -// } -// -// forSaved = model.getCallBacksForSaved(); -// -// // init callBackUI -// -// ConfigCallBackUI lastUI = new ConfigCallBackUI( -// new JAXXInitialContext(). -// add("parent", parentWindow). -// add(ui). -// add(CALLBACKS_WITH_OPTIONS, forSaved). -// add(CALLBACKS, new ArrayList<CallBackEntry>(forSaved.keySet())). -// add(new ConfigCallBackUIHandler()) -// ); -// -// lastUI.init(); -// ui.setVisible(false); -// parentWindow.remove(ui); -// parentWindow.add(lastUI); -// -// SwingUtilities.invokeLater(new Runnable() { -// -// @Override -// public void run() { -// parentWindow.validate(); -// } -// }); -// } -// }; -// String tip = quitButton.getToolTipText(); -// quitButton.setAction(quitAction); -// quitButton.setToolTipText(tip); -// -// // build categories tabs -// for (CategoryModel categoryModel : model) { -// String category = categoryModel.getCategory(); -// String categoryLabel = _(categoryModel.getCategoryLabel()); -// ConfigCategoryUI p = new ConfigCategoryUI(new -// JAXXInitialContext().add(ui).add(categoryModel)); -// p.getCategoryLabel().setText(categoryLabel); -// p.setName(category); -// ui.getCategories().addTab(_(category), null, p, categoryLabel); -// } -// -// model.setCategory(defaultCategory); -// int categoryIndex = model.getCategoryIndex(defaultCategory); -// if (log.isDebugEnabled()) { -// log.debug("index of default category (" + defaultCategory + ") : " -// + categoryIndex); -// } -// ui.getCategories().setSelectedIndex(categoryIndex); -// return ui; - } - - /** - * Affiche l'ui de configuration dans un boite de dialogue. - * - * @param configUI l'ui de configuration - * @param ui l'ui parent de la boite de dialogue a afficher - * (peut etre nulle) - * @param undecorated un drapeau pour savoir si on affiche les decorations - * de fenetre - */ - public static void showConfigUI(ConfigUI configUI, - Frame ui, - boolean undecorated) { - configUI.getHandler().displayUI(ui,undecorated); -// JDialog f = new JDialog(ui, true); -// f.setTitle(_("config.title")); -// f.add(configUI); -// if (ui != null) { -// f.setIconImage(ui.getIconImage()); -// } -// // pour savoir si l'ui est autonome -// configUI.getModel().setStandalone(ui == null); -// -// f.setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE); -// f.addWindowListener(new WindowAdapter() { -// -// @Override -// public void windowClosing(WindowEvent e) { -// ActionEvent myEvent = new ActionEvent(e.getSource(), 1, "quit"); -// configUI.getQuit().getAction().actionPerformed(myEvent); -// } -// }); -// f.setUndecorated(undecorated); -// JRootPane rootPane = f.getRootPane(); -// rootPane.setDefaultButton(configUI.getQuit()); -// rootPane.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put( -// KeyStroke.getKeyStroke("ESCAPE"), "quit"); -// rootPane.getActionMap().put("quit", configUI.getQuit().getAction()); -// f.pack(); -// SwingUtil.center(ui, f); -// f.setVisible(true); - } - - protected static boolean canQuitCategory(ConfigUI ui) { - - boolean canContinue = ui.getHandler().canQuitCategory(); - return canContinue; -// boolean canContinue = true; -// ConfigUIModel model = ui.getModel(); -// CategoryModel categoryModel = model.getCategoryModel(); -// String categoryName = _(categoryModel.getCategory()); -// if (!categoryModel.isValid()) { -// -// // the category is not valid -// // get all the invalid options -// -// StringBuilder buffer = new StringBuilder(); -// buffer.append(_("config.message.quit.invalid.category", -// categoryName)); -// buffer.append('\n'); -// for (OptionModel m : categoryModel.getInvalidOptions()) { -// buffer.append("\n- ").append(m.getKey()); -// } -// buffer.append('\n'); -// int reponse = askUser(ui, -// _("config.title.need.confirm"), -// buffer.toString(), -// JOptionPane.ERROR_MESSAGE, -// new Object[]{ -// _("config.choice.continue"), -// _("config.choice.cancel")}, -// 0); -// -// switch (reponse) { -// case JOptionPane.CLOSED_OPTION: -// case 1: -// canContinue = false; -// break; -// case 0: -// if (categoryModel.isModified()) { -// // wil reset category -// model.reset(); -// } -// break; -// } -// } else if (categoryModel.isModified()) { -// -// // category was modified, ask user if wants to save -// -// StringBuilder buffer = new StringBuilder(); -// buffer.append(_("config.message.quit.valid.and.modified.category", -// categoryName)).append('\n'); -// for (OptionModel m : categoryModel.getModifiedOptions()) { -// buffer.append("\n- ").append(m.getKey()); -// } -// buffer.append('\n'); -// -// int reponse = askUser(ui, -// _("config.title.need.confirm"), buffer.toString(), -// JOptionPane.WARNING_MESSAGE, -// new Object[]{ -// _("config.choice.save"), -// _("config.choice.doNotSave"), -// _("config.choice.cancel")}, -// 0); -// -// switch (reponse) { -// case JOptionPane.CLOSED_OPTION: -// case 2: -// canContinue = false; -// break; -// case 0: -// // will save ui -// model.saveModified(); -// break; -// case 1: -// // wil reset ui -// model.reset(); -// break; -// } -// -// } -// return canContinue; - } - - public static int askUser(ConfigUI parent, - String title, - String message, - int typeMessage, - Object[] options, - int defaultOption) { - int response = parent.getHandler().askUser(title, - message, - typeMessage, - options, - defaultOption); - return response; - -// int response = JOptionPane.showOptionDialog( -// parent, -// message, -// title, -// JOptionPane.DEFAULT_OPTION, -// typeMessage, -// null, -// options, -// options[defaultOption] -// ); -// -// return response; - } -}
participants (1)
-
tchemit@users.nuiton.org