use of com.ramussoft.gui.common.prefrence.Preferences in project ramus by Vitaliy-Yakovchuk.
the class FilePlugin method getApplicationPreferences.
@Override
public Preferences[] getApplicationPreferences() {
return new Preferences[] { new AbstractPreferences() {
private JPanel panel;
private JCheckBox checkBox = new JCheckBox();
private JCheckBox checkForUpdates = new JCheckBox(GlobalResourcesManager.getString("Action.CheckForUpdates"));
private JCheckBox startup = new JCheckBox(GlobalResourcesManager.getString("ShowStartupLauncher"));
private JComboBox langsBox;
{
double[][] size = { { 5, TableLayout.MINIMUM, 5, TableLayout.MINIMUM, 5 }, { 5, TableLayout.MINIMUM, 5, TableLayout.MINIMUM, 5, TableLayout.MINIMUM, 5, TableLayout.MINIMUM, 5 } };
panel = new JPanel(new TableLayout(size));
checkBox.setText(GlobalResourcesManager.getString("SaveProgramInTheMemory"));
checkBox.setToolTipText(GlobalResourcesManager.getString("SaveProgramInTheMemory.Describe"));
checkBox.setSelected(!Options.getBoolean("EXIT_IF_NO_FILE", true));
checkForUpdates.setSelected(Options.getBoolean(CHECK_FOR_UPDATES, true));
startup.setSelected(!Options.getBoolean("DO_NOT_ASK_AGAIN_FIRST_LOAD", false));
panel.add(checkBox, "1,1");
panel.add(startup, "1,3");
JLabel label = new JLabel(GlobalResourcesManager.getString("GUI.Language"));
panel.add(label, "1,5");
langsBox = new JComboBox();
langsBox.addItem(new Lang("en", "en_GB"));
langsBox.addItem(new Lang("uk", "uk_UA"));
langsBox.addItem(new Lang("ru", "ru"));
for (int i = 0; i < langsBox.getItemCount(); i++) {
if (((Lang) langsBox.getItemAt(i)).isActive()) {
langsBox.setSelectedIndex(i);
}
}
panel.add(langsBox, "3,5");
if (!Metadata.CORPORATE)
panel.add(checkForUpdates, "1,7");
}
@Override
public JComponent createComponent() {
return panel;
}
@Override
public String getTitle() {
return GlobalResourcesManager.getString("Main.Preferences");
}
@Override
public boolean save(JDialog dialog) {
Options.setBoolean("EXIT_IF_NO_FILE", !checkBox.isSelected());
Options.setBoolean("DO_NOT_ASK_AGAIN_FIRST_LOAD", !startup.isSelected());
Options.setBoolean(CHECK_FOR_UPDATES, checkForUpdates.isSelected());
Options.setString("LANG", ((Lang) langsBox.getSelectedItem()).key);
Locale newLocale = new Locale(((Lang) langsBox.getSelectedItem()).key);
Locale.setDefault(newLocale);
return true;
}
} };
}
use of com.ramussoft.gui.common.prefrence.Preferences in project ramus by Vitaliy-Yakovchuk.
the class IDEF0ViewPlugin method getProjectPreferences.
@Override
public Preferences[] getProjectPreferences() {
List<Qualifier> list = IDEF0Plugin.getBaseQualifiers(engine);
Preferences[] res = new Preferences[((list.size() > 0) ? 1 : 0)];
final DataPlugin dataPlugin;
if (list.size() == 0)
dataPlugin = null;
else
dataPlugin = NDataPluginFactory.getDataPlugin(list.get(0), engine, rules);
if (res.length > 0)
res[res.length - 1] = new AbstractPreferences() {
private OwnerClasificators c = new OwnerClasificators(dataPlugin);
{
c.updateOuners();
}
@Override
public JComponent createComponent() {
return c;
}
@Override
public String getTitle() {
return ResourceLoader.getString("Owners.Clasificators");
}
@Override
public boolean save(JDialog dialog) {
c.apply();
return true;
}
};
return res;
}
use of com.ramussoft.gui.common.prefrence.Preferences in project ramus by Vitaliy-Yakovchuk.
the class QualifierPlugin method getProjectPreferences.
@Override
public Preferences[] getProjectPreferences() {
return new Preferences[] { new AbstractPreferences() {
class Button extends JRadioButton {
/**
*/
private static final long serialVersionUID = 1L;
private Language language;
public Button(Language language) {
this.language = language;
}
public Language getLanguage() {
return language;
}
}
private JPanel component;
private Button[] buttons;
private JCheckBox box;
{
Properties ps = engine.getProperties(TextAttributePlugin.USER_GUI_SPELL_PROPERTIES);
Language language = getCurrentLanguage(ps);
Language[] languages = SpellFactory.getLanguages();
box = new JCheckBox(GlobalResourcesManager.getString("Editor.SpellCheck"));
box.setSelected(Options.getBoolean(TextAttributePlugin.SPELL_CHECK, true, ps));
JPanel languagesPanel = new JPanel();
languagesPanel.setLayout(new BoxLayout(languagesPanel, BoxLayout.Y_AXIS));
buttons = new Button[languages.length];
ButtonGroup group = new ButtonGroup();
for (int i = 0; i < languages.length; i++) {
Button button = new Button(languages[i]);
button.setText(languages[i].getLocalizedName());
languagesPanel.add(button);
buttons[i] = button;
if (languages[i].equals(language))
button.setSelected(true);
group.add(button);
}
JScrollPane pane = new JScrollPane();
pane.setViewportView(languagesPanel);
component = new JPanel(new BorderLayout());
component.add(pane, BorderLayout.CENTER);
component.add(box, BorderLayout.NORTH);
}
@Override
public JComponent createComponent() {
return component;
}
@Override
public String getTitle() {
return GlobalResourcesManager.getString("Preferences.SpellChecking");
}
@Override
public boolean save(JDialog dialog) {
Properties ps = engine.getProperties(TextAttributePlugin.USER_GUI_SPELL_PROPERTIES);
Options.setBoolean(TextAttributePlugin.SPELL_CHECK, box.isSelected(), ps);
String l = "";
for (Button button : buttons) if (button.isSelected()) {
l = button.getLanguage().getName();
break;
}
Options.setString(TextAttributePlugin.LANGUAGE, l, ps);
engine.setProperties(TextAttributePlugin.USER_GUI_SPELL_PROPERTIES, ps);
return true;
}
private Language getCurrentLanguage(Properties ps) {
String langName = Options.getString(TextAttributePlugin.LANGUAGE, "", ps);
Language language;
if ((langName == null) || (langName.equals("")))
language = SpellFactory.getDefaultLanguage();
else
language = SpellFactory.findLanguage(langName);
return language;
}
}, new AbstractPreferences() {
SelectableTableView tableView;
JComboBox attributeForName = new JComboBox();
private JPanel panel;
{
tableView = new SelectableTableView(framework, engine, accessor, StandardAttributesPlugin.getAttributesQualifier(engine)) {
@Override
protected Attribute[] getAttributes() {
return new Attribute[] { StandardAttributesPlugin.getAttributeNameAttribute(engine), StandardAttributesPlugin.getAttributeTypeNameAttribute(engine) };
}
};
double[][] size = { { 5, TableLayout.MINIMUM, 5, TableLayout.FILL, 5 }, { 5, TableLayout.MINIMUM, 5 } };
JPanel attrForName = new JPanel(new TableLayout(size));
attrForName.add(new JLabel(GlobalResourcesManager.getString("Qualifier.AttributeForName")), "1, 1");
attrForName.add(attributeForName, "3, 1");
panel = new JPanel(new BorderLayout());
panel.add(tableView.createComponent(), BorderLayout.CENTER);
panel.add(attrForName, BorderLayout.SOUTH);
Properties ps = engine.getProperties(AutochangePlugin.AUTO_ADD_ATTRIBUTES);
String ids = ps.getProperty(AutochangePlugin.AUTO_ADD_ATTRIBUTE_IDS);
if (ids == null)
ids = "";
String aForName = ps.getProperty(AutochangePlugin.ATTRIBUTE_FOR_NAME);
StringTokenizer st = new StringTokenizer(ids, " ,");
List<Row> rows = tableView.getComponent().getRowSet().getAllRows();
attributeForName.addItem(null);
while (st.hasMoreElements()) {
String s = st.nextToken();
Long long1 = new Long(s);
Row row = findRow(long1, rows);
if (row != null) {
tableView.setSelectedRow(row, true);
attributeForName.addItem(row);
if (s.equals(aForName))
attributeForName.setSelectedItem(row);
}
}
attributeForName.addPopupMenuListener(new PopupMenuListener() {
@Override
public void popupMenuCanceled(PopupMenuEvent e) {
}
@Override
public void popupMenuWillBecomeInvisible(PopupMenuEvent e) {
}
@Override
public void popupMenuWillBecomeVisible(PopupMenuEvent e) {
attributeForName.removeAllItems();
List<Row> list = tableView.getSelectedRows();
for (Row p : list) {
Attribute a = StandardAttributesPlugin.getAttribute(engine, p.getElement());
if (StandardAttributesPlugin.isNameType(a.getAttributeType()))
attributeForName.addItem(p);
}
JComboBox box = (JComboBox) e.getSource();
Object comp = box.getUI().getAccessibleChild(box, 0);
if (!(comp instanceof JPopupMenu))
return;
JComponent scrollPane = (JComponent) ((JPopupMenu) comp).getComponent(0);
Dimension size = new Dimension();
size.width = box.getPreferredSize().width;
size.height = scrollPane.getPreferredSize().height;
scrollPane.setPreferredSize(size);
}
});
}
@Override
public JComponent createComponent() {
return panel;
}
private Row findRow(Long long1, List<Row> rows) {
Attribute attr = engine.getAttribute(long1.longValue());
if (attr != null) {
for (Row row : rows) {
Long long2 = StandardAttributesPlugin.getAttributeId(engine, row.getElement());
if (long2 != null) {
if (attr.getId() == long2.longValue())
return row;
}
}
}
return null;
}
@Override
public String getTitle() {
return GlobalResourcesManager.getString("Preferences.AutoaddAttributes");
}
@Override
public boolean save(JDialog dialog) {
List<Row> list = tableView.getSelectedRows();
StringBuffer sb = new StringBuffer();
for (Row row : list) {
Long id = StandardAttributesPlugin.getAttributeId(engine, row.getElement());
if (id != null)
sb.append(id + " ");
}
Properties properties = engine.getProperties(AutochangePlugin.AUTO_ADD_ATTRIBUTES);
properties.setProperty(AutochangePlugin.AUTO_ADD_ATTRIBUTE_IDS, sb.toString());
Row row = (Row) attributeForName.getSelectedItem();
if (row != null)
properties.setProperty(AutochangePlugin.ATTRIBUTE_FOR_NAME, Long.toString(StandardAttributesPlugin.getAttributeId(engine, row.getElement())));
engine.setProperties(AutochangePlugin.AUTO_ADD_ATTRIBUTES, properties);
return true;
}
@Override
public void close() {
tableView.close();
}
} };
}
Aggregations