Changeset 15084

Show
Ignore:
Timestamp:
07/03/08 13:03:27 (2 months ago)
Author:
daisuke_m
Message:

Preferenceページをサービス毎に分割。

Location:
lang/java/sabotter/trunk
Files:
3 added
4 modified

Legend:

Unmodified
Added
Removed
  • lang/java/sabotter/trunk/plugin.xml

    r15071 r15084  
    6767            id="jp.xet.sabotter.preference" 
    6868            name="%SabotterPreferencePage.name"/> 
     69      <page 
     70            class="jp.xet.eclipse.sabotter.preferences.TwitterPreferencePage" 
     71            id="jp.xet.sabotter.preference.twitter" 
     72            category="jp.xet.sabotter.preference" 
     73            name="Twitter"/> 
     74      <page 
     75            class="jp.xet.eclipse.sabotter.preferences.WassrPreferencePage" 
     76            id="jp.xet.sabotter.preference.wassr" 
     77            category="jp.xet.sabotter.preference" 
     78            name="Wassr"/> 
    6979   </extension> 
    7080   <extension 
  • lang/java/sabotter/trunk/src/jp/xet/eclipse/sabotter/preferences/SabotterPreferencePage.java

    r14773 r15084  
    22 
    33import jp.xet.eclipse.sabotter.SabotterPlugin; 
    4 import jp.xet.eclipse.sabotter.helper.TextSelectionOnFocusAdapter; 
    5  
    64import org.eclipse.jface.preference.IPreferenceStore; 
    75import org.eclipse.jface.preference.PreferencePage; 
     
    97import org.eclipse.swt.events.SelectionAdapter; 
    108import org.eclipse.swt.events.SelectionEvent; 
    11 import org.eclipse.swt.events.SelectionListener; 
    129import org.eclipse.swt.layout.GridData; 
    1310import org.eclipse.swt.layout.GridLayout; 
     
    1916import org.eclipse.swt.widgets.Label; 
    2017import org.eclipse.swt.widgets.Scale; 
    21 import org.eclipse.swt.widgets.Spinner; 
    22 import org.eclipse.swt.widgets.Text; 
    2318import org.eclipse.ui.IWorkbench; 
    2419import org.eclipse.ui.IWorkbenchPreferencePage; 
     
    3126public class SabotterPreferencePage extends PreferencePage implements IWorkbenchPreferencePage { 
    3227         
    33         private Text txtUsername; 
    34          
    35         private Text txtPassword; 
    36          
    3728        private Combo cmbImage; 
    3829         
     
    4132        private Combo cmbFocusMove; 
    4233         
     34        private Combo cmbBaloonDispayType; 
     35         
    4336        private Scale sclMaxEntries; 
    4437         
     
    5043         
    5144        private Button radExternalBrowser; 
    52          
    53         private Spinner spnAPILimitRate; 
    54          
    55         private Spinner spnTimeLineInterval; 
    56          
    57         private Spinner spnRepliesInterval; 
    58          
    59         private Spinner spnDirectMessagesInterval; 
    60          
    61         private SelectionListener intervalListener = new SelectionListener() { 
    62                  
    63                 public void widgetDefaultSelected(SelectionEvent e) { 
    64                         widgetSelected(e); 
    65                 } 
    66                  
    67                 public void widgetSelected(SelectionEvent e) { 
    68                         int limit = spnAPILimitRate.getSelection(); 
    69                         int f = spnTimeLineInterval.getSelection(); 
    70                         int r = spnRepliesInterval.getSelection(); 
    71                         int d = spnDirectMessagesInterval.getSelection(); 
    72                         if (valid(limit, f, r, d)) { 
    73                                 return; 
    74                         } 
    75                         Spinner fixed = (Spinner) e.getSource(); 
    76                         while (valid(limit, f, r, d) == false) { 
    77                                 if (fixed.equals(spnAPILimitRate)) { 
    78                                         if (f < r && f < d) { 
    79                                                 f++; 
    80                                         } else if (r < d) { 
    81                                                 r++; 
    82                                         } else { 
    83                                                 d++; 
    84                                         } 
    85                                 } else if (fixed.equals(spnTimeLineInterval)) { 
    86                                         if (60 / f >= limit) { 
    87                                                 f++; 
    88                                         } else if (r < d) { 
    89                                                 r++; 
    90                                         } else { 
    91                                                 d++; 
    92                                         } 
    93                                 } else if (fixed.equals(spnRepliesInterval)) { 
    94                                         if (60 / r >= limit) { 
    95                                                 r++; 
    96                                         } else if (f < d) { 
    97                                                 f++; 
    98                                         } else { 
    99                                                 d++; 
    100                                         } 
    101                                 } else if (fixed.equals(spnDirectMessagesInterval)) { 
    102                                         if (60 / d >= limit) { 
    103                                                 d++; 
    104                                         } else if (f < r) { 
    105                                                 f++; 
    106                                         } else { 
    107                                                 r++; 
    108                                         } 
    109                                 } else { 
    110                                         System.err.println("!!"); 
    111                                 } 
    112                         } 
    113                          
    114                         spnAPILimitRate.setSelection(limit); 
    115                         spnTimeLineInterval.setSelection(f); 
    116                         spnRepliesInterval.setSelection(r); 
    117                         spnDirectMessagesInterval.setSelection(d); 
    118                 } 
    119                  
    120                 private boolean valid(int limit, int... values) { 
    121                         return limit > calcRate(values); 
    122                 } 
    123                  
    124                 private double calcRate(int[] intervals) { 
    125                         double result = 0; 
    126                         for (int interval : intervals) { 
    127                                 result += 60 / interval; 
    128                         } 
    129                         return result; 
    130                 } 
    131         }; 
    132          
    133         private Combo cmbBaloonDispayType; 
    13445         
    13546 
     
    14556                composite.setLayout(new GridLayout(1, true)); 
    14657                 
    147                 Group account = new Group(composite, SWT.NONE); 
    148                 account.setText(Messages.group_account); 
    149                 account.setLayout(new GridLayout(2, false)); 
    150                 account.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); 
    151                  
    152                 Label label = new Label(account, SWT.NONE); 
    153                 label.setText(Messages.label_username); 
    154                  
    155                 txtUsername = new Text(account, SWT.BORDER); 
    156                 txtUsername.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); 
    157                 txtUsername.addFocusListener(new TextSelectionOnFocusAdapter(txtUsername)); 
    158                  
    159                 label = new Label(account, SWT.NONE); 
    160                 label.setText(Messages.label_password); 
    161                  
    162                 txtPassword = new Text(account, SWT.PASSWORD | SWT.BORDER); 
    163                 txtPassword.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); 
    164                 txtPassword.addFocusListener(new TextSelectionOnFocusAdapter(txtPassword)); 
    165                  
    16658                Group browser = new Group(composite, SWT.NONE); 
    16759                browser.setText(Messages.group_browser); 
     
    17567                radExternalBrowser.setText(Messages.radio_use_external_browser); 
    17668                 
    177                 Group interval = new Group(composite, SWT.NONE); 
    178                 interval.setText(Messages.group_access_interval); 
    179                 interval.setLayout(new GridLayout(3, false)); 
    180                 interval.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); 
    181                  
    182                 label = new Label(interval, SWT.NONE); 
    183                 label.setText(Messages.label_api_limit_rate); 
    184                 spnAPILimitRate = new Spinner(interval, SWT.BORDER); 
    185                 spnAPILimitRate.setMinimum(10); 
    186                 spnAPILimitRate.setMaximum(99); 
    187                 spnAPILimitRate.setIncrement(1); 
    188                 label = new Label(interval, SWT.NONE); 
    189                 label.setText(Messages.label_times_per_hour); 
    190                  
    191                 label = new Label(interval, SWT.NONE); 
    192                 label.setText(Messages.label_friend_timeline); 
    193                 spnTimeLineInterval = new Spinner(interval, SWT.BORDER); 
    194                 spnTimeLineInterval.setMinimum(1); 
    195                 spnAPILimitRate.setMaximum(99); 
    196                 spnAPILimitRate.setIncrement(1); 
    197                 label = new Label(interval, SWT.NONE); 
    198                 label.setText(Messages.label_min); 
    199                  
    200                 label = new Label(interval, SWT.NONE); 
    201                 label.setText(Messages.label_replies); 
    202                 spnRepliesInterval = new Spinner(interval, SWT.BORDER); 
    203                 spnRepliesInterval.setMinimum(1); 
    204                 spnAPILimitRate.setMaximum(99); 
    205                 spnAPILimitRate.setIncrement(1); 
    206                 label = new Label(interval, SWT.NONE); 
    207                 label.setText(Messages.label_min); 
    208                  
    209                 label = new Label(interval, SWT.NONE); 
    210                 label.setText(Messages.label_direct_messages); 
    211                 spnDirectMessagesInterval = new Spinner(interval, SWT.BORDER); 
    212                 spnDirectMessagesInterval.setMinimum(1); 
    213                 spnAPILimitRate.setMaximum(99); 
    214                 spnAPILimitRate.setIncrement(1); 
    215                 label = new Label(interval, SWT.NONE); 
    216                 label.setText(Messages.label_min); 
    217                  
    21869                Group other = new Group(composite, SWT.NONE); 
    21970                other.setText(Messages.group_other); 
     
    22172                other.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); 
    22273                 
    223                 label = new Label(other, SWT.NONE); 
    224                 label.setText(Messages.label_image); 
     74                new Label(other, SWT.NONE).setText(Messages.label_image); 
    22575                 
    22676                cmbImage = new Combo(other, SWT.BORDER | SWT.READ_ONLY); 
     
    23282                } 
    23383                 
    234                 label = new Label(other, SWT.NONE); 
    235                 label.setText(Messages.label_name); 
     84                new Label(other, SWT.NONE).setText(Messages.label_name); 
    23685                 
    23786                cmbName = new Combo(other, SWT.BORDER | SWT.READ_ONLY); 
     
    24392                } 
    24493                 
    245                 label = new Label(other, SWT.NONE); 
    246                 label.setText(Messages.label_focus_move); 
     94                new Label(other, SWT.NONE).setText(Messages.label_focus_move); 
    24795                 
    24896                cmbFocusMove = new Combo(other, SWT.BORDER | SWT.READ_ONLY); 
     
    254102                } 
    255103                 
    256                 label = new Label(other, SWT.NONE); 
    257                 label.setText(Messages.label_balloon_notice); 
     104                new Label(other, SWT.NONE).setText(Messages.label_balloon_notice); 
    258105                 
    259106                cmbBaloonDispayType = new Combo(other, SWT.BORDER | SWT.READ_ONLY); 
     
    265112                } 
    266113                 
    267                 label = new Label(other, SWT.NONE); 
    268                 label.setText(Messages.label_max_entries); 
     114                new Label(other, SWT.NONE).setText(Messages.label_max_entries); 
    269115                 
    270116                sclMaxEntries = new Scale(other, SWT.HORIZONTAL); 
     
    332178        private void setCurrentValueToControls() { 
    333179                IPreferenceStore ps = SabotterPlugin.getDefault().getPreferenceStore(); 
    334                 txtUsername.setText(ps.getString(PreferenceKeys.USERNAME)); 
    335                 txtPassword.setText(ps.getString(PreferenceKeys.PASSWORD)); 
    336                  
    337180                int value = ps.getInt(PreferenceKeys.IMAGE_PROCESS_TYPE); 
    338181                cmbImage.setText(ImageProcessType.getImageProcessType(value).getDisplayName()); 
     
    356199                radInternalBrowser.setSelection(ps.getBoolean(PreferenceKeys.INTERNAL_BROWSER) == true); 
    357200                radExternalBrowser.setSelection(ps.getBoolean(PreferenceKeys.INTERNAL_BROWSER) == false); 
    358                  
    359                 spnAPILimitRate.setSelection(ps.getInt(PreferenceKeys.API_LIMIT_RATE)); 
    360                 spnAPILimitRate.addSelectionListener(intervalListener); 
    361                 spnTimeLineInterval.setSelection(ps.getInt(PreferenceKeys.INTERVAL_FRIEND_TIMELINE)); 
    362                 spnTimeLineInterval.addSelectionListener(intervalListener); 
    363                 spnRepliesInterval.setSelection(ps.getInt(PreferenceKeys.INTERVAL_REPLIES)); 
    364                 spnRepliesInterval.addSelectionListener(intervalListener); 
    365                 spnDirectMessagesInterval.setSelection(ps.getInt(PreferenceKeys.INTERVAL_DIRECT_MESSAGES)); 
    366                 spnDirectMessagesInterval.addSelectionListener(intervalListener); 
    367201        } 
    368202         
    369203        private void loadDefaultValues() { 
    370204                IPreferenceStore ps = SabotterPlugin.getDefault().getPreferenceStore(); 
    371                 ps.setValue(PreferenceKeys.USERNAME, SabotterPreferenceInitializer.DEF_USERNAME); 
    372                 ps.setValue(PreferenceKeys.PASSWORD, SabotterPreferenceInitializer.DEF_PASSWORD); 
    373205                ps.setValue(PreferenceKeys.IMAGE_PROCESS_TYPE, ImageProcessType.SIZE16.getId()); 
    374206                ps.setValue(PreferenceKeys.NAME_TYPE, NameDisplayType.NAME.getId()); 
     
    377209                ps.setValue(PreferenceKeys.UNREAD_MANAGEMENT, true); 
    378210                ps.setValue(PreferenceKeys.INTERNAL_BROWSER, true); 
    379                 ps.setValue(PreferenceKeys.API_LIMIT_RATE, 30); 
    380                 ps.setValue(PreferenceKeys.INTERVAL_FRIEND_TIMELINE, 5); 
    381                 ps.setValue(PreferenceKeys.INTERVAL_REPLIES, 12); 
    382                 ps.setValue(PreferenceKeys.INTERVAL_DIRECT_MESSAGES, 20); 
    383211                ps.setValue(PreferenceKeys.BALOON_DISPLAY_TYPE, BaloonDispayType.ALL.toString()); 
    384212        } 
     
    386214        private void storeValues() { 
    387215                IPreferenceStore ps = SabotterPlugin.getDefault().getPreferenceStore(); 
    388                 ps.setValue(PreferenceKeys.USERNAME, txtUsername.getText()); 
    389                 ps.setValue(PreferenceKeys.PASSWORD, txtPassword.getText()); 
    390216                 
    391217                String text = cmbImage.getText(); 
     
    409235                boolean useInternalBrowser = radInternalBrowser.getSelection(); 
    410236                ps.setValue(PreferenceKeys.INTERNAL_BROWSER, useInternalBrowser); 
    411                  
    412                 int apiLimitRate = spnAPILimitRate.getSelection(); 
    413                 ps.setValue(PreferenceKeys.API_LIMIT_RATE, apiLimitRate); 
    414                  
    415                 int timeLineInterval = spnTimeLineInterval.getSelection(); 
    416                 ps.setValue(PreferenceKeys.INTERVAL_FRIEND_TIMELINE, timeLineInterval); 
    417                  
    418                 int replyInterval = spnRepliesInterval.getSelection(); 
    419                 ps.setValue(PreferenceKeys.INTERVAL_REPLIES, replyInterval); 
    420                  
    421                 int dmInterval = spnDirectMessagesInterval.getSelection(); 
    422                 ps.setValue(PreferenceKeys.INTERVAL_DIRECT_MESSAGES, dmInterval); 
    423237        } 
    424238         
  • lang/java/sabotter/trunk/src/jp/xet/eclipse/sabotter/preferences/messages.properties

    r14743 r15084  
    1616 
    1717### SabotterPreferencePage 
    18 group_account = Twitter account 
     18group_account = Account 
    1919label_username = Username 
    2020label_password = Password 
  • lang/java/sabotter/trunk/src/jp/xet/eclipse/sabotter/preferences/messages_ja.properties

    r14743 r15084  
    1616 
    1717### SabotterPreferencePage 
    18 group_account = Twitter\u30a2\u30ab\u30a6\u30f3\u30c8 
     18group_account = \u30a2\u30ab\u30a6\u30f3\u30c8 
    1919label_username = \u30e6\u30fc\u30b6\u540d 
    2020label_password = \u30d1\u30b9\u30ef\u30fc\u30c9