blob_id stringlengths 40 40 | __id__ int64 225 39,780B | directory_id stringlengths 40 40 | path stringlengths 6 313 | content_id stringlengths 40 40 | detected_licenses list | license_type stringclasses 2
values | repo_name stringlengths 6 132 | repo_url stringlengths 25 151 | snapshot_id stringlengths 40 40 | revision_id stringlengths 40 40 | branch_name stringlengths 4 70 | visit_date timestamp[ns] | revision_date timestamp[ns] | committer_date timestamp[ns] | github_id int64 7.28k 689M ⌀ | star_events_count int64 0 131k | fork_events_count int64 0 48k | gha_license_id stringclasses 23
values | gha_fork bool 2
classes | gha_event_created_at timestamp[ns] | gha_created_at timestamp[ns] | gha_updated_at timestamp[ns] | gha_pushed_at timestamp[ns] | gha_size int64 0 40.4M ⌀ | gha_stargazers_count int32 0 112k ⌀ | gha_forks_count int32 0 39.4k ⌀ | gha_open_issues_count int32 0 11k ⌀ | gha_language stringlengths 1 21 ⌀ | gha_archived bool 2
classes | gha_disabled bool 1
class | content stringlengths 7 4.37M | src_encoding stringlengths 3 16 | language stringclasses 1
value | length_bytes int64 7 4.37M | extension stringclasses 24
values | filename stringlengths 4 174 | language_id stringclasses 1
value | entities list | contaminating_dataset stringclasses 0
values | malware_signatures list | redacted_content stringlengths 7 4.37M | redacted_length_bytes int64 7 4.37M | alphanum_fraction float32 0.25 0.94 | alpha_fraction float32 0.25 0.94 | num_lines int32 1 84k | avg_line_length float32 0.76 99.9 | std_line_length float32 0 220 | max_line_length int32 5 998 | is_vendor bool 2
classes | is_generated bool 1
class | max_hex_length int32 0 319 | hex_fraction float32 0 0.38 | max_unicode_length int32 0 408 | unicode_fraction float32 0 0.36 | max_base64_length int32 0 506 | base64_fraction float32 0 0.5 | avg_csv_sep_count float32 0 4 | is_autogen_header bool 1
class | is_empty_html bool 1
class | shard stringclasses 16
values |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
8b216073e23b74c9b3c4f38430dd8c8fc74fb53f | 3,848,290,746,920 | bd668d85b4cc3941bcb0344fb3bec84a760cde39 | /AddressDataManager.java | f3e70e7158b5e008c4856a2e6a0a3297a0bd89bd | [] | no_license | Bacchusliuy/MaskCustomerInfo | https://github.com/Bacchusliuy/MaskCustomerInfo | 3c363e97cdb419a5ea297dff748a1f590814a799 | bd773e905f3e39111e8e75168fb98bf36dc182c8 | refs/heads/master | 2021-01-19T15:03:51.588000 | 2017-08-22T07:08:16 | 2017-08-22T07:08:16 | 100,797,440 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | import java.util.ArrayList;
import java.io.*;
// Copyright (c) 2017. Lorem ipsum dolor sit amet, consectetur adipiscing elit.
// Morbi non lorem porttitor neque feugiat blandit. Ut vitae ipsum eget quam lacinia accumsan.
// Etiam sed turpis ac ipsum condimentum fringilla. Maecenas magna.
// Proin dapibus sapien vel ante. Aliquam erat volutpat. Pellentesque sagittis ligula eget metus.
// Vestibulum commodo. Ut rhoncus gravida arcu.
public class AddressDataManager {
private ArrayList<Province> allProvince;
public AddressDataManager() {
allProvince = new ArrayList<Province>();
}
public ArrayList<Province> getProvinces() {
//int provinceNum=0;
Province currentProvince = new Province("blank");
City currentCity = new City("blank", "blank");
try {
File file = new File("./CustomerInfoMask/src/address-data.txt");
if (file.isFile() && file.exists()) { //判断文件是否存在
InputStreamReader read = new InputStreamReader(
new FileInputStream(file), "UTF-8");//考虑到编码格式
BufferedReader bufferedReader = new BufferedReader(read);
String lineTxt = null;
while ((lineTxt = bufferedReader.readLine()) != null) {
if (lineTxt.length() > 0) {
if (lineTxt.charAt(0) != ' ') {
allProvince.add(currentProvince);
String provinceName = lineTxt.substring(11, lineTxt.length());
currentProvince = new Province(provinceName);
} else if (lineTxt.charAt(1) != ' ') {
String cityName = lineTxt.substring(17, lineTxt.length());
currentCity = new City(cityName, currentProvince.getProvinceName());
currentProvince.addCity(cityName);
} else if (lineTxt.charAt(2) != ' ') {
String districtName = lineTxt.substring(15, lineTxt.length());
currentProvince.addDistrict(districtName, currentCity.getCityName());
}
}
}
read.close();
} else {
System.out.println("找不到指定的文件");
}
} catch (Exception e) {
System.out.println("读取文件内容出错");
e.printStackTrace();
}
allProvince.add(currentProvince);
allProvince.remove(0);
return allProvince;
}
//Test
// public static void main(String[] args)
//{
// AddressDataManager adm=new AddressDataManager();
// ArrayList<Province> list=new ArrayList<Province>();
// list=adm.getProvinces();
//
// for(Province p:list)
// {
// System.out.println(p.getProvinceName().length()+":"+p.getProvinceName());
// for(City c:p.getCitiesGoverned())
// {
// System.out.println(c.getCityName().length()+":"+c.getCityName());
// for(District d:c.getDistrictList())
// {
// System.out.println(d.getDistrictName().length()+":"+d.getDistrictName());
// }
// }
// }
//}
} | UTF-8 | Java | 2,899 | java | AddressDataManager.java | Java | [] | null | [] | import java.util.ArrayList;
import java.io.*;
// Copyright (c) 2017. Lorem ipsum dolor sit amet, consectetur adipiscing elit.
// Morbi non lorem porttitor neque feugiat blandit. Ut vitae ipsum eget quam lacinia accumsan.
// Etiam sed turpis ac ipsum condimentum fringilla. Maecenas magna.
// Proin dapibus sapien vel ante. Aliquam erat volutpat. Pellentesque sagittis ligula eget metus.
// Vestibulum commodo. Ut rhoncus gravida arcu.
public class AddressDataManager {
private ArrayList<Province> allProvince;
public AddressDataManager() {
allProvince = new ArrayList<Province>();
}
public ArrayList<Province> getProvinces() {
//int provinceNum=0;
Province currentProvince = new Province("blank");
City currentCity = new City("blank", "blank");
try {
File file = new File("./CustomerInfoMask/src/address-data.txt");
if (file.isFile() && file.exists()) { //判断文件是否存在
InputStreamReader read = new InputStreamReader(
new FileInputStream(file), "UTF-8");//考虑到编码格式
BufferedReader bufferedReader = new BufferedReader(read);
String lineTxt = null;
while ((lineTxt = bufferedReader.readLine()) != null) {
if (lineTxt.length() > 0) {
if (lineTxt.charAt(0) != ' ') {
allProvince.add(currentProvince);
String provinceName = lineTxt.substring(11, lineTxt.length());
currentProvince = new Province(provinceName);
} else if (lineTxt.charAt(1) != ' ') {
String cityName = lineTxt.substring(17, lineTxt.length());
currentCity = new City(cityName, currentProvince.getProvinceName());
currentProvince.addCity(cityName);
} else if (lineTxt.charAt(2) != ' ') {
String districtName = lineTxt.substring(15, lineTxt.length());
currentProvince.addDistrict(districtName, currentCity.getCityName());
}
}
}
read.close();
} else {
System.out.println("找不到指定的文件");
}
} catch (Exception e) {
System.out.println("读取文件内容出错");
e.printStackTrace();
}
allProvince.add(currentProvince);
allProvince.remove(0);
return allProvince;
}
//Test
// public static void main(String[] args)
//{
// AddressDataManager adm=new AddressDataManager();
// ArrayList<Province> list=new ArrayList<Province>();
// list=adm.getProvinces();
//
// for(Province p:list)
// {
// System.out.println(p.getProvinceName().length()+":"+p.getProvinceName());
// for(City c:p.getCitiesGoverned())
// {
// System.out.println(c.getCityName().length()+":"+c.getCityName());
// for(District d:c.getDistrictList())
// {
// System.out.println(d.getDistrictName().length()+":"+d.getDistrictName());
// }
// }
// }
//}
} | 2,899 | 0.630519 | 0.624514 | 80 | 34.400002 | 27.395073 | 97 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.5 | false | false | 9 |
e635a4ac831dd779b447ce0041b43945b1146343 | 8,349,416,475,247 | e2343d63597c0198dd8d78faf9d40c95b989f47a | /app/src/main/java/com/utils/AlarmIntentService.java | e706c33f4bebb91c405d4eeadb44be2a3107a234 | [] | no_license | 18942019004/Mdssview | https://github.com/18942019004/Mdssview | f8313e1f96670b1e8df69f9a877d3bbed572bee2 | 47d7875cb7aa65c0d90558605a0d1de8e25c6cb5 | refs/heads/master | 2021-01-11T08:47:51.065000 | 2016-12-19T00:09:27 | 2016-12-19T00:09:27 | 76,811,192 | 0 | 1 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.utils;
import android.app.Notification;
import android.app.NotificationManager;
import android.content.Context;
import android.net.Uri;
import android.support.v4.app.NotificationCompat;
import android.text.TextUtils;
import com.alibaba.fastjson.JSON;
import com.gdmss.R;
import com.gdmss.entity.AlarmMessage;
import com.gdmss.entity.AlarmPushMessage;
import com.gdmss.entity.OptionInfo;
import com.igexin.sdk.GTIntentService;
import com.igexin.sdk.message.GTCmdMessage;
import com.igexin.sdk.message.GTTransmitMessage;
/**
* Created by Administrator on 2016/12/7.
*/
public class AlarmIntentService extends GTIntentService
{
NotificationManager nm;// = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
public AlarmIntentService()
{
}
@Override
public void onReceiveServicePid(Context context,int i)
{
L.e("onReceiveClientId -> " + "clientid = ");
}
@Override
public void onReceiveClientId(Context context,String s)
{
AlarmUtils.CID = s;
L.e("onReceiveClientId -> " + "onReceiveClientId = " + s);
}
@Override
public void onReceiveMessageData(Context context,GTTransmitMessage gtTransmitMessage)
{
L.e("onReceiveMessageData -> " + "onReceiveMessageData = ");
byte[] payload = gtTransmitMessage.getPayload();
if (null != payload)
{
String msg = new String(payload);
if (!TextUtils.isEmpty(msg))
{
AlarmPushMessage alarmMessage;
L.e("开始转换对象");
alarmMessage = JSON.parseObject(msg,AlarmPushMessage.class);
if (null != alarmMessage)
{
if (null != alarmMessage.aps)
{
push(context,alarmMessage);
}
}
L.e("转换成功");
}
}
}
@Override
public void onReceiveOnlineState(Context context,boolean b)
{
L.e("onReceiveClientId -> " + "onReceiveOnlineState = ");
}
@Override
public void onReceiveCommandResult(Context context,GTCmdMessage gtCmdMessage)
{
}
void push(Context context,AlarmPushMessage message)
{
if (null == nm)
{
nm = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
}
NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this);
mBuilder.setContentTitle(toTitle(context,message));// 设置通知栏标题
mBuilder.setSmallIcon(R.drawable.icon);// 设置通知小ICON
mBuilder.setContentText(message.aps.alert.body);
mBuilder.setTicker(message.aps.alert.body); // 通知首次出现在通知栏,带上升动画效果的
mBuilder.setWhen(System.currentTimeMillis());// 通知产生的时间,会在通知信息里显示,一般是系统获取到的时间
mBuilder.setDefaults(Notification.DEFAULT_VIBRATE | Notification.DEFAULT_LIGHTS);
mBuilder.setSound(Uri.parse("android.resource://" + context.getPackageName() + "/" + R.raw.alarm));
OptionInfo optionInfo = Utils.readJsonObject(Path.optionInfo, OptionInfo.class);
}
String toTitle(Context context,AlarmPushMessage alarmMessage)
{
return String.format(context.getString(R.string.message_title),alarmMessage.CameraName);
}
}
| UTF-8 | Java | 3,433 | java | AlarmIntentService.java | Java | [
{
"context": ".sdk.message.GTTransmitMessage;\n\n/**\n * Created by Administrator on 2016/12/7.\n */\n\npublic class AlarmIntentServic",
"end": 565,
"score": 0.7187301516532898,
"start": 552,
"tag": "USERNAME",
"value": "Administrator"
}
] | null | [] | package com.utils;
import android.app.Notification;
import android.app.NotificationManager;
import android.content.Context;
import android.net.Uri;
import android.support.v4.app.NotificationCompat;
import android.text.TextUtils;
import com.alibaba.fastjson.JSON;
import com.gdmss.R;
import com.gdmss.entity.AlarmMessage;
import com.gdmss.entity.AlarmPushMessage;
import com.gdmss.entity.OptionInfo;
import com.igexin.sdk.GTIntentService;
import com.igexin.sdk.message.GTCmdMessage;
import com.igexin.sdk.message.GTTransmitMessage;
/**
* Created by Administrator on 2016/12/7.
*/
public class AlarmIntentService extends GTIntentService
{
NotificationManager nm;// = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
public AlarmIntentService()
{
}
@Override
public void onReceiveServicePid(Context context,int i)
{
L.e("onReceiveClientId -> " + "clientid = ");
}
@Override
public void onReceiveClientId(Context context,String s)
{
AlarmUtils.CID = s;
L.e("onReceiveClientId -> " + "onReceiveClientId = " + s);
}
@Override
public void onReceiveMessageData(Context context,GTTransmitMessage gtTransmitMessage)
{
L.e("onReceiveMessageData -> " + "onReceiveMessageData = ");
byte[] payload = gtTransmitMessage.getPayload();
if (null != payload)
{
String msg = new String(payload);
if (!TextUtils.isEmpty(msg))
{
AlarmPushMessage alarmMessage;
L.e("开始转换对象");
alarmMessage = JSON.parseObject(msg,AlarmPushMessage.class);
if (null != alarmMessage)
{
if (null != alarmMessage.aps)
{
push(context,alarmMessage);
}
}
L.e("转换成功");
}
}
}
@Override
public void onReceiveOnlineState(Context context,boolean b)
{
L.e("onReceiveClientId -> " + "onReceiveOnlineState = ");
}
@Override
public void onReceiveCommandResult(Context context,GTCmdMessage gtCmdMessage)
{
}
void push(Context context,AlarmPushMessage message)
{
if (null == nm)
{
nm = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
}
NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this);
mBuilder.setContentTitle(toTitle(context,message));// 设置通知栏标题
mBuilder.setSmallIcon(R.drawable.icon);// 设置通知小ICON
mBuilder.setContentText(message.aps.alert.body);
mBuilder.setTicker(message.aps.alert.body); // 通知首次出现在通知栏,带上升动画效果的
mBuilder.setWhen(System.currentTimeMillis());// 通知产生的时间,会在通知信息里显示,一般是系统获取到的时间
mBuilder.setDefaults(Notification.DEFAULT_VIBRATE | Notification.DEFAULT_LIGHTS);
mBuilder.setSound(Uri.parse("android.resource://" + context.getPackageName() + "/" + R.raw.alarm));
OptionInfo optionInfo = Utils.readJsonObject(Path.optionInfo, OptionInfo.class);
}
String toTitle(Context context,AlarmPushMessage alarmMessage)
{
return String.format(context.getString(R.string.message_title),alarmMessage.CameraName);
}
}
| 3,433 | 0.651078 | 0.648649 | 112 | 28.401785 | 29.108007 | 107 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.473214 | false | false | 9 |
504b49afda44118bb6d29b4009416744e7c572d4 | 17,480,516,938,504 | 2c4ffbec4059e0b83d27034f2c7b142fb1633fd8 | /app/src/main/java/com/sairajen/saibabamantra/MainActivity.java | 7df57f1e354a8073cc75aefc2beceae00222efc6 | [] | no_license | gmonetix/SaiBabaMantra2 | https://github.com/gmonetix/SaiBabaMantra2 | 82b1e25cfa4826963f3204eae1692da4da71395b | 97e41d38b67420edc60d233d3123020c749d376d | refs/heads/master | 2018-02-07T20:06:12.593000 | 2017-07-14T08:30:38 | 2017-07-14T08:30:38 | 96,097,640 | 0 | 2 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.sairajen.saibabamantra;
import android.app.AlarmManager;
import android.app.PendingIntent;
import android.content.Intent;
import android.graphics.Color;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.support.v7.widget.Toolbar;
import android.view.KeyEvent;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.inputmethod.EditorInfo;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import com.google.android.gms.ads.AdRequest;
import com.google.android.gms.ads.AdView;
import com.google.android.gms.ads.MobileAds;
import java.util.Calendar;
public class MainActivity extends AppCompatActivity implements View.OnClickListener {
private Toolbar toolbar;
private Button startChantBtn;
private EditText editText;
private TextView readMoreTxt;
private AdView adView;
private int count = 0;
private final static String INTENT_COUNT = "count";
private SharedPref sharedPref;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
initToolbar();
initViews();
sharedPref = new SharedPref(MainActivity.this);
if (sharedPref.isFirstTime()) {
sharedPref.setFirstTime(false);
setNotification();
}
MobileAds.initialize(getApplicationContext(),getResources().getString(R.string.banner_ad));
adView = (AdView) findViewById(R.id.adViewMainActivity);
AdRequest adRequest = new AdRequest.Builder().build();
adView.loadAd(adRequest);
startChantBtn.setOnClickListener(this);
readMoreTxt.setOnClickListener(this);
editText.setOnEditorActionListener(new TextView.OnEditorActionListener() {
@Override
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
if ((event != null && (event.getKeyCode() == KeyEvent.KEYCODE_ENTER)) || (actionId == EditorInfo.IME_ACTION_DONE)) {
startChant();
}
return false;
}
});
}
private void startChant() {
if (editText.getText().toString().trim() != null && !editText.getText().toString().trim().equals("")) {
count = Integer.parseInt(editText.getText().toString().trim());
if (count>0 && count < 1000) {
Intent intent = new Intent(MainActivity.this, MediaPlayerActivity.class);
intent.putExtra(INTENT_COUNT, count);
startActivity(intent);
} else {
Helper.showDialog(MainActivity.this,"ERROR","please enter count value betweeen 0 and 1000","OK",android.R.drawable.stat_sys_warning);
}
} else {
Helper.showDialog(MainActivity.this,"ERROR","please enter valid count value before proceeding","OK",android.R.drawable.stat_sys_warning);
}
}
private void initViews() {
startChantBtn = (Button) findViewById(R.id.startChantBtn);
editText = (EditText) findViewById(R.id.editText);
readMoreTxt = (TextView) findViewById(R.id.readMoreTextView);
}
private void initToolbar() {
toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
MainActivity.this.setTitle("");
toolbar.findViewById(R.id.toolbar_title).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Helper.openLink(MainActivity.this,"http://www.saihere.com/more-app.html");
}
});
}
@Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.startChantBtn:
startChant();
break;
case R.id.readMoreTextView:
startActivity(new Intent(MainActivity.this,About.class));
break;
}
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.home_menu,menu);
return super.onCreateOptionsMenu(menu);
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.menu_share:
Helper.shareApp(MainActivity.this);
break;
case R.id.menu_about_us:
startActivity(new Intent(MainActivity.this,About.class));
break;
}
return super.onOptionsItemSelected(item);
}
@Override
protected void onPause() {
if (adView != null)
adView.pause();
super.onPause();
}
@Override
protected void onResume() {
if (adView != null) {
adView.resume();
}
super.onResume();
count = 0;
}
@Override
protected void onDestroy() {
super.onDestroy();
if (adView != null) {
adView.destroy();
}
}
private void setNotification() {
Calendar calendar = Calendar.getInstance();
calendar.set(Calendar.HOUR_OF_DAY,6);
calendar.set(Calendar.MINUTE,30);
Intent intent = new Intent(getApplicationContext(),NotificationReceiver.class);
PendingIntent pendingIntent = PendingIntent.getBroadcast(getApplicationContext(),100,intent,PendingIntent.FLAG_UPDATE_CURRENT);
AlarmManager alarmManager = (AlarmManager) getSystemService(ALARM_SERVICE);
alarmManager.setRepeating(AlarmManager.RTC_WAKEUP, calendar.getTimeInMillis(), AlarmManager.INTERVAL_DAY, pendingIntent);
}
}
| UTF-8 | Java | 5,745 | java | MainActivity.java | Java | [] | null | [] | package com.sairajen.saibabamantra;
import android.app.AlarmManager;
import android.app.PendingIntent;
import android.content.Intent;
import android.graphics.Color;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.support.v7.widget.Toolbar;
import android.view.KeyEvent;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.inputmethod.EditorInfo;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import com.google.android.gms.ads.AdRequest;
import com.google.android.gms.ads.AdView;
import com.google.android.gms.ads.MobileAds;
import java.util.Calendar;
public class MainActivity extends AppCompatActivity implements View.OnClickListener {
private Toolbar toolbar;
private Button startChantBtn;
private EditText editText;
private TextView readMoreTxt;
private AdView adView;
private int count = 0;
private final static String INTENT_COUNT = "count";
private SharedPref sharedPref;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
initToolbar();
initViews();
sharedPref = new SharedPref(MainActivity.this);
if (sharedPref.isFirstTime()) {
sharedPref.setFirstTime(false);
setNotification();
}
MobileAds.initialize(getApplicationContext(),getResources().getString(R.string.banner_ad));
adView = (AdView) findViewById(R.id.adViewMainActivity);
AdRequest adRequest = new AdRequest.Builder().build();
adView.loadAd(adRequest);
startChantBtn.setOnClickListener(this);
readMoreTxt.setOnClickListener(this);
editText.setOnEditorActionListener(new TextView.OnEditorActionListener() {
@Override
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
if ((event != null && (event.getKeyCode() == KeyEvent.KEYCODE_ENTER)) || (actionId == EditorInfo.IME_ACTION_DONE)) {
startChant();
}
return false;
}
});
}
private void startChant() {
if (editText.getText().toString().trim() != null && !editText.getText().toString().trim().equals("")) {
count = Integer.parseInt(editText.getText().toString().trim());
if (count>0 && count < 1000) {
Intent intent = new Intent(MainActivity.this, MediaPlayerActivity.class);
intent.putExtra(INTENT_COUNT, count);
startActivity(intent);
} else {
Helper.showDialog(MainActivity.this,"ERROR","please enter count value betweeen 0 and 1000","OK",android.R.drawable.stat_sys_warning);
}
} else {
Helper.showDialog(MainActivity.this,"ERROR","please enter valid count value before proceeding","OK",android.R.drawable.stat_sys_warning);
}
}
private void initViews() {
startChantBtn = (Button) findViewById(R.id.startChantBtn);
editText = (EditText) findViewById(R.id.editText);
readMoreTxt = (TextView) findViewById(R.id.readMoreTextView);
}
private void initToolbar() {
toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
MainActivity.this.setTitle("");
toolbar.findViewById(R.id.toolbar_title).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Helper.openLink(MainActivity.this,"http://www.saihere.com/more-app.html");
}
});
}
@Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.startChantBtn:
startChant();
break;
case R.id.readMoreTextView:
startActivity(new Intent(MainActivity.this,About.class));
break;
}
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.home_menu,menu);
return super.onCreateOptionsMenu(menu);
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.menu_share:
Helper.shareApp(MainActivity.this);
break;
case R.id.menu_about_us:
startActivity(new Intent(MainActivity.this,About.class));
break;
}
return super.onOptionsItemSelected(item);
}
@Override
protected void onPause() {
if (adView != null)
adView.pause();
super.onPause();
}
@Override
protected void onResume() {
if (adView != null) {
adView.resume();
}
super.onResume();
count = 0;
}
@Override
protected void onDestroy() {
super.onDestroy();
if (adView != null) {
adView.destroy();
}
}
private void setNotification() {
Calendar calendar = Calendar.getInstance();
calendar.set(Calendar.HOUR_OF_DAY,6);
calendar.set(Calendar.MINUTE,30);
Intent intent = new Intent(getApplicationContext(),NotificationReceiver.class);
PendingIntent pendingIntent = PendingIntent.getBroadcast(getApplicationContext(),100,intent,PendingIntent.FLAG_UPDATE_CURRENT);
AlarmManager alarmManager = (AlarmManager) getSystemService(ALARM_SERVICE);
alarmManager.setRepeating(AlarmManager.RTC_WAKEUP, calendar.getTimeInMillis(), AlarmManager.INTERVAL_DAY, pendingIntent);
}
}
| 5,745 | 0.637076 | 0.633594 | 174 | 32.017242 | 30.268999 | 149 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.637931 | false | false | 9 |
eee8060d8ce15637a4247035d9568aebc9796a79 | 23,888,608,109,595 | 66b079a53963bce2d14af39ea8043ffe5a153a33 | /src/test/java/testngexampleTest.java | 751d981c2376f3f829f27c70cd96657df235d54b | [] | no_license | alexsavenok-savenduk/MvnTestProject | https://github.com/alexsavenok-savenduk/MvnTestProject | a48a8e20a142a2bad236ddaf0fc00015dc66a66e | edc170fa620fe07990fb9368bec4714d9a87ade9 | refs/heads/master | 2021-06-10T17:09:17.965000 | 2016-12-27T15:07:27 | 2016-12-27T15:07:27 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
/**
* Created by AlexanderSavenok on 12/27/2016.
*/
public class testngexampleTest {
@Test(dataProvider = "getClient2Data")
public void firstTest() {
}
@DataProvider
public static Object[][] getClient2Data() {
return new Object[][]{
{2},
{3},
{5}
};
}
}
| UTF-8 | Java | 431 | java | testngexampleTest.java | Java | [
{
"context": "rt org.testng.annotations.Test;\n\n/**\n * Created by AlexanderSavenok on 12/27/2016.\n */\npublic class testngexampleTest",
"end": 115,
"score": 0.9997346997261047,
"start": 99,
"tag": "NAME",
"value": "AlexanderSavenok"
}
] | null | [] | import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
/**
* Created by AlexanderSavenok on 12/27/2016.
*/
public class testngexampleTest {
@Test(dataProvider = "getClient2Data")
public void firstTest() {
}
@DataProvider
public static Object[][] getClient2Data() {
return new Object[][]{
{2},
{3},
{5}
};
}
}
| 431 | 0.561485 | 0.531322 | 25 | 16.24 | 16.568113 | 47 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.2 | false | false | 9 |
f069c49b749b71810144cf033ea2a1e08c383156 | 26,826,365,760,088 | 2d874eaa413b1ff65827a431200aa45b7d7a74d3 | /app/src/main/java/uk/ac/aber/vocabhelper/vocabhelper/VocabAddModel.java | 5ff8f1128e0509d1fa1d72fcf033a5bbbfbdf4d3 | [] | no_license | Eithen1/VocabHelper | https://github.com/Eithen1/VocabHelper | cb69da7dc26e619e9661fe8ba25fa0d5afef80f2 | b60fed85e5dbf84799ed35715260dae815947c49 | refs/heads/master | 2020-08-15T10:03:06.461000 | 2019-10-16T21:15:08 | 2019-10-16T21:15:08 | 215,322,368 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package uk.ac.aber.vocabhelper.vocabhelper;
import android.app.Application;
import android.arch.lifecycle.AndroidViewModel;
import android.support.annotation.NonNull;
import uk.ac.aber.vocabhelper.vocabhelper.datasource.VocabRepository;
public class VocabAddModel extends AndroidViewModel {
private VocabRepository repository;
public VocabAddModel(@NonNull Application application){
super(application);
repository = new VocabRepository(application);
}
public void insertVocab(Vocab vocab){
repository.insert(vocab);
}
}
| UTF-8 | Java | 541 | java | VocabAddModel.java | Java | [] | null | [] | package uk.ac.aber.vocabhelper.vocabhelper;
import android.app.Application;
import android.arch.lifecycle.AndroidViewModel;
import android.support.annotation.NonNull;
import uk.ac.aber.vocabhelper.vocabhelper.datasource.VocabRepository;
public class VocabAddModel extends AndroidViewModel {
private VocabRepository repository;
public VocabAddModel(@NonNull Application application){
super(application);
repository = new VocabRepository(application);
}
public void insertVocab(Vocab vocab){
repository.insert(vocab);
}
}
| 541 | 0.809612 | 0.809612 | 20 | 26.049999 | 22.69025 | 69 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.45 | false | false | 9 |
db87c1a7e3700294cd87ccbea5a90e6ecabba37d | 30,537,217,496,946 | e5fa2bd47f350d96ab342a6021eea20a2d5196ac | /Diccionario-MVC/src/controlador/ControladorPalabra.java | d4c6e26c9520d0de0689227ae7ba58932a7cf817 | [] | no_license | EduardoGuerraSanchez/PSP-EXTRA | https://github.com/EduardoGuerraSanchez/PSP-EXTRA | 36fd2700d29115d732d156a2d0c2abe9f2183571 | bb5b2b941ac1ba0190a70dab437374e974abc0a7 | refs/heads/master | 2023-06-07T13:23:05.978000 | 2021-06-21T20:32:47 | 2021-06-21T20:32:47 | 358,318,840 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package controlador;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Scanner;
import modelo.Palabra;
public class ControladorPalabra {
private ArrayList<Palabra> arrayControladorPalabra;
public ControladorPalabra() {
arrayControladorPalabra = new ArrayList<Palabra>();
}
public ArrayList<Palabra> getArrayControladorPalabra() {
return arrayControladorPalabra;
}
public void setArrayControladorPalabra(ArrayList<Palabra> arrayControladorPalabra) {
this.arrayControladorPalabra = arrayControladorPalabra;
}
public ArrayList<Palabra> getTablaPalabra() throws SQLException {
Palabra palabra = new Palabra();
this.setArrayControladorPalabra(palabra.getPalabraBD());
return this.arrayControladorPalabra;
}
public int traerUnaPalabra(String nombre) throws SQLException {
Palabra palabra = new Palabra();
int numero = 0;
this.setArrayControladorPalabra(palabra.getPalabraBD());
for (int contador = 0; contador < this.arrayControladorPalabra.size(); contador++) {
if (this.arrayControladorPalabra.get(contador).getNombre().contains(nombre)) {
numero = contador;
}
}
return numero;
}
public ArrayList insertarPalabra(String nombre,String definicion) throws SQLException {
Palabra palabra = new Palabra();
this.setArrayControladorPalabra(palabra.getPalabraBD());
palabra.crearPalabra(nombre,definicion);
this.arrayControladorPalabra.add(palabra);
return this.arrayControladorPalabra;
}
public boolean comprobarSiExiste(String nombre) throws SQLException{
boolean encontrado = false;
Palabra palabra = new Palabra();
this.setArrayControladorPalabra(palabra.getPalabraBD());
for (int contador = 0; contador < this.arrayControladorPalabra.size(); contador++) {
if (this.arrayControladorPalabra.get(contador).getNombre().contains(nombre)) {
encontrado = true;
}
}
return encontrado;
}
public ArrayList actualizarPalabra(String nombre,String definicion) throws SQLException{
Palabra palabra = new Palabra();
this.setArrayControladorPalabra(palabra.getPalabraBD());
// palabra.modificarPalabra(nombre, definicion);
for (int contador = 0; contador < this.arrayControladorPalabra.size(); contador++) {
if (this.arrayControladorPalabra.get(contador).getNombre().contains(nombre)) {
palabra.modificarPalabra(nombre, definicion);
}
}
return this.arrayControladorPalabra;
}
public ArrayList borrarPalabra(String nombre) throws SQLException {
Palabra palabra = new Palabra();
this.setArrayControladorPalabra(palabra.getPalabraBD());
palabra.eliminarPalabra(nombre);
for (int contador = 0; contador < this.arrayControladorPalabra.size(); contador++) {
if (this.arrayControladorPalabra.get(contador).getNombre().contains(nombre)) {
this.arrayControladorPalabra.remove(contador);
}
}
return this.arrayControladorPalabra;
}
} | UTF-8 | Java | 3,446 | java | ControladorPalabra.java | Java | [] | null | [] | package controlador;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Scanner;
import modelo.Palabra;
public class ControladorPalabra {
private ArrayList<Palabra> arrayControladorPalabra;
public ControladorPalabra() {
arrayControladorPalabra = new ArrayList<Palabra>();
}
public ArrayList<Palabra> getArrayControladorPalabra() {
return arrayControladorPalabra;
}
public void setArrayControladorPalabra(ArrayList<Palabra> arrayControladorPalabra) {
this.arrayControladorPalabra = arrayControladorPalabra;
}
public ArrayList<Palabra> getTablaPalabra() throws SQLException {
Palabra palabra = new Palabra();
this.setArrayControladorPalabra(palabra.getPalabraBD());
return this.arrayControladorPalabra;
}
public int traerUnaPalabra(String nombre) throws SQLException {
Palabra palabra = new Palabra();
int numero = 0;
this.setArrayControladorPalabra(palabra.getPalabraBD());
for (int contador = 0; contador < this.arrayControladorPalabra.size(); contador++) {
if (this.arrayControladorPalabra.get(contador).getNombre().contains(nombre)) {
numero = contador;
}
}
return numero;
}
public ArrayList insertarPalabra(String nombre,String definicion) throws SQLException {
Palabra palabra = new Palabra();
this.setArrayControladorPalabra(palabra.getPalabraBD());
palabra.crearPalabra(nombre,definicion);
this.arrayControladorPalabra.add(palabra);
return this.arrayControladorPalabra;
}
public boolean comprobarSiExiste(String nombre) throws SQLException{
boolean encontrado = false;
Palabra palabra = new Palabra();
this.setArrayControladorPalabra(palabra.getPalabraBD());
for (int contador = 0; contador < this.arrayControladorPalabra.size(); contador++) {
if (this.arrayControladorPalabra.get(contador).getNombre().contains(nombre)) {
encontrado = true;
}
}
return encontrado;
}
public ArrayList actualizarPalabra(String nombre,String definicion) throws SQLException{
Palabra palabra = new Palabra();
this.setArrayControladorPalabra(palabra.getPalabraBD());
// palabra.modificarPalabra(nombre, definicion);
for (int contador = 0; contador < this.arrayControladorPalabra.size(); contador++) {
if (this.arrayControladorPalabra.get(contador).getNombre().contains(nombre)) {
palabra.modificarPalabra(nombre, definicion);
}
}
return this.arrayControladorPalabra;
}
public ArrayList borrarPalabra(String nombre) throws SQLException {
Palabra palabra = new Palabra();
this.setArrayControladorPalabra(palabra.getPalabraBD());
palabra.eliminarPalabra(nombre);
for (int contador = 0; contador < this.arrayControladorPalabra.size(); contador++) {
if (this.arrayControladorPalabra.get(contador).getNombre().contains(nombre)) {
this.arrayControladorPalabra.remove(contador);
}
}
return this.arrayControladorPalabra;
}
} | 3,446 | 0.640453 | 0.639002 | 116 | 28.715517 | 29.660669 | 92 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.431034 | false | false | 9 |
b638758ab513920e1750d77d33b4ec70fc66e974 | 25,847,113,234,786 | 15367cd60da140cd52bbbfc8c0f1547f926b3193 | /ouip-app/ouip-portal/src/test/java/org/codingtoy/ouip/domain/UserRepositoryTest.java | a31ef10466f9e81c8259dadb0e2ae311a44733c8 | [
"MIT"
] | permissive | reactNew/OUIP | https://github.com/reactNew/OUIP | 7374e5b87a1226a163981d400c4d867e73f0b5d5 | c2234a9b5d096e6d0eab6aa924ce7b3be4b48619 | refs/heads/master | 2020-03-16T15:18:18.412000 | 2018-05-09T09:51:04 | 2018-05-09T09:51:04 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | /*
* Copyright (c) 2018-present the original author or authors.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
package org.codingtoy.ouip.domain;
import java.util.ArrayList;
import java.util.List;
import org.codingtoy.ouip.BaseTest;
import org.junit.Assert;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
/**
*
* @author 7cat
* @since 1.0
*/
public class UserRepositoryTest extends BaseTest {
@Autowired
private FunctionRepository functionRepository;
@Autowired
private UserRepository userRepository;
@Test
public void test() {
User user = new User();
user.setPhoneNo("18603010481");
user.setUsername("7upcat");
user.setPassword("123456");
user.setEmail("7upcat@gmail.com");
user.setGender(User.GENDER_MALE);
user.setStatus(User.STATUS_ACTIVE);
Function function01 = new Function();
function01.setCode("FUNC01");
function01.setName("TestFunction1");
function01.setType(Function.FUNCTION_CODE_MENU);
Function function02 = new Function();
function02.setCode("FUNC02");
function02.setName("TestFunction2");
function02.setType(Function.FUNCTION_CODE_MENU);
Function homeFunction = new Function();
homeFunction.setCode("FUNC03");
homeFunction.setName("HomeFunction");
homeFunction.setType(Function.FUNCTION_CODE_MENU);
functionRepository.save(homeFunction);
List<Function> functions = new ArrayList<>();
functions.add(function01);
functions.add(function02);
functionRepository.saveAll(functions);
UserSetting userSetting = new UserSetting();
userSetting.setFavFunctions(functions);
userSetting.setHomeFunction(homeFunction);
user.setUserSetting(userSetting);
userRepository.save(user);
user = userRepository.findOneByUsernameAndPassword("7upcat", "123456");
Assert.assertNotNull(user.getUserSetting());
Assert.assertEquals(2, user.getUserSetting().getFavFunctions().size());
Assert.assertNotNull(user.getUserSetting().getHomeFunction());
}
}
| UTF-8 | Java | 3,001 | java | UserRepositoryTest.java | Java | [
{
"context": "factory.annotation.Autowired;\n\n/**\n * \n * @author 7cat\n * @since 1.0\n */\npublic class UserRepositoryTest",
"end": 1407,
"score": 0.9995232820510864,
"start": 1403,
"tag": "USERNAME",
"value": "7cat"
},
{
"context": "er.setPhoneNo(\"18603010481\");\n\t\tuser.setUs... | null | [] | /*
* Copyright (c) 2018-present the original author or authors.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
package org.codingtoy.ouip.domain;
import java.util.ArrayList;
import java.util.List;
import org.codingtoy.ouip.BaseTest;
import org.junit.Assert;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
/**
*
* @author 7cat
* @since 1.0
*/
public class UserRepositoryTest extends BaseTest {
@Autowired
private FunctionRepository functionRepository;
@Autowired
private UserRepository userRepository;
@Test
public void test() {
User user = new User();
user.setPhoneNo("18603010481");
user.setUsername("7upcat");
user.setPassword("<PASSWORD>");
user.setEmail("<EMAIL>");
user.setGender(User.GENDER_MALE);
user.setStatus(User.STATUS_ACTIVE);
Function function01 = new Function();
function01.setCode("FUNC01");
function01.setName("TestFunction1");
function01.setType(Function.FUNCTION_CODE_MENU);
Function function02 = new Function();
function02.setCode("FUNC02");
function02.setName("TestFunction2");
function02.setType(Function.FUNCTION_CODE_MENU);
Function homeFunction = new Function();
homeFunction.setCode("FUNC03");
homeFunction.setName("HomeFunction");
homeFunction.setType(Function.FUNCTION_CODE_MENU);
functionRepository.save(homeFunction);
List<Function> functions = new ArrayList<>();
functions.add(function01);
functions.add(function02);
functionRepository.saveAll(functions);
UserSetting userSetting = new UserSetting();
userSetting.setFavFunctions(functions);
userSetting.setHomeFunction(homeFunction);
user.setUserSetting(userSetting);
userRepository.save(user);
user = userRepository.findOneByUsernameAndPassword("7upcat", "<PASSWORD>");
Assert.assertNotNull(user.getUserSetting());
Assert.assertEquals(2, user.getUserSetting().getFavFunctions().size());
Assert.assertNotNull(user.getUserSetting().getHomeFunction());
}
}
| 3,000 | 0.762746 | 0.742086 | 87 | 33.494251 | 24.410227 | 73 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.597701 | false | false | 9 |
6668403e17fbd659d74d588709afbce1d8b9cfb5 | 7,206,955,172,763 | 692cb1b15ad81f21c6c134adcca0e9493bda759e | /2020 summer prep/array, string/src/TreeNode.java | c3b934c49dca872073ae8c060a38ca47735d4c08 | [] | no_license | melindajohnson/Interview_Practise | https://github.com/melindajohnson/Interview_Practise | 27fd59cb52e4f0eee374eb35f5d40b1fafe170b8 | a113f27aa6b1c043057a670c0afe57ef1d809834 | refs/heads/main | 2023-02-03T14:52:33.337000 | 2020-12-01T19:21:03 | 2020-12-01T19:21:03 | 305,843,552 | 0 | 0 | null | false | 2020-12-01T19:21:05 | 2020-10-20T22:01:49 | 2020-10-20T22:01:54 | 2020-12-01T19:21:04 | 0 | 0 | 0 | 0 | null | false | false |
class TreeNode {
int val;
TreeNode left;
TreeNode right;
TreeNode parent;
TreeNode(int x) {
val = x;
}
};
//
//
//public class ListNode {
// int value = 0;
// ListNode next;
//
// ListNode(int value) {
// this.value = value;
// }
//}
// public static void reorder(ListNode head) {
// ListNode fast = head;
// ListNode slow = head;
// while (fast != null && fast.next != null) {
// fast = fast.next.next;
// slow = slow.next;
// }
// ListNode secondHalf = reverse(slow);
// ListNode secondHalfHead = secondHalf;
// ListNode FirstHalfHead = head;
// while (FirstHalfHead.next.next != null) {
//
// ListNode temp = FirstHalfHead.next;
// FirstHalfHead.next = secondHalfHead;
// FirstHalfHead = temp;
//
// ListNode secondHeadNext = secondHalfHead.next;
// secondHalfHead.next = temp;
// if(secondHalfHead==secondHeadNext) break;
// FirstHalfHead = temp;
// secondHalfHead = secondHeadNext;
//
// }
// }
// private static ListNode reverse(ListNode head) {
// ListNode prev = null;
// while(head!=null){
// ListNode next = head.next;
// head.next = prev;
// prev = head;
// head = next;
// }
// return prev;
// }
//
//
//
//} | UTF-8 | Java | 1,437 | java | TreeNode.java | Java | [] | null | [] |
class TreeNode {
int val;
TreeNode left;
TreeNode right;
TreeNode parent;
TreeNode(int x) {
val = x;
}
};
//
//
//public class ListNode {
// int value = 0;
// ListNode next;
//
// ListNode(int value) {
// this.value = value;
// }
//}
// public static void reorder(ListNode head) {
// ListNode fast = head;
// ListNode slow = head;
// while (fast != null && fast.next != null) {
// fast = fast.next.next;
// slow = slow.next;
// }
// ListNode secondHalf = reverse(slow);
// ListNode secondHalfHead = secondHalf;
// ListNode FirstHalfHead = head;
// while (FirstHalfHead.next.next != null) {
//
// ListNode temp = FirstHalfHead.next;
// FirstHalfHead.next = secondHalfHead;
// FirstHalfHead = temp;
//
// ListNode secondHeadNext = secondHalfHead.next;
// secondHalfHead.next = temp;
// if(secondHalfHead==secondHeadNext) break;
// FirstHalfHead = temp;
// secondHalfHead = secondHeadNext;
//
// }
// }
// private static ListNode reverse(ListNode head) {
// ListNode prev = null;
// while(head!=null){
// ListNode next = head.next;
// head.next = prev;
// prev = head;
// head = next;
// }
// return prev;
// }
//
//
//
//} | 1,437 | 0.505219 | 0.504523 | 63 | 21.777779 | 18.098886 | 60 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.47619 | false | false | 9 |
62309eecf4639a34d7b688df42e6de0b09458858 | 22,660,247,513,313 | 935a5ae77fa4aa4c519a93c3d2def34d15110dbb | /src/Main.java | facb10e0f0ba367bd5565ddbacfa427f084dec71 | [] | no_license | ennoace/FatFighters | https://github.com/ennoace/FatFighters | 3056388ccf967f0d042958e94cad266950a09099 | daf43c58d6796b03ed3e98adf2f27db7a6b0f120 | refs/heads/master | 2016-05-22T04:50:32.636000 | 2015-09-10T16:00:44 | 2015-09-10T16:00:44 | 42,255,034 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | import java.io.IOException;
import java.util.Random;
import java.util.Scanner;
public class Main {
public static void main(String[] args) throws IOException {
Scanner scanner = new Scanner(System.in);
Random random = new Random();
Player opponent;
Player player;
String opponentName;
String playerName;
System.out.println("Enter your name:");
String name = scanner.next();
Players players = new Players(name);
player = players.getPlayer();
playerName = player.getName();
System.out.println("Your name is " + playerName);
int randomIndex = random.nextInt(players.getNpcList().size());
opponent = players.getNpcList().get(randomIndex);
opponentName = opponent.getName();
System.out.println("\nYour stats: \nName: " + playerName + "\nWeight: " + player.getWeight() + " kg");
System.out.println("\nOpponents stats: \nName: " + opponentName + "\nWeight: " + opponent.getWeight() + " kg");
Fight fight = new Fight(player, opponent);
Player winner = fight.winner();
if(winner != null){
String winnerName = winner.getName();
if(winnerName.equals(playerName)) System.out.println("\nYou won");
else if(winnerName.equals(opponentName)) System.out.println("\nYou lose");
} else System.out.println("\nIt's a draw");
}
}
| UTF-8 | Java | 1,426 | java | Main.java | Java | [] | null | [] | import java.io.IOException;
import java.util.Random;
import java.util.Scanner;
public class Main {
public static void main(String[] args) throws IOException {
Scanner scanner = new Scanner(System.in);
Random random = new Random();
Player opponent;
Player player;
String opponentName;
String playerName;
System.out.println("Enter your name:");
String name = scanner.next();
Players players = new Players(name);
player = players.getPlayer();
playerName = player.getName();
System.out.println("Your name is " + playerName);
int randomIndex = random.nextInt(players.getNpcList().size());
opponent = players.getNpcList().get(randomIndex);
opponentName = opponent.getName();
System.out.println("\nYour stats: \nName: " + playerName + "\nWeight: " + player.getWeight() + " kg");
System.out.println("\nOpponents stats: \nName: " + opponentName + "\nWeight: " + opponent.getWeight() + " kg");
Fight fight = new Fight(player, opponent);
Player winner = fight.winner();
if(winner != null){
String winnerName = winner.getName();
if(winnerName.equals(playerName)) System.out.println("\nYou won");
else if(winnerName.equals(opponentName)) System.out.println("\nYou lose");
} else System.out.println("\nIt's a draw");
}
}
| 1,426 | 0.620617 | 0.620617 | 38 | 36.526318 | 29.406172 | 119 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.710526 | false | false | 9 |
0f0ad0c52932b6b8a8ca2443c2ac954f9f6dbf13 | 27,187,143,027,427 | 5049e4cb7bfc5008ff3406f416278b838f847cca | /src/main/java/com/eduhansol/app/services/ReportServiceImpl.java | e33e4f48c8ef815e3fb4c941c891d583a2e7d366 | [] | no_license | tychejin1218/hansol-personality | https://github.com/tychejin1218/hansol-personality | 7183ce083a7e68b4e5ea205874bdfda11639e74c | d8186a3d50a23f9fd45ef672356d24d39c3eae4e | refs/heads/master | 2023-07-07T17:39:03.149000 | 2021-08-13T02:04:13 | 2021-08-13T02:04:13 | 395,489,557 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.eduhansol.app.services;
import java.util.List;
import com.eduhansol.app.entities.Report;
import com.eduhansol.app.repositories.ReportRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@Service
public class ReportServiceImpl implements ReportService {
private final ReportRepository _reportRepository;
@Autowired
public ReportServiceImpl(ReportRepository reportRepository) {
_reportRepository = reportRepository;
}
@Override
public List<Report> getList() {
return _reportRepository.findAll();
}
@Override
public Report get(int id) {
return _reportRepository.findById(id).get();
}
} | UTF-8 | Java | 735 | java | ReportServiceImpl.java | Java | [] | null | [] | package com.eduhansol.app.services;
import java.util.List;
import com.eduhansol.app.entities.Report;
import com.eduhansol.app.repositories.ReportRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@Service
public class ReportServiceImpl implements ReportService {
private final ReportRepository _reportRepository;
@Autowired
public ReportServiceImpl(ReportRepository reportRepository) {
_reportRepository = reportRepository;
}
@Override
public List<Report> getList() {
return _reportRepository.findAll();
}
@Override
public Report get(int id) {
return _reportRepository.findById(id).get();
}
} | 735 | 0.746939 | 0.746939 | 30 | 23.533333 | 22.716709 | 65 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.333333 | false | false | 9 |
6ef4132a83cbb869b9f1abb9bba16551efcfb706 | 17,617,955,895,419 | 3535f478b7d835c3e93eb1255ec836bb0c762f51 | /AndFrameWorks-andframe-v14/src/main/java/com/andframe/widget/treeview/AfTreeEstablisher.java | 3728cc90151bc623dabbc3b9f82970e76079c16b | [] | no_license | huyongqiang/com.example.goals.listviewsignalandmultiplechoice | https://github.com/huyongqiang/com.example.goals.listviewsignalandmultiplechoice | 6bc53482cf137d3769dbf9f23e78c27e5e3c8cf8 | fc8688858c7f18a16527d30749b6ce9b6989afee | refs/heads/master | 2021-01-22T10:46:44.867000 | 2018-12-20T07:43:56 | 2018-12-20T07:43:56 | 82,032,751 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.andframe.widget.treeview;
import java.util.Collection;
public class AfTreeEstablisher<T>{
protected AfTreeNodeable<T> mNodeable = null;
protected AfTreeEstablishable<T> mEstablishable = null;
public AfTreeEstablisher(AfTreeNodeable<T> nodeable) {
mNodeable = nodeable;
}
public AfTreeEstablisher(AfTreeEstablishable<T> establishable) {
mEstablishable = establishable;
}
public AfTreeNode<T> establish(Collection<? extends T> collect,boolean isExpanded){
if(mNodeable != null){
return establish(collect,mNodeable,isExpanded);
}else if (mEstablishable != null) {
return establish(collect,mEstablishable,isExpanded);
}
throw new NullPointerException("AfTreeable = null");
}
public AfTreeNode<T> establish(Collection<? extends T> collect,AfTreeNodeable<T> able,boolean isExpanded) {
return new AfTreeNode<T>(collect, able,isExpanded);
}
public AfTreeNode<T> establish(Collection<? extends T> collect,AfTreeEstablishable<T> able,boolean isExpanded) {
return new AfTreeNode<T>(collect, able,isExpanded);
}
}
| UTF-8 | Java | 1,059 | java | AfTreeEstablisher.java | Java | [] | null | [] | package com.andframe.widget.treeview;
import java.util.Collection;
public class AfTreeEstablisher<T>{
protected AfTreeNodeable<T> mNodeable = null;
protected AfTreeEstablishable<T> mEstablishable = null;
public AfTreeEstablisher(AfTreeNodeable<T> nodeable) {
mNodeable = nodeable;
}
public AfTreeEstablisher(AfTreeEstablishable<T> establishable) {
mEstablishable = establishable;
}
public AfTreeNode<T> establish(Collection<? extends T> collect,boolean isExpanded){
if(mNodeable != null){
return establish(collect,mNodeable,isExpanded);
}else if (mEstablishable != null) {
return establish(collect,mEstablishable,isExpanded);
}
throw new NullPointerException("AfTreeable = null");
}
public AfTreeNode<T> establish(Collection<? extends T> collect,AfTreeNodeable<T> able,boolean isExpanded) {
return new AfTreeNode<T>(collect, able,isExpanded);
}
public AfTreeNode<T> establish(Collection<? extends T> collect,AfTreeEstablishable<T> able,boolean isExpanded) {
return new AfTreeNode<T>(collect, able,isExpanded);
}
}
| 1,059 | 0.766761 | 0.766761 | 35 | 29.257143 | 31.620377 | 113 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.714286 | false | false | 9 |
ab789d50f5b8985f6d2ffd92a8bda6b76225987d | 8,254,927,204,073 | 4fd7dd226443c84ed42473103e211043ea0b2e07 | /micro-service-oracle-feign/src/main/java/com/caafc/client/hystrics/TbWxApplyInfoServiceClientHystric.java | a04d3c6c76b58d7a812c0cfc1a67908b235c17e9 | [] | no_license | crashiers/weixin | https://github.com/crashiers/weixin | 8d3735ba5cd7df63f900bca4e3ccc8d7509b675d | 63515ab49bc10e87ba6e38bba5aaf9bc6cb92c52 | refs/heads/master | 2020-11-25T15:45:58.869000 | 2019-06-27T09:03:55 | 2019-06-27T09:03:55 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.caafc.client.hystrics;
/**
* Copyright (C),长安汽车金融有限公司
* FileName: com.caafc.client.hystrics
* Author: hhc
* Date: 2018/7/6
* Description:
* History:
* <author> <time> <version> <desc>
* 作者姓名 修改时间 版本号 描述
*/
import com.caafc.client.TbWxApiLogServiceClient;
import com.caafc.client.TbWxApplyInfoServiceClient;
import com.caafc.client.model.ProCarInfo;
import com.caafc.client.model.ProCarRequest;
import com.caafc.client.model.TbWxApplyInfo;
import com.github.pagehelper.PageInfo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.RequestParam;
import java.util.List;
/**
* Copyright (C),长安汽车金融有限公司
* FileName: com.caafc.client.hystrics
* Author: hhc
* Date: 2018/7/6
* Description:
* History:
* <author> <time> <version> <desc>
* 作者姓名 修改时间 版本号 描述
*/
@Component
public class TbWxApplyInfoServiceClientHystric implements TbWxApplyInfoServiceClient {
private static Logger logger = LoggerFactory.getLogger(TbWxApplyInfoServiceClientHystric.class);
@Override
public List<TbWxApplyInfo> selectTbWxApplyInfoList(String prodId, String modelCode, String applyCode, String prdCode, String statusLocal, Integer lowerLoanAmt, Long upperLoanAmt, String downRatio, String prdTerm) {
logger.error("TbWxApplyInfoServiceClientHystric selectTbWxApplyInfoList failed");
return null;
}
@Override
public PageInfo<ProCarInfo> selectProCarInfo(ProCarRequest proCarRequest) {
logger.error("TbWxApplyInfoServiceClientHystric selectProCarInfo failed");
return null;
}
@Override
public Integer insertTbWxApplyInfo(TbWxApplyInfo tbWxApplyInfo) {
logger.error("TbWxApplyInfoServiceClientHystric insertTbWxApplyInfo failed");
return null;
}
@Override
public Integer updateTbWxApplyInfo(TbWxApplyInfo tbWxApplyInfo) {
logger.error("TbWxApplyInfoServiceClientHystric updateTbWxApplyInfo failed");
return null;
}
@Override
public Integer deleteTbWxApplyInfoById(String prodId) {
logger.error("TbWxApplyInfoServiceClientHystric deleteTbWxApplyInfoById failed");
return null;
}
@Override
public PageInfo<TbWxApplyInfo> getPrdInfoList(String prdCode, String prdName, String statusLocal, Integer downRatio, Integer prdTerm, String calStatus, Integer pageNum, Integer pageSize){
logger.error("TbWxApplyInfoServiceClientHystric getPrdInfoList failed");
return null;
}
}
| UTF-8 | Java | 2,772 | java | TbWxApplyInfoServiceClientHystric.java | Java | [
{
"context": " FileName: com.caafc.client.hystrics\n * Author: hhc\n * Date: 2018/7/6\n * Description:\n * History:",
"end": 124,
"score": 0.9996429681777954,
"start": 121,
"tag": "USERNAME",
"value": "hhc"
},
{
"context": " FileName: com.caafc.client.hystrics\n * Author: h... | null | [] | package com.caafc.client.hystrics;
/**
* Copyright (C),长安汽车金融有限公司
* FileName: com.caafc.client.hystrics
* Author: hhc
* Date: 2018/7/6
* Description:
* History:
* <author> <time> <version> <desc>
* 作者姓名 修改时间 版本号 描述
*/
import com.caafc.client.TbWxApiLogServiceClient;
import com.caafc.client.TbWxApplyInfoServiceClient;
import com.caafc.client.model.ProCarInfo;
import com.caafc.client.model.ProCarRequest;
import com.caafc.client.model.TbWxApplyInfo;
import com.github.pagehelper.PageInfo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.RequestParam;
import java.util.List;
/**
* Copyright (C),长安汽车金融有限公司
* FileName: com.caafc.client.hystrics
* Author: hhc
* Date: 2018/7/6
* Description:
* History:
* <author> <time> <version> <desc>
* 作者姓名 修改时间 版本号 描述
*/
@Component
public class TbWxApplyInfoServiceClientHystric implements TbWxApplyInfoServiceClient {
private static Logger logger = LoggerFactory.getLogger(TbWxApplyInfoServiceClientHystric.class);
@Override
public List<TbWxApplyInfo> selectTbWxApplyInfoList(String prodId, String modelCode, String applyCode, String prdCode, String statusLocal, Integer lowerLoanAmt, Long upperLoanAmt, String downRatio, String prdTerm) {
logger.error("TbWxApplyInfoServiceClientHystric selectTbWxApplyInfoList failed");
return null;
}
@Override
public PageInfo<ProCarInfo> selectProCarInfo(ProCarRequest proCarRequest) {
logger.error("TbWxApplyInfoServiceClientHystric selectProCarInfo failed");
return null;
}
@Override
public Integer insertTbWxApplyInfo(TbWxApplyInfo tbWxApplyInfo) {
logger.error("TbWxApplyInfoServiceClientHystric insertTbWxApplyInfo failed");
return null;
}
@Override
public Integer updateTbWxApplyInfo(TbWxApplyInfo tbWxApplyInfo) {
logger.error("TbWxApplyInfoServiceClientHystric updateTbWxApplyInfo failed");
return null;
}
@Override
public Integer deleteTbWxApplyInfoById(String prodId) {
logger.error("TbWxApplyInfoServiceClientHystric deleteTbWxApplyInfoById failed");
return null;
}
@Override
public PageInfo<TbWxApplyInfo> getPrdInfoList(String prdCode, String prdName, String statusLocal, Integer downRatio, Integer prdTerm, String calStatus, Integer pageNum, Integer pageSize){
logger.error("TbWxApplyInfoServiceClientHystric getPrdInfoList failed");
return null;
}
}
| 2,772 | 0.720149 | 0.714925 | 75 | 34.720001 | 39.674866 | 218 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.56 | false | false | 9 |
86b6a040428f24ba83bc85ca5920c7eb8ccf97c7 | 20,134,806,742,547 | f850ef05bd64dbd008fc1907b5750e0e9f92618f | /src/Modelo/Lugar.java | 1dd1578031b09d660f0b0c355042aacf48db7b70 | [] | no_license | reymundotenorio/TPF-Supervisor | https://github.com/reymundotenorio/TPF-Supervisor | 66cd5c914fbd0bcbf106002c0fe1ba45034bfe3b | f74670112e36d3e1f936204b341e5585e45e556e | refs/heads/master | 2018-02-18T12:23:05.455000 | 2018-01-28T22:27:17 | 2018-01-28T22:27:17 | 50,538,042 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package Modelo;
import Main.LugarP;
import java.sql.CallableStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import javax.swing.JOptionPane;
/**
*
* @author Reymundo Tenorio
*/
public class Lugar {
public static ResultSet resultado;
public static void Agregar_Lugar(String Nombre, String Descripcion, LugarP Lugar) {
try {
CallableStatement consulta = Conexion.con.prepareCall("{call Agregar_Lugar(?,?)}");
consulta.setString(1, Nombre);
consulta.setString(2, Descripcion);
consulta.execute();
JOptionPane.showMessageDialog(Lugar, "Datos del Lugar guardados correctamente", "Información", JOptionPane.INFORMATION_MESSAGE);
} catch (SQLException ex) {
JOptionPane.showMessageDialog(Lugar, ex.getMessage(), "Error al guardar Lugar", JOptionPane.ERROR_MESSAGE);
}
}
public static void Actualizar_Lugar(int ID, String Nombre, String Descripcion, LugarP Lugar) {
try {
CallableStatement consulta = Conexion.con.prepareCall("{call Editar_Lugar(?,?,?)}");
consulta.setInt(1, ID);
consulta.setString(2, Nombre);
consulta.setString(3, Descripcion);
consulta.execute();
JOptionPane.showMessageDialog(Lugar, "Datos del Lugar editados correctamente", "Información", JOptionPane.INFORMATION_MESSAGE);
} catch (SQLException ex) {
JOptionPane.showMessageDialog(Lugar, ex.getMessage(), "Error al editar Lugar", JOptionPane.ERROR_MESSAGE);
}
}
public static void Desactivar_Lugar(int ID, LugarP Lugar) {
try {
CallableStatement consulta = Conexion.con.prepareCall("{call Desactivar_Lugar (?)}");
consulta.setInt(1, ID);
consulta.execute();
} catch (SQLException ex) {
JOptionPane.showMessageDialog(Lugar, ex.getMessage(), "Error al desactivar Lugar", JOptionPane.ERROR_MESSAGE);
}
}
public static void Activar_Lugar(int ID, LugarP Lugar) {
try {
CallableStatement consulta = Conexion.con.prepareCall("{call Activar_Lugar (?)}");
consulta.setInt(1, ID);
consulta.execute();
} catch (SQLException ex) {
JOptionPane.showMessageDialog(Lugar, ex.getMessage(), "Error al activars Lugar", JOptionPane.ERROR_MESSAGE);
}
}
}
| UTF-8 | Java | 2,443 | java | Lugar.java | Java | [
{
"context": "import javax.swing.JOptionPane;\n\n/**\n *\n * @author Reymundo Tenorio\n */\npublic class Lugar {\n\n public static Resul",
"end": 196,
"score": 0.9998887181282043,
"start": 180,
"tag": "NAME",
"value": "Reymundo Tenorio"
}
] | null | [] | package Modelo;
import Main.LugarP;
import java.sql.CallableStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import javax.swing.JOptionPane;
/**
*
* @author <NAME>
*/
public class Lugar {
public static ResultSet resultado;
public static void Agregar_Lugar(String Nombre, String Descripcion, LugarP Lugar) {
try {
CallableStatement consulta = Conexion.con.prepareCall("{call Agregar_Lugar(?,?)}");
consulta.setString(1, Nombre);
consulta.setString(2, Descripcion);
consulta.execute();
JOptionPane.showMessageDialog(Lugar, "Datos del Lugar guardados correctamente", "Información", JOptionPane.INFORMATION_MESSAGE);
} catch (SQLException ex) {
JOptionPane.showMessageDialog(Lugar, ex.getMessage(), "Error al guardar Lugar", JOptionPane.ERROR_MESSAGE);
}
}
public static void Actualizar_Lugar(int ID, String Nombre, String Descripcion, LugarP Lugar) {
try {
CallableStatement consulta = Conexion.con.prepareCall("{call Editar_Lugar(?,?,?)}");
consulta.setInt(1, ID);
consulta.setString(2, Nombre);
consulta.setString(3, Descripcion);
consulta.execute();
JOptionPane.showMessageDialog(Lugar, "Datos del Lugar editados correctamente", "Información", JOptionPane.INFORMATION_MESSAGE);
} catch (SQLException ex) {
JOptionPane.showMessageDialog(Lugar, ex.getMessage(), "Error al editar Lugar", JOptionPane.ERROR_MESSAGE);
}
}
public static void Desactivar_Lugar(int ID, LugarP Lugar) {
try {
CallableStatement consulta = Conexion.con.prepareCall("{call Desactivar_Lugar (?)}");
consulta.setInt(1, ID);
consulta.execute();
} catch (SQLException ex) {
JOptionPane.showMessageDialog(Lugar, ex.getMessage(), "Error al desactivar Lugar", JOptionPane.ERROR_MESSAGE);
}
}
public static void Activar_Lugar(int ID, LugarP Lugar) {
try {
CallableStatement consulta = Conexion.con.prepareCall("{call Activar_Lugar (?)}");
consulta.setInt(1, ID);
consulta.execute();
} catch (SQLException ex) {
JOptionPane.showMessageDialog(Lugar, ex.getMessage(), "Error al activars Lugar", JOptionPane.ERROR_MESSAGE);
}
}
}
| 2,433 | 0.639082 | 0.636215 | 90 | 26.122223 | 37.176105 | 140 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.7 | false | false | 9 |
f15ce638ee02d0b043deaabc0a1a4abd71abdf82 | 609,885,422,063 | 8e2a21bd1bdd29b85c5587590adc5e5a60f76a0c | /src/map/TreeMap.java | 06c3c64fe00562d05f35d7b720092e8878bc4f77 | [] | no_license | mahonecon/DSA | https://github.com/mahonecon/DSA | a8f4f80f45708aa3bb48767dc56d0910d1c01f13 | 6883926de1a84fe4bbdc885bbc87f58619a2b17e | refs/heads/master | 2021-01-11T19:35:02.953000 | 2016-12-16T18:02:52 | 2016-12-16T18:02:52 | 50,144,887 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package map;
import list.ArrayList;
import list.Iterator;
import tree.*;
public class TreeMap<K extends Comparable, V> implements Map<K,V>{
BinaryTree<Entry<K,V>> tree = new EmptyBinarySearchTree<Entry<K,V>>();
int size = 0;
public boolean containsKey(K key){
Entry<K,V> entry = new Entry<K,V>(key,null);
return tree.containsKey(entry);
}
public V get(K key){
Entry<K,V> entry = new Entry<K,V>(key,null);
entry = tree.get(entry);
if(entry == null)return null;
return entry.value;
}
public V put(K key, V value){
Entry<K,V> newEntry = new Entry<K,V>(key,value);
Entry<K,V> oldEntry = tree.get(newEntry);
if(oldEntry == null){
tree=tree.add(newEntry);
size++;
return null;
}
V oldValue = oldEntry.value;
oldEntry.value = value;
return oldValue;
}
public V remove(K key){
Entry<K,V> entry = new Entry<K,V>(key,null);
entry = tree.get(entry);
if(entry == null)
return null;
tree=tree.remove(entry);
size--;
return entry.value;
}
public int size() {
return size;
}
public void clear() {
tree = new EmptyBinarySearchTree<Entry<K,V>>();
}
public boolean isEmpty() {
return size()==0;
}
public boolean hasDuplicateValues() {
Iterator<Entry<K,V>> itty = tree.iterator();
ArrayList<V> values = new ArrayList<V>();
Entry<K,V> e;
while(itty.hasNext()) {
e = itty.next();
if(values.contains(e.value)) {
return true;
}
values.add(e.value);
}
return false;
}
} | UTF-8 | Java | 1,461 | java | TreeMap.java | Java | [] | null | [] | package map;
import list.ArrayList;
import list.Iterator;
import tree.*;
public class TreeMap<K extends Comparable, V> implements Map<K,V>{
BinaryTree<Entry<K,V>> tree = new EmptyBinarySearchTree<Entry<K,V>>();
int size = 0;
public boolean containsKey(K key){
Entry<K,V> entry = new Entry<K,V>(key,null);
return tree.containsKey(entry);
}
public V get(K key){
Entry<K,V> entry = new Entry<K,V>(key,null);
entry = tree.get(entry);
if(entry == null)return null;
return entry.value;
}
public V put(K key, V value){
Entry<K,V> newEntry = new Entry<K,V>(key,value);
Entry<K,V> oldEntry = tree.get(newEntry);
if(oldEntry == null){
tree=tree.add(newEntry);
size++;
return null;
}
V oldValue = oldEntry.value;
oldEntry.value = value;
return oldValue;
}
public V remove(K key){
Entry<K,V> entry = new Entry<K,V>(key,null);
entry = tree.get(entry);
if(entry == null)
return null;
tree=tree.remove(entry);
size--;
return entry.value;
}
public int size() {
return size;
}
public void clear() {
tree = new EmptyBinarySearchTree<Entry<K,V>>();
}
public boolean isEmpty() {
return size()==0;
}
public boolean hasDuplicateValues() {
Iterator<Entry<K,V>> itty = tree.iterator();
ArrayList<V> values = new ArrayList<V>();
Entry<K,V> e;
while(itty.hasNext()) {
e = itty.next();
if(values.contains(e.value)) {
return true;
}
values.add(e.value);
}
return false;
}
} | 1,461 | 0.644764 | 0.643395 | 71 | 19.591549 | 16.739578 | 71 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 2.295775 | false | false | 9 |
d310e2ea21a0367f1559ecc9dce8fb563167f5f5 | 37,950,331,055,345 | 47c71e8efeff9585eb97536131e429e3c2aea52b | /src/main/java/org/pshiblo/compiler/Compiler.java | ebcc02ca3d4b82404aca973154bb49857e03eec4 | [] | no_license | Makunika/compiler | https://github.com/Makunika/compiler | f162a76182576696608b2dafd164e1b78e224251 | 1ea562813e42be1ae9d92cd4260521b204f03912 | refs/heads/master | 2023-01-22T22:08:48.394000 | 2020-11-17T09:57:40 | 2020-11-17T09:57:40 | 295,481,938 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package org.pshiblo.compiler;
public class Compiler {
public static void main(String[] args) {
//Lexis.analysisExpression("zat=10.0-20-40+10+10.0;");
//Lexis.analysisExpression("x;");
// try {
// Lexis.analysisDoWhile(
// "do\n{\nn=x+1;\na=g+s;\n} while(a >= b)\n"
// );
// } catch (MatcherCompileException e) {
// e.printStackTrace();
// }
}
}
| UTF-8 | Java | 445 | java | Compiler.java | Java | [] | null | [] | package org.pshiblo.compiler;
public class Compiler {
public static void main(String[] args) {
//Lexis.analysisExpression("zat=10.0-20-40+10+10.0;");
//Lexis.analysisExpression("x;");
// try {
// Lexis.analysisDoWhile(
// "do\n{\nn=x+1;\na=g+s;\n} while(a >= b)\n"
// );
// } catch (MatcherCompileException e) {
// e.printStackTrace();
// }
}
}
| 445 | 0.503371 | 0.474157 | 17 | 25.17647 | 20.920677 | 64 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.529412 | false | false | 9 |
a084c72654b6342a0c5c66f3ddbfb0ad531f76e0 | 39,539,468,934,770 | b25a29ed3c00c920a298106977231d9645f437b7 | /1 semester/progamming 1/hw/DN04/extensiveTests/Test06.java | 5900e30307657b8ca66cf696a25bf7d1f260ae4e | [
"MIT"
] | permissive | greenstatic/fri-undergraduate-coursework | https://github.com/greenstatic/fri-undergraduate-coursework | 75422a0100a2ab79e00065955b8fe19ed707fbad | 6f4c931f3fa590e85ece4d1be400c82839097d9d | refs/heads/master | 2017-12-02T10:11:35.060000 | 2017-10-11T21:38:24 | 2017-10-11T21:38:24 | 85,229,810 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
public class Test06 {
public static void main(String[] args) {
Nota nota = new Nota(1, 9);
System.out.println(nota.vrniOktavo());
}
}
| UTF-8 | Java | 160 | java | Test06.java | Java | [] | null | [] |
public class Test06 {
public static void main(String[] args) {
Nota nota = new Nota(1, 9);
System.out.println(nota.vrniOktavo());
}
}
| 160 | 0.5875 | 0.5625 | 7 | 21.714285 | 18.68318 | 46 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.428571 | false | false | 9 |
ff634124c926f4f9559734a9f0f7b4229ccc7480 | 12,240,656,796,395 | 028d6009f3beceba80316daa84b628496a210f8d | /project/com.nokia.carbide.cpp.epoc.engine/src/com/nokia/carbide/internal/cpp/epoc/engine/image/SVGSourceReference.java | 8d05fa533e00f265a061223f71f6cf281867f33d | [] | no_license | JamesLinus/oss.FCL.sftools.dev.ide.carbidecpp | https://github.com/JamesLinus/oss.FCL.sftools.dev.ide.carbidecpp | fa50cafa69d3e317abf0db0f4e3e557150fd88b3 | 4420f338bc4e522c563f8899d81201857236a66a | refs/heads/master | 2020-12-30T16:45:28.474000 | 2010-10-20T16:19:31 | 2010-10-20T16:19:31 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | /*
* Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
* All rights reserved.
* This component and the accompanying materials are made available
* under the terms of the License "Eclipse Public License v1.0"
* which accompanies this distribution, and is available
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
*
* Initial Contributors:
* Nokia Corporation - initial contribution.
*
* Contributors:
*
* Description:
*
*/
package com.nokia.carbide.internal.cpp.epoc.engine.image;
import com.nokia.carbide.cpp.epoc.engine.image.*;
import org.eclipse.core.runtime.IPath;
public class SVGSourceReference extends SVGSource implements ISVGSourceReference {
public SVGSourceReference(IPath path) {
super(path);
}
/* (non-Javadoc)
* @see com.nokia.carbide.cpp.epoc.engine.image.IImageSource#copy()
*/
public IImageSourceReference copy() {
SVGSourceReference copy_ = new SVGSourceReference(getPath());
return copy_;
}
public boolean equals(Object obj) {
if (!(obj instanceof ISVGSourceReference))
return false;
return super.equals(obj);
}
/* (non-Javadoc)
* @see java.lang.Object#toString()
*/
@Override
public String toString() {
return "SVGSourceReference path="+getPath()+" implied mask="+getImpliedMaskPath(); //$NON-NLS-1$ //$NON-NLS-2$
}
/* (non-Javadoc)
* @see java.lang.Object#hashCode()
*/
@Override
public int hashCode() {
return super.hashCode() ^ 938549095;
}
}
| UTF-8 | Java | 1,520 | java | SVGSourceReference.java | Java | [] | null | [] | /*
* Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
* All rights reserved.
* This component and the accompanying materials are made available
* under the terms of the License "Eclipse Public License v1.0"
* which accompanies this distribution, and is available
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
*
* Initial Contributors:
* Nokia Corporation - initial contribution.
*
* Contributors:
*
* Description:
*
*/
package com.nokia.carbide.internal.cpp.epoc.engine.image;
import com.nokia.carbide.cpp.epoc.engine.image.*;
import org.eclipse.core.runtime.IPath;
public class SVGSourceReference extends SVGSource implements ISVGSourceReference {
public SVGSourceReference(IPath path) {
super(path);
}
/* (non-Javadoc)
* @see com.nokia.carbide.cpp.epoc.engine.image.IImageSource#copy()
*/
public IImageSourceReference copy() {
SVGSourceReference copy_ = new SVGSourceReference(getPath());
return copy_;
}
public boolean equals(Object obj) {
if (!(obj instanceof ISVGSourceReference))
return false;
return super.equals(obj);
}
/* (non-Javadoc)
* @see java.lang.Object#toString()
*/
@Override
public String toString() {
return "SVGSourceReference path="+getPath()+" implied mask="+getImpliedMaskPath(); //$NON-NLS-1$ //$NON-NLS-2$
}
/* (non-Javadoc)
* @see java.lang.Object#hashCode()
*/
@Override
public int hashCode() {
return super.hashCode() ^ 938549095;
}
}
| 1,520 | 0.690132 | 0.675 | 62 | 22.516129 | 25.634995 | 112 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.83871 | false | false | 9 |
1bd9aeb4b087c27a874bc3f26a71f3288de81b03 | 31,413,390,856,031 | 28da2b5924bbb183f9abbd5815bf9e5902352489 | /src-ui/org/pentaho/di/ui/trans/steps/pgbulkloader/PGBulkLoaderDialog.java | df7ac0d239ce173067fdc30a2dedf2b565efc692 | [
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | jianjunchu/etl_designer_30 | https://github.com/jianjunchu/etl_designer_30 | 079ed1bcd2b208cf3bb86842a12c815f1db49204 | 996951c4b0ab9d89bffdb550161c2f3871bcf03e | refs/heads/master | 2023-08-09T09:19:43.992000 | 2023-07-20T23:22:35 | 2023-07-20T23:22:35 | 128,722,775 | 3 | 4 | Apache-2.0 | false | 2018-04-18T06:07:17 | 2018-04-09T06:08:53 | 2018-04-17T10:15:56 | 2018-04-18T06:07:17 | 605,286 | 1 | 1 | 0 | Java | false | null | /*******************************************************************************
*
* Pentaho Data Integration
*
* Copyright (C) 2002-2012 by Pentaho : http://www.pentaho.com
*
*******************************************************************************
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
******************************************************************************/
package org.pentaho.di.ui.trans.steps.pgbulkloader;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.CCombo;
import org.eclipse.swt.events.FocusAdapter;
import org.eclipse.swt.events.FocusEvent;
import org.eclipse.swt.events.FocusListener;
import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.events.ModifyListener;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.ShellAdapter;
import org.eclipse.swt.events.ShellEvent;
import org.eclipse.swt.layout.FormAttachment;
import org.eclipse.swt.layout.FormData;
import org.eclipse.swt.layout.FormLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.FileDialog;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.MessageBox;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.TableItem;
import org.eclipse.swt.widgets.Text;
import org.pentaho.di.core.Const;
import org.pentaho.di.core.SQLStatement;
import org.pentaho.di.core.SourceToTargetMapping;
import org.pentaho.di.core.database.Database;
import org.pentaho.di.core.database.DatabaseMeta;
import org.pentaho.di.core.exception.KettleException;
import org.pentaho.di.core.row.RowMetaInterface;
import org.pentaho.di.core.row.ValueMetaInterface;
import org.pentaho.di.i18n.BaseMessages;
import org.pentaho.di.trans.TransMeta;
import org.pentaho.di.trans.step.BaseStepMeta;
import org.pentaho.di.trans.step.StepDialogInterface;
import org.pentaho.di.trans.step.StepMeta;
import org.pentaho.di.trans.step.StepMetaInterface;
import org.pentaho.di.trans.steps.pgbulkloader.PGBulkLoaderMeta;
import org.pentaho.di.ui.core.database.dialog.DatabaseExplorerDialog;
import org.pentaho.di.ui.core.database.dialog.SQLEditor;
import org.pentaho.di.ui.core.dialog.EnterMappingDialog;
import org.pentaho.di.ui.core.dialog.ErrorDialog;
import org.pentaho.di.ui.core.gui.GUIResource;
import org.pentaho.di.ui.core.widget.ColumnInfo;
import org.pentaho.di.ui.core.widget.TableView;
import org.pentaho.di.ui.core.widget.TextVar;
import org.pentaho.di.ui.trans.step.BaseStepDialog;
import org.pentaho.di.ui.trans.step.TableItemInsertListener;
/**
* Dialog class for the Greenplum bulk loader step.
* Created on 28mar2008, copied from Sven Boden's Oracle version
*
* @author Luke Lonergan
*/
public class PGBulkLoaderDialog extends BaseStepDialog implements StepDialogInterface
{
private static Class<?> PKG = PGBulkLoaderMeta.class; // for i18n purposes, needed by Translator2!! $NON-NLS-1$
private CCombo wConnection;
private Label wlSchema;
private TextVar wSchema;
private FormData fdlSchema, fdSchema;
private Label wlTable;
private Button wbTable;
private TextVar wTable;
private FormData fdlTable, fdbTable, fdTable;
private Label wlPsqlPath;
private Button wbPsqlPath;
private TextVar wPsqlPath;
private FormData fdlPsqlPath, fdbPsqlPath, fdPsqlPath;
private Label wlLoadAction;
private CCombo wLoadAction;
private FormData fdlLoadAction, fdLoadAction;
private Label wlReturn;
private TableView wReturn;
private FormData fdlReturn, fdReturn;
private Label wlEnclosure;
private TextVar wEnclosure;
private FormData fdlEnclosure, fdEnclosure;
private Label wlDelimiter;
private TextVar wDelimiter;
private FormData fdlDelimiter, fdDelimiter;
private Label wlDbNameOverride;
private TextVar wDbNameOverride;
private FormData fdlDbNameOverride, fdDbNameOverride;
private Button wGetLU;
private FormData fdGetLU;
private Listener lsGetLU;
private Button wDoMapping;
private FormData fdDoMapping;
private PGBulkLoaderMeta input;
private static final String[] ALL_FILETYPES = new String[] {
BaseMessages.getString(PKG, "PGBulkLoaderDialog.Filetype.All") };
private ColumnInfo[] ciReturn ;
private Map<String, Integer> inputFields;
/**
* List of ColumnInfo that should have the field names of the selected database table
*/
private List<ColumnInfo> tableFieldColumns = new ArrayList<ColumnInfo>();
public PGBulkLoaderDialog(Shell parent, Object in, TransMeta transMeta, String sname)
{
super(parent, (BaseStepMeta)in, transMeta, sname);
input = (PGBulkLoaderMeta) in;
inputFields =new HashMap<String, Integer>();
}
public String open()
{
Shell parent = getParent();
Display display = parent.getDisplay();
shell = new Shell(parent, SWT.DIALOG_TRIM | SWT.RESIZE | SWT.MAX | SWT.MIN);
props.setLook(shell);
setShellImage(shell, input);
ModifyListener lsMod = new ModifyListener()
{
public void modifyText(ModifyEvent e)
{
input.setChanged();
}
};
FocusListener lsFocusLost = new FocusAdapter() {
public void focusLost(FocusEvent arg0) {
setTableFieldCombo();
}
};
changed = input.hasChanged();
FormLayout formLayout = new FormLayout();
formLayout.marginWidth = Const.FORM_MARGIN;
formLayout.marginHeight = Const.FORM_MARGIN;
shell.setLayout(formLayout);
shell.setText(BaseMessages.getString(PKG, "PGBulkLoaderDialog.Shell.Title")); //$NON-NLS-1$
int middle = props.getMiddlePct();
int margin = Const.MARGIN;
// Stepname line
wlStepname = new Label(shell, SWT.RIGHT);
wlStepname.setText(BaseMessages.getString(PKG, "PGBulkLoaderDialog.Stepname.Label")); //$NON-NLS-1$
props.setLook(wlStepname);
fdlStepname = new FormData();
fdlStepname.left = new FormAttachment(0, 0);
fdlStepname.right = new FormAttachment(middle, -margin);
fdlStepname.top = new FormAttachment(0, margin);
wlStepname.setLayoutData(fdlStepname);
wStepname = new Text(shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
wStepname.setText(stepname);
props.setLook(wStepname);
wStepname.addModifyListener(lsMod);
fdStepname = new FormData();
fdStepname.left = new FormAttachment(middle, 0);
fdStepname.top = new FormAttachment(0, margin);
fdStepname.right = new FormAttachment(100, 0);
wStepname.setLayoutData(fdStepname);
// Connection line
wConnection = addConnectionLine(shell, wStepname, middle, margin);
if (input.getDatabaseMeta()==null && transMeta.nrDatabases()==1) wConnection.select(0);
wConnection.addModifyListener(lsMod);
// Schema line...
wlSchema=new Label(shell, SWT.RIGHT);
wlSchema.setText(BaseMessages.getString(PKG, "PGBulkLoaderDialog.TargetSchema.Label")); //$NON-NLS-1$
props.setLook(wlSchema);
fdlSchema=new FormData();
fdlSchema.left = new FormAttachment(0, 0);
fdlSchema.right= new FormAttachment(middle, -margin);
fdlSchema.top = new FormAttachment(wConnection, margin*2);
wlSchema.setLayoutData(fdlSchema);
wSchema=new TextVar(transMeta, shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
props.setLook(wSchema);
wSchema.addModifyListener(lsMod);
wSchema.addFocusListener(lsFocusLost);
fdSchema=new FormData();
fdSchema.left = new FormAttachment(middle, 0);
fdSchema.top = new FormAttachment(wConnection, margin*2);
fdSchema.right= new FormAttachment(100, 0);
wSchema.setLayoutData(fdSchema);
// Table line...
wlTable = new Label(shell, SWT.RIGHT);
wlTable.setText(BaseMessages.getString(PKG, "PGBulkLoaderDialog.TargetTable.Label")); //$NON-NLS-1$
props.setLook(wlTable);
fdlTable = new FormData();
fdlTable.left = new FormAttachment(0, 0);
fdlTable.right = new FormAttachment(middle, -margin);
fdlTable.top = new FormAttachment(wSchema, margin);
wlTable.setLayoutData(fdlTable);
wbTable = new Button(shell, SWT.PUSH | SWT.CENTER);
props.setLook(wbTable);
wbTable.setText(BaseMessages.getString(PKG, "PGBulkLoaderDialog.Browse.Button")); //$NON-NLS-1$
fdbTable = new FormData();
fdbTable.right = new FormAttachment(100, 0);
fdbTable.top = new FormAttachment(wSchema, margin);
wbTable.setLayoutData(fdbTable);
wTable = new TextVar(transMeta, shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
props.setLook(wTable);
wTable.addModifyListener(lsMod);
wTable.addFocusListener(lsFocusLost);
fdTable = new FormData();
fdTable.left = new FormAttachment(middle, 0);
fdTable.top = new FormAttachment(wSchema, margin);
fdTable.right = new FormAttachment(wbTable, -margin);
wTable.setLayoutData(fdTable);
// PsqlPath line...
wlPsqlPath = new Label(shell, SWT.RIGHT);
wlPsqlPath.setText(BaseMessages.getString(PKG, "PGBulkLoaderDialog.PsqlPath.Label")); //$NON-NLS-1$
props.setLook(wlPsqlPath);
fdlPsqlPath = new FormData();
fdlPsqlPath.left = new FormAttachment(0, 0);
fdlPsqlPath.right = new FormAttachment(middle, -margin);
fdlPsqlPath.top = new FormAttachment(wTable, margin);
wlPsqlPath.setLayoutData(fdlPsqlPath);
wbPsqlPath = new Button(shell, SWT.PUSH | SWT.CENTER);
props.setLook(wbPsqlPath);
wbPsqlPath.setText(BaseMessages.getString(PKG, "PGBulkLoaderDialog.Browse.Button")); //$NON-NLS-1$
fdbPsqlPath = new FormData();
fdbPsqlPath.right = new FormAttachment(100, 0);
fdbPsqlPath.top = new FormAttachment(wTable, margin);
wbPsqlPath.setLayoutData(fdbPsqlPath);
wPsqlPath = new TextVar(transMeta, shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
props.setLook(wPsqlPath);
wPsqlPath.addModifyListener(lsMod);
fdPsqlPath = new FormData();
fdPsqlPath.left = new FormAttachment(middle, 0);
fdPsqlPath.top = new FormAttachment(wTable, margin);
fdPsqlPath.right = new FormAttachment(wbPsqlPath, -margin);
wPsqlPath.setLayoutData(fdPsqlPath);
// Load Action line
wlLoadAction = new Label(shell, SWT.RIGHT);
wlLoadAction.setText(BaseMessages.getString(PKG, "PGBulkLoaderDialog.LoadAction.Label"));
props.setLook(wlLoadAction);
fdlLoadAction = new FormData();
fdlLoadAction.left = new FormAttachment(0, 0);
fdlLoadAction.right = new FormAttachment(middle, -margin);
fdlLoadAction.top = new FormAttachment(wPsqlPath, margin);
wlLoadAction.setLayoutData(fdlLoadAction);
wLoadAction = new CCombo(shell, SWT.SINGLE | SWT.READ_ONLY | SWT.BORDER);
wLoadAction.add(BaseMessages.getString(PKG, "PGBulkLoaderDialog.InsertLoadAction.Label"));
wLoadAction.add(BaseMessages.getString(PKG, "PGBulkLoaderDialog.TruncateLoadAction.Label"));
wLoadAction.select(0); // +1: starts at -1
wLoadAction.addModifyListener(lsMod);
props.setLook(wLoadAction);
fdLoadAction= new FormData();
fdLoadAction.left = new FormAttachment(middle, 0);
fdLoadAction.top = new FormAttachment(wPsqlPath, margin);
fdLoadAction.right = new FormAttachment(100, 0);
wLoadAction.setLayoutData(fdLoadAction);
fdLoadAction = new FormData();
fdLoadAction.left = new FormAttachment(middle, 0);
fdLoadAction.top = new FormAttachment(wPsqlPath, margin);
fdLoadAction.right = new FormAttachment(100, 0);
wLoadAction.setLayoutData(fdLoadAction);
// Db Name Override line
wlDbNameOverride = new Label(shell, SWT.RIGHT);
wlDbNameOverride.setText(BaseMessages.getString(PKG, "PGBulkLoaderDialog.DbNameOverride.Label")); //$NON-NLS-1$
props.setLook(wlDbNameOverride);
fdlDbNameOverride = new FormData();
fdlDbNameOverride.left = new FormAttachment(0, 0);
fdlDbNameOverride.top = new FormAttachment(wLoadAction, margin);
fdlDbNameOverride.right = new FormAttachment(middle, -margin);
wlDbNameOverride.setLayoutData(fdlDbNameOverride);
wDbNameOverride = new TextVar(transMeta, shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
props.setLook(wDbNameOverride);
wDbNameOverride.addModifyListener(lsMod);
fdDbNameOverride = new FormData();
fdDbNameOverride.left = new FormAttachment(middle, 0);
fdDbNameOverride.top = new FormAttachment(wLoadAction, margin);
fdDbNameOverride.right = new FormAttachment(100, 0);
wDbNameOverride.setLayoutData(fdDbNameOverride);
// Enclosure line
wlEnclosure = new Label(shell, SWT.RIGHT);
wlEnclosure.setText(BaseMessages.getString(PKG, "PGBulkLoaderDialog.Enclosure.Label")); //$NON-NLS-1$
props.setLook(wlEnclosure);
fdlEnclosure = new FormData();
fdlEnclosure.left = new FormAttachment(0, 0);
fdlEnclosure.top = new FormAttachment(wDbNameOverride, margin);
fdlEnclosure.right = new FormAttachment(middle, -margin);
wlEnclosure.setLayoutData(fdlEnclosure);
wEnclosure = new TextVar(transMeta, shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
props.setLook(wEnclosure);
wEnclosure.addModifyListener(lsMod);
fdEnclosure = new FormData();
fdEnclosure.left = new FormAttachment(middle, 0);
fdEnclosure.top = new FormAttachment(wDbNameOverride, margin);
fdEnclosure.right = new FormAttachment(100, 0);
wEnclosure.setLayoutData(fdEnclosure);
// Delimiter
wlDelimiter = new Label(shell, SWT.RIGHT);
wlDelimiter.setText(BaseMessages.getString(PKG, "PGBulkLoaderDialog.Delimiter.Label")); //$NON-NLS-1$
props.setLook(wlDelimiter);
fdlDelimiter = new FormData();
fdlDelimiter.left = new FormAttachment(0, 0);
fdlDelimiter.top = new FormAttachment(wEnclosure, margin);
fdlDelimiter.right = new FormAttachment(middle, -margin);
wlDelimiter.setLayoutData(fdlDelimiter);
wDelimiter = new TextVar(transMeta, shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
props.setLook(wDelimiter);
wDelimiter.addModifyListener(lsMod);
fdDelimiter = new FormData();
fdDelimiter.left = new FormAttachment(middle, 0);
fdDelimiter.top = new FormAttachment(wEnclosure, margin);
fdDelimiter.right = new FormAttachment(100, 0);
wDelimiter.setLayoutData(fdDelimiter);
// THE BUTTONS
wOK = new Button(shell, SWT.PUSH);
wOK.setText(BaseMessages.getString(PKG, "System.Button.OK")); //$NON-NLS-1$
wSQL = new Button(shell, SWT.PUSH);
wSQL.setText(BaseMessages.getString(PKG, "PGBulkLoaderDialog.SQL.Button")); //$NON-NLS-1$
wCancel = new Button(shell, SWT.PUSH);
wCancel.setText(BaseMessages.getString(PKG, "System.Button.Cancel")); //$NON-NLS-1$
setButtonPositions(new Button[] { wOK, wCancel , wSQL }, margin, null);
// The field Table
wlReturn = new Label(shell, SWT.NONE);
wlReturn.setText(BaseMessages.getString(PKG, "PGBulkLoaderDialog.Fields.Label")); //$NON-NLS-1$
props.setLook(wlReturn);
fdlReturn = new FormData();
fdlReturn.left = new FormAttachment(0, 0);
fdlReturn.top = new FormAttachment(wDelimiter, margin);
wlReturn.setLayoutData(fdlReturn);
int UpInsCols = 3;
int UpInsRows = (input.getFieldTable() != null ? input.getFieldTable().length : 1);
ciReturn = new ColumnInfo[UpInsCols];
ciReturn[0] = new ColumnInfo(BaseMessages.getString(PKG, "PGBulkLoaderDialog.ColumnInfo.TableField"), ColumnInfo.COLUMN_TYPE_CCOMBO, new String[] { "" }, false); //$NON-NLS-1$
ciReturn[1] = new ColumnInfo(BaseMessages.getString(PKG, "PGBulkLoaderDialog.ColumnInfo.StreamField"), ColumnInfo.COLUMN_TYPE_CCOMBO, new String[] { "" }, false); //$NON-NLS-1$
ciReturn[2] = new ColumnInfo(BaseMessages.getString(PKG, "PGBulkLoaderDialog.ColumnInfo.DateMask"), ColumnInfo.COLUMN_TYPE_CCOMBO,
new String[] {"",
BaseMessages.getString(PKG, "PGBulkLoaderDialog.PassThrough.Label"), //$NON-NLS-1$
BaseMessages.getString(PKG, "PGBulkLoaderDialog.DateMask.Label"),//$NON-NLS-1$
BaseMessages.getString(PKG, "PGBulkLoaderDialog.DateTimeMask.Label")}, true); //$NON-NLS-1$
tableFieldColumns.add(ciReturn[0]);
wReturn = new TableView(transMeta, shell, SWT.BORDER | SWT.FULL_SELECTION | SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL,
ciReturn, UpInsRows, lsMod, props);
wGetLU = new Button(shell, SWT.PUSH);
wGetLU.setText(BaseMessages.getString(PKG, "PGBulkLoaderDialog.GetFields.Label")); //$NON-NLS-1$
fdGetLU = new FormData();
fdGetLU.top = new FormAttachment(wlReturn, margin);
fdGetLU.right = new FormAttachment(100, 0);
wGetLU.setLayoutData(fdGetLU);
wDoMapping = new Button(shell, SWT.PUSH);
wDoMapping.setText(BaseMessages.getString(PKG, "PGBulkLoaderDialog.EditMapping.Label")); //$NON-NLS-1$
fdDoMapping = new FormData();
fdDoMapping.top = new FormAttachment(wGetLU, margin);
fdDoMapping.right = new FormAttachment(100, 0);
wDoMapping.setLayoutData(fdDoMapping);
wDoMapping.addListener(SWT.Selection, new Listener() { public void handleEvent(Event arg0) { generateMappings();}});
fdReturn = new FormData();
fdReturn.left = new FormAttachment(0, 0);
fdReturn.top = new FormAttachment(wlReturn, margin);
fdReturn.right = new FormAttachment(wGetLU, -margin);
fdReturn.bottom = new FormAttachment(wOK, -2*margin);
wReturn.setLayoutData(fdReturn);
//
// Search the fields in the background
//
final Runnable runnable = new Runnable()
{
public void run()
{
StepMeta stepMeta = transMeta.findStep(stepname);
if (stepMeta!=null)
{
try
{
RowMetaInterface row = transMeta.getPrevStepFields(stepMeta);
// Remember these fields...
for (int i=0;i<row.size();i++)
{
inputFields.put(row.getValueMeta(i).getName(), Integer.valueOf(i));
}
setComboBoxes();
}
catch(KettleException e)
{
logError(BaseMessages.getString(PKG, "System.Dialog.GetFieldsFailed.Message"));
}
}
}
};
new Thread(runnable).start();
wbPsqlPath.addSelectionListener(new SelectionAdapter()
{
public void widgetSelected(SelectionEvent e)
{
FileDialog dialog = new FileDialog(shell, SWT.OPEN);
dialog.setFilterExtensions(new String[] { "*" });
if (wPsqlPath.getText() != null)
{
dialog.setFileName(wPsqlPath.getText());
}
dialog.setFilterNames(ALL_FILETYPES);
if (dialog.open() != null)
{
wPsqlPath.setText(dialog.getFilterPath() + Const.FILE_SEPARATOR
+ dialog.getFileName());
}
}
});
// Add listeners
lsOK = new Listener()
{
public void handleEvent(Event e)
{
ok();
}
};
lsGetLU = new Listener()
{
public void handleEvent(Event e)
{
getUpdate();
}
};
lsSQL = new Listener()
{
public void handleEvent(Event e)
{
create();
}
};
lsCancel = new Listener()
{
public void handleEvent(Event e)
{
cancel();
}
};
wOK.addListener(SWT.Selection, lsOK);
wGetLU.addListener(SWT.Selection, lsGetLU);
wSQL.addListener(SWT.Selection, lsSQL);
wCancel.addListener(SWT.Selection, lsCancel);
lsDef = new SelectionAdapter() { public void widgetDefaultSelected(SelectionEvent e) { ok(); } };
wStepname.addSelectionListener(lsDef);
wSchema.addSelectionListener(lsDef);
wTable.addSelectionListener(lsDef);
wDbNameOverride.addSelectionListener(lsDef);
wEnclosure.addSelectionListener(lsDef);
wDelimiter.addSelectionListener(lsDef);
// Detect X or ALT-F4 or something that kills this window...
shell.addShellListener(new ShellAdapter()
{
public void shellClosed(ShellEvent e)
{
cancel();
}
});
wbTable.addSelectionListener(new SelectionAdapter()
{
public void widgetSelected(SelectionEvent e)
{
getTableName();
}
});
// Set the shell size, based upon previous time...
setSize();
getData();
setTableFieldCombo();
input.setChanged(changed);
checkPriviledges();
shell.open();
while (!shell.isDisposed())
{
if (!display.readAndDispatch())
display.sleep();
}
return stepname;
}
/**
* Copy information from the meta-data input to the dialog fields.
*/
public void getData()
{
int i;
logDebug(BaseMessages.getString(PKG, "PGBulkLoaderDialog.Log.GettingKeyInfo")); //$NON-NLS-1$
if (input.getFieldTable() != null)
for (i = 0; i < input.getFieldTable().length; i++)
{
TableItem item = wReturn.table.getItem(i);
if (input.getFieldTable()[i] != null)
item.setText(1, input.getFieldTable()[i]);
if (input.getFieldStream()[i] != null)
item.setText(2, input.getFieldStream()[i]);
String dateMask = input.getDateMask()[i];
if (dateMask!=null) {
if ( PGBulkLoaderMeta.DATE_MASK_PASS_THROUGH.equals(dateMask) )
{
item.setText(3,BaseMessages.getString(PKG, "PGBulkLoaderDialog.PassThrough.Label"));
}
else if ( PGBulkLoaderMeta.DATE_MASK_DATE.equals(dateMask) )
{
item.setText(3,BaseMessages.getString(PKG, "PGBulkLoaderDialog.DateMask.Label"));
}
else if ( PGBulkLoaderMeta.DATE_MASK_DATETIME.equals(dateMask))
{
item.setText(3,BaseMessages.getString(PKG, "PGBulkLoaderDialog.DateTimeMask.Label"));
}
else
{
item.setText(3,"");
}
}
else {
item.setText(3,"");
}
}
if (input.getDatabaseMeta() != null)
wConnection.setText(input.getDatabaseMeta().getName());
else
{
if (transMeta.nrDatabases() == 1)
{
wConnection.setText(transMeta.getDatabase(0).getName());
}
}
if (input.getSchemaName() != null) wSchema.setText(input.getSchemaName());
if (input.getTableName() != null) wTable.setText(input.getTableName());
if (input.getPsqlpath() != null) wPsqlPath.setText(input.getPsqlpath());
if (input.getDelimiter() != null) wDelimiter.setText(input.getDelimiter());
if (input.getEnclosure() != null) wEnclosure.setText(input.getEnclosure());
if (input.getDbNameOverride() != null ) wDbNameOverride.setText(input.getDbNameOverride());
String action = input.getLoadAction();
if ( PGBulkLoaderMeta.ACTION_INSERT.equals(action))
{
wLoadAction.select(0);
}
else if ( PGBulkLoaderMeta.ACTION_TRUNCATE.equals(action))
{
wLoadAction.select(1);
}
else
{
logDebug("Internal error: load_action set to default 'insert'"); //$NON-NLS-1$
wLoadAction.select(0);
}
wStepname.selectAll();
wReturn.setRowNums();
wReturn.optWidth(true);
}
protected void setComboBoxes()
{
// Something was changed in the row.
//
final Map<String, Integer> fields = new HashMap<String, Integer>();
// Add the currentMeta fields...
fields.putAll(inputFields);
Set<String> keySet = fields.keySet();
List<String> entries = new ArrayList<String>(keySet);
String[] fieldNames= (String[]) entries.toArray(new String[entries.size()]);
Const.sortStrings(fieldNames);
// return fields
ciReturn[1].setComboValues(fieldNames);
}
/**
* Reads in the fields from the previous steps and from the ONE next step and opens an
* EnterMappingDialog with this information. After the user did the mapping, those information
* is put into the Select/Rename table.
*/
private void generateMappings() {
// Determine the source and target fields...
//
RowMetaInterface sourceFields;
RowMetaInterface targetFields;
try {
sourceFields = transMeta.getPrevStepFields(stepMeta);
} catch(KettleException e) {
new ErrorDialog(shell, BaseMessages.getString(PKG, "PGBulkLoaderDialog.DoMapping.UnableToFindSourceFields.Title"), BaseMessages.getString(PKG, "PGBulkLoaderDialog.DoMapping.UnableToFindSourceFields.Message"), e);
return;
}
// refresh data
input.setDatabaseMeta(transMeta.findDatabase(wConnection.getText()) );
input.setTableName(transMeta.environmentSubstitute(wTable.getText()));
StepMetaInterface stepMetaInterface = stepMeta.getStepMetaInterface();
try {
targetFields = stepMetaInterface.getRequiredFields(transMeta);
} catch (KettleException e) {
new ErrorDialog(shell, BaseMessages.getString(PKG, "PGBulkLoaderDialog.DoMapping.UnableToFindTargetFields.Title"), BaseMessages.getString(PKG, "PGBulkLoaderDialog.DoMapping.UnableToFindTargetFields.Message"), e);
return;
}
String[] inputNames = new String[sourceFields.size()];
for (int i = 0; i < sourceFields.size(); i++) {
ValueMetaInterface value = sourceFields.getValueMeta(i);
inputNames[i] = value.getName()+
EnterMappingDialog.STRING_ORIGIN_SEPARATOR+value.getOrigin()+")";
}
// Create the existing mapping list...
//
List<SourceToTargetMapping> mappings = new ArrayList<SourceToTargetMapping>();
StringBuffer missingSourceFields = new StringBuffer();
StringBuffer missingTargetFields = new StringBuffer();
int nrFields = wReturn.nrNonEmpty();
for (int i = 0; i < nrFields ; i++) {
TableItem item = wReturn.getNonEmpty(i);
String source = item.getText(2);
String target = item.getText(1);
int sourceIndex = sourceFields.indexOfValue(source);
if (sourceIndex<0) {
missingSourceFields.append(Const.CR + " " + source+" --> " + target);
}
int targetIndex = targetFields.indexOfValue(target);
if (targetIndex<0) {
missingTargetFields.append(Const.CR + " " + source+" --> " + target);
}
if (sourceIndex<0 || targetIndex<0) {
continue;
}
SourceToTargetMapping mapping = new SourceToTargetMapping(sourceIndex, targetIndex);
mappings.add(mapping);
}
// show a confirm dialog if some missing field was found
//
if (missingSourceFields.length()>0 || missingTargetFields.length()>0){
String message="";
if (missingSourceFields.length()>0) {
message+=BaseMessages.getString(PKG, "PGBulkLoaderDialog.DoMapping.SomeSourceFieldsNotFound", missingSourceFields.toString())+Const.CR;
}
if (missingTargetFields.length()>0) {
message+=BaseMessages.getString(PKG, "PGBulkLoaderDialog.DoMapping.SomeTargetFieldsNotFound", missingSourceFields.toString())+Const.CR;
}
message+=Const.CR;
message+=BaseMessages.getString(PKG, "PGBulkLoaderDialog.DoMapping.SomeFieldsNotFoundContinue")+Const.CR;
MessageDialog.setDefaultImage(GUIResource.getInstance().getImageSpoon());
boolean goOn = MessageDialog.openConfirm(shell, BaseMessages.getString(PKG, "PGBulkLoaderDialog.DoMapping.SomeFieldsNotFoundTitle"), message);
if (!goOn) {
return;
}
}
EnterMappingDialog d = new EnterMappingDialog(PGBulkLoaderDialog.this.shell, sourceFields.getFieldNames(), targetFields.getFieldNames(), mappings);
mappings = d.open();
// mappings == null if the user pressed cancel
//
if (mappings!=null) {
// Clear and re-populate!
//
wReturn.table.removeAll();
wReturn.table.setItemCount(mappings.size());
for (int i = 0; i < mappings.size(); i++) {
SourceToTargetMapping mapping = (SourceToTargetMapping) mappings.get(i);
TableItem item = wReturn.table.getItem(i);
item.setText(2, sourceFields.getValueMeta(mapping.getSourcePosition()).getName());
item.setText(1, targetFields.getValueMeta(mapping.getTargetPosition()).getName());
}
wReturn.setRowNums();
wReturn.optWidth(true);
}
}
private void cancel()
{
stepname = null;
input.setChanged(changed);
dispose();
}
private void getInfo(PGBulkLoaderMeta inf)
{
int nrfields = wReturn.nrNonEmpty();
inf.allocate(nrfields);
inf.setDbNameOverride(wDbNameOverride.getText());
logDebug(BaseMessages.getString(PKG, "PGBulkLoaderDialog.Log.FoundFields", "" + nrfields)); //$NON-NLS-1$ //$NON-NLS-2$
for (int i = 0; i < nrfields; i++)
{
TableItem item = wReturn.getNonEmpty(i);
inf.getFieldTable()[i] = item.getText(1);
inf.getFieldStream()[i] = item.getText(2);
if ( BaseMessages.getString(PKG, "PGBulkLoaderDialog.PassThrough.Label").equals(item.getText(3)) )
inf.getDateMask()[i] = PGBulkLoaderMeta.DATE_MASK_PASS_THROUGH;
else if ( BaseMessages.getString(PKG, "PGBulkLoaderDialog.DateMask.Label").equals(item.getText(3)) )
inf.getDateMask()[i] = PGBulkLoaderMeta.DATE_MASK_DATE;
else if ( BaseMessages.getString(PKG, "PGBulkLoaderDialog.DateTimeMask.Label").equals(item.getText(3)) )
inf.getDateMask()[i] = PGBulkLoaderMeta.DATE_MASK_DATETIME;
else inf.getDateMask()[i] = "";
}
inf.setSchemaName( wSchema.getText() );
inf.setTableName( wTable.getText() );
inf.setDatabaseMeta( transMeta.findDatabase(wConnection.getText()) );
inf.setPsqlpath( wPsqlPath.getText() );
inf.setDelimiter( wDelimiter.getText() );
inf.setEnclosure( wEnclosure.getText() );
/*
/*
* Set the loadaction
*/
String action = wLoadAction.getText();
if ( BaseMessages.getString(PKG, "PGBulkLoaderDialog.InsertLoadAction.Label").equals(action) )
{
inf.setLoadAction(PGBulkLoaderMeta.ACTION_INSERT);
}
else if ( BaseMessages.getString(PKG, "PGBulkLoaderDialog.TruncateLoadAction.Label").equals(action) )
{
inf.setLoadAction(PGBulkLoaderMeta.ACTION_TRUNCATE);
}
else
{
logDebug("Internal error: load_action set to default 'insert', value found '" + action + "'."); //$NON-NLS-1$
inf.setLoadAction(PGBulkLoaderMeta.ACTION_INSERT);
}
stepname = wStepname.getText(); // return value
}
private void ok()
{
if (Const.isEmpty(wStepname.getText())) return;
// Get the information for the dialog into the input structure.
getInfo(input);
if (input.getDatabaseMeta() == null)
{
MessageBox mb = new MessageBox(shell, SWT.OK | SWT.ICON_ERROR);
mb.setMessage(BaseMessages.getString(PKG, "PGBulkLoaderDialog.InvalidConnection.DialogMessage")); //$NON-NLS-1$
mb.setText(BaseMessages.getString(PKG, "PGBulkLoaderDialog.InvalidConnection.DialogTitle")); //$NON-NLS-1$
mb.open();
}
dispose();
}
private void getTableName()
{
DatabaseMeta inf = null;
// New class: SelectTableDialog
int connr = wConnection.getSelectionIndex();
if (connr >= 0)
inf = transMeta.getDatabase(connr);
if (inf != null)
{
logDebug(BaseMessages.getString(PKG, "PGBulkLoaderDialog.Log.LookingAtConnection") + inf.toString()); //$NON-NLS-1$
DatabaseExplorerDialog std = new DatabaseExplorerDialog(shell, SWT.NONE, inf, transMeta.getDatabases());
std.setSelectedSchemaAndTable(wSchema.getText(), wTable.getText());
if (std.open())
{
wSchema.setText(Const.NVL(std.getSchemaName(), ""));
wTable.setText(Const.NVL(std.getTableName(), ""));
}
}
else
{
MessageBox mb = new MessageBox(shell, SWT.OK | SWT.ICON_ERROR);
mb.setMessage(BaseMessages.getString(PKG, "PGBulkLoaderDialog.InvalidConnection.DialogMessage")); //$NON-NLS-1$
mb.setText(BaseMessages.getString(PKG, "PGBulkLoaderDialog.InvalidConnection.DialogTitle")); //$NON-NLS-1$
mb.open();
}
}
private void getUpdate()
{
try
{
RowMetaInterface r = transMeta.getPrevStepFields(stepname);
if (r != null)
{
TableItemInsertListener listener = new TableItemInsertListener()
{
public boolean tableItemInserted(TableItem tableItem, ValueMetaInterface v)
{
if ( v.getType() == ValueMetaInterface.TYPE_DATE )
{
// The default is date mask.
tableItem.setText(3, BaseMessages.getString(PKG, "PGBulkLoaderDialog.DateMask.Label"));
}
else
{
tableItem.setText(3, "");
}
return true;
}
};
BaseStepDialog.getFieldsFromPrevious(r, wReturn, 1, new int[] { 1, 2}, new int[] {}, -1, -1, listener);
}
}
catch (KettleException ke)
{
new ErrorDialog(shell, BaseMessages.getString(PKG, "PGBulkLoaderDialog.FailedToGetFields.DialogTitle"), //$NON-NLS-1$
BaseMessages.getString(PKG, "PGBulkLoaderDialog.FailedToGetFields.DialogMessage"), ke); //$NON-NLS-1$
}
}
// Generate code for create table...
// Conversions done by Database
private void create()
{
try
{
PGBulkLoaderMeta info = new PGBulkLoaderMeta();
getInfo(info);
String name = stepname; // new name might not yet be linked to other steps!
StepMeta stepMeta = new StepMeta(BaseMessages.getString(PKG, "PGBulkLoaderDialog.StepMeta.Title"), name, info); //$NON-NLS-1$
RowMetaInterface prev = transMeta.getPrevStepFields(stepname);
SQLStatement sql = info.getSQLStatements(transMeta, stepMeta, prev);
if (!sql.hasError())
{
if (sql.hasSQL())
{
SQLEditor sqledit = new SQLEditor(transMeta, shell, SWT.NONE, info.getDatabaseMeta(), transMeta.getDbCache(),
sql.getSQL());
sqledit.open();
}
else
{
MessageBox mb = new MessageBox(shell, SWT.OK | SWT.ICON_INFORMATION);
mb.setMessage(BaseMessages.getString(PKG, "PGBulkLoaderDialog.NoSQLNeeds.DialogMessage")); //$NON-NLS-1$
mb.setText(BaseMessages.getString(PKG, "PGBulkLoaderDialog.NoSQLNeeds.DialogTitle")); //$NON-NLS-1$
mb.open();
}
}
else
{
MessageBox mb = new MessageBox(shell, SWT.OK | SWT.ICON_ERROR);
mb.setMessage(sql.getError());
mb.setText(BaseMessages.getString(PKG, "PGBulkLoaderDialog.SQLError.DialogTitle")); //$NON-NLS-1$
mb.open();
}
}
catch (KettleException ke)
{
new ErrorDialog(shell, BaseMessages.getString(PKG, "PGBulkLoaderDialog.CouldNotBuildSQL.DialogTitle"), //$NON-NLS-1$
BaseMessages.getString(PKG, "PGBulkLoaderDialog.CouldNotBuildSQL.DialogMessage"), ke); //$NON-NLS-1$
}
}
private void setTableFieldCombo(){
Runnable fieldLoader = new Runnable() {
public void run() {
//clear
for (int i = 0; i < tableFieldColumns.size(); i++) {
ColumnInfo colInfo = (ColumnInfo) tableFieldColumns.get(i);
colInfo.setComboValues(new String[] {});
}
if (!Const.isEmpty(wTable.getText())) {
DatabaseMeta ci = transMeta.findDatabase(wConnection.getText());
if (ci != null) {
Database db = new Database(loggingObject, ci);
try {
db.connect();
String schemaTable = ci .getQuotedSchemaTableCombination(transMeta.environmentSubstitute(wSchema
.getText()), transMeta.environmentSubstitute(wTable.getText()));
RowMetaInterface r = db.getTableFields(schemaTable);
if (null != r) {
String[] fieldNames = r.getFieldNames();
if (null != fieldNames) {
for (int i = 0; i < tableFieldColumns.size(); i++) {
ColumnInfo colInfo = (ColumnInfo) tableFieldColumns.get(i);
colInfo.setComboValues(fieldNames);
}
}
}
} catch (Exception e) {
for (int i = 0; i < tableFieldColumns.size(); i++) {
ColumnInfo colInfo = (ColumnInfo) tableFieldColumns .get(i);
colInfo.setComboValues(new String[] {});
}
// ignore any errors here. drop downs will not be
// filled, but no problem for the user
}
}
}
}
};
shell.getDisplay().asyncExec(fieldLoader);
}
} | UTF-8 | Java | 36,274 | java | PGBulkLoaderDialog.java | Java | [
{
"context": "ed from Sven Boden's Oracle version\n * \n * @author Luke Lonergan\n */\npublic class PGBulkLoaderDialog extends BaseS",
"end": 3524,
"score": 0.9998679161071777,
"start": 3511,
"tag": "NAME",
"value": "Luke Lonergan"
}
] | null | [] | /*******************************************************************************
*
* Pentaho Data Integration
*
* Copyright (C) 2002-2012 by Pentaho : http://www.pentaho.com
*
*******************************************************************************
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
******************************************************************************/
package org.pentaho.di.ui.trans.steps.pgbulkloader;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.CCombo;
import org.eclipse.swt.events.FocusAdapter;
import org.eclipse.swt.events.FocusEvent;
import org.eclipse.swt.events.FocusListener;
import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.events.ModifyListener;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.ShellAdapter;
import org.eclipse.swt.events.ShellEvent;
import org.eclipse.swt.layout.FormAttachment;
import org.eclipse.swt.layout.FormData;
import org.eclipse.swt.layout.FormLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.FileDialog;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.MessageBox;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.TableItem;
import org.eclipse.swt.widgets.Text;
import org.pentaho.di.core.Const;
import org.pentaho.di.core.SQLStatement;
import org.pentaho.di.core.SourceToTargetMapping;
import org.pentaho.di.core.database.Database;
import org.pentaho.di.core.database.DatabaseMeta;
import org.pentaho.di.core.exception.KettleException;
import org.pentaho.di.core.row.RowMetaInterface;
import org.pentaho.di.core.row.ValueMetaInterface;
import org.pentaho.di.i18n.BaseMessages;
import org.pentaho.di.trans.TransMeta;
import org.pentaho.di.trans.step.BaseStepMeta;
import org.pentaho.di.trans.step.StepDialogInterface;
import org.pentaho.di.trans.step.StepMeta;
import org.pentaho.di.trans.step.StepMetaInterface;
import org.pentaho.di.trans.steps.pgbulkloader.PGBulkLoaderMeta;
import org.pentaho.di.ui.core.database.dialog.DatabaseExplorerDialog;
import org.pentaho.di.ui.core.database.dialog.SQLEditor;
import org.pentaho.di.ui.core.dialog.EnterMappingDialog;
import org.pentaho.di.ui.core.dialog.ErrorDialog;
import org.pentaho.di.ui.core.gui.GUIResource;
import org.pentaho.di.ui.core.widget.ColumnInfo;
import org.pentaho.di.ui.core.widget.TableView;
import org.pentaho.di.ui.core.widget.TextVar;
import org.pentaho.di.ui.trans.step.BaseStepDialog;
import org.pentaho.di.ui.trans.step.TableItemInsertListener;
/**
* Dialog class for the Greenplum bulk loader step.
* Created on 28mar2008, copied from Sven Boden's Oracle version
*
* @author <NAME>
*/
public class PGBulkLoaderDialog extends BaseStepDialog implements StepDialogInterface
{
private static Class<?> PKG = PGBulkLoaderMeta.class; // for i18n purposes, needed by Translator2!! $NON-NLS-1$
private CCombo wConnection;
private Label wlSchema;
private TextVar wSchema;
private FormData fdlSchema, fdSchema;
private Label wlTable;
private Button wbTable;
private TextVar wTable;
private FormData fdlTable, fdbTable, fdTable;
private Label wlPsqlPath;
private Button wbPsqlPath;
private TextVar wPsqlPath;
private FormData fdlPsqlPath, fdbPsqlPath, fdPsqlPath;
private Label wlLoadAction;
private CCombo wLoadAction;
private FormData fdlLoadAction, fdLoadAction;
private Label wlReturn;
private TableView wReturn;
private FormData fdlReturn, fdReturn;
private Label wlEnclosure;
private TextVar wEnclosure;
private FormData fdlEnclosure, fdEnclosure;
private Label wlDelimiter;
private TextVar wDelimiter;
private FormData fdlDelimiter, fdDelimiter;
private Label wlDbNameOverride;
private TextVar wDbNameOverride;
private FormData fdlDbNameOverride, fdDbNameOverride;
private Button wGetLU;
private FormData fdGetLU;
private Listener lsGetLU;
private Button wDoMapping;
private FormData fdDoMapping;
private PGBulkLoaderMeta input;
private static final String[] ALL_FILETYPES = new String[] {
BaseMessages.getString(PKG, "PGBulkLoaderDialog.Filetype.All") };
private ColumnInfo[] ciReturn ;
private Map<String, Integer> inputFields;
/**
* List of ColumnInfo that should have the field names of the selected database table
*/
private List<ColumnInfo> tableFieldColumns = new ArrayList<ColumnInfo>();
public PGBulkLoaderDialog(Shell parent, Object in, TransMeta transMeta, String sname)
{
super(parent, (BaseStepMeta)in, transMeta, sname);
input = (PGBulkLoaderMeta) in;
inputFields =new HashMap<String, Integer>();
}
public String open()
{
Shell parent = getParent();
Display display = parent.getDisplay();
shell = new Shell(parent, SWT.DIALOG_TRIM | SWT.RESIZE | SWT.MAX | SWT.MIN);
props.setLook(shell);
setShellImage(shell, input);
ModifyListener lsMod = new ModifyListener()
{
public void modifyText(ModifyEvent e)
{
input.setChanged();
}
};
FocusListener lsFocusLost = new FocusAdapter() {
public void focusLost(FocusEvent arg0) {
setTableFieldCombo();
}
};
changed = input.hasChanged();
FormLayout formLayout = new FormLayout();
formLayout.marginWidth = Const.FORM_MARGIN;
formLayout.marginHeight = Const.FORM_MARGIN;
shell.setLayout(formLayout);
shell.setText(BaseMessages.getString(PKG, "PGBulkLoaderDialog.Shell.Title")); //$NON-NLS-1$
int middle = props.getMiddlePct();
int margin = Const.MARGIN;
// Stepname line
wlStepname = new Label(shell, SWT.RIGHT);
wlStepname.setText(BaseMessages.getString(PKG, "PGBulkLoaderDialog.Stepname.Label")); //$NON-NLS-1$
props.setLook(wlStepname);
fdlStepname = new FormData();
fdlStepname.left = new FormAttachment(0, 0);
fdlStepname.right = new FormAttachment(middle, -margin);
fdlStepname.top = new FormAttachment(0, margin);
wlStepname.setLayoutData(fdlStepname);
wStepname = new Text(shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
wStepname.setText(stepname);
props.setLook(wStepname);
wStepname.addModifyListener(lsMod);
fdStepname = new FormData();
fdStepname.left = new FormAttachment(middle, 0);
fdStepname.top = new FormAttachment(0, margin);
fdStepname.right = new FormAttachment(100, 0);
wStepname.setLayoutData(fdStepname);
// Connection line
wConnection = addConnectionLine(shell, wStepname, middle, margin);
if (input.getDatabaseMeta()==null && transMeta.nrDatabases()==1) wConnection.select(0);
wConnection.addModifyListener(lsMod);
// Schema line...
wlSchema=new Label(shell, SWT.RIGHT);
wlSchema.setText(BaseMessages.getString(PKG, "PGBulkLoaderDialog.TargetSchema.Label")); //$NON-NLS-1$
props.setLook(wlSchema);
fdlSchema=new FormData();
fdlSchema.left = new FormAttachment(0, 0);
fdlSchema.right= new FormAttachment(middle, -margin);
fdlSchema.top = new FormAttachment(wConnection, margin*2);
wlSchema.setLayoutData(fdlSchema);
wSchema=new TextVar(transMeta, shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
props.setLook(wSchema);
wSchema.addModifyListener(lsMod);
wSchema.addFocusListener(lsFocusLost);
fdSchema=new FormData();
fdSchema.left = new FormAttachment(middle, 0);
fdSchema.top = new FormAttachment(wConnection, margin*2);
fdSchema.right= new FormAttachment(100, 0);
wSchema.setLayoutData(fdSchema);
// Table line...
wlTable = new Label(shell, SWT.RIGHT);
wlTable.setText(BaseMessages.getString(PKG, "PGBulkLoaderDialog.TargetTable.Label")); //$NON-NLS-1$
props.setLook(wlTable);
fdlTable = new FormData();
fdlTable.left = new FormAttachment(0, 0);
fdlTable.right = new FormAttachment(middle, -margin);
fdlTable.top = new FormAttachment(wSchema, margin);
wlTable.setLayoutData(fdlTable);
wbTable = new Button(shell, SWT.PUSH | SWT.CENTER);
props.setLook(wbTable);
wbTable.setText(BaseMessages.getString(PKG, "PGBulkLoaderDialog.Browse.Button")); //$NON-NLS-1$
fdbTable = new FormData();
fdbTable.right = new FormAttachment(100, 0);
fdbTable.top = new FormAttachment(wSchema, margin);
wbTable.setLayoutData(fdbTable);
wTable = new TextVar(transMeta, shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
props.setLook(wTable);
wTable.addModifyListener(lsMod);
wTable.addFocusListener(lsFocusLost);
fdTable = new FormData();
fdTable.left = new FormAttachment(middle, 0);
fdTable.top = new FormAttachment(wSchema, margin);
fdTable.right = new FormAttachment(wbTable, -margin);
wTable.setLayoutData(fdTable);
// PsqlPath line...
wlPsqlPath = new Label(shell, SWT.RIGHT);
wlPsqlPath.setText(BaseMessages.getString(PKG, "PGBulkLoaderDialog.PsqlPath.Label")); //$NON-NLS-1$
props.setLook(wlPsqlPath);
fdlPsqlPath = new FormData();
fdlPsqlPath.left = new FormAttachment(0, 0);
fdlPsqlPath.right = new FormAttachment(middle, -margin);
fdlPsqlPath.top = new FormAttachment(wTable, margin);
wlPsqlPath.setLayoutData(fdlPsqlPath);
wbPsqlPath = new Button(shell, SWT.PUSH | SWT.CENTER);
props.setLook(wbPsqlPath);
wbPsqlPath.setText(BaseMessages.getString(PKG, "PGBulkLoaderDialog.Browse.Button")); //$NON-NLS-1$
fdbPsqlPath = new FormData();
fdbPsqlPath.right = new FormAttachment(100, 0);
fdbPsqlPath.top = new FormAttachment(wTable, margin);
wbPsqlPath.setLayoutData(fdbPsqlPath);
wPsqlPath = new TextVar(transMeta, shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
props.setLook(wPsqlPath);
wPsqlPath.addModifyListener(lsMod);
fdPsqlPath = new FormData();
fdPsqlPath.left = new FormAttachment(middle, 0);
fdPsqlPath.top = new FormAttachment(wTable, margin);
fdPsqlPath.right = new FormAttachment(wbPsqlPath, -margin);
wPsqlPath.setLayoutData(fdPsqlPath);
// Load Action line
wlLoadAction = new Label(shell, SWT.RIGHT);
wlLoadAction.setText(BaseMessages.getString(PKG, "PGBulkLoaderDialog.LoadAction.Label"));
props.setLook(wlLoadAction);
fdlLoadAction = new FormData();
fdlLoadAction.left = new FormAttachment(0, 0);
fdlLoadAction.right = new FormAttachment(middle, -margin);
fdlLoadAction.top = new FormAttachment(wPsqlPath, margin);
wlLoadAction.setLayoutData(fdlLoadAction);
wLoadAction = new CCombo(shell, SWT.SINGLE | SWT.READ_ONLY | SWT.BORDER);
wLoadAction.add(BaseMessages.getString(PKG, "PGBulkLoaderDialog.InsertLoadAction.Label"));
wLoadAction.add(BaseMessages.getString(PKG, "PGBulkLoaderDialog.TruncateLoadAction.Label"));
wLoadAction.select(0); // +1: starts at -1
wLoadAction.addModifyListener(lsMod);
props.setLook(wLoadAction);
fdLoadAction= new FormData();
fdLoadAction.left = new FormAttachment(middle, 0);
fdLoadAction.top = new FormAttachment(wPsqlPath, margin);
fdLoadAction.right = new FormAttachment(100, 0);
wLoadAction.setLayoutData(fdLoadAction);
fdLoadAction = new FormData();
fdLoadAction.left = new FormAttachment(middle, 0);
fdLoadAction.top = new FormAttachment(wPsqlPath, margin);
fdLoadAction.right = new FormAttachment(100, 0);
wLoadAction.setLayoutData(fdLoadAction);
// Db Name Override line
wlDbNameOverride = new Label(shell, SWT.RIGHT);
wlDbNameOverride.setText(BaseMessages.getString(PKG, "PGBulkLoaderDialog.DbNameOverride.Label")); //$NON-NLS-1$
props.setLook(wlDbNameOverride);
fdlDbNameOverride = new FormData();
fdlDbNameOverride.left = new FormAttachment(0, 0);
fdlDbNameOverride.top = new FormAttachment(wLoadAction, margin);
fdlDbNameOverride.right = new FormAttachment(middle, -margin);
wlDbNameOverride.setLayoutData(fdlDbNameOverride);
wDbNameOverride = new TextVar(transMeta, shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
props.setLook(wDbNameOverride);
wDbNameOverride.addModifyListener(lsMod);
fdDbNameOverride = new FormData();
fdDbNameOverride.left = new FormAttachment(middle, 0);
fdDbNameOverride.top = new FormAttachment(wLoadAction, margin);
fdDbNameOverride.right = new FormAttachment(100, 0);
wDbNameOverride.setLayoutData(fdDbNameOverride);
// Enclosure line
wlEnclosure = new Label(shell, SWT.RIGHT);
wlEnclosure.setText(BaseMessages.getString(PKG, "PGBulkLoaderDialog.Enclosure.Label")); //$NON-NLS-1$
props.setLook(wlEnclosure);
fdlEnclosure = new FormData();
fdlEnclosure.left = new FormAttachment(0, 0);
fdlEnclosure.top = new FormAttachment(wDbNameOverride, margin);
fdlEnclosure.right = new FormAttachment(middle, -margin);
wlEnclosure.setLayoutData(fdlEnclosure);
wEnclosure = new TextVar(transMeta, shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
props.setLook(wEnclosure);
wEnclosure.addModifyListener(lsMod);
fdEnclosure = new FormData();
fdEnclosure.left = new FormAttachment(middle, 0);
fdEnclosure.top = new FormAttachment(wDbNameOverride, margin);
fdEnclosure.right = new FormAttachment(100, 0);
wEnclosure.setLayoutData(fdEnclosure);
// Delimiter
wlDelimiter = new Label(shell, SWT.RIGHT);
wlDelimiter.setText(BaseMessages.getString(PKG, "PGBulkLoaderDialog.Delimiter.Label")); //$NON-NLS-1$
props.setLook(wlDelimiter);
fdlDelimiter = new FormData();
fdlDelimiter.left = new FormAttachment(0, 0);
fdlDelimiter.top = new FormAttachment(wEnclosure, margin);
fdlDelimiter.right = new FormAttachment(middle, -margin);
wlDelimiter.setLayoutData(fdlDelimiter);
wDelimiter = new TextVar(transMeta, shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
props.setLook(wDelimiter);
wDelimiter.addModifyListener(lsMod);
fdDelimiter = new FormData();
fdDelimiter.left = new FormAttachment(middle, 0);
fdDelimiter.top = new FormAttachment(wEnclosure, margin);
fdDelimiter.right = new FormAttachment(100, 0);
wDelimiter.setLayoutData(fdDelimiter);
// THE BUTTONS
wOK = new Button(shell, SWT.PUSH);
wOK.setText(BaseMessages.getString(PKG, "System.Button.OK")); //$NON-NLS-1$
wSQL = new Button(shell, SWT.PUSH);
wSQL.setText(BaseMessages.getString(PKG, "PGBulkLoaderDialog.SQL.Button")); //$NON-NLS-1$
wCancel = new Button(shell, SWT.PUSH);
wCancel.setText(BaseMessages.getString(PKG, "System.Button.Cancel")); //$NON-NLS-1$
setButtonPositions(new Button[] { wOK, wCancel , wSQL }, margin, null);
// The field Table
wlReturn = new Label(shell, SWT.NONE);
wlReturn.setText(BaseMessages.getString(PKG, "PGBulkLoaderDialog.Fields.Label")); //$NON-NLS-1$
props.setLook(wlReturn);
fdlReturn = new FormData();
fdlReturn.left = new FormAttachment(0, 0);
fdlReturn.top = new FormAttachment(wDelimiter, margin);
wlReturn.setLayoutData(fdlReturn);
int UpInsCols = 3;
int UpInsRows = (input.getFieldTable() != null ? input.getFieldTable().length : 1);
ciReturn = new ColumnInfo[UpInsCols];
ciReturn[0] = new ColumnInfo(BaseMessages.getString(PKG, "PGBulkLoaderDialog.ColumnInfo.TableField"), ColumnInfo.COLUMN_TYPE_CCOMBO, new String[] { "" }, false); //$NON-NLS-1$
ciReturn[1] = new ColumnInfo(BaseMessages.getString(PKG, "PGBulkLoaderDialog.ColumnInfo.StreamField"), ColumnInfo.COLUMN_TYPE_CCOMBO, new String[] { "" }, false); //$NON-NLS-1$
ciReturn[2] = new ColumnInfo(BaseMessages.getString(PKG, "PGBulkLoaderDialog.ColumnInfo.DateMask"), ColumnInfo.COLUMN_TYPE_CCOMBO,
new String[] {"",
BaseMessages.getString(PKG, "PGBulkLoaderDialog.PassThrough.Label"), //$NON-NLS-1$
BaseMessages.getString(PKG, "PGBulkLoaderDialog.DateMask.Label"),//$NON-NLS-1$
BaseMessages.getString(PKG, "PGBulkLoaderDialog.DateTimeMask.Label")}, true); //$NON-NLS-1$
tableFieldColumns.add(ciReturn[0]);
wReturn = new TableView(transMeta, shell, SWT.BORDER | SWT.FULL_SELECTION | SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL,
ciReturn, UpInsRows, lsMod, props);
wGetLU = new Button(shell, SWT.PUSH);
wGetLU.setText(BaseMessages.getString(PKG, "PGBulkLoaderDialog.GetFields.Label")); //$NON-NLS-1$
fdGetLU = new FormData();
fdGetLU.top = new FormAttachment(wlReturn, margin);
fdGetLU.right = new FormAttachment(100, 0);
wGetLU.setLayoutData(fdGetLU);
wDoMapping = new Button(shell, SWT.PUSH);
wDoMapping.setText(BaseMessages.getString(PKG, "PGBulkLoaderDialog.EditMapping.Label")); //$NON-NLS-1$
fdDoMapping = new FormData();
fdDoMapping.top = new FormAttachment(wGetLU, margin);
fdDoMapping.right = new FormAttachment(100, 0);
wDoMapping.setLayoutData(fdDoMapping);
wDoMapping.addListener(SWT.Selection, new Listener() { public void handleEvent(Event arg0) { generateMappings();}});
fdReturn = new FormData();
fdReturn.left = new FormAttachment(0, 0);
fdReturn.top = new FormAttachment(wlReturn, margin);
fdReturn.right = new FormAttachment(wGetLU, -margin);
fdReturn.bottom = new FormAttachment(wOK, -2*margin);
wReturn.setLayoutData(fdReturn);
//
// Search the fields in the background
//
final Runnable runnable = new Runnable()
{
public void run()
{
StepMeta stepMeta = transMeta.findStep(stepname);
if (stepMeta!=null)
{
try
{
RowMetaInterface row = transMeta.getPrevStepFields(stepMeta);
// Remember these fields...
for (int i=0;i<row.size();i++)
{
inputFields.put(row.getValueMeta(i).getName(), Integer.valueOf(i));
}
setComboBoxes();
}
catch(KettleException e)
{
logError(BaseMessages.getString(PKG, "System.Dialog.GetFieldsFailed.Message"));
}
}
}
};
new Thread(runnable).start();
wbPsqlPath.addSelectionListener(new SelectionAdapter()
{
public void widgetSelected(SelectionEvent e)
{
FileDialog dialog = new FileDialog(shell, SWT.OPEN);
dialog.setFilterExtensions(new String[] { "*" });
if (wPsqlPath.getText() != null)
{
dialog.setFileName(wPsqlPath.getText());
}
dialog.setFilterNames(ALL_FILETYPES);
if (dialog.open() != null)
{
wPsqlPath.setText(dialog.getFilterPath() + Const.FILE_SEPARATOR
+ dialog.getFileName());
}
}
});
// Add listeners
lsOK = new Listener()
{
public void handleEvent(Event e)
{
ok();
}
};
lsGetLU = new Listener()
{
public void handleEvent(Event e)
{
getUpdate();
}
};
lsSQL = new Listener()
{
public void handleEvent(Event e)
{
create();
}
};
lsCancel = new Listener()
{
public void handleEvent(Event e)
{
cancel();
}
};
wOK.addListener(SWT.Selection, lsOK);
wGetLU.addListener(SWT.Selection, lsGetLU);
wSQL.addListener(SWT.Selection, lsSQL);
wCancel.addListener(SWT.Selection, lsCancel);
lsDef = new SelectionAdapter() { public void widgetDefaultSelected(SelectionEvent e) { ok(); } };
wStepname.addSelectionListener(lsDef);
wSchema.addSelectionListener(lsDef);
wTable.addSelectionListener(lsDef);
wDbNameOverride.addSelectionListener(lsDef);
wEnclosure.addSelectionListener(lsDef);
wDelimiter.addSelectionListener(lsDef);
// Detect X or ALT-F4 or something that kills this window...
shell.addShellListener(new ShellAdapter()
{
public void shellClosed(ShellEvent e)
{
cancel();
}
});
wbTable.addSelectionListener(new SelectionAdapter()
{
public void widgetSelected(SelectionEvent e)
{
getTableName();
}
});
// Set the shell size, based upon previous time...
setSize();
getData();
setTableFieldCombo();
input.setChanged(changed);
checkPriviledges();
shell.open();
while (!shell.isDisposed())
{
if (!display.readAndDispatch())
display.sleep();
}
return stepname;
}
/**
* Copy information from the meta-data input to the dialog fields.
*/
public void getData()
{
int i;
logDebug(BaseMessages.getString(PKG, "PGBulkLoaderDialog.Log.GettingKeyInfo")); //$NON-NLS-1$
if (input.getFieldTable() != null)
for (i = 0; i < input.getFieldTable().length; i++)
{
TableItem item = wReturn.table.getItem(i);
if (input.getFieldTable()[i] != null)
item.setText(1, input.getFieldTable()[i]);
if (input.getFieldStream()[i] != null)
item.setText(2, input.getFieldStream()[i]);
String dateMask = input.getDateMask()[i];
if (dateMask!=null) {
if ( PGBulkLoaderMeta.DATE_MASK_PASS_THROUGH.equals(dateMask) )
{
item.setText(3,BaseMessages.getString(PKG, "PGBulkLoaderDialog.PassThrough.Label"));
}
else if ( PGBulkLoaderMeta.DATE_MASK_DATE.equals(dateMask) )
{
item.setText(3,BaseMessages.getString(PKG, "PGBulkLoaderDialog.DateMask.Label"));
}
else if ( PGBulkLoaderMeta.DATE_MASK_DATETIME.equals(dateMask))
{
item.setText(3,BaseMessages.getString(PKG, "PGBulkLoaderDialog.DateTimeMask.Label"));
}
else
{
item.setText(3,"");
}
}
else {
item.setText(3,"");
}
}
if (input.getDatabaseMeta() != null)
wConnection.setText(input.getDatabaseMeta().getName());
else
{
if (transMeta.nrDatabases() == 1)
{
wConnection.setText(transMeta.getDatabase(0).getName());
}
}
if (input.getSchemaName() != null) wSchema.setText(input.getSchemaName());
if (input.getTableName() != null) wTable.setText(input.getTableName());
if (input.getPsqlpath() != null) wPsqlPath.setText(input.getPsqlpath());
if (input.getDelimiter() != null) wDelimiter.setText(input.getDelimiter());
if (input.getEnclosure() != null) wEnclosure.setText(input.getEnclosure());
if (input.getDbNameOverride() != null ) wDbNameOverride.setText(input.getDbNameOverride());
String action = input.getLoadAction();
if ( PGBulkLoaderMeta.ACTION_INSERT.equals(action))
{
wLoadAction.select(0);
}
else if ( PGBulkLoaderMeta.ACTION_TRUNCATE.equals(action))
{
wLoadAction.select(1);
}
else
{
logDebug("Internal error: load_action set to default 'insert'"); //$NON-NLS-1$
wLoadAction.select(0);
}
wStepname.selectAll();
wReturn.setRowNums();
wReturn.optWidth(true);
}
protected void setComboBoxes()
{
// Something was changed in the row.
//
final Map<String, Integer> fields = new HashMap<String, Integer>();
// Add the currentMeta fields...
fields.putAll(inputFields);
Set<String> keySet = fields.keySet();
List<String> entries = new ArrayList<String>(keySet);
String[] fieldNames= (String[]) entries.toArray(new String[entries.size()]);
Const.sortStrings(fieldNames);
// return fields
ciReturn[1].setComboValues(fieldNames);
}
/**
* Reads in the fields from the previous steps and from the ONE next step and opens an
* EnterMappingDialog with this information. After the user did the mapping, those information
* is put into the Select/Rename table.
*/
private void generateMappings() {
// Determine the source and target fields...
//
RowMetaInterface sourceFields;
RowMetaInterface targetFields;
try {
sourceFields = transMeta.getPrevStepFields(stepMeta);
} catch(KettleException e) {
new ErrorDialog(shell, BaseMessages.getString(PKG, "PGBulkLoaderDialog.DoMapping.UnableToFindSourceFields.Title"), BaseMessages.getString(PKG, "PGBulkLoaderDialog.DoMapping.UnableToFindSourceFields.Message"), e);
return;
}
// refresh data
input.setDatabaseMeta(transMeta.findDatabase(wConnection.getText()) );
input.setTableName(transMeta.environmentSubstitute(wTable.getText()));
StepMetaInterface stepMetaInterface = stepMeta.getStepMetaInterface();
try {
targetFields = stepMetaInterface.getRequiredFields(transMeta);
} catch (KettleException e) {
new ErrorDialog(shell, BaseMessages.getString(PKG, "PGBulkLoaderDialog.DoMapping.UnableToFindTargetFields.Title"), BaseMessages.getString(PKG, "PGBulkLoaderDialog.DoMapping.UnableToFindTargetFields.Message"), e);
return;
}
String[] inputNames = new String[sourceFields.size()];
for (int i = 0; i < sourceFields.size(); i++) {
ValueMetaInterface value = sourceFields.getValueMeta(i);
inputNames[i] = value.getName()+
EnterMappingDialog.STRING_ORIGIN_SEPARATOR+value.getOrigin()+")";
}
// Create the existing mapping list...
//
List<SourceToTargetMapping> mappings = new ArrayList<SourceToTargetMapping>();
StringBuffer missingSourceFields = new StringBuffer();
StringBuffer missingTargetFields = new StringBuffer();
int nrFields = wReturn.nrNonEmpty();
for (int i = 0; i < nrFields ; i++) {
TableItem item = wReturn.getNonEmpty(i);
String source = item.getText(2);
String target = item.getText(1);
int sourceIndex = sourceFields.indexOfValue(source);
if (sourceIndex<0) {
missingSourceFields.append(Const.CR + " " + source+" --> " + target);
}
int targetIndex = targetFields.indexOfValue(target);
if (targetIndex<0) {
missingTargetFields.append(Const.CR + " " + source+" --> " + target);
}
if (sourceIndex<0 || targetIndex<0) {
continue;
}
SourceToTargetMapping mapping = new SourceToTargetMapping(sourceIndex, targetIndex);
mappings.add(mapping);
}
// show a confirm dialog if some missing field was found
//
if (missingSourceFields.length()>0 || missingTargetFields.length()>0){
String message="";
if (missingSourceFields.length()>0) {
message+=BaseMessages.getString(PKG, "PGBulkLoaderDialog.DoMapping.SomeSourceFieldsNotFound", missingSourceFields.toString())+Const.CR;
}
if (missingTargetFields.length()>0) {
message+=BaseMessages.getString(PKG, "PGBulkLoaderDialog.DoMapping.SomeTargetFieldsNotFound", missingSourceFields.toString())+Const.CR;
}
message+=Const.CR;
message+=BaseMessages.getString(PKG, "PGBulkLoaderDialog.DoMapping.SomeFieldsNotFoundContinue")+Const.CR;
MessageDialog.setDefaultImage(GUIResource.getInstance().getImageSpoon());
boolean goOn = MessageDialog.openConfirm(shell, BaseMessages.getString(PKG, "PGBulkLoaderDialog.DoMapping.SomeFieldsNotFoundTitle"), message);
if (!goOn) {
return;
}
}
EnterMappingDialog d = new EnterMappingDialog(PGBulkLoaderDialog.this.shell, sourceFields.getFieldNames(), targetFields.getFieldNames(), mappings);
mappings = d.open();
// mappings == null if the user pressed cancel
//
if (mappings!=null) {
// Clear and re-populate!
//
wReturn.table.removeAll();
wReturn.table.setItemCount(mappings.size());
for (int i = 0; i < mappings.size(); i++) {
SourceToTargetMapping mapping = (SourceToTargetMapping) mappings.get(i);
TableItem item = wReturn.table.getItem(i);
item.setText(2, sourceFields.getValueMeta(mapping.getSourcePosition()).getName());
item.setText(1, targetFields.getValueMeta(mapping.getTargetPosition()).getName());
}
wReturn.setRowNums();
wReturn.optWidth(true);
}
}
private void cancel()
{
stepname = null;
input.setChanged(changed);
dispose();
}
private void getInfo(PGBulkLoaderMeta inf)
{
int nrfields = wReturn.nrNonEmpty();
inf.allocate(nrfields);
inf.setDbNameOverride(wDbNameOverride.getText());
logDebug(BaseMessages.getString(PKG, "PGBulkLoaderDialog.Log.FoundFields", "" + nrfields)); //$NON-NLS-1$ //$NON-NLS-2$
for (int i = 0; i < nrfields; i++)
{
TableItem item = wReturn.getNonEmpty(i);
inf.getFieldTable()[i] = item.getText(1);
inf.getFieldStream()[i] = item.getText(2);
if ( BaseMessages.getString(PKG, "PGBulkLoaderDialog.PassThrough.Label").equals(item.getText(3)) )
inf.getDateMask()[i] = PGBulkLoaderMeta.DATE_MASK_PASS_THROUGH;
else if ( BaseMessages.getString(PKG, "PGBulkLoaderDialog.DateMask.Label").equals(item.getText(3)) )
inf.getDateMask()[i] = PGBulkLoaderMeta.DATE_MASK_DATE;
else if ( BaseMessages.getString(PKG, "PGBulkLoaderDialog.DateTimeMask.Label").equals(item.getText(3)) )
inf.getDateMask()[i] = PGBulkLoaderMeta.DATE_MASK_DATETIME;
else inf.getDateMask()[i] = "";
}
inf.setSchemaName( wSchema.getText() );
inf.setTableName( wTable.getText() );
inf.setDatabaseMeta( transMeta.findDatabase(wConnection.getText()) );
inf.setPsqlpath( wPsqlPath.getText() );
inf.setDelimiter( wDelimiter.getText() );
inf.setEnclosure( wEnclosure.getText() );
/*
/*
* Set the loadaction
*/
String action = wLoadAction.getText();
if ( BaseMessages.getString(PKG, "PGBulkLoaderDialog.InsertLoadAction.Label").equals(action) )
{
inf.setLoadAction(PGBulkLoaderMeta.ACTION_INSERT);
}
else if ( BaseMessages.getString(PKG, "PGBulkLoaderDialog.TruncateLoadAction.Label").equals(action) )
{
inf.setLoadAction(PGBulkLoaderMeta.ACTION_TRUNCATE);
}
else
{
logDebug("Internal error: load_action set to default 'insert', value found '" + action + "'."); //$NON-NLS-1$
inf.setLoadAction(PGBulkLoaderMeta.ACTION_INSERT);
}
stepname = wStepname.getText(); // return value
}
private void ok()
{
if (Const.isEmpty(wStepname.getText())) return;
// Get the information for the dialog into the input structure.
getInfo(input);
if (input.getDatabaseMeta() == null)
{
MessageBox mb = new MessageBox(shell, SWT.OK | SWT.ICON_ERROR);
mb.setMessage(BaseMessages.getString(PKG, "PGBulkLoaderDialog.InvalidConnection.DialogMessage")); //$NON-NLS-1$
mb.setText(BaseMessages.getString(PKG, "PGBulkLoaderDialog.InvalidConnection.DialogTitle")); //$NON-NLS-1$
mb.open();
}
dispose();
}
private void getTableName()
{
DatabaseMeta inf = null;
// New class: SelectTableDialog
int connr = wConnection.getSelectionIndex();
if (connr >= 0)
inf = transMeta.getDatabase(connr);
if (inf != null)
{
logDebug(BaseMessages.getString(PKG, "PGBulkLoaderDialog.Log.LookingAtConnection") + inf.toString()); //$NON-NLS-1$
DatabaseExplorerDialog std = new DatabaseExplorerDialog(shell, SWT.NONE, inf, transMeta.getDatabases());
std.setSelectedSchemaAndTable(wSchema.getText(), wTable.getText());
if (std.open())
{
wSchema.setText(Const.NVL(std.getSchemaName(), ""));
wTable.setText(Const.NVL(std.getTableName(), ""));
}
}
else
{
MessageBox mb = new MessageBox(shell, SWT.OK | SWT.ICON_ERROR);
mb.setMessage(BaseMessages.getString(PKG, "PGBulkLoaderDialog.InvalidConnection.DialogMessage")); //$NON-NLS-1$
mb.setText(BaseMessages.getString(PKG, "PGBulkLoaderDialog.InvalidConnection.DialogTitle")); //$NON-NLS-1$
mb.open();
}
}
private void getUpdate()
{
try
{
RowMetaInterface r = transMeta.getPrevStepFields(stepname);
if (r != null)
{
TableItemInsertListener listener = new TableItemInsertListener()
{
public boolean tableItemInserted(TableItem tableItem, ValueMetaInterface v)
{
if ( v.getType() == ValueMetaInterface.TYPE_DATE )
{
// The default is date mask.
tableItem.setText(3, BaseMessages.getString(PKG, "PGBulkLoaderDialog.DateMask.Label"));
}
else
{
tableItem.setText(3, "");
}
return true;
}
};
BaseStepDialog.getFieldsFromPrevious(r, wReturn, 1, new int[] { 1, 2}, new int[] {}, -1, -1, listener);
}
}
catch (KettleException ke)
{
new ErrorDialog(shell, BaseMessages.getString(PKG, "PGBulkLoaderDialog.FailedToGetFields.DialogTitle"), //$NON-NLS-1$
BaseMessages.getString(PKG, "PGBulkLoaderDialog.FailedToGetFields.DialogMessage"), ke); //$NON-NLS-1$
}
}
// Generate code for create table...
// Conversions done by Database
private void create()
{
try
{
PGBulkLoaderMeta info = new PGBulkLoaderMeta();
getInfo(info);
String name = stepname; // new name might not yet be linked to other steps!
StepMeta stepMeta = new StepMeta(BaseMessages.getString(PKG, "PGBulkLoaderDialog.StepMeta.Title"), name, info); //$NON-NLS-1$
RowMetaInterface prev = transMeta.getPrevStepFields(stepname);
SQLStatement sql = info.getSQLStatements(transMeta, stepMeta, prev);
if (!sql.hasError())
{
if (sql.hasSQL())
{
SQLEditor sqledit = new SQLEditor(transMeta, shell, SWT.NONE, info.getDatabaseMeta(), transMeta.getDbCache(),
sql.getSQL());
sqledit.open();
}
else
{
MessageBox mb = new MessageBox(shell, SWT.OK | SWT.ICON_INFORMATION);
mb.setMessage(BaseMessages.getString(PKG, "PGBulkLoaderDialog.NoSQLNeeds.DialogMessage")); //$NON-NLS-1$
mb.setText(BaseMessages.getString(PKG, "PGBulkLoaderDialog.NoSQLNeeds.DialogTitle")); //$NON-NLS-1$
mb.open();
}
}
else
{
MessageBox mb = new MessageBox(shell, SWT.OK | SWT.ICON_ERROR);
mb.setMessage(sql.getError());
mb.setText(BaseMessages.getString(PKG, "PGBulkLoaderDialog.SQLError.DialogTitle")); //$NON-NLS-1$
mb.open();
}
}
catch (KettleException ke)
{
new ErrorDialog(shell, BaseMessages.getString(PKG, "PGBulkLoaderDialog.CouldNotBuildSQL.DialogTitle"), //$NON-NLS-1$
BaseMessages.getString(PKG, "PGBulkLoaderDialog.CouldNotBuildSQL.DialogMessage"), ke); //$NON-NLS-1$
}
}
private void setTableFieldCombo(){
Runnable fieldLoader = new Runnable() {
public void run() {
//clear
for (int i = 0; i < tableFieldColumns.size(); i++) {
ColumnInfo colInfo = (ColumnInfo) tableFieldColumns.get(i);
colInfo.setComboValues(new String[] {});
}
if (!Const.isEmpty(wTable.getText())) {
DatabaseMeta ci = transMeta.findDatabase(wConnection.getText());
if (ci != null) {
Database db = new Database(loggingObject, ci);
try {
db.connect();
String schemaTable = ci .getQuotedSchemaTableCombination(transMeta.environmentSubstitute(wSchema
.getText()), transMeta.environmentSubstitute(wTable.getText()));
RowMetaInterface r = db.getTableFields(schemaTable);
if (null != r) {
String[] fieldNames = r.getFieldNames();
if (null != fieldNames) {
for (int i = 0; i < tableFieldColumns.size(); i++) {
ColumnInfo colInfo = (ColumnInfo) tableFieldColumns.get(i);
colInfo.setComboValues(fieldNames);
}
}
}
} catch (Exception e) {
for (int i = 0; i < tableFieldColumns.size(); i++) {
ColumnInfo colInfo = (ColumnInfo) tableFieldColumns .get(i);
colInfo.setComboValues(new String[] {});
}
// ignore any errors here. drop downs will not be
// filled, but no problem for the user
}
}
}
}
};
shell.getDisplay().asyncExec(fieldLoader);
}
} | 36,267 | 0.68669 | 0.681121 | 978 | 36.091003 | 31.712004 | 215 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 2.819018 | false | false | 9 |
c9aa1f749dbf2cf5655808de1962964a748cef5b | 3,564,822,926,192 | 9f92a87dc0ea655629822f70e5886659b76afba6 | /Composite/so/Directory.java | 2e08662881c687c89e17d915d810e68a50c1c0e1 | [
"MIT"
] | permissive | reginaldomota/design-patterns | https://github.com/reginaldomota/design-patterns | c2677591da5db4fc28574e54c9f8941300524bf1 | 2368a0538b74fbdafded799cbfd6fb9f5318ed76 | refs/heads/master | 2020-04-29T11:51:18.117000 | 2019-03-17T22:57:49 | 2019-03-17T22:57:49 | 176,115,419 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package so;
import java.util.ArrayList;
//composite
public class Directory implements AbstractFile
{
private String nome;
private ArrayList<AbstractFile> aFile = new ArrayList<AbstractFile>();
public Directory(String nome)
{
this.nome = nome;
}
public void adicionar(AbstractFile obj)
{
this.aFile.add(obj);
}
public void remover(AbstractFile obj)
{
this.aFile.remove(obj);
}
public void listar()
{
System.out.println(this.nome);
System.out.println("");
for (AbstractFile file : aFile) {
System.out.print("Em " + nome + " temos: ");
file.listar();
}
}
} | UTF-8 | Java | 752 | java | Directory.java | Java | [] | null | [] | package so;
import java.util.ArrayList;
//composite
public class Directory implements AbstractFile
{
private String nome;
private ArrayList<AbstractFile> aFile = new ArrayList<AbstractFile>();
public Directory(String nome)
{
this.nome = nome;
}
public void adicionar(AbstractFile obj)
{
this.aFile.add(obj);
}
public void remover(AbstractFile obj)
{
this.aFile.remove(obj);
}
public void listar()
{
System.out.println(this.nome);
System.out.println("");
for (AbstractFile file : aFile) {
System.out.print("Em " + nome + " temos: ");
file.listar();
}
}
} | 752 | 0.542553 | 0.542553 | 39 | 18.307692 | 18.07556 | 74 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.384615 | false | false | 9 |
189b69e15bd3332fd322774d8adb3a36c97cd3a0 | 8,710,193,742,584 | e059f22390c27854853fd28fb31099478c6d0f35 | /app/src/main/java/xuehuiniaoyu/github/oxpecker/activity/CustomActivity.java | 28e1c3e0e476cfa3f1f81941529c47e74f78173c | [] | no_license | xuehuiniaoyu/oxpecker | https://github.com/xuehuiniaoyu/oxpecker | c404f3e2b90f4b4f841781e1f2e40ee3f1f0cdc9 | 9da8adfc5f91ea7a9c4b669f81e7cb6a84a6fe82 | refs/heads/master | 2020-04-19T23:01:05.876000 | 2019-03-21T03:58:51 | 2019-03-21T03:58:51 | 168,485,733 | 2 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package xuehuiniaoyu.github.oxpecker.activity;
import android.os.Bundle;
import org.ny.woods.app.HActivity;
public class CustomActivity extends HActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentViewFromAssets(getIntent().getStringExtra("layout"), true);
}
}
| UTF-8 | Java | 361 | java | CustomActivity.java | Java | [] | null | [] | package xuehuiniaoyu.github.oxpecker.activity;
import android.os.Bundle;
import org.ny.woods.app.HActivity;
public class CustomActivity extends HActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentViewFromAssets(getIntent().getStringExtra("layout"), true);
}
}
| 361 | 0.753463 | 0.753463 | 14 | 24.785715 | 24.805468 | 77 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.428571 | false | false | 9 |
72392fa1191d76ab2c4fa4ca10a8b114785804c4 | 25,950,192,442,791 | 9b8243b54a7492634c808a175ea28063c3863594 | /app/src/main/java/com/skyworth_hightong/formwork/net/face/IFaceNetTvGroupManager.java | f4dfdde0418448c2a3032c35c662624f2b693a50 | [] | no_license | fanlongbo/Android_phone_communal | https://github.com/fanlongbo/Android_phone_communal | 50a9c6e8ccc2027009e6b3849c8d94d71d89181c | 14daa2a6c75b84ff7731c00df046c38689b58511 | refs/heads/master | 2016-05-07T01:51:21.979000 | 2016-02-27T09:06:34 | 2016-02-27T09:06:34 | 52,650,543 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.skyworth_hightong.formwork.net.face;
import com.skyworth_hightong.service.callback.GetTvGroupsListener;
/**
* 获取电视台分类的管理类,目前电视台的分类,和电视节目列表都是一次性的从网上取下来直接放入数据里,然后才开始
* 进行使用的,所以在使用的过程中暂时不牵涉网络的问题.
*
* @author LeeYewKuan
* @creatDate:2014年6月20日
*/
public interface IFaceNetTvGroupManager {
/**
* 获取TvGroup列表,如果成功,则调用CallBackListener.onSuccess(), 如果失败
* 则调用CallBackListener.onFail(),并返回失败的异常码,如果出现异常,则调用
* onError()方法,返回对应的错误码.(可以暂不实现)
*
* onFail()返回值
* 0:失败
* -10: 服务器返回成功,但是缺失成功时需要的参数,或者解析异常
*
* @param mContext
* @param listener
* @author: LeeYewKuan
* @update: 2014年6月16日
*/
void getTvGroupList(int conTimeout, int soTimeout,
GetTvGroupsListener tvGroupsListener);
}
| UTF-8 | Java | 1,063 | java | IFaceNetTvGroupManager.java | Java | [
{
"context": "然后才开始\n * 进行使用的,所以在使用的过程中暂时不牵涉网络的问题.\n * \n * @author LeeYewKuan\n * @creatDate:2014年6月20日\n */\npublic interface IFa",
"end": 234,
"score": 0.8885524868965149,
"start": 224,
"tag": "NAME",
"value": "LeeYewKuan"
},
{
"context": "* @param mContext\n\t * @param listener\n... | null | [] | package com.skyworth_hightong.formwork.net.face;
import com.skyworth_hightong.service.callback.GetTvGroupsListener;
/**
* 获取电视台分类的管理类,目前电视台的分类,和电视节目列表都是一次性的从网上取下来直接放入数据里,然后才开始
* 进行使用的,所以在使用的过程中暂时不牵涉网络的问题.
*
* @author LeeYewKuan
* @creatDate:2014年6月20日
*/
public interface IFaceNetTvGroupManager {
/**
* 获取TvGroup列表,如果成功,则调用CallBackListener.onSuccess(), 如果失败
* 则调用CallBackListener.onFail(),并返回失败的异常码,如果出现异常,则调用
* onError()方法,返回对应的错误码.(可以暂不实现)
*
* onFail()返回值
* 0:失败
* -10: 服务器返回成功,但是缺失成功时需要的参数,或者解析异常
*
* @param mContext
* @param listener
* @author: LeeYewKuan
* @update: 2014年6月16日
*/
void getTvGroupList(int conTimeout, int soTimeout,
GetTvGroupsListener tvGroupsListener);
}
| 1,063 | 0.740638 | 0.71706 | 30 | 23.033333 | 20.360884 | 66 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.066667 | false | false | 9 |
d35b914eaaad42985fefac6e927d5ffc842056e8 | 8,916,352,166,651 | 84d51c2e58abecbdca0ced168873bc89a5e448b8 | /springcloud2.0-huihuang-parent/springcloud2.0-huihuang-api-service/springcloud2.0-huihuang-api-member-service/src/test/java/com/test/TestClient.java | 7fd0bf251f68945f104bd55ae68559629cbba56b | [] | no_license | RaidenXin/springcloud2.0-feign | https://github.com/RaidenXin/springcloud2.0-feign | 67e953505ce34bd7a785941bc6e3b382b0a9972f | 47fc09da2d64d20ca4f7dcd9cb122f019687a24c | refs/heads/master | 2020-05-09T17:29:08.157000 | 2019-04-14T13:40:42 | 2019-04-14T13:40:42 | 181,311,532 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.test;
import com.huihuang.entiy.User;
public class TestClient {
public void test(){
User user = new User();
}
}
| UTF-8 | Java | 143 | java | TestClient.java | Java | [] | null | [] | package com.test;
import com.huihuang.entiy.User;
public class TestClient {
public void test(){
User user = new User();
}
}
| 143 | 0.629371 | 0.629371 | 10 | 13.3 | 12.736169 | 31 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.3 | false | false | 9 |
347d73eeb467d2eea4f49c66e93c3b18a88a1beb | 29,996,051,663,986 | 3beb6af961f596fb89d500a8674dfc52a1a3e0c6 | /src/com/danimar/irregularVerbsGame/data/SimpleGameData.java | a81159a5568f015363b572d76fd1b97692664a99 | [] | no_license | danfranco/IrregularVerbsGame | https://github.com/danfranco/IrregularVerbsGame | ced54862785d18e26863e2f4f526b9779c1f423c | 8e4d9d80eaa4ba9753e6e3e8940f89c3af441009 | refs/heads/master | 2023-01-24T01:17:38.072000 | 2020-11-17T20:57:06 | 2020-11-17T20:57:06 | 313,741,515 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.danimar.irregularVerbsGame.data;
import java.util.Vector;
public class SimpleGameData {
private Vector<String> espanol;
private Vector<String> ingles;
public SimpleGameData() {
espanol = new Vector<String>();
ingles = new Vector<String>();
}
public Vector<String> getEspanol() {
return espanol;
}
public Vector<String> getIngles() {
return ingles;
}
public void addQuestion(String espanol, String ingles) {
this.espanol.add(espanol);
this.ingles.add(ingles);
}
}
| UTF-8 | Java | 507 | java | SimpleGameData.java | Java | [] | null | [] | package com.danimar.irregularVerbsGame.data;
import java.util.Vector;
public class SimpleGameData {
private Vector<String> espanol;
private Vector<String> ingles;
public SimpleGameData() {
espanol = new Vector<String>();
ingles = new Vector<String>();
}
public Vector<String> getEspanol() {
return espanol;
}
public Vector<String> getIngles() {
return ingles;
}
public void addQuestion(String espanol, String ingles) {
this.espanol.add(espanol);
this.ingles.add(ingles);
}
}
| 507 | 0.717949 | 0.717949 | 28 | 17.107143 | 16.765907 | 57 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.25 | false | false | 9 |
1fc256e3065a7de3af4c29e0e98c71b24848a6a1 | 4,260,607,562,850 | 025717878c83903cdc34cc7c1b9912a67c30dd24 | /src/main/java/com/softeng/ticket_application/model/Ticket.java | b13316d130c6b98837abbaaaa7741f8d56689c5f | [
"MIT"
] | permissive | callyall/SoftwareEngineeringClassProject | https://github.com/callyall/SoftwareEngineeringClassProject | 629c1b38309fb6dadbbcd8a790ae2569ca61a77b | 3057efe15fc62d76f489e6bae811d1e58821ee6e | refs/heads/master | 2021-09-05T17:03:21.297000 | 2018-01-29T21:06:43 | 2018-01-29T21:06:43 | 111,205,578 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.softeng.ticket_application.model;
import org.hibernate.validator.constraints.Email;
import org.hibernate.validator.constraints.NotEmpty;
import javax.persistence.*;
import javax.validation.constraints.NotNull;
/**
*
*
* @author Argiris Sideris
*/
@Entity
public class Ticket {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private int id;
@Column(name="first_name")
@NotEmpty
private String firstName;
@Column(name="last_name")
@NotEmpty
private String lastName;
@Email
@NotEmpty
private String email;
@NotNull
private long phone;
@ManyToOne(fetch = FetchType.EAGER)
@JoinColumn(name="gid",referencedColumnName="id")
private Gate gate;
public Ticket() {
// Default constructor
}
public int getId() {
return id;
}
public void setId(final int id) {
this.id = id;
}
public String getFirstName() {
return firstName;
}
public void setFirstName(final String firstName) {
this.firstName = firstName;
}
public String getLastName() {
return lastName;
}
public void setLastName(final String lastName) {
this.lastName = lastName;
}
public String getEmail() {
return email;
}
public void setEmail(final String email) {
this.email = email;
}
public long getPhone() {
return phone;
}
public void setPhone(final long phone) {
this.phone = phone;
}
public Gate getGate() {
return gate;
}
public void setGate(final Gate gate) {
this.gate = gate;
}
}
| UTF-8 | Java | 1,736 | java | Ticket.java | Java | [
{
"context": ".constraints.NotNull;\r\n\r\n\r\n/**\r\n *\r\n *\r\n * @author Argiris Sideris\r\n */\r\n@Entity\r\npublic class Ticket {\r\n\r\n @Id\r\n",
"end": 274,
"score": 0.9998397827148438,
"start": 259,
"tag": "NAME",
"value": "Argiris Sideris"
}
] | null | [] | package com.softeng.ticket_application.model;
import org.hibernate.validator.constraints.Email;
import org.hibernate.validator.constraints.NotEmpty;
import javax.persistence.*;
import javax.validation.constraints.NotNull;
/**
*
*
* @author <NAME>
*/
@Entity
public class Ticket {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private int id;
@Column(name="first_name")
@NotEmpty
private String firstName;
@Column(name="last_name")
@NotEmpty
private String lastName;
@Email
@NotEmpty
private String email;
@NotNull
private long phone;
@ManyToOne(fetch = FetchType.EAGER)
@JoinColumn(name="gid",referencedColumnName="id")
private Gate gate;
public Ticket() {
// Default constructor
}
public int getId() {
return id;
}
public void setId(final int id) {
this.id = id;
}
public String getFirstName() {
return firstName;
}
public void setFirstName(final String firstName) {
this.firstName = firstName;
}
public String getLastName() {
return lastName;
}
public void setLastName(final String lastName) {
this.lastName = lastName;
}
public String getEmail() {
return email;
}
public void setEmail(final String email) {
this.email = email;
}
public long getPhone() {
return phone;
}
public void setPhone(final long phone) {
this.phone = phone;
}
public Gate getGate() {
return gate;
}
public void setGate(final Gate gate) {
this.gate = gate;
}
}
| 1,727 | 0.591014 | 0.591014 | 87 | 17.954023 | 16.396599 | 54 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.275862 | false | false | 9 |
87a0f4bd8aa7faae6441cd511bfb5dfdb44d4841 | 4,260,607,564,731 | c5345bf63d8ff240c50c49b6a6326676e8e3bb82 | /src/_06_set/BSTSet.java | ee0c86da1c31ce0781171e4ff589f80c161923f7 | [] | no_license | XiZiwei/algorithm | https://github.com/XiZiwei/algorithm | ee5e749bf75c950806b1efe86c33b637da39264c | 575dd5e4b987f32d625cfcdd793eb7b4a567b928 | refs/heads/master | 2020-05-17T18:26:40.723000 | 2019-07-10T13:45:29 | 2019-07-10T13:45:29 | 120,900,453 | 1 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package _06_set;
import _05_tree.BinarySearchTree;
/**
* 基于二分搜索树实现集合
* @param <E>
*/
public class BSTSet<E extends Comparable<E>> {
private BinarySearchTree<E> binarySearchTree;
public BSTSet() {
binarySearchTree = new BinarySearchTree<>();
}
public int getSize() {
return binarySearchTree.getSize();
}
public boolean isEmpty() {
return binarySearchTree.isEmpty();
}
public boolean contains(E e) {
return binarySearchTree.contains(e);
}
public void add(E e) {
binarySearchTree.add(e);
}
public void remove(E e) {
binarySearchTree.remove(e);
}
}
| UTF-8 | Java | 675 | java | BSTSet.java | Java | [] | null | [] | package _06_set;
import _05_tree.BinarySearchTree;
/**
* 基于二分搜索树实现集合
* @param <E>
*/
public class BSTSet<E extends Comparable<E>> {
private BinarySearchTree<E> binarySearchTree;
public BSTSet() {
binarySearchTree = new BinarySearchTree<>();
}
public int getSize() {
return binarySearchTree.getSize();
}
public boolean isEmpty() {
return binarySearchTree.isEmpty();
}
public boolean contains(E e) {
return binarySearchTree.contains(e);
}
public void add(E e) {
binarySearchTree.add(e);
}
public void remove(E e) {
binarySearchTree.remove(e);
}
}
| 675 | 0.618683 | 0.612557 | 32 | 19.40625 | 17.186222 | 52 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.28125 | false | false | 9 |
1728b5a88d32ab520788a7b1a0515a4eeca42f7a | 33,758,442,968,335 | 9dd6d0e2399e616d64f71d6faf53e2f06374151c | /src/com/app/overloading3/Demo.java | e324843df07dfc423ac2b1e0b26afa60346cdef8 | [] | no_license | raviyasas/Java-Study | https://github.com/raviyasas/Java-Study | e7ecb34dbe3287e57a61233d738f2d848f3d8b59 | 7e1306371e16d39e090432efea13c602f055f493 | refs/heads/master | 2019-07-06T04:34:15.458000 | 2016-09-16T15:34:20 | 2016-09-16T15:34:20 | 65,061,111 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.app.overloading3;
public class Demo {
public void m1(int i){
System.out.println("int");
}
public void m1(float f){
System.out.println("float");
}
}
| UTF-8 | Java | 183 | java | Demo.java | Java | [] | null | [] | package com.app.overloading3;
public class Demo {
public void m1(int i){
System.out.println("int");
}
public void m1(float f){
System.out.println("float");
}
}
| 183 | 0.622951 | 0.606557 | 12 | 13.25 | 12.722192 | 30 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.916667 | false | false | 9 |
dbc554089152f70f399c1b3f1f55e1123638c51a | 28,759,101,071,619 | e1d24070345f8c459f7c0f81d60f3e43071c6cb0 | /JavaDocSamplingProject/src/main/java/kr/co/noel/javadoc/kafka/KafkaProducerTest.java | 28bedc95cfc6666ebf91efe5c2dfa1922837dba1 | [] | no_license | choi-ys/JavaDocSample | https://github.com/choi-ys/JavaDocSample | 06cc0459f7a01a1417c230b25d908c5e5025044f | f778599b4f4d85cc8ae445c51f289abe0b1ed85b | refs/heads/master | 2021-10-27T19:01:02.358000 | 2019-04-19T00:48:25 | 2019-04-19T00:48:25 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package kr.co.noel.javadoc.kafka;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import lombok.extern.slf4j.Slf4j;
@Component
@Slf4j
public class KafkaProducerTest {
@Scheduled(fixedRate = 10000)
public void kafkaProducerTest() {
log.info("Send Topic");
}
}
| UTF-8 | Java | 345 | java | KafkaProducerTest.java | Java | [] | null | [] | package kr.co.noel.javadoc.kafka;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import lombok.extern.slf4j.Slf4j;
@Component
@Slf4j
public class KafkaProducerTest {
@Scheduled(fixedRate = 10000)
public void kafkaProducerTest() {
log.info("Send Topic");
}
}
| 345 | 0.750725 | 0.727536 | 16 | 19.5625 | 18.85129 | 59 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.625 | false | false | 9 |
30f4eae06a80fd105424bf0cdaa0c31fcc254b21 | 35,588,099,035,077 | b26394d449ab551546ca130747302a85d47bb973 | /erp/src/test/java/com/digitoll/erp/service/CountryServiceTest.java | 5d329e05ab7f181a92ca9bbd17756dd23bc7d465 | [] | no_license | meryathadt/test-jenkon-digitoll-services-dev | https://github.com/meryathadt/test-jenkon-digitoll-services-dev | cfc54e1704e6a51a30631e74c1b2dc189d6ce685 | 5dd5929e200e10c2d661301d6370d6d7181156e9 | refs/heads/master | 2021-06-22T23:32:56.487000 | 2019-10-31T17:43:27 | 2019-10-31T17:43:27 | 217,485,228 | 0 | 0 | null | false | 2021-04-26T19:38:20 | 2019-10-25T08:13:12 | 2019-10-31T17:43:30 | 2021-04-26T19:38:20 | 1,344 | 0 | 0 | 2 | Java | false | false | package com.digitoll.erp.service;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mockito;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.mock.mockito.MockBean;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringRunner;
import com.digitoll.commons.dto.CountryResponseDTO;
import com.digitoll.commons.model.Country;
import com.digitoll.commons.util.BasicUtils;
import com.digitoll.erp.repository.CountryRepository;
import static org.junit.Assert.*;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.mockito.Mockito.when;
@RunWith(SpringRunner.class)
@ContextConfiguration(classes = { CountryService.class })
public class CountryServiceTest {
@MockBean
CountryRepository repository;
@Autowired
CountryService service;
@Test
public void testGetCountriesByLanguageSuccess() {
String language = "en";
List<Country> countriesInRepo = new LinkedList<>();
List<CountryResponseDTO> mockedCountries = new LinkedList<>();
Country mockCountry = new Country();
mockCountry.setCountryCode("BG");
mockCountry.setCountryName("Bulgaria");
mockCountry.setLanguage(language);
mockCountry.setId("9");
countriesInRepo.add(mockCountry);
Mockito.when(repository.findAllByLanguage(language)).thenReturn(countriesInRepo);
countriesInRepo.forEach(country -> {
CountryResponseDTO newCountry = new CountryResponseDTO();
BasicUtils.copyPropsSkip(country, newCountry, Arrays.asList("id", "language"));
mockedCountries.add(newCountry);
});
List<CountryResponseDTO> countries = service.getCountriesByLanguage(language);
assertFalse(countries.isEmpty());
assertEquals(mockedCountries, countries);
assertTrue(countries.size() == countriesInRepo.size());
}
@Test
public void testGetCountriesByLanguageSuccessEmpty() {
String language = "en";
Mockito.when(repository.findAllByLanguage(language)).thenReturn(new ArrayList<Country>());
List<CountryResponseDTO> countries = service.getCountriesByLanguage(language);
assertTrue(countries.isEmpty());
}
@Test
public void testInsertCountryListSuccess() {
String language = "bulgarian";
Country mockCountry = new Country("BG", "Bulgaria", language.toLowerCase());
HashMap<String, String> countries = new HashMap<String, String>();
countries.put("BG", "Bulgaria");
when(repository.save(mockCountry)).thenReturn(mockCountry);
service.insertCountryList(countries, language);
}
@Test
public void testGetCountryNameByCodeAndLanguage() {
String code = "BG";
String language = "bulgarian";
Country mockCountry = new Country();
Mockito.when(repository.findByCountryCodeAndLanguage(code, language)).thenReturn(mockCountry);
Country response = service.getCountryNameByCodeAndLanguage(code, language);
assertEquals(mockCountry, response);
}
}
| UTF-8 | Java | 3,057 | java | CountryServiceTest.java | Java | [] | null | [] | package com.digitoll.erp.service;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mockito;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.mock.mockito.MockBean;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringRunner;
import com.digitoll.commons.dto.CountryResponseDTO;
import com.digitoll.commons.model.Country;
import com.digitoll.commons.util.BasicUtils;
import com.digitoll.erp.repository.CountryRepository;
import static org.junit.Assert.*;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.mockito.Mockito.when;
@RunWith(SpringRunner.class)
@ContextConfiguration(classes = { CountryService.class })
public class CountryServiceTest {
@MockBean
CountryRepository repository;
@Autowired
CountryService service;
@Test
public void testGetCountriesByLanguageSuccess() {
String language = "en";
List<Country> countriesInRepo = new LinkedList<>();
List<CountryResponseDTO> mockedCountries = new LinkedList<>();
Country mockCountry = new Country();
mockCountry.setCountryCode("BG");
mockCountry.setCountryName("Bulgaria");
mockCountry.setLanguage(language);
mockCountry.setId("9");
countriesInRepo.add(mockCountry);
Mockito.when(repository.findAllByLanguage(language)).thenReturn(countriesInRepo);
countriesInRepo.forEach(country -> {
CountryResponseDTO newCountry = new CountryResponseDTO();
BasicUtils.copyPropsSkip(country, newCountry, Arrays.asList("id", "language"));
mockedCountries.add(newCountry);
});
List<CountryResponseDTO> countries = service.getCountriesByLanguage(language);
assertFalse(countries.isEmpty());
assertEquals(mockedCountries, countries);
assertTrue(countries.size() == countriesInRepo.size());
}
@Test
public void testGetCountriesByLanguageSuccessEmpty() {
String language = "en";
Mockito.when(repository.findAllByLanguage(language)).thenReturn(new ArrayList<Country>());
List<CountryResponseDTO> countries = service.getCountriesByLanguage(language);
assertTrue(countries.isEmpty());
}
@Test
public void testInsertCountryListSuccess() {
String language = "bulgarian";
Country mockCountry = new Country("BG", "Bulgaria", language.toLowerCase());
HashMap<String, String> countries = new HashMap<String, String>();
countries.put("BG", "Bulgaria");
when(repository.save(mockCountry)).thenReturn(mockCountry);
service.insertCountryList(countries, language);
}
@Test
public void testGetCountryNameByCodeAndLanguage() {
String code = "BG";
String language = "bulgarian";
Country mockCountry = new Country();
Mockito.when(repository.findByCountryCodeAndLanguage(code, language)).thenReturn(mockCountry);
Country response = service.getCountryNameByCodeAndLanguage(code, language);
assertEquals(mockCountry, response);
}
}
| 3,057 | 0.784102 | 0.783448 | 100 | 29.57 | 26.285835 | 96 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.58 | false | false | 9 |
eac40959babf07e0090567e2996c5481bf39c56d | 7,997,229,165,079 | 6aedf138241f071e47b4f5608c06391d24f04656 | /src/main/java/sample/model/SysModule.java | e4106a59599e9ab43a913c733566cc7e78218824 | [] | no_license | wxj19890410/vitality | https://github.com/wxj19890410/vitality | bac55689e666fab00955ae93e0a321b8d7047075 | 2d0fbd952e32ba0abee2acf1ebe7ef989348e0c7 | refs/heads/master | 2020-04-02T17:10:21.891000 | 2018-10-25T09:45:12 | 2018-10-25T09:45:12 | 154,646,857 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package sample.model;
import java.util.List;
import javax.persistence.Entity;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import com.google.gson.annotations.Expose;
@Entity
@Table(name = "sys_module")
public class SysModule extends BaseModel {
private String name;
private Integer sequence;
@OneToMany(mappedBy = "sysModule")
@Expose(serialize = false, deserialize = false)
private List<SysMenu> sysMenus;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Integer getSequence() {
return sequence;
}
public void setSequence(Integer sequence) {
this.sequence = sequence;
}
public List<SysMenu> getSysMenus() {
return sysMenus;
}
public void setSysMenus(List<SysMenu> sysMenus) {
this.sysMenus = sysMenus;
}
}
| UTF-8 | Java | 825 | java | SysModule.java | Java | [] | null | [] | package sample.model;
import java.util.List;
import javax.persistence.Entity;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import com.google.gson.annotations.Expose;
@Entity
@Table(name = "sys_module")
public class SysModule extends BaseModel {
private String name;
private Integer sequence;
@OneToMany(mappedBy = "sysModule")
@Expose(serialize = false, deserialize = false)
private List<SysMenu> sysMenus;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Integer getSequence() {
return sequence;
}
public void setSequence(Integer sequence) {
this.sequence = sequence;
}
public List<SysMenu> getSysMenus() {
return sysMenus;
}
public void setSysMenus(List<SysMenu> sysMenus) {
this.sysMenus = sysMenus;
}
}
| 825 | 0.738182 | 0.738182 | 45 | 17.333334 | 16.293148 | 50 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1 | false | false | 9 |
2f403c9554495f9b523f0f572273150ed7725106 | 34,961,033,807,254 | ea4032c14ec8fa679945ac320a9c88622ba0ac05 | /files/ps0/private-sp15-ps0-beta-0-day-ainezm-src-turtle-TurtleSoup.java | 531343dda8529810bcc7a9d20ee444cf68782b54 | [] | no_license | kleinab/codeSearch | https://github.com/kleinab/codeSearch | 5827df74d3fde8eeff0dbf311a05134db9c50dd5 | 1f233f40d91e5b659e5ac0575289c05aed09d164 | refs/heads/master | 2015-08-20T05:48:35.811000 | 2015-07-24T11:30:00 | 2015-07-24T11:30:00 | 30,426,667 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | /* Copyright (c) 2007-2015 MIT 6.005 course staff, all rights reserved.
* Redistribution of original or derived work requires permission of course staff.
*/
package turtle;
import java.util.List;
import java.util.ArrayList;
public class TurtleSoup {
/**
* Draw a square.
*
* @param turtle the turtle context
* @param sideLength length of each side
*/
public static void drawSquare(Turtle turtle, int sideLength) {
int sides=4;
while (sides > 0){
turtle.turn(90);
turtle.forward(sideLength);
sides=sides-1;
}
}
/**
* Determine inside angles of a regular polygon.
*
* There is a simple formula for calculating the inside angles of a polygon;
* you should derive it and use it here.
*
* @param sides number of sides, where sides must be > 2
* @return angle in degrees, where 0 <= angle < 360
*/
public static double calculateRegularPolygonAngle(int sides) {
double divSide=(double)sides;
double angle=((divSide-2)*180)/divSide;
//System.out.println(angle);
return (angle);
}
/**
* Determine number of sides given the size of interior angles of a regular polygon.
*
* There is a simple formula for this; you should derive it and use it here.
* Make sure you *properly round* the answer before you return it (see java.lang.Math).
* HINT: it is easier if you think about the exterior angles.
*
* @param angle size of interior angles in degrees
* @return the integer number of sides
*/
public static int calculatePolygonSidesFromAngle(double angle) {
double divAngle=(double)angle;
double sides=-360/(divAngle-180);
int intSide=(int) Math.round(sides);
//System.out.println(intSide+ " ");
return intSide;
}
/**
* Given the number of sides, draw a regular polygon.
*
* (0,0) is the lower-left corner of the polygon; use only right-hand turns to draw.
*
* @param turtle the turtle context
* @param sides number of sides of the polygon to draw
* @param sideLength length of each side
*/
public static void drawRegularPolygon(Turtle turtle, int sides, int sideLength) {
int polySide = sides;
double polyAngle= 180-calculateRegularPolygonAngle(sides);
while (polySide > 0){
turtle.forward(sideLength);
turtle.turn(polyAngle);
//System.out.println(polyAngle);
polySide=polySide-1;}
}
/**
* Given the current direction, current location, and a target location, calculate the heading
* towards the target point.
*
* The return value is the angle input to turn() that would point the turtle in the direction of
* the target point (targetX,targetY), given that the turtle is already at the point
* (currentX,currentY) and is facing at angle currentHeading. The angle must be expressed in
* degrees, where 0 <= angle < 360.
*
* HINT: look at http://en.wikipedia.org/wiki/Atan2 and Java's math libraries
*
* @param currentHeading current direction as clockwise from north
* @param currentX current location x-coordinate
* @param currentY current location y-coordinate
* @param targetX target point x-coordinate
* @param targetY target point y-coordinate
* @return adjustment to heading (right turn amount) to get to target point,
* must be 0 <= angle < 360.
*/
public static double calculateHeadingToPoint(double currentHeading, int currentX, int currentY,
int targetX, int targetY) {
int deltaY = targetY-currentY;//we will calculate the angle between the points using trig, then the difference between that angle and the currentHeading to see how far to turn
int deltaX= targetX-currentX;
double targetAngle=0.0;
double targetSlope=0.0;
if (deltaX==0){ //special case where atan won't work due to division by 0
if (deltaY>=0){
targetAngle=0.0;
}
else{
targetAngle=180.0;
}
}
else{
targetSlope= (double) deltaY/deltaX;
targetAngle= -Math.toDegrees(Math.atan(targetSlope))+90; //we want the reflection and 90 degree rotation of what atan returns to be consistent with how currentHeading is defined
}
return (targetAngle-currentHeading %360 +360) %360; //was having trouble getting mod 360 to return nonnegative value, the +360 %360 ensures it will be positive
}
/**
* Given a sequence of points, calculate the heading adjustments needed to get from each point
* to the next.
*
* Assumes that the turtle starts at the first point given, facing up (i.e. 0 degrees).
* For each subsequent point, assumes that the turtle is still facing in the direction it was
* facing when it moved to the previous point.
* You should use calculateHeadingToPoint() to implement this function.
*
* @param xCoords list of x-coordinates (must be same length as yCoords)
* @param yCoords list of y-coordinates (must be same length as xCoords)
* @return list of heading adjustments between points, of size (# of points) - 1.
*/
public static List<Double> calculateHeadings(List<Integer> xCoords, List<Integer> yCoords) {
List<Double> HeadingAdjustments = new ArrayList<Double>();
double currentHeading=0.0;
for (int n=0; n < xCoords.size()-1; n++){
double adjustment=calculateHeadingToPoint(currentHeading,xCoords.get(n),yCoords.get(n),xCoords.get(n+1),yCoords.get(n+1));
HeadingAdjustments.add(adjustment);
currentHeading= currentHeading+adjustment;
}
return HeadingAdjustments;
}
/**
* Draw your personal, custom art.
*
* Many interesting images can be drawn using the simple implementation of a turtle. For this
* function, draw something interesting; the complexity can be as little or as much as you want.
* We'll be peer-voting on the different images, and the highest-rated one will win a prize.
*
* @param turtle the turtle context
*/
public static void drawPersonalArt(Turtle turtle) {
String toBeReplaced= "G";
String pattern= "GLGRGRGLG";
//The idea is we will encode instructions in the char sequence of a string
//G: Go Forward; L: Turn Left; R: Turn Right
String it1 =pattern.replaceAll(toBeReplaced,pattern);
String it2 =it1.replaceAll(toBeReplaced,pattern);
String it3 =it2.replaceAll(toBeReplaced,pattern);
String iteratedStr =it3.replaceAll(toBeReplaced,pattern);
//Why must strings be immutable
for (int horizontal = 2; horizontal > 0; horizontal--) { //creates the two diamonds along the x axis
for (int lower = 2; lower > 0; lower--) { //This loop creates the lower diamond
for (int diamond = 2; diamond > 0; diamond--) { //This loop creates a diamond
for (int i = 0; i < iteratedStr.length(); i++) {
char instruction = iteratedStr.charAt(i); //The meat of the code, it reads the instructions encoded in the iteratedStr
if (instruction == 'G') {
turtle.forward(3);
}
if (instruction == 'L') {
turtle.turn(270.0);
}
if (instruction == 'R') {
turtle.turn(90.0);
}
}
turtle.turn(180.0);
}
turtle.turn(180.0);
}
turtle.turn(90.0);
}
}
/**
* Main method.
*
* This is the method that runs when you run "java TurtleSoup".
*
* @param args unused
*/
public static void main(String args[]) {
DrawableTurtle turtle = new DrawableTurtle();
drawPersonalArt(turtle);
// draw the window
turtle.draw();
}
} | UTF-8 | Java | 7,876 | java | private-sp15-ps0-beta-0-day-ainezm-src-turtle-TurtleSoup.java | Java | [] | null | [] | /* Copyright (c) 2007-2015 MIT 6.005 course staff, all rights reserved.
* Redistribution of original or derived work requires permission of course staff.
*/
package turtle;
import java.util.List;
import java.util.ArrayList;
public class TurtleSoup {
/**
* Draw a square.
*
* @param turtle the turtle context
* @param sideLength length of each side
*/
public static void drawSquare(Turtle turtle, int sideLength) {
int sides=4;
while (sides > 0){
turtle.turn(90);
turtle.forward(sideLength);
sides=sides-1;
}
}
/**
* Determine inside angles of a regular polygon.
*
* There is a simple formula for calculating the inside angles of a polygon;
* you should derive it and use it here.
*
* @param sides number of sides, where sides must be > 2
* @return angle in degrees, where 0 <= angle < 360
*/
public static double calculateRegularPolygonAngle(int sides) {
double divSide=(double)sides;
double angle=((divSide-2)*180)/divSide;
//System.out.println(angle);
return (angle);
}
/**
* Determine number of sides given the size of interior angles of a regular polygon.
*
* There is a simple formula for this; you should derive it and use it here.
* Make sure you *properly round* the answer before you return it (see java.lang.Math).
* HINT: it is easier if you think about the exterior angles.
*
* @param angle size of interior angles in degrees
* @return the integer number of sides
*/
public static int calculatePolygonSidesFromAngle(double angle) {
double divAngle=(double)angle;
double sides=-360/(divAngle-180);
int intSide=(int) Math.round(sides);
//System.out.println(intSide+ " ");
return intSide;
}
/**
* Given the number of sides, draw a regular polygon.
*
* (0,0) is the lower-left corner of the polygon; use only right-hand turns to draw.
*
* @param turtle the turtle context
* @param sides number of sides of the polygon to draw
* @param sideLength length of each side
*/
public static void drawRegularPolygon(Turtle turtle, int sides, int sideLength) {
int polySide = sides;
double polyAngle= 180-calculateRegularPolygonAngle(sides);
while (polySide > 0){
turtle.forward(sideLength);
turtle.turn(polyAngle);
//System.out.println(polyAngle);
polySide=polySide-1;}
}
/**
* Given the current direction, current location, and a target location, calculate the heading
* towards the target point.
*
* The return value is the angle input to turn() that would point the turtle in the direction of
* the target point (targetX,targetY), given that the turtle is already at the point
* (currentX,currentY) and is facing at angle currentHeading. The angle must be expressed in
* degrees, where 0 <= angle < 360.
*
* HINT: look at http://en.wikipedia.org/wiki/Atan2 and Java's math libraries
*
* @param currentHeading current direction as clockwise from north
* @param currentX current location x-coordinate
* @param currentY current location y-coordinate
* @param targetX target point x-coordinate
* @param targetY target point y-coordinate
* @return adjustment to heading (right turn amount) to get to target point,
* must be 0 <= angle < 360.
*/
public static double calculateHeadingToPoint(double currentHeading, int currentX, int currentY,
int targetX, int targetY) {
int deltaY = targetY-currentY;//we will calculate the angle between the points using trig, then the difference between that angle and the currentHeading to see how far to turn
int deltaX= targetX-currentX;
double targetAngle=0.0;
double targetSlope=0.0;
if (deltaX==0){ //special case where atan won't work due to division by 0
if (deltaY>=0){
targetAngle=0.0;
}
else{
targetAngle=180.0;
}
}
else{
targetSlope= (double) deltaY/deltaX;
targetAngle= -Math.toDegrees(Math.atan(targetSlope))+90; //we want the reflection and 90 degree rotation of what atan returns to be consistent with how currentHeading is defined
}
return (targetAngle-currentHeading %360 +360) %360; //was having trouble getting mod 360 to return nonnegative value, the +360 %360 ensures it will be positive
}
/**
* Given a sequence of points, calculate the heading adjustments needed to get from each point
* to the next.
*
* Assumes that the turtle starts at the first point given, facing up (i.e. 0 degrees).
* For each subsequent point, assumes that the turtle is still facing in the direction it was
* facing when it moved to the previous point.
* You should use calculateHeadingToPoint() to implement this function.
*
* @param xCoords list of x-coordinates (must be same length as yCoords)
* @param yCoords list of y-coordinates (must be same length as xCoords)
* @return list of heading adjustments between points, of size (# of points) - 1.
*/
public static List<Double> calculateHeadings(List<Integer> xCoords, List<Integer> yCoords) {
List<Double> HeadingAdjustments = new ArrayList<Double>();
double currentHeading=0.0;
for (int n=0; n < xCoords.size()-1; n++){
double adjustment=calculateHeadingToPoint(currentHeading,xCoords.get(n),yCoords.get(n),xCoords.get(n+1),yCoords.get(n+1));
HeadingAdjustments.add(adjustment);
currentHeading= currentHeading+adjustment;
}
return HeadingAdjustments;
}
/**
* Draw your personal, custom art.
*
* Many interesting images can be drawn using the simple implementation of a turtle. For this
* function, draw something interesting; the complexity can be as little or as much as you want.
* We'll be peer-voting on the different images, and the highest-rated one will win a prize.
*
* @param turtle the turtle context
*/
public static void drawPersonalArt(Turtle turtle) {
String toBeReplaced= "G";
String pattern= "GLGRGRGLG";
//The idea is we will encode instructions in the char sequence of a string
//G: Go Forward; L: Turn Left; R: Turn Right
String it1 =pattern.replaceAll(toBeReplaced,pattern);
String it2 =it1.replaceAll(toBeReplaced,pattern);
String it3 =it2.replaceAll(toBeReplaced,pattern);
String iteratedStr =it3.replaceAll(toBeReplaced,pattern);
//Why must strings be immutable
for (int horizontal = 2; horizontal > 0; horizontal--) { //creates the two diamonds along the x axis
for (int lower = 2; lower > 0; lower--) { //This loop creates the lower diamond
for (int diamond = 2; diamond > 0; diamond--) { //This loop creates a diamond
for (int i = 0; i < iteratedStr.length(); i++) {
char instruction = iteratedStr.charAt(i); //The meat of the code, it reads the instructions encoded in the iteratedStr
if (instruction == 'G') {
turtle.forward(3);
}
if (instruction == 'L') {
turtle.turn(270.0);
}
if (instruction == 'R') {
turtle.turn(90.0);
}
}
turtle.turn(180.0);
}
turtle.turn(180.0);
}
turtle.turn(90.0);
}
}
/**
* Main method.
*
* This is the method that runs when you run "java TurtleSoup".
*
* @param args unused
*/
public static void main(String args[]) {
DrawableTurtle turtle = new DrawableTurtle();
drawPersonalArt(turtle);
// draw the window
turtle.draw();
}
} | 7,876 | 0.645251 | 0.629634 | 209 | 36.688995 | 35.209068 | 186 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.287081 | false | false | 9 |
56fcf1435df789d8a190b0f070b9eb02ff571a00 | 35,983,236,016,426 | 7bae27cbbc4af0f26c7f2c00deb2849b1780dbca | /skeleton/src/main/java/cn/sinjinsong/skeleton/exception/user/UsernameExistedException.java | 0c93e42725c8d9e4110303f006ebb15cbd0f3bfd | [] | no_license | yeshaohuagg/JavaWebSkeleton | https://github.com/yeshaohuagg/JavaWebSkeleton | 4244adc626e7046472a4b4c9c0c1a775da08e2ce | 20ca13263f09744011da23147b62c24668fe77c6 | refs/heads/master | 2021-09-19T09:10:27.835000 | 2018-07-26T06:34:20 | 2018-07-26T06:34:20 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package cn.sinjinsong.skeleton.exception.user;
import cn.sinjinsong.common.exception.annotation.RESTField;
import cn.sinjinsong.common.exception.annotation.RESTResponseStatus;
import cn.sinjinsong.common.exception.base.BaseRESTException;
import org.springframework.http.HttpStatus;
@RESTResponseStatus(value = HttpStatus.CONFLICT, code = 1)
@RESTField("name")
public class UsernameExistedException extends BaseRESTException {
public UsernameExistedException(String name) {
super(name);
}
}
| UTF-8 | Java | 509 | java | UsernameExistedException.java | Java | [] | null | [] | package cn.sinjinsong.skeleton.exception.user;
import cn.sinjinsong.common.exception.annotation.RESTField;
import cn.sinjinsong.common.exception.annotation.RESTResponseStatus;
import cn.sinjinsong.common.exception.base.BaseRESTException;
import org.springframework.http.HttpStatus;
@RESTResponseStatus(value = HttpStatus.CONFLICT, code = 1)
@RESTField("name")
public class UsernameExistedException extends BaseRESTException {
public UsernameExistedException(String name) {
super(name);
}
}
| 509 | 0.80943 | 0.807466 | 15 | 32.933334 | 26.281721 | 68 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.466667 | false | false | 9 |
a5d24bf88b13cabd2dcd6f0c4c0e64d977c4f811 | 37,778,532,336,809 | 70a49c5e628e1dc7ecbb62065a4efb9621ee8a15 | /src/main/java/machinecoding/splitwise/service/ExpenseService.java | 7b73ce7e39aee9c5ffd7b29ecab57e6a8e768a37 | [] | no_license | neeraj11789/tech-interview-problems | https://github.com/neeraj11789/tech-interview-problems | bfc7a86942d0dc1348154e0dd552ce423abf8dba | a90dc20fd0a31d50838a92b92c280cfc49f3714b | refs/heads/master | 2023-05-25T09:28:55.333000 | 2021-06-13T11:28:48 | 2021-06-13T11:28:48 | 253,031,147 | 1 | 2 | null | false | 2021-05-23T15:03:47 | 2020-04-04T15:24:25 | 2021-05-23T15:02:23 | 2021-05-23T15:03:46 | 733 | 1 | 2 | 1 | Java | false | false | package machinecoding.splitwise.service;
import machinecoding.splitwise.model.Expense;
import machinecoding.splitwise.model.User;
import java.util.List;
/** The interface Expense service. */
public interface ExpenseService {
/**
* Add expense.
*
* @param expense the expense
*/
void addExpense(Expense expense);
/**
* Remove expense.
*
* @param expense the expense
*/
void removeExpense(Expense expense);
/**
* Expense by user list.
*
* @param user the user
* @return the list
*/
List<Expense> expenseByUser(User user);
} | UTF-8 | Java | 572 | java | ExpenseService.java | Java | [] | null | [] | package machinecoding.splitwise.service;
import machinecoding.splitwise.model.Expense;
import machinecoding.splitwise.model.User;
import java.util.List;
/** The interface Expense service. */
public interface ExpenseService {
/**
* Add expense.
*
* @param expense the expense
*/
void addExpense(Expense expense);
/**
* Remove expense.
*
* @param expense the expense
*/
void removeExpense(Expense expense);
/**
* Expense by user list.
*
* @param user the user
* @return the list
*/
List<Expense> expenseByUser(User user);
} | 572 | 0.681818 | 0.681818 | 32 | 16.90625 | 15.454287 | 45 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.21875 | false | false | 9 |
d400a360785d53bb348cd4e79710b0fd6a74927b | 18,047,452,623,936 | a1a21c2774368c462f1e854448049004085174bc | /src/org/processmining/plugins/xpdl/deprecated/XpdlTool.java | c469657a43cb06290568d82f7b2de95247b31022 | [] | no_license | imatesiu/BPMN | https://github.com/imatesiu/BPMN | 07a009cb5365219c55de35412b130a3c9062c6e3 | a112e7762bf83d8a64fa0f6a5b45aefed26a1aca | refs/heads/master | 2020-04-01T22:57:11.647000 | 2011-11-29T14:19:19 | 2011-11-29T14:19:19 | 2,875,313 | 1 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package org.processmining.plugins.xpdl.deprecated;
import org.processmining.plugins.xpdl.XpdlElement;
public class XpdlTool extends XpdlElement {
public XpdlTool(String tag) {
super(tag);
}
}
| UTF-8 | Java | 211 | java | XpdlTool.java | Java | [] | null | [] | package org.processmining.plugins.xpdl.deprecated;
import org.processmining.plugins.xpdl.XpdlElement;
public class XpdlTool extends XpdlElement {
public XpdlTool(String tag) {
super(tag);
}
}
| 211 | 0.739336 | 0.739336 | 11 | 17.181818 | 20.616932 | 50 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.636364 | false | false | 9 |
0b13558abfed37eb794224c58186ba51447c9a0c | 36,094,905,164,488 | bb9a06e3d661afab65d334acaa2fe94590c0524f | /test/src/test/java/demo2/tests/ChromeDemo2Test.java | c1c6cbe21a9e367b2107a7107da39f966b3f2766 | [] | no_license | sharkxxx/Example | https://github.com/sharkxxx/Example | 0bf47d524364f91dc5b143869bb1e864d5f4cfe4 | 6c50ee0d891975e88df2f3c552b1c7d48a831849 | refs/heads/master | 2020-08-10T20:32:12.615000 | 2014-12-05T11:41:30 | 2014-12-05T11:41:30 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package demo2.tests;
import java.io.File;
import java.util.concurrent.TimeUnit;
import org.apache.commons.io.FileUtils;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.openqa.selenium.OutputType;
import org.openqa.selenium.TakesScreenshot;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.support.PageFactory;
import com.thoughtworks.selenium.Selenium;
import demo2.steps.CreateRequestforProposal;
import demo2.steps.HomePage;
import demo2.steps.LoginPage;
public class ChromeDemo2Test {
public WebDriver driver;
public Selenium selenium;
private static String login = "”;
private static String pass = "";
@Before
public void setUp() throws Exception {
System.setProperty("webdriver.chrome.driver","C:\\selenium-2.41.0\\chromedriver2.10.exe");
driver=new ChromeDriver();
// steps = new WebDriverSteps(
// new FirefoxDriver(new DesiredCapabilities())
// );
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
driver.manage().window().maximize();
try{
File file = new File("C:\\Users\\пользователь 2\\workspace\\screen\\testFireFox.png");
if(file.delete()){
System.out.println(file.getName() + " is deleted!");
}else{
System.out.println("Delete operation is failed.");
}
} catch(Exception e){
e.printStackTrace();
}
}
@Test
public void testChrome() throws Exception {
driver.get("https://*****************");
LoginPage loginPage = PageFactory.initElements(driver, LoginPage.class);
CreateRequestforProposal RequestforProposal=PageFactory.initElements(driver, CreateRequestforProposal.class);
HomePage homePage = loginPage.login(login, pass);
CreateRequestforProposal new_proc= homePage.CreateNewProc();
HomePage create_proc= RequestforProposal.CreateProc();
LoginPage loginPageAfterLogout = homePage.logout();
}
//@Attach(type = AttachmentType.PNG)
// public File makeScreenshotDemo() {
// return ((TakesScreenshot) driver).getScreenshotAs(OutputType.FILE);
// }
@After
public void tearDown() throws Exception {
{
try {
File scrFile =
((TakesScreenshot)driver).getScreenshotAs(OutputType.FILE);
FileUtils.copyFile(scrFile, new
File("C:\\Users\\пользователь 2\\workspace\\screen\\testFireFox.png"));
// makeScreenshotDemo();
} catch (Exception e) {
e.printStackTrace();
}
}
driver.quit();
}
}
| UTF-8 | Java | 2,605 | java | ChromeDemo2Test.java | Java | [] | null | [] | package demo2.tests;
import java.io.File;
import java.util.concurrent.TimeUnit;
import org.apache.commons.io.FileUtils;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.openqa.selenium.OutputType;
import org.openqa.selenium.TakesScreenshot;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.support.PageFactory;
import com.thoughtworks.selenium.Selenium;
import demo2.steps.CreateRequestforProposal;
import demo2.steps.HomePage;
import demo2.steps.LoginPage;
public class ChromeDemo2Test {
public WebDriver driver;
public Selenium selenium;
private static String login = "”;
private static String pass = "";
@Before
public void setUp() throws Exception {
System.setProperty("webdriver.chrome.driver","C:\\selenium-2.41.0\\chromedriver2.10.exe");
driver=new ChromeDriver();
// steps = new WebDriverSteps(
// new FirefoxDriver(new DesiredCapabilities())
// );
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
driver.manage().window().maximize();
try{
File file = new File("C:\\Users\\пользователь 2\\workspace\\screen\\testFireFox.png");
if(file.delete()){
System.out.println(file.getName() + " is deleted!");
}else{
System.out.println("Delete operation is failed.");
}
} catch(Exception e){
e.printStackTrace();
}
}
@Test
public void testChrome() throws Exception {
driver.get("https://*****************");
LoginPage loginPage = PageFactory.initElements(driver, LoginPage.class);
CreateRequestforProposal RequestforProposal=PageFactory.initElements(driver, CreateRequestforProposal.class);
HomePage homePage = loginPage.login(login, pass);
CreateRequestforProposal new_proc= homePage.CreateNewProc();
HomePage create_proc= RequestforProposal.CreateProc();
LoginPage loginPageAfterLogout = homePage.logout();
}
//@Attach(type = AttachmentType.PNG)
// public File makeScreenshotDemo() {
// return ((TakesScreenshot) driver).getScreenshotAs(OutputType.FILE);
// }
@After
public void tearDown() throws Exception {
{
try {
File scrFile =
((TakesScreenshot)driver).getScreenshotAs(OutputType.FILE);
FileUtils.copyFile(scrFile, new
File("C:\\Users\\пользователь 2\\workspace\\screen\\testFireFox.png"));
// makeScreenshotDemo();
} catch (Exception e) {
e.printStackTrace();
}
}
driver.quit();
}
}
| 2,605 | 0.706636 | 0.700427 | 111 | 22.216217 | 24.587555 | 110 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.720721 | false | false | 9 |
ff6b4d6b772e57190b400690c915270aba4dac3b | 34,239,479,321,869 | 2a4fd7ecba12ccf9994ac13a994538df1d8394a4 | /app/src/main/java/com/rommelbendel/scanQ/VokabelSpender.java | a04d8b408e14438e6b925f0c57533a03e63d8d63 | [] | no_license | marrommel/ScanQ | https://github.com/marrommel/ScanQ | eb915e50ba6e0032355bee394c76c979058e1078 | 8e6751d3fd3a56050f044c1788e694f357e63c39 | refs/heads/master | 2023-02-20T23:40:49.007000 | 2021-01-24T15:58:37 | 2021-01-24T15:58:37 | 283,950,496 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.rommelbendel.firstapp;;
import android.content.Context;
import android.os.Handler;
import android.os.Looper;
import android.util.Log;
import androidx.room.Room;
import org.jetbrains.annotations.NotNull;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
import java.util.concurrent.Executor;
public class VokabelSpender {
private Context context;
public Datenbank db;
public VokabelnDao vokabelnDao;
public List<Vokabel> alleVokabeln;
public List<Vokabel> kategorieVokabeln;
public List<Vokabel> answeredVokabeln;
static class ThreadPerTaskExecutor implements Executor {
@Override
public void execute(@NotNull Runnable runnable) {
Thread thread = new Thread(runnable);
thread.start();
}
}
/*
static class DirectExecuter implements Executor {
@Override
public void execute(@NotNull Runnable runnable) {
runnable.run();
}
}
*/
public VokabelSpender(@NotNull Context context) {
this.context = context;
final Datenbank db = Room.databaseBuilder(context, Datenbank.class, "VokabelnDatenbank").build();
this.vokabelnDao = db.vokabelnDao();
}
public void setAlleVokabeln(@NotNull List<Vokabel> alleVokabeln) {
Log.i("setAlleVokabeln", alleVokabeln.toString());
this.alleVokabeln = alleVokabeln;
}
public List<Vokabel> getAlleVokabeln() {
final VokabelnDao vokabelnDao = this.vokabelnDao;
//List<Vokabel> alleVokabeln;
new ThreadPerTaskExecutor().execute(new Runnable() {
@Override
public void run() {
final List<Vokabel> alleVokabeln = vokabelnDao.getAlle().getValue();
new Handler(Looper.getMainLooper()).post(new Runnable() {
@Override
public void run() {
Log.i("getAlleVokabeln", alleVokabeln.toString());
setAlleVokabeln(alleVokabeln);
}
});
}
});
return this.alleVokabeln;
}
public void setKategorieVokabeln(@NotNull List<Vokabel> kategorieVokabeln) {
this.kategorieVokabeln = kategorieVokabeln;
}
public List<Vokabel> getKategorieVokabeln(final String kategorie) {
final VokabelnDao vokabelnDao = this.vokabelnDao;
List<Vokabel> kategorieVokabeln;
new ThreadPerTaskExecutor().execute(new Runnable() {
@Override
public void run() {
final List<Vokabel> kategorieVokabeln = vokabelnDao.getKategorieVokabeln(kategorie).getValue();
new Handler(Looper.getMainLooper()).post(new Runnable() {
@Override
public void run() {
setKategorieVokabeln(kategorieVokabeln);
}
});
}
});
return this.kategorieVokabeln;
}
public Vokabel getRandomVokabel(String kategorie) {
Log.i("getRandomVokabel", kategorie);
List<Vokabel> vokabeln;
if (kategorie.equals("alle")) {
vokabeln = getAlleVokabeln();
} else {
vokabeln = getKategorieVokabeln(kategorie);
}
int index = new Random().nextInt(vokabeln.size());
return vokabeln.get(index);
}
public List<Vokabel> getQuizFrage(String kategorie) {
List<Vokabel> frageAntworten = new ArrayList<>();
Vokabel frage = getRandomVokabel(kategorie);
frageAntworten.add(frage);
List<Vokabel> falscheAntworten = getAlleVokabeln();
falscheAntworten.remove(frage);
for (int i = 0; i < 3; i++) {
Vokabel antwort = falscheAntworten.get(new Random().nextInt(falscheAntworten.size()));
frageAntworten.add(antwort);
falscheAntworten.remove(antwort);
}
return frageAntworten;
}
public void insertVokabeln(final Vokabel... vokabeln) {
final VokabelnDao vokabelnDao = this.vokabelnDao;
new ThreadPerTaskExecutor().execute(new Runnable() {
@Override
public void run() {
vokabelnDao.insertAlleVokabeln(vokabeln);
}
});
}
public void setAnsweredVokabeln(List<Vokabel> answeredVokabeln) {
this.answeredVokabeln = answeredVokabeln;
}
public List<Vokabel> getAlreadyAnswered(final int answered) {
final VokabelnDao vokabelnDao = this.vokabelnDao;
new ThreadPerTaskExecutor().execute(new Runnable() {
@Override
public void run() {
final List<Vokabel> answeredVokabeln = vokabelnDao.getAlreadyAnswered(answered).getValue();
new Handler(Looper.getMainLooper()).post(new Runnable() {
@Override
public void run() {
setAnsweredVokabeln(answeredVokabeln);
}
});
}
});
return this.answeredVokabeln;
}
public List<QuizFrage> generateQuiz(String kategorie, String type) {
List<QuizFrage> fragen = new ArrayList<>();
List<Vokabel> kategorieVokabeln = getKategorieVokabeln(kategorie);
Vokabel frage;
List<Vokabel> antworten = new ArrayList<>();
for (int i = 0; i < kategorieVokabeln.size(); i++) {
frage = kategorieVokabeln.get(i);
List<Vokabel> falscheAntworten = getAlleVokabeln();
falscheAntworten.remove(frage);
for (int count = 0; count < 3; count++) {
Vokabel antwort = falscheAntworten.get(new Random().nextInt(falscheAntworten.size()));
antworten.add(antwort);
falscheAntworten.remove(antwort);
}
fragen.add(new QuizFrage(frage, antworten, type));
antworten.clear();
}
return fragen;
}
/*
public void setVokabeln() {
final VokabelnDao vokabelnDao = this.vokabelnDao;
new ThreadPerTaskExecutor().execute(new Runnable() {
@Override
public void run() {
Vokabel vokabel = new Vokabel("car", "Auto", "Unit1");
Vokabel vokabel1 = new Vokabel("window", "Fenster", "Unit1");
vokabelnDao.insertAlleVokabeln(vokabel, vokabel1);
}
});
}
*/
}
| UTF-8 | Java | 6,486 | java | VokabelSpender.java | Java | [
{
"context": "package com.rommelbendel.firstapp;;\n\nimport android.content.Context;\n",
"end": 19,
"score": 0.613329291343689,
"start": 15,
"tag": "USERNAME",
"value": "melb"
}
] | null | [] | package com.rommelbendel.firstapp;;
import android.content.Context;
import android.os.Handler;
import android.os.Looper;
import android.util.Log;
import androidx.room.Room;
import org.jetbrains.annotations.NotNull;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
import java.util.concurrent.Executor;
public class VokabelSpender {
private Context context;
public Datenbank db;
public VokabelnDao vokabelnDao;
public List<Vokabel> alleVokabeln;
public List<Vokabel> kategorieVokabeln;
public List<Vokabel> answeredVokabeln;
static class ThreadPerTaskExecutor implements Executor {
@Override
public void execute(@NotNull Runnable runnable) {
Thread thread = new Thread(runnable);
thread.start();
}
}
/*
static class DirectExecuter implements Executor {
@Override
public void execute(@NotNull Runnable runnable) {
runnable.run();
}
}
*/
public VokabelSpender(@NotNull Context context) {
this.context = context;
final Datenbank db = Room.databaseBuilder(context, Datenbank.class, "VokabelnDatenbank").build();
this.vokabelnDao = db.vokabelnDao();
}
public void setAlleVokabeln(@NotNull List<Vokabel> alleVokabeln) {
Log.i("setAlleVokabeln", alleVokabeln.toString());
this.alleVokabeln = alleVokabeln;
}
public List<Vokabel> getAlleVokabeln() {
final VokabelnDao vokabelnDao = this.vokabelnDao;
//List<Vokabel> alleVokabeln;
new ThreadPerTaskExecutor().execute(new Runnable() {
@Override
public void run() {
final List<Vokabel> alleVokabeln = vokabelnDao.getAlle().getValue();
new Handler(Looper.getMainLooper()).post(new Runnable() {
@Override
public void run() {
Log.i("getAlleVokabeln", alleVokabeln.toString());
setAlleVokabeln(alleVokabeln);
}
});
}
});
return this.alleVokabeln;
}
public void setKategorieVokabeln(@NotNull List<Vokabel> kategorieVokabeln) {
this.kategorieVokabeln = kategorieVokabeln;
}
public List<Vokabel> getKategorieVokabeln(final String kategorie) {
final VokabelnDao vokabelnDao = this.vokabelnDao;
List<Vokabel> kategorieVokabeln;
new ThreadPerTaskExecutor().execute(new Runnable() {
@Override
public void run() {
final List<Vokabel> kategorieVokabeln = vokabelnDao.getKategorieVokabeln(kategorie).getValue();
new Handler(Looper.getMainLooper()).post(new Runnable() {
@Override
public void run() {
setKategorieVokabeln(kategorieVokabeln);
}
});
}
});
return this.kategorieVokabeln;
}
public Vokabel getRandomVokabel(String kategorie) {
Log.i("getRandomVokabel", kategorie);
List<Vokabel> vokabeln;
if (kategorie.equals("alle")) {
vokabeln = getAlleVokabeln();
} else {
vokabeln = getKategorieVokabeln(kategorie);
}
int index = new Random().nextInt(vokabeln.size());
return vokabeln.get(index);
}
public List<Vokabel> getQuizFrage(String kategorie) {
List<Vokabel> frageAntworten = new ArrayList<>();
Vokabel frage = getRandomVokabel(kategorie);
frageAntworten.add(frage);
List<Vokabel> falscheAntworten = getAlleVokabeln();
falscheAntworten.remove(frage);
for (int i = 0; i < 3; i++) {
Vokabel antwort = falscheAntworten.get(new Random().nextInt(falscheAntworten.size()));
frageAntworten.add(antwort);
falscheAntworten.remove(antwort);
}
return frageAntworten;
}
public void insertVokabeln(final Vokabel... vokabeln) {
final VokabelnDao vokabelnDao = this.vokabelnDao;
new ThreadPerTaskExecutor().execute(new Runnable() {
@Override
public void run() {
vokabelnDao.insertAlleVokabeln(vokabeln);
}
});
}
public void setAnsweredVokabeln(List<Vokabel> answeredVokabeln) {
this.answeredVokabeln = answeredVokabeln;
}
public List<Vokabel> getAlreadyAnswered(final int answered) {
final VokabelnDao vokabelnDao = this.vokabelnDao;
new ThreadPerTaskExecutor().execute(new Runnable() {
@Override
public void run() {
final List<Vokabel> answeredVokabeln = vokabelnDao.getAlreadyAnswered(answered).getValue();
new Handler(Looper.getMainLooper()).post(new Runnable() {
@Override
public void run() {
setAnsweredVokabeln(answeredVokabeln);
}
});
}
});
return this.answeredVokabeln;
}
public List<QuizFrage> generateQuiz(String kategorie, String type) {
List<QuizFrage> fragen = new ArrayList<>();
List<Vokabel> kategorieVokabeln = getKategorieVokabeln(kategorie);
Vokabel frage;
List<Vokabel> antworten = new ArrayList<>();
for (int i = 0; i < kategorieVokabeln.size(); i++) {
frage = kategorieVokabeln.get(i);
List<Vokabel> falscheAntworten = getAlleVokabeln();
falscheAntworten.remove(frage);
for (int count = 0; count < 3; count++) {
Vokabel antwort = falscheAntworten.get(new Random().nextInt(falscheAntworten.size()));
antworten.add(antwort);
falscheAntworten.remove(antwort);
}
fragen.add(new QuizFrage(frage, antworten, type));
antworten.clear();
}
return fragen;
}
/*
public void setVokabeln() {
final VokabelnDao vokabelnDao = this.vokabelnDao;
new ThreadPerTaskExecutor().execute(new Runnable() {
@Override
public void run() {
Vokabel vokabel = new Vokabel("car", "Auto", "Unit1");
Vokabel vokabel1 = new Vokabel("window", "Fenster", "Unit1");
vokabelnDao.insertAlleVokabeln(vokabel, vokabel1);
}
});
}
*/
}
| 6,486 | 0.594665 | 0.593278 | 210 | 29.885714 | 26.388783 | 111 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.495238 | false | false | 9 |
ef18be6304f98dd185ba8dbd1bdc2025c70afc93 | 33,621,004,052,834 | 6b05321e556b5db897bb0e5e61f781d0a018b86c | /code/src/main/java/org/miage/memoire/bean/package-info.java | 6f53d1b235eece8aa1cc2f54bcb1f0545358cc1e | [] | no_license | guillaume-humbert/masters-degree-thesis | https://github.com/guillaume-humbert/masters-degree-thesis | d3a6f5950d1eb6b4c8a28917530ea375da11ccfa | c06a4a594124d9ae7c8ab95891690327b7be6327 | refs/heads/master | 2020-05-30T07:06:44.129000 | 2014-03-29T05:54:47 | 2014-03-29T05:54:47 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | /**
* This packages contains the beans used by the view layer.
*/
package org.miage.memoire.bean;
| UTF-8 | Java | 101 | java | package-info.java | Java | [] | null | [] | /**
* This packages contains the beans used by the view layer.
*/
package org.miage.memoire.bean;
| 101 | 0.712871 | 0.712871 | 4 | 24 | 23.216373 | 59 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.25 | false | false | 9 |
b0470d5be69e73c0bed59e5c593e3e6d0254ff18 | 34,514,357,211,433 | 97f77e60efedadfb15f7b5c15b3b462b9bcb8064 | /app/src/main/java/com/shpro/xus/shproject/view/views/ProLoadingDialog.java | 9b69a8bb79e595d72492ba23b7aafad8698742ce | [] | no_license | eggbrid/SHProject | https://github.com/eggbrid/SHProject | cc9735cb70567586e423cba94f554b01be2fc948 | 324183949dfb1e01f22bca781952a6358821073c | refs/heads/master | 2020-12-24T12:20:38.720000 | 2017-05-08T06:33:05 | 2017-05-08T06:33:05 | 73,052,969 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.shpro.xus.shproject.view.views;
import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface;
import android.os.Bundle;
import android.widget.TextView;
import com.shpro.xus.shproject.R;
/**
* Created by xus on 2016/11/17.
*/
public class ProLoadingDialog extends Dialog {
private TaiJiView taiji;
private TextView text;
public ProLoadingDialog(Context context) {
super(context, R.style.Dialog_Fullscreen);
}
public ProLoadingDialog(Context context, int themeResId) {
super(context, R.style.Dialog_Fullscreen);
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.dialog_proload);
taiji=(TaiJiView)findViewById(R.id.taiji);
text=(TextView)findViewById(R.id.text);
}
public void show(String s) {
super.show();
taiji.start();
text.setText(s);
}
@Override
public void dismiss() {
super.dismiss();
taiji.stop();
}
}
| UTF-8 | Java | 1,087 | java | ProLoadingDialog.java | Java | [
{
"context": "port com.shpro.xus.shproject.R;\n\n/**\n * Created by xus on 2016/11/17.\n */\n\npublic class ProLoadingDialog",
"end": 259,
"score": 0.9996311664581299,
"start": 256,
"tag": "USERNAME",
"value": "xus"
}
] | null | [] | package com.shpro.xus.shproject.view.views;
import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface;
import android.os.Bundle;
import android.widget.TextView;
import com.shpro.xus.shproject.R;
/**
* Created by xus on 2016/11/17.
*/
public class ProLoadingDialog extends Dialog {
private TaiJiView taiji;
private TextView text;
public ProLoadingDialog(Context context) {
super(context, R.style.Dialog_Fullscreen);
}
public ProLoadingDialog(Context context, int themeResId) {
super(context, R.style.Dialog_Fullscreen);
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.dialog_proload);
taiji=(TaiJiView)findViewById(R.id.taiji);
text=(TextView)findViewById(R.id.text);
}
public void show(String s) {
super.show();
taiji.start();
text.setText(s);
}
@Override
public void dismiss() {
super.dismiss();
taiji.stop();
}
}
| 1,087 | 0.672493 | 0.665133 | 46 | 22.630434 | 18.901758 | 62 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.5 | false | false | 9 |
d0ec1604cbb42ad403828d77fcd05654b25c9095 | 14,130,442,435,903 | 1134ef712cdc20fe325bd659b59df2ff8ac7e01b | /src/main/java/com/eagletsoft/boot/framework/data/json/meta/LoadOnes.java | d4654c4e0cdf93c6a37d97cf5dc45ea6061994b9 | [] | no_license | mark-he/springboot-mybatis | https://github.com/mark-he/springboot-mybatis | 42f20e7de580148955111d8e210b522abda2fa02 | dda20af5cf898b5a9cd8dacc1b3bb77dd95ed8c6 | refs/heads/master | 2020-04-16T22:51:16.792000 | 2019-01-16T06:49:05 | 2019-01-16T06:49:05 | 165,986,877 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.eagletsoft.boot.framework.data.json.meta;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.FIELD, ElementType.METHOD})
public @interface LoadOnes {
LoadOne[] value();
}
| UTF-8 | Java | 353 | java | LoadOnes.java | Java | [] | null | [] | package com.eagletsoft.boot.framework.data.json.meta;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.FIELD, ElementType.METHOD})
public @interface LoadOnes {
LoadOne[] value();
}
| 353 | 0.813031 | 0.813031 | 12 | 28.416666 | 18.254946 | 53 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.666667 | false | false | 9 |
41863e45758ea88a05626c33a7778cf0ba43c505 | 14,130,442,433,224 | b8332ff21523210a5377a485dcc0a5757f4a4d61 | /app/src/main/java/com/youjing/yjeducation/ui/dispaly/activity/AYJGuideActivity.java | 91c56b375379ca8758671e7db2a3cb4c3f33dcc0 | [] | no_license | sun529417168/youjingmain | https://github.com/sun529417168/youjingmain | c59e54c8d53112ca53e105db011a56ef59ad9266 | ae575c5bafedcef57008faf9738d96192a70e8fb | refs/heads/master | 2021-01-21T18:21:22.632000 | 2017-05-22T09:30:50 | 2017-05-22T09:30:50 | 92,035,873 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.youjing.yjeducation.ui.dispaly.activity;
import com.youjing.yjeducation.util.StringUtils;
import android.view.MotionEvent;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.ViewFlipper;
import com.youjing.yjeducation.R;
import com.youjing.yjeducation.core.YJBaseActivity;
/**
* user 秦伟宁
* Date 2016/3/11
* Time 11:43
*/
public abstract class AYJGuideActivity extends YJBaseActivity {
private String TAG = "AYJGuideActivity";
ViewFlipper mViewFlipper = null;
private Button mBtnExperience;
private ImageView mImgFocus1;
private ImageView mImgFocus2;
private ImageView mImgFocus3;
float startX;
@Override
protected void onLoadingView() {
setContentView(R.layout.guide);
init();
}
private void init() {
mViewFlipper = (ViewFlipper) this.findViewById(R.id.viewFlipper);
mBtnExperience = (Button) findViewById(R.id.btn_experience);
mImgFocus1 = (ImageView) findViewById(R.id.img_focus1);
//mImgFocus2 = (ImageView) findViewById(R.id.img_focus2);
mImgFocus3 = (ImageView) findViewById(R.id.img_focus3);
mImgFocus1.setEnabled(false);
// mImgFocus2.setEnabled(true);
mImgFocus3.setEnabled(true);
mBtnExperience.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
start();
}
});
}
public boolean onTouchEvent(MotionEvent event) {
switch (event.getAction()) {
case MotionEvent.ACTION_DOWN:
startX = event.getX();
break;
case MotionEvent.ACTION_UP:
if (event.getX() > startX) {
/* if (mViewFlipper.getDisplayedChild() == mViewFlipper.getChildCount() - 3) {
break;
}*/
if (mViewFlipper.getDisplayedChild() == mViewFlipper.getChildCount() - 2) {
break;
}
mViewFlipper.setInAnimation(this, R.anim.right_in);
mViewFlipper.setOutAnimation(this, R.anim.right_out);
mViewFlipper.showNext();
change(mViewFlipper.getDisplayedChild());
} else if (event.getX() < startX) {
StringUtils.Log(TAG,"mViewFlipper.getDisplayedChild()="+mViewFlipper.getDisplayedChild());
StringUtils.Log(TAG,"mViewFlipper.getChildCount()="+mViewFlipper.getChildCount());
if (mViewFlipper.getDisplayedChild()+1 == mViewFlipper.getChildCount()) {
start();
}
/* if (mViewFlipper.getDisplayedChild()+2 == mViewFlipper.getChildCount()) {
start();
}*/
mViewFlipper.setInAnimation(this, R.anim.left_in);
mViewFlipper.setOutAnimation(this, R.anim.left_out);
mViewFlipper.showPrevious();
change(mViewFlipper.getDisplayedChild());
}
break;
}
return super.onTouchEvent(event);
}
private void change(int position) {
switch (position) {
case 0:
mImgFocus1.setEnabled(false);
// mImgFocus2.setEnabled(true);
mImgFocus3.setEnabled(true);
mImgFocus1.setVisibility(View.VISIBLE);
// mImgFocus2.setVisibility(View.VISIBLE);
mImgFocus3.setVisibility(View.VISIBLE);
break;
/* case 1:
mImgFocus1.setEnabled(true);
mImgFocus2.setEnabled(true);
mImgFocus3.setEnabled(false);
mImgFocus1.setVisibility(View.VISIBLE);
mImgFocus2.setVisibility(View.VISIBLE);
mImgFocus3.setVisibility(View.VISIBLE);
break;*/
case 1:
mImgFocus1.setEnabled(true);
// mImgFocus2.setEnabled(false);
mImgFocus3.setEnabled(false);
mImgFocus1.setVisibility(View.VISIBLE);
// mImgFocus2.setVisibility(View.VISIBLE);
mImgFocus3.setVisibility(View.VISIBLE);
}
}
protected abstract void start();
}
| UTF-8 | Java | 4,414 | java | AYJGuideActivity.java | Java | [
{
"context": "ng.yjeducation.core.YJBaseActivity;\n\n/**\n * user 秦伟宁\n * Date 2016/3/11\n * Time 11:43\n */\npublic abstra",
"end": 364,
"score": 0.9987832903862,
"start": 361,
"tag": "NAME",
"value": "秦伟宁"
}
] | null | [] | package com.youjing.yjeducation.ui.dispaly.activity;
import com.youjing.yjeducation.util.StringUtils;
import android.view.MotionEvent;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.ViewFlipper;
import com.youjing.yjeducation.R;
import com.youjing.yjeducation.core.YJBaseActivity;
/**
* user 秦伟宁
* Date 2016/3/11
* Time 11:43
*/
public abstract class AYJGuideActivity extends YJBaseActivity {
private String TAG = "AYJGuideActivity";
ViewFlipper mViewFlipper = null;
private Button mBtnExperience;
private ImageView mImgFocus1;
private ImageView mImgFocus2;
private ImageView mImgFocus3;
float startX;
@Override
protected void onLoadingView() {
setContentView(R.layout.guide);
init();
}
private void init() {
mViewFlipper = (ViewFlipper) this.findViewById(R.id.viewFlipper);
mBtnExperience = (Button) findViewById(R.id.btn_experience);
mImgFocus1 = (ImageView) findViewById(R.id.img_focus1);
//mImgFocus2 = (ImageView) findViewById(R.id.img_focus2);
mImgFocus3 = (ImageView) findViewById(R.id.img_focus3);
mImgFocus1.setEnabled(false);
// mImgFocus2.setEnabled(true);
mImgFocus3.setEnabled(true);
mBtnExperience.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
start();
}
});
}
public boolean onTouchEvent(MotionEvent event) {
switch (event.getAction()) {
case MotionEvent.ACTION_DOWN:
startX = event.getX();
break;
case MotionEvent.ACTION_UP:
if (event.getX() > startX) {
/* if (mViewFlipper.getDisplayedChild() == mViewFlipper.getChildCount() - 3) {
break;
}*/
if (mViewFlipper.getDisplayedChild() == mViewFlipper.getChildCount() - 2) {
break;
}
mViewFlipper.setInAnimation(this, R.anim.right_in);
mViewFlipper.setOutAnimation(this, R.anim.right_out);
mViewFlipper.showNext();
change(mViewFlipper.getDisplayedChild());
} else if (event.getX() < startX) {
StringUtils.Log(TAG,"mViewFlipper.getDisplayedChild()="+mViewFlipper.getDisplayedChild());
StringUtils.Log(TAG,"mViewFlipper.getChildCount()="+mViewFlipper.getChildCount());
if (mViewFlipper.getDisplayedChild()+1 == mViewFlipper.getChildCount()) {
start();
}
/* if (mViewFlipper.getDisplayedChild()+2 == mViewFlipper.getChildCount()) {
start();
}*/
mViewFlipper.setInAnimation(this, R.anim.left_in);
mViewFlipper.setOutAnimation(this, R.anim.left_out);
mViewFlipper.showPrevious();
change(mViewFlipper.getDisplayedChild());
}
break;
}
return super.onTouchEvent(event);
}
private void change(int position) {
switch (position) {
case 0:
mImgFocus1.setEnabled(false);
// mImgFocus2.setEnabled(true);
mImgFocus3.setEnabled(true);
mImgFocus1.setVisibility(View.VISIBLE);
// mImgFocus2.setVisibility(View.VISIBLE);
mImgFocus3.setVisibility(View.VISIBLE);
break;
/* case 1:
mImgFocus1.setEnabled(true);
mImgFocus2.setEnabled(true);
mImgFocus3.setEnabled(false);
mImgFocus1.setVisibility(View.VISIBLE);
mImgFocus2.setVisibility(View.VISIBLE);
mImgFocus3.setVisibility(View.VISIBLE);
break;*/
case 1:
mImgFocus1.setEnabled(true);
// mImgFocus2.setEnabled(false);
mImgFocus3.setEnabled(false);
mImgFocus1.setVisibility(View.VISIBLE);
// mImgFocus2.setVisibility(View.VISIBLE);
mImgFocus3.setVisibility(View.VISIBLE);
}
}
protected abstract void start();
}
| 4,414 | 0.57078 | 0.559891 | 122 | 35.131149 | 25.283945 | 110 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.598361 | false | false | 9 |
c100acb1bb2bb440aadff8bbaf2e269538019fbc | 31,138,512,923,062 | 0cb625dd4fca8dc9dc64b1bd91bdf12b194bf570 | /app/src/main/java/com/mobdeve/s13/group2/financify/model/Model.java | 725c5e051a0c7d88a003fa606589e0c8f248485d | [] | no_license | Nostradongus/Financify | https://github.com/Nostradongus/Financify | c96e36aec44e70d3c003dd5f8b304ba250053be4 | 0b6a16a6904ad62a19981f7ff9d52b36cfef3b29 | refs/heads/master | 2023-08-17T03:05:25.156000 | 2021-09-19T10:35:19 | 2021-09-19T10:35:19 | 395,725,132 | 1 | 1 | null | false | 2021-08-21T13:52:00 | 2021-08-13T16:43:36 | 2021-08-13T16:59:45 | 2021-08-21T13:51:59 | 281 | 1 | 0 | 0 | Java | false | false | package com.mobdeve.s13.group2.financify.model;
public enum Model {
users,
accounts,
transactions,
reminders
}
| UTF-8 | Java | 128 | java | Model.java | Java | [] | null | [] | package com.mobdeve.s13.group2.financify.model;
public enum Model {
users,
accounts,
transactions,
reminders
}
| 128 | 0.695313 | 0.671875 | 8 | 15 | 13.683932 | 47 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.5 | false | false | 9 |
90f6d447e7845c00c1a3664b4ac2018bcd03cbf2 | 32,358,283,639,168 | 70cdbea4dd5dfe856ead541cafc0dd0032a0ba46 | /base-0100-command-line_runner/src/main/java/com/wondersgroup/Base0100CommandLineRunnerApplication.java | 3030cef43d232825595393a1b05bf91e03e44ceb | [] | no_license | hbys126878033/base | https://github.com/hbys126878033/base | 97053939a8a6073207175ebe78c808d640f1a15e | 36aa355c99f3c3cfa11b3cc606eabb5eff13a58f | refs/heads/master | 2022-06-21T13:44:42.068000 | 2019-11-18T03:18:35 | 2019-11-18T03:18:35 | 220,940,884 | 0 | 0 | null | false | 2022-06-21T02:12:50 | 2019-11-11T09:04:06 | 2019-11-18T03:19:39 | 2022-06-21T02:12:49 | 3,811 | 0 | 0 | 11 | JavaScript | false | false | package com.wondersgroup;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.core.annotation.Order;
@SpringBootApplication
public class Base0100CommandLineRunnerApplication {
public static void main(String[] args) {
System.out.println("app init start ...");
SpringApplication.run(Base0100CommandLineRunnerApplication.class, args);
System.out.println("app init stop ...");
}
@Bean
public CommandLineRunner commandLineRunner(){
return new CommandLineRunner() {
@Override
public void run(String... args) throws Exception {
System.out.println("commandLineRunner init....");
}
};
}
@Bean
@Order(1)
public CommandLineRunner commandLineRunner1(){
return new CommandLineRunner() {
@Override
public void run(String... args) throws Exception {
System.out.println("commandLineRunner init 1....");
}
};
}
@Bean
@Order(2)
public CommandLineRunner commandLineRunner2(){
return new CommandLineRunner() {
@Override
public void run(String... args) throws Exception {
System.out.println("commandLineRunner init 2....");
}
};
}
}
| UTF-8 | Java | 1,503 | java | Base0100CommandLineRunnerApplication.java | Java | [] | null | [] | package com.wondersgroup;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.core.annotation.Order;
@SpringBootApplication
public class Base0100CommandLineRunnerApplication {
public static void main(String[] args) {
System.out.println("app init start ...");
SpringApplication.run(Base0100CommandLineRunnerApplication.class, args);
System.out.println("app init stop ...");
}
@Bean
public CommandLineRunner commandLineRunner(){
return new CommandLineRunner() {
@Override
public void run(String... args) throws Exception {
System.out.println("commandLineRunner init....");
}
};
}
@Bean
@Order(1)
public CommandLineRunner commandLineRunner1(){
return new CommandLineRunner() {
@Override
public void run(String... args) throws Exception {
System.out.println("commandLineRunner init 1....");
}
};
}
@Bean
@Order(2)
public CommandLineRunner commandLineRunner2(){
return new CommandLineRunner() {
@Override
public void run(String... args) throws Exception {
System.out.println("commandLineRunner init 2....");
}
};
}
}
| 1,503 | 0.635396 | 0.626081 | 56 | 25.839285 | 24.544258 | 80 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.285714 | false | false | 9 |
6aee729ea2bd254ac316ca7a8f7dafe8a95c7f9d | 7,172,595,414,850 | ddebde474f667ead89352636348754150ebfa4b7 | /app/src/main/java/com/jiatianmong/my/fragment/ContentFragment.java | 1b59f6e4977673eecd20aadb8043a65cb739fe05 | [] | no_license | jiatianmong/Life | https://github.com/jiatianmong/Life | e5daefbb3718df5d29e74cf5ac787f83bc5e5078 | 6df116eab87fd215039cc8902d44edab6e4b6800 | refs/heads/master | 2021-01-10T23:46:16.322000 | 2016-10-11T13:03:25 | 2016-10-11T13:03:25 | 70,402,676 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.jiatianmong.my.fragment;
import android.support.v4.view.PagerAdapter;
import android.support.v4.view.ViewPager;
import android.view.View;
import android.view.ViewGroup;
import android.widget.RadioGroup;
import com.jeremyfeinstein.slidingmenu.lib.SlidingMenu;
import com.jiatianmong.activity.R;
import com.jiatianmong.my.HomeActivity;
import com.jiatianmong.my.centerpager.BasePager;
import com.jiatianmong.my.centerpager.implement.GovAffairsPager;
import com.jiatianmong.my.centerpager.implement.HomePager;
import com.jiatianmong.my.centerpager.implement.NewsCenterPager;
import com.jiatianmong.my.centerpager.implement.SettingPager;
import com.jiatianmong.my.centerpager.implement.SmartServicePager;
import java.util.ArrayList;
/**
* Created by jiatianmong on 2016-10-10 15:59
*/
public class ContentFragment extends BaseFragment{
private ViewPager mViewPager;
private ArrayList<BasePager> mBasePagers;
private RadioGroup mRadioGroup;
@Override
public View initView() {
View view = View.inflate(mActivity, R.layout.fragment_content, null);
mViewPager = (ViewPager) view.findViewById(R.id.vp_content);
mRadioGroup = (RadioGroup) view.findViewById(R.id.rb_group);
return view;
}
@Override
public void initData() {
mBasePagers = new ArrayList<>();
//添加五个标签页
mBasePagers.add(new HomePager(mActivity));
mBasePagers.add(new NewsCenterPager(mActivity));
mBasePagers.add(new SmartServicePager(mActivity));
mBasePagers.add(new GovAffairsPager(mActivity));
mBasePagers.add(new SettingPager(mActivity));
mViewPager.setAdapter(new ContentAdapter());
//对底部的标签栏监听实现与页面匹配
mRadioGroup.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(RadioGroup group, int checkedId) {
switch (checkedId){
case R.id.rb_home:
//首页
mViewPager.setCurrentItem(0,false);//参2:是否有滑动动画
break;
case R.id.rb_news:
//新闻中心
mViewPager.setCurrentItem(1,false);
break;
case R.id.rb_smart:
//智慧服务
mViewPager.setCurrentItem(2,false);
break;
case R.id.rb_gov:
//政务
mViewPager.setCurrentItem(3,false);
break;
case R.id.rb_setting:
//设置
mViewPager.setCurrentItem(4,false);
break;
}
}
});
mBasePagers.get(0).initData();
setslidingMenuEnable(false);
mViewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
@Override
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
}
@Override
public void onPageSelected(int position) {
mBasePagers.get(mViewPager.getCurrentItem()).initData();
if (position == 0 || position == 4) {
setslidingMenuEnable(false);
} else {
setslidingMenuEnable(true);
}
switch (position) {
case 0:
//
mRadioGroup.check(R.id.rb_home);
break;
case 1:
//
mRadioGroup.check(R.id.rb_news);
break;
case 2:
//
mRadioGroup.check(R.id.rb_smart);
break;
case 3:
//
mRadioGroup.check(R.id.rb_gov);
break;
case 4:
//
mRadioGroup.check(R.id.rb_setting);
break;
}
}
@Override
public void onPageScrollStateChanged(int state) {
}
});
}
private void setslidingMenuEnable(boolean b) {
HomeActivity activity = (HomeActivity) mActivity;
SlidingMenu slidingMenu = activity.getSlidingMenu();
if (b) {
slidingMenu.setTouchModeAbove(slidingMenu.TOUCHMODE_MARGIN);
} else {
slidingMenu.setTouchModeAbove(slidingMenu.TOUCHMODE_NONE);
}
}
class ContentAdapter extends PagerAdapter {
@Override
public int getCount() {
return mBasePagers.size();
}
@Override
public boolean isViewFromObject(View view, Object object) {
return view == object;
}
@Override
public Object instantiateItem(ViewGroup container, int position) {
BasePager pager = mBasePagers.get(position);
View view = pager.mRootView;
//pager.initData();//初始化数据,ViewPager会默认加载下一个页面,为了节省资源和流量,不在此处初始化数据
container.addView(view);
return view;
}
@Override
public void destroyItem(ViewGroup container, int position, Object object) {
container.removeView((View) object);
}
}
}
| UTF-8 | Java | 5,710 | java | ContentFragment.java | Java | [
{
"context": "up;\nimport android.widget.RadioGroup;\n\nimport com.jeremyfeinstein.slidingmenu.lib.SlidingMenu;\nimport com.jiatianmo",
"end": 243,
"score": 0.8669835925102234,
"start": 228,
"tag": "USERNAME",
"value": "jeremyfeinstein"
},
{
"context": "r;\n\nimport java.util.ArrayLi... | null | [] | package com.jiatianmong.my.fragment;
import android.support.v4.view.PagerAdapter;
import android.support.v4.view.ViewPager;
import android.view.View;
import android.view.ViewGroup;
import android.widget.RadioGroup;
import com.jeremyfeinstein.slidingmenu.lib.SlidingMenu;
import com.jiatianmong.activity.R;
import com.jiatianmong.my.HomeActivity;
import com.jiatianmong.my.centerpager.BasePager;
import com.jiatianmong.my.centerpager.implement.GovAffairsPager;
import com.jiatianmong.my.centerpager.implement.HomePager;
import com.jiatianmong.my.centerpager.implement.NewsCenterPager;
import com.jiatianmong.my.centerpager.implement.SettingPager;
import com.jiatianmong.my.centerpager.implement.SmartServicePager;
import java.util.ArrayList;
/**
* Created by jiatianmong on 2016-10-10 15:59
*/
public class ContentFragment extends BaseFragment{
private ViewPager mViewPager;
private ArrayList<BasePager> mBasePagers;
private RadioGroup mRadioGroup;
@Override
public View initView() {
View view = View.inflate(mActivity, R.layout.fragment_content, null);
mViewPager = (ViewPager) view.findViewById(R.id.vp_content);
mRadioGroup = (RadioGroup) view.findViewById(R.id.rb_group);
return view;
}
@Override
public void initData() {
mBasePagers = new ArrayList<>();
//添加五个标签页
mBasePagers.add(new HomePager(mActivity));
mBasePagers.add(new NewsCenterPager(mActivity));
mBasePagers.add(new SmartServicePager(mActivity));
mBasePagers.add(new GovAffairsPager(mActivity));
mBasePagers.add(new SettingPager(mActivity));
mViewPager.setAdapter(new ContentAdapter());
//对底部的标签栏监听实现与页面匹配
mRadioGroup.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(RadioGroup group, int checkedId) {
switch (checkedId){
case R.id.rb_home:
//首页
mViewPager.setCurrentItem(0,false);//参2:是否有滑动动画
break;
case R.id.rb_news:
//新闻中心
mViewPager.setCurrentItem(1,false);
break;
case R.id.rb_smart:
//智慧服务
mViewPager.setCurrentItem(2,false);
break;
case R.id.rb_gov:
//政务
mViewPager.setCurrentItem(3,false);
break;
case R.id.rb_setting:
//设置
mViewPager.setCurrentItem(4,false);
break;
}
}
});
mBasePagers.get(0).initData();
setslidingMenuEnable(false);
mViewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
@Override
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
}
@Override
public void onPageSelected(int position) {
mBasePagers.get(mViewPager.getCurrentItem()).initData();
if (position == 0 || position == 4) {
setslidingMenuEnable(false);
} else {
setslidingMenuEnable(true);
}
switch (position) {
case 0:
//
mRadioGroup.check(R.id.rb_home);
break;
case 1:
//
mRadioGroup.check(R.id.rb_news);
break;
case 2:
//
mRadioGroup.check(R.id.rb_smart);
break;
case 3:
//
mRadioGroup.check(R.id.rb_gov);
break;
case 4:
//
mRadioGroup.check(R.id.rb_setting);
break;
}
}
@Override
public void onPageScrollStateChanged(int state) {
}
});
}
private void setslidingMenuEnable(boolean b) {
HomeActivity activity = (HomeActivity) mActivity;
SlidingMenu slidingMenu = activity.getSlidingMenu();
if (b) {
slidingMenu.setTouchModeAbove(slidingMenu.TOUCHMODE_MARGIN);
} else {
slidingMenu.setTouchModeAbove(slidingMenu.TOUCHMODE_NONE);
}
}
class ContentAdapter extends PagerAdapter {
@Override
public int getCount() {
return mBasePagers.size();
}
@Override
public boolean isViewFromObject(View view, Object object) {
return view == object;
}
@Override
public Object instantiateItem(ViewGroup container, int position) {
BasePager pager = mBasePagers.get(position);
View view = pager.mRootView;
//pager.initData();//初始化数据,ViewPager会默认加载下一个页面,为了节省资源和流量,不在此处初始化数据
container.addView(view);
return view;
}
@Override
public void destroyItem(ViewGroup container, int position, Object object) {
container.removeView((View) object);
}
}
}
| 5,710 | 0.542898 | 0.537851 | 172 | 31.255814 | 23.597736 | 102 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.5 | false | false | 9 |
e6e38548e0c4c0278c83493e993f5aec7825e3f2 | 23,441,931,534,047 | c405d8fd44339c6650e24d3de4035e246ba247db | /StockAndPortfolioManagementSystem/src/main/java/com/app/dao/ICompanyDao.java | 0cb0460727c2c520815455cc91204f3f70bc3008 | [] | no_license | udayk3456/StockAndPortfolioManagement | https://github.com/udayk3456/StockAndPortfolioManagement | 1156c5f8072e16ee9cadd272f93d301eaae95ca7 | b87494fe3d2119e8cef39a107d0f85f8694f1ed5 | refs/heads/master | 2020-04-07T21:30:22.803000 | 2018-12-08T18:00:31 | 2018-12-08T18:00:31 | 158,729,748 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.app.dao;
import java.util.List;
import com.app.model.Company;
public interface ICompanyDao {
Integer saveCompany(Company company);
void updateCompany(Company company);
void deleteCompany(int id);
Company getCompanyById(int id);
List<Company> getAllCompanies();
}
| UTF-8 | Java | 284 | java | ICompanyDao.java | Java | [] | null | [] | package com.app.dao;
import java.util.List;
import com.app.model.Company;
public interface ICompanyDao {
Integer saveCompany(Company company);
void updateCompany(Company company);
void deleteCompany(int id);
Company getCompanyById(int id);
List<Company> getAllCompanies();
}
| 284 | 0.778169 | 0.778169 | 14 | 19.285715 | 14.949575 | 38 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.928571 | false | false | 9 |
d633f396ab33f67418b1f76e5e62976f93ad7309 | 28,217,935,166,903 | 2240a54f0b2c2212524e951d147254918a987579 | /Day63_Pinyougou/pinyougou/pinyougou_web_manager/src/main/java/cn/itcast/core/controller/TypeTemplateController.java | 8a674f108d9afa39f24fb11e06e0e68e232130ab | [] | no_license | niyueyeee/MyCode | https://github.com/niyueyeee/MyCode | 2d2aa61cb872f4ccd48b447d41383359639c2465 | 68cc2a2abe40dfe4372de0adbddd7fd50f6c5bc2 | refs/heads/master | 2022-12-22T06:13:14.343000 | 2019-07-12T04:15:50 | 2019-07-12T04:15:50 | 167,680,349 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package cn.itcast.core.controller;
import cn.itcast.core.service.TypeTemplateService;
import com.alibaba.dubbo.config.annotation.Reference;
import entity.PageResult;
import entity.Result;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* @author niyueyeee
* @create 2019-04-27 15:30
*/
@RestController
@RequestMapping("/typeTemplate")
public class TypeTemplateController {
@Reference
private TypeTemplateService typeTemplateService;
//显示所有 加分页数据
@RequestMapping("search")
public PageResult search(Integer page, Integer rows, @RequestBody cn.itcast.core.pojo.template.TypeTemplate tt) {
return typeTemplateService.search(page, rows, tt);
}
//添加
@RequestMapping("/add")
public Result add(@RequestBody cn.itcast.core.pojo.template.TypeTemplate tt) {
try {
typeTemplateService.add(tt);
return new Result(true, "成功");
} catch (Exception e) {
e.printStackTrace();
return new Result(false, "失败");
}
}
//查询一个数据
@RequestMapping("/findOne")
public cn.itcast.core.pojo.template.TypeTemplate findOne(Long id) {
return typeTemplateService.findOne(id);
}
//修改数据
@RequestMapping("/update")
public Result update(@RequestBody cn.itcast.core.pojo.template.TypeTemplate tt) {
try {
typeTemplateService.update(tt);
return new Result(true, "成功");
} catch (Exception e) {
e.printStackTrace();
return new Result(false, "失败");
}
}
//删除数据
@RequestMapping("/delete")
public Result delete(Long[] ids) {
try {
typeTemplateService.delete(ids);
return new Result(true, "成功");
} catch (Exception e) {
e.printStackTrace();
return new Result(false, "失败");
}
}
}
| UTF-8 | Java | 2,076 | java | TypeTemplateController.java | Java | [
{
"context": "eb.bind.annotation.RestController;\n\n/**\n * @author niyueyeee\n * @create 2019-04-27 15:30\n */\n@RestController\n@",
"end": 400,
"score": 0.9996509552001953,
"start": 391,
"tag": "USERNAME",
"value": "niyueyeee"
}
] | null | [] | package cn.itcast.core.controller;
import cn.itcast.core.service.TypeTemplateService;
import com.alibaba.dubbo.config.annotation.Reference;
import entity.PageResult;
import entity.Result;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* @author niyueyeee
* @create 2019-04-27 15:30
*/
@RestController
@RequestMapping("/typeTemplate")
public class TypeTemplateController {
@Reference
private TypeTemplateService typeTemplateService;
//显示所有 加分页数据
@RequestMapping("search")
public PageResult search(Integer page, Integer rows, @RequestBody cn.itcast.core.pojo.template.TypeTemplate tt) {
return typeTemplateService.search(page, rows, tt);
}
//添加
@RequestMapping("/add")
public Result add(@RequestBody cn.itcast.core.pojo.template.TypeTemplate tt) {
try {
typeTemplateService.add(tt);
return new Result(true, "成功");
} catch (Exception e) {
e.printStackTrace();
return new Result(false, "失败");
}
}
//查询一个数据
@RequestMapping("/findOne")
public cn.itcast.core.pojo.template.TypeTemplate findOne(Long id) {
return typeTemplateService.findOne(id);
}
//修改数据
@RequestMapping("/update")
public Result update(@RequestBody cn.itcast.core.pojo.template.TypeTemplate tt) {
try {
typeTemplateService.update(tt);
return new Result(true, "成功");
} catch (Exception e) {
e.printStackTrace();
return new Result(false, "失败");
}
}
//删除数据
@RequestMapping("/delete")
public Result delete(Long[] ids) {
try {
typeTemplateService.delete(ids);
return new Result(true, "成功");
} catch (Exception e) {
e.printStackTrace();
return new Result(false, "失败");
}
}
}
| 2,076 | 0.645854 | 0.63986 | 69 | 28.014492 | 23.761797 | 117 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.478261 | false | false | 9 |
9334288abb57fae371832dc179387e2433c73405 | 25,649,544,736,719 | c0299fbd842c72f8ff4cd14a5073413f834b8c2a | /src/com/syntax/class09/SimpleWindowHandle.java | 30b5282eb330767268afc2735f0cd6e1159ba6c4 | [] | no_license | ReyhanBarindik/SeleniumJavaBatch6 | https://github.com/ReyhanBarindik/SeleniumJavaBatch6 | cb7b3f90f5ea949fdfed11043e85951ad773485b | 779510b6503fa04e61b81ca75e97116d62af1a57 | refs/heads/master | 2022-09-04T01:34:31.629000 | 2020-05-30T19:33:29 | 2020-05-30T19:33:29 | 266,171,514 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.syntax.class09;
import java.util.Iterator;
import java.util.Set;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
public class SimpleWindowHandle {
public static void main(String[] args) {
System.setProperty("webdriver.chrome.driver", "drivers\\chromedriver.exe");
WebDriver driver = new ChromeDriver();
driver.get("https://accounts.google.com/signup");
String signUpTitle=driver.getTitle();
System.out.println("Main page Title is :: "+signUpTitle);
driver.findElement(By.linkText("Help")).click();
//How to get window handle ?
//In Selenium We have 2 methods for it.
//getWindowHandle();
//getWindowHandles();
Set<String>allWindows=driver.getWindowHandles();
//Returns Set of String IDs of all windows currently opened by the current intance.
System.out.println("Number of Windows opened are :: "+allWindows.size());
Iterator<String>it=allWindows.iterator();
String mainWindowHandle= it.next();
System.out.println("ID of Main Window :: "+mainWindowHandle);
String childWindowHandle= it.next();
System.out.println("ID of Child Window :: "+childWindowHandle);
driver.switchTo().window(childWindowHandle);
String childWindowTitle=driver.getTitle();
System.out.println("Child page Title is :: "+childWindowTitle);
//driver.close();
}
}
| UTF-8 | Java | 1,421 | java | SimpleWindowHandle.java | Java | [] | null | [] | package com.syntax.class09;
import java.util.Iterator;
import java.util.Set;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
public class SimpleWindowHandle {
public static void main(String[] args) {
System.setProperty("webdriver.chrome.driver", "drivers\\chromedriver.exe");
WebDriver driver = new ChromeDriver();
driver.get("https://accounts.google.com/signup");
String signUpTitle=driver.getTitle();
System.out.println("Main page Title is :: "+signUpTitle);
driver.findElement(By.linkText("Help")).click();
//How to get window handle ?
//In Selenium We have 2 methods for it.
//getWindowHandle();
//getWindowHandles();
Set<String>allWindows=driver.getWindowHandles();
//Returns Set of String IDs of all windows currently opened by the current intance.
System.out.println("Number of Windows opened are :: "+allWindows.size());
Iterator<String>it=allWindows.iterator();
String mainWindowHandle= it.next();
System.out.println("ID of Main Window :: "+mainWindowHandle);
String childWindowHandle= it.next();
System.out.println("ID of Child Window :: "+childWindowHandle);
driver.switchTo().window(childWindowHandle);
String childWindowTitle=driver.getTitle();
System.out.println("Child page Title is :: "+childWindowTitle);
//driver.close();
}
}
| 1,421 | 0.713582 | 0.711471 | 57 | 23.929825 | 24.748461 | 86 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.859649 | false | false | 9 |
8041f4694f02883801f3449ff64af23da17290ee | 19,937,238,228,221 | 7cf4c6bd236e9a63ba0b532d3f7c2705f9707011 | /src/main/java/net/crizin/learning/controller/AbstractController.java | 72bfff8739905b66dcbb2d6e64cc9b44cec1e32a | [] | no_license | crizin/learning-spring-mvc | https://github.com/crizin/learning-spring-mvc | 3ac90733b098dc865d61eec5ad0184f6e3c51675 | c252cfb634dab4abec86ebe73d884d64f970853f | refs/heads/master | 2021-01-17T21:00:39.094000 | 2017-04-12T08:22:27 | 2017-04-12T08:22:27 | 64,025,658 | 1 | 1 | null | false | 2017-04-12T08:31:30 | 2016-07-23T16:42:41 | 2017-04-12T08:16:38 | 2017-04-12T08:26:27 | 113 | 0 | 1 | 0 | Java | null | null | package net.crizin.learning.controller;
import net.crizin.learning.entity.Member;
import org.springframework.http.HttpStatus;
import org.springframework.web.servlet.ModelAndView;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
public abstract class AbstractController {
protected Member getCurrentMember(HttpServletRequest request) {
return (Member) request.getAttribute("currentMember");
}
protected ModelAndView getErrorModelAndView(HttpServletResponse response, HttpStatus httpStatus, String errorMessage) {
response.setStatus(httpStatus.value());
ModelAndView modelAndView = new ModelAndView();
modelAndView.addObject("errorTitle", String.format("%d %s", httpStatus.value(), httpStatus.getReasonPhrase()));
modelAndView.addObject("errorDetails", errorMessage);
modelAndView.setViewName("error");
return modelAndView;
}
protected Map<String, Object> respondJsonOk() {
return Collections.singletonMap("success", true);
}
protected Map<String, Object> respondJsonError(String message) {
Map<String, Object> response = new HashMap<>(2);
response.put("success", false);
response.put("message", message);
return response;
}
} | UTF-8 | Java | 1,286 | java | AbstractController.java | Java | [] | null | [] | package net.crizin.learning.controller;
import net.crizin.learning.entity.Member;
import org.springframework.http.HttpStatus;
import org.springframework.web.servlet.ModelAndView;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
public abstract class AbstractController {
protected Member getCurrentMember(HttpServletRequest request) {
return (Member) request.getAttribute("currentMember");
}
protected ModelAndView getErrorModelAndView(HttpServletResponse response, HttpStatus httpStatus, String errorMessage) {
response.setStatus(httpStatus.value());
ModelAndView modelAndView = new ModelAndView();
modelAndView.addObject("errorTitle", String.format("%d %s", httpStatus.value(), httpStatus.getReasonPhrase()));
modelAndView.addObject("errorDetails", errorMessage);
modelAndView.setViewName("error");
return modelAndView;
}
protected Map<String, Object> respondJsonOk() {
return Collections.singletonMap("success", true);
}
protected Map<String, Object> respondJsonError(String message) {
Map<String, Object> response = new HashMap<>(2);
response.put("success", false);
response.put("message", message);
return response;
}
} | 1,286 | 0.787714 | 0.786936 | 39 | 32 | 29.178495 | 120 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.666667 | false | false | 9 |
a0e16bf445e16a6df2eb3c17f0554d72db467d78 | 31,593,779,470,159 | cb5211cbc4a2550dc4f279b0c4cf70899371ec99 | /Prueba1/app/src/main/java/com/example/prueba1/MainActivity.java | e40d9d74f0b8a2a92b2f4d8011d21f6439f84ea4 | [] | no_license | wendysoto/Prueba1_Topicos | https://github.com/wendysoto/Prueba1_Topicos | 4ae587cb91737624728bdeee809979e4130f727e | 4340eb3b0bde5699cff9a82c9d42de288d8379d0 | refs/heads/master | 2022-11-05T14:07:22.154000 | 2020-07-01T05:11:04 | 2020-07-01T05:11:04 | 276,189,539 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.example.prueba1;
import androidx.appcompat.app.AppCompatActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;
public class MainActivity extends AppCompatActivity {
Button btnCrear,btnDelete, btnMod, btnRead;
//FirebaseAuth fAuth;
private String mail="";
private String clave="";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
btnCrear=findViewById(R.id.btnInsert);
btnDelete=findViewById(R.id.btnEliminar);
btnMod=findViewById(R.id.btnUpdate);
btnDelete=findViewById(R.id.btnEliminar);
}
public void Crear(View view){
Intent i=new Intent(this, Crear.class);
startActivity(i);
}
public void Leer(View view){
Intent i=new Intent(this, Leer.class);
startActivity(i);
}
public void Actualizar(View view){
Intent i=new Intent(this, Actualizar.class);
startActivity(i);
}
public void Eliminar(View view){
Intent i=new Intent(this, Eliminar.class);
startActivity(i);
}
} | UTF-8 | Java | 1,319 | java | MainActivity.java | Java | [] | null | [] | package com.example.prueba1;
import androidx.appcompat.app.AppCompatActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;
public class MainActivity extends AppCompatActivity {
Button btnCrear,btnDelete, btnMod, btnRead;
//FirebaseAuth fAuth;
private String mail="";
private String clave="";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
btnCrear=findViewById(R.id.btnInsert);
btnDelete=findViewById(R.id.btnEliminar);
btnMod=findViewById(R.id.btnUpdate);
btnDelete=findViewById(R.id.btnEliminar);
}
public void Crear(View view){
Intent i=new Intent(this, Crear.class);
startActivity(i);
}
public void Leer(View view){
Intent i=new Intent(this, Leer.class);
startActivity(i);
}
public void Actualizar(View view){
Intent i=new Intent(this, Actualizar.class);
startActivity(i);
}
public void Eliminar(View view){
Intent i=new Intent(this, Eliminar.class);
startActivity(i);
}
} | 1,319 | 0.685368 | 0.68461 | 57 | 22.157894 | 19.319828 | 56 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.596491 | false | false | 9 |
70815166387677c86db8c4957b7a437847bb5631 | 17,300,128,308,062 | 96f3c83f7c712f31f9abfc6a66b2b51e592a8d56 | /pristine/70/70815166387677c86db8c4957b7a437847bb5631.svn-base | 35a7d920538c19bc571ebb0e2d810509c3aec3fa | [] | no_license | VitalPet/OPEN | https://github.com/VitalPet/OPEN | f549558e35383e3fd992a6007548d1e8e4670396 | 54f1fb3359de8ac9dc70b9a91e1bad4766e2aa7f | refs/heads/master | 2021-01-10T14:31:33.321000 | 2015-09-25T19:35:01 | 2015-09-25T19:35:01 | 43,171,665 | 0 | 2 | null | null | null | null | null | null | null | null | null | null | null | null | null | /*
* Version: 1.0
*
* The contents of this file are subject to the OpenVPMS License Version
* 1.0 (the 'License'); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.openvpms.org/license/
*
* Software distributed under the License is distributed on an 'AS IS' basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* Copyright 2013 (C) OpenVPMS Ltd. All Rights Reserved.
*/
package org.openvpms.web.component.im.relationship;
import nextapp.echo2.app.CheckBox;
import nextapp.echo2.app.Component;
import nextapp.echo2.app.event.ActionEvent;
import org.openvpms.component.business.domain.im.common.IMObject;
import org.openvpms.component.business.domain.im.common.IMObjectRelationship;
import org.openvpms.component.business.service.archetype.ArchetypeServiceException;
import org.openvpms.web.component.im.layout.LayoutContext;
import org.openvpms.web.component.im.view.IMObjectTableCollectionViewer;
import org.openvpms.web.component.property.CollectionProperty;
import org.openvpms.web.echo.event.ActionListener;
import org.openvpms.web.echo.factory.CheckBoxFactory;
import org.openvpms.web.resource.i18n.Messages;
/**
* Viewer for collections of {@link IMObjectRelationship}s.
*
* @author <a href="mailto:support@openvpms.org">OpenVPMS Team</a>
* @version $LastChangedDate: 2006-05-02 05:16:31Z $
*/
public class RelationshipCollectionTargetViewer
extends IMObjectTableCollectionViewer {
/**
* Determines if inactive relationships should be displayed.
*/
private CheckBox hideInactive;
/**
* Constructs a <tt>RelationshipCollectionTargetViewer</tt>.
*
* @param property the collection to view
* @param parent the parent object
* @param context the layout context. May be <tt>null</tt>
* @throws ArchetypeServiceException for any archetype service error
*/
public RelationshipCollectionTargetViewer(CollectionProperty property,
IMObject parent,
LayoutContext context) {
super(property, parent, context);
}
/**
* Browse an object.
*
* @param object the object to browse.
*/
@Override
protected void browse(IMObject object) {
IMObjectRelationship relationship = (IMObjectRelationship) object;
IMObject target = getLayoutContext().getCache().get(relationship.getTarget());
if (target != null) {
browse(target);
}
}
/**
* Lays out the component.
*/
@Override
protected Component doLayout() {
String name = getProperty().getDisplayName();
String label = Messages.format("relationship.hide.inactive", name);
hideInactive = CheckBoxFactory.create(null, true);
hideInactive.setText(label);
hideInactive.addActionListener(new ActionListener() {
public void onAction(ActionEvent event) {
onHideInactiveChanged();
}
});
Component component = super.doLayout();
component.add(hideInactive, 0);
return component;
}
/**
* Determines if inactive objects should be hidden.
*
* @return <code>true</code> if inactive objects should be hidden
*/
protected boolean hideInactive() {
return hideInactive.isSelected();
}
/**
* Invoked when the 'hide inactive' checkbox changes.
*/
private void onHideInactiveChanged() {
populateTable();
}
} | UTF-8 | Java | 3,805 | 70815166387677c86db8c4957b7a437847bb5631.svn-base | Java | [
{
"context": "ctRelationship}s.\r\n *\r\n * @author <a href=\"mailto:support@openvpms.org\">OpenVPMS Team</a>\r\n * @version $LastChangedDate:",
"end": 1464,
"score": 0.9999271631240845,
"start": 1444,
"tag": "EMAIL",
"value": "support@openvpms.org"
}
] | null | [] | /*
* Version: 1.0
*
* The contents of this file are subject to the OpenVPMS License Version
* 1.0 (the 'License'); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.openvpms.org/license/
*
* Software distributed under the License is distributed on an 'AS IS' basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* Copyright 2013 (C) OpenVPMS Ltd. All Rights Reserved.
*/
package org.openvpms.web.component.im.relationship;
import nextapp.echo2.app.CheckBox;
import nextapp.echo2.app.Component;
import nextapp.echo2.app.event.ActionEvent;
import org.openvpms.component.business.domain.im.common.IMObject;
import org.openvpms.component.business.domain.im.common.IMObjectRelationship;
import org.openvpms.component.business.service.archetype.ArchetypeServiceException;
import org.openvpms.web.component.im.layout.LayoutContext;
import org.openvpms.web.component.im.view.IMObjectTableCollectionViewer;
import org.openvpms.web.component.property.CollectionProperty;
import org.openvpms.web.echo.event.ActionListener;
import org.openvpms.web.echo.factory.CheckBoxFactory;
import org.openvpms.web.resource.i18n.Messages;
/**
* Viewer for collections of {@link IMObjectRelationship}s.
*
* @author <a href="mailto:<EMAIL>">OpenVPMS Team</a>
* @version $LastChangedDate: 2006-05-02 05:16:31Z $
*/
public class RelationshipCollectionTargetViewer
extends IMObjectTableCollectionViewer {
/**
* Determines if inactive relationships should be displayed.
*/
private CheckBox hideInactive;
/**
* Constructs a <tt>RelationshipCollectionTargetViewer</tt>.
*
* @param property the collection to view
* @param parent the parent object
* @param context the layout context. May be <tt>null</tt>
* @throws ArchetypeServiceException for any archetype service error
*/
public RelationshipCollectionTargetViewer(CollectionProperty property,
IMObject parent,
LayoutContext context) {
super(property, parent, context);
}
/**
* Browse an object.
*
* @param object the object to browse.
*/
@Override
protected void browse(IMObject object) {
IMObjectRelationship relationship = (IMObjectRelationship) object;
IMObject target = getLayoutContext().getCache().get(relationship.getTarget());
if (target != null) {
browse(target);
}
}
/**
* Lays out the component.
*/
@Override
protected Component doLayout() {
String name = getProperty().getDisplayName();
String label = Messages.format("relationship.hide.inactive", name);
hideInactive = CheckBoxFactory.create(null, true);
hideInactive.setText(label);
hideInactive.addActionListener(new ActionListener() {
public void onAction(ActionEvent event) {
onHideInactiveChanged();
}
});
Component component = super.doLayout();
component.add(hideInactive, 0);
return component;
}
/**
* Determines if inactive objects should be hidden.
*
* @return <code>true</code> if inactive objects should be hidden
*/
protected boolean hideInactive() {
return hideInactive.isSelected();
}
/**
* Invoked when the 'hide inactive' checkbox changes.
*/
private void onHideInactiveChanged() {
populateTable();
}
} | 3,792 | 0.659658 | 0.6523 | 112 | 31.991072 | 27.033873 | 86 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.348214 | false | false | 9 | |
6a5d0c44393939922ffc793f12c7cdf9ae5814b4 | 25,194,278,193,099 | cc511ceb3194cfdd51f591e50e52385ba46a91b3 | /example/source_code/80e99a69dab14876745185669eb54244b587a4d5/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/name/PathFactoryImpl.java | 2aa686706aa1a2ef4f166f9b7a48ce9045566615 | [] | no_license | huox-lamda/testing_hw | https://github.com/huox-lamda/testing_hw | a86cdce8d92983e31e653dd460abf38b94a647e4 | d41642c1e3ffa298684ec6f0196f2094527793c3 | refs/heads/master | 2020-04-16T19:24:49.643000 | 2019-01-16T15:47:13 | 2019-01-16T15:47:13 | 165,858,365 | 3 | 3 | null | null | null | null | null | null | null | null | null | null | null | null | null | org apach jackrabbit spi common
org apach jackrabbit spi path
org apach jackrabbit spi
org apach jackrabbit spi path factori pathfactori
org apach jackrabbit spi factori namefactori
javax jcr repositori except repositoryexcept
javax jcr path found except pathnotfoundexcept
java util link list linkedlist
java util list
java util arrai list arraylist
java util arrai
code pathfactoryimpl code
path factori impl pathfactoryimpl path factori pathfactori
path factori pathfactori factori path factori impl pathfactoryimpl
string current liter current liter
string parent liter parent liter
factori namefactori factori factori factori impl namefactoryimpl instanc getinst
current current factori factori creat default uri default uri current liter current liter
parent parent factori factori creat default uri default uri parent liter parent liter
root root factori factori creat default uri default uri
path element current element current element special element specialel current current
path element parent element parent element special element specialel parent parent
path element root element root element special element specialel root root
root path
path root path impl pathimpl path element root element root element
path factori impl pathfactoryimpl
path factori pathfactori instanc getinst
factori
pathfactori
pathfactori creat path path boolean
path creat path parent path rel path relpath normal illeg argument except illegalargumentexcept repositori except repositoryexcept
rel path relpath absolut isabsolut
illeg argument except illegalargumentexcept relpath rel path
list arrai list arraylist
add addal arrai list aslist parent element getel
add addal arrai list aslist rel path relpath element getel
builder builder
path path path getpath
normal
path normal path getnormalizedpath
path
pathfactori creat path boolean
path creat path parent normal repositori except repositoryexcept
list element arrai list arraylist
element add addal arrai list aslist parent element getel
element add creat element createel
builder builder element
path path path getpath
normal
path normal path getnormalizedpath
path
pathfactori creat path int boolean
path creat path parent index normal illeg argument except illegalargumentexcept repositori except repositoryexcept
list element arrai list arraylist
element add addal arrai list aslist parent element getel
element add creat element createel index
builder builder element
path path path getpath
normal
path normal path getnormalizedpath
path
pathfactori creat
path creat illeg argument except illegalargumentexcept
path element elem creat element createel
builder path element elem path getpath
pathfactori creat int
path creat index illeg argument except illegalargumentexcept
index path index undefin index undefin
illeg argument except illegalargumentexcept index neg index
path element elem creat element createel index
builder path element elem path getpath
pathfactori creat path element
path creat path element element illeg argument except illegalargumentexcept
builder element path getpath
pathfactori creat string
path creat string path string pathstr illeg argument except illegalargumentexcept
path string pathstr equal path string pathstr
illeg argument except illegalargumentexcept invalid path liter
split path element
po lastpo
po path string pathstr index indexof path delimit
arrai list arraylist list arrai list arraylist
po lastpo
path element elem
po
elem creat element createel path string pathstr substr po lastpo po
po lastpo po
po path string pathstr index indexof path delimit po lastpo
elem creat element createel path string pathstr substr po lastpo
po lastpo
list add elem
builder list path getpath
pathfactori createel
path element creat element createel illeg argument except illegalargumentexcept
illeg argument except illegalargumentexcept null
equal parent parent
parent element parent element
equal current current
current element current element
equal root root
root element root element
element path index undefin index undefin
pathfactori createel int
path element creat element createel index illeg argument except illegalargumentexcept
index path index undefin index undefin
illeg argument except illegalargumentexcept index neg
illeg argument except illegalargumentexcept null
equal parent parent
equal current current
equal root root
illeg argument except illegalargumentexcept
special path element root explicit index
element index
creat element element string
path element creat element createel string element string elementstr
element string elementstr
illeg argument except illegalargumentexcept null pathel liter
element string elementstr equal root root string tostr
root element root element
element string elementstr equal current liter current liter
current element current element
element string elementstr equal parent liter parent liter
parent element parent element
po element string elementstr index indexof
po
factori factori creat element string elementstr
element path index undefin index undefin
factori factori creat element string elementstr substr po
pos1 element string elementstr index indexof
pos1
illeg argument except illegalargumentexcept invalid pathel liter element string elementstr miss
index integ valueof element string elementstr substr po pos1 int intvalu
index
illeg argument except illegalargumentexcept invalid pathel liter element string elementstr index base
element index
number format except numberformatexcept
illeg argument except illegalargumentexcept invalid pathel liter element string elementstr messag getmessag
pathfactori getcurrentel
path element current element getcurrentel
current element current element
pathfactori getparentel
path element parent element getparentel
parent element parent element
pathfactori getrootel
path element root element getrootel
root element root element
pathfactori getrootpath
path root path getrootpath
root
path impl pathimpl path
element path
path element element
flag indic path normal
normal
flag indic path absolut
absolut
cach hashcod path
hash
cach 'tostring' path
string string
path impl pathimpl path element element normal isnorm
element element length
illeg argument except illegalargumentexcept empti path allow
element element
absolut element denot root denotesroot
normal normal isnorm
path denotesroot
denot root denotesroot
absolut element length
path isabsolut
absolut isabsolut
absolut
path iscanon
canon iscanon
absolut normal
path isnorm
normal isnorm
normal
path getnormalizedpath
path normal path getnormalizedpath repositori except repositoryexcept
normal isnorm
link list linkedlist queue link list linkedlist
path element parent element parent element
element length
path element elem element
elem denot parent denotespar denot parent denotespar
denot root denotesroot
element root element
refer parent root
repositori except repositoryexcept path canonic unresolv element
queue remov removelast
queue empti isempti
parent element parent element
path element queue getlast
elem denot current denotescurr
elem
queue add
queue empti isempti
repositori except repositoryexcept path normal result empti path
normal isnorm
path impl pathimpl path element queue arrai toarrai element queue size normal isnorm
path getcanonicalpath
path canon path getcanonicalpath repositori except repositoryexcept
canon iscanon
absolut isabsolut
repositori except repositoryexcept absolut path canonic
normal path getnormalizedpath
path computerelativepath path
path comput rel path computerelativepath path repositori except repositoryexcept
illeg argument except illegalargumentexcept null argument
make path absolut
absolut isabsolut absolut isabsolut
repositori except repositoryexcept comput rel path rel path
make compar canon path
path canon path getcanonicalpath
path canon path getcanonicalpath
equal
path equal rel path
builder builder path element current element current element
path getpath
determin length common path fragment
length common lengthcommon
path element elems0 element getel
path element elems1 element getel
elems0 length elems1 length
elems0 equal elems1
length common lengthcommon
list arrai list arraylist
length common lengthcommon elems0 length
common path fragment ancestor path
account prepend element
rel path
tmp elems0 length length common lengthcommon
tmp
add parent element parent element
add remaind path
length common lengthcommon elems1 length
add elems1
builder path getpath
path getancestor int
path ancestor getancestor degre illeg argument except illegalargumentexcept path found except pathnotfoundexcept
degre
illeg argument except illegalargumentexcept degre
degre
length element length degre
length
path found except pathnotfoundexcept ancestor path degre degre
path element element element length
system arraycopi element element length
path impl pathimpl element normal
path getancestorcount
ancestor count getancestorcount
depth getdepth
path getlength
length getlength
element length
path getdepth
depth getdepth
depth root depth root depth
element length
element denot parent denotespar
depth
element denot current denotescurr
depth
depth
path isancestorof path
ancestor isancestorof path illeg argument except illegalargumentexcept repositori except repositoryexcept
illeg argument except illegalargumentexcept null argument
make path absolut rel
absolut isabsolut absolut isabsolut
illeg argument except illegalargumentexcept compar rel path absolut path
make compar normal path
path normal path getnormalizedpath
path normal path getnormalizedpath
equal
calcul depth path neg
depth getdepth depth getdepth
path element elems0 element getel
path element elems1 element getel
elems0 length
elems0 equal elems1
path isdescendantof path
descend isdescendantof path illeg argument except illegalargumentexcept repositori except repositoryexcept
illeg argument except illegalargumentexcept null argument
ancestor isancestorof
path subpath int int
path path subpath illeg argument except illegalargumentexcept repositori except repositoryexcept
element length
illeg argument except illegalargumentexcept
normal isnorm
repositori except repositoryexcept extract path normal path
path element dest path element
system arraycopi element dest dest length
builder builder dest
path getpath
path getnameel
element element getnameel
element element length
path getstr
string string getstr
string tostr
path getel
element element getel
element
object
return intern string represent code path code
note return string valid jcr path
namespac uri' individu path element replac
map prefix
return intern string represent code path code
string string tostr
path immut store string represent
string
string buffer stringbuff string buffer stringbuff
element length
append path delimit
path element element element
string elem element string tostr
append elem
string string tostr
string
return hash code path
return hash code path
object hashcod
hash code hashcod
path immut store comput hash code
hash
element length
element hash code hashcod
hash
compar object path equal
param obj object compar equal path
return true object equal path
equal object obj
obj
obj path impl pathimpl
path path obj
arrai equal element element getel
path element
object represent singl jcr path element
path element
element path element
qualifi path element
option index path element set
explicitli base index
index
privat constructor creat path element
qualifi index constructor directli
factori method link pathfactori createel
link pathfactori creat int
param qualifi
param index index
element index
index index
path element getnam
getnam
path element getindex
index getindex
index
path element getnormalizedindex
normal index getnormalizedindex
index path index undefin index undefin
path index default index default
index
return return fals
path element denotesroot
denot root denotesroot
return return fals
path element denotespar
denot parent denotespar
return return fals
path element denotescurr
denot current denotescurr
return return true
path element denotesnam
denot denotesnam
path element getstr
string string getstr
string tostr
return string represent path element note
path element express code uri code
syntax
return string represent path element
object tostr
string string tostr
string buffer stringbuff string buffer stringbuff
append string tostr
index
index path index default index default
append
append index
append
string tostr
comput hash code path element
return hash code
object hashcod
hash code hashcod
normal index getnormalizedindex
hash code hashcod
check path element equal return true
object pathel index
param obj object compar
return code true code path element equal
object equal object
equal object obj
obj
obj path element
path element path element obj
equal getnam
normal index getnormalizedindex normal index getnormalizedindex
object represent special jcr path element notabl root
current parent element
special element specialel element
root
current
parent
type
special element specialel
path index undefin index undefin
root root equal
type root
current current equal
type current
parent parent equal
type parent
illeg argument except illegalargumentexcept
return true link root root element
path element denotesroot
denot root denotesroot
type root
return true link parent parent element
path element denotespar
denot parent denotespar
type parent
return true link current current element
path element denotescurr
denot current denotescurr
type current
return return fals
path element denotespar
denot denotesnam
builder intern class
builder
lpath element construct path
path element element
flag indic current path normal
normal isnorm
flag indic current path lead parent element
lead parent leadingpar
creat builder initi path
element
param elemlist
throw illegalargumentexcept element arrai null
length
builder list elem list elemlist
path element elem list elemlist arrai toarrai path element elem list elemlist size
creat builder initi path
element
param element
throw illegalargumentexcept element arrai null
length
builder path element element
element element length
illeg argument except illegalargumentexcept build path null element
element element
element length
path element elem element
lead parent leadingpar elem denot parent denotespar
normal isnorm elem denot current denotescurr lead parent leadingpar elem denot parent denotespar
assembl built path return link path
return link path
path path getpath
check path format assum name correct
path impl pathimpl element normal isnorm
| UTF-8 | Java | 14,444 | java | PathFactoryImpl.java | Java | [] | null | [] | org apach jackrabbit spi common
org apach jackrabbit spi path
org apach jackrabbit spi
org apach jackrabbit spi path factori pathfactori
org apach jackrabbit spi factori namefactori
javax jcr repositori except repositoryexcept
javax jcr path found except pathnotfoundexcept
java util link list linkedlist
java util list
java util arrai list arraylist
java util arrai
code pathfactoryimpl code
path factori impl pathfactoryimpl path factori pathfactori
path factori pathfactori factori path factori impl pathfactoryimpl
string current liter current liter
string parent liter parent liter
factori namefactori factori factori factori impl namefactoryimpl instanc getinst
current current factori factori creat default uri default uri current liter current liter
parent parent factori factori creat default uri default uri parent liter parent liter
root root factori factori creat default uri default uri
path element current element current element special element specialel current current
path element parent element parent element special element specialel parent parent
path element root element root element special element specialel root root
root path
path root path impl pathimpl path element root element root element
path factori impl pathfactoryimpl
path factori pathfactori instanc getinst
factori
pathfactori
pathfactori creat path path boolean
path creat path parent path rel path relpath normal illeg argument except illegalargumentexcept repositori except repositoryexcept
rel path relpath absolut isabsolut
illeg argument except illegalargumentexcept relpath rel path
list arrai list arraylist
add addal arrai list aslist parent element getel
add addal arrai list aslist rel path relpath element getel
builder builder
path path path getpath
normal
path normal path getnormalizedpath
path
pathfactori creat path boolean
path creat path parent normal repositori except repositoryexcept
list element arrai list arraylist
element add addal arrai list aslist parent element getel
element add creat element createel
builder builder element
path path path getpath
normal
path normal path getnormalizedpath
path
pathfactori creat path int boolean
path creat path parent index normal illeg argument except illegalargumentexcept repositori except repositoryexcept
list element arrai list arraylist
element add addal arrai list aslist parent element getel
element add creat element createel index
builder builder element
path path path getpath
normal
path normal path getnormalizedpath
path
pathfactori creat
path creat illeg argument except illegalargumentexcept
path element elem creat element createel
builder path element elem path getpath
pathfactori creat int
path creat index illeg argument except illegalargumentexcept
index path index undefin index undefin
illeg argument except illegalargumentexcept index neg index
path element elem creat element createel index
builder path element elem path getpath
pathfactori creat path element
path creat path element element illeg argument except illegalargumentexcept
builder element path getpath
pathfactori creat string
path creat string path string pathstr illeg argument except illegalargumentexcept
path string pathstr equal path string pathstr
illeg argument except illegalargumentexcept invalid path liter
split path element
po lastpo
po path string pathstr index indexof path delimit
arrai list arraylist list arrai list arraylist
po lastpo
path element elem
po
elem creat element createel path string pathstr substr po lastpo po
po lastpo po
po path string pathstr index indexof path delimit po lastpo
elem creat element createel path string pathstr substr po lastpo
po lastpo
list add elem
builder list path getpath
pathfactori createel
path element creat element createel illeg argument except illegalargumentexcept
illeg argument except illegalargumentexcept null
equal parent parent
parent element parent element
equal current current
current element current element
equal root root
root element root element
element path index undefin index undefin
pathfactori createel int
path element creat element createel index illeg argument except illegalargumentexcept
index path index undefin index undefin
illeg argument except illegalargumentexcept index neg
illeg argument except illegalargumentexcept null
equal parent parent
equal current current
equal root root
illeg argument except illegalargumentexcept
special path element root explicit index
element index
creat element element string
path element creat element createel string element string elementstr
element string elementstr
illeg argument except illegalargumentexcept null pathel liter
element string elementstr equal root root string tostr
root element root element
element string elementstr equal current liter current liter
current element current element
element string elementstr equal parent liter parent liter
parent element parent element
po element string elementstr index indexof
po
factori factori creat element string elementstr
element path index undefin index undefin
factori factori creat element string elementstr substr po
pos1 element string elementstr index indexof
pos1
illeg argument except illegalargumentexcept invalid pathel liter element string elementstr miss
index integ valueof element string elementstr substr po pos1 int intvalu
index
illeg argument except illegalargumentexcept invalid pathel liter element string elementstr index base
element index
number format except numberformatexcept
illeg argument except illegalargumentexcept invalid pathel liter element string elementstr messag getmessag
pathfactori getcurrentel
path element current element getcurrentel
current element current element
pathfactori getparentel
path element parent element getparentel
parent element parent element
pathfactori getrootel
path element root element getrootel
root element root element
pathfactori getrootpath
path root path getrootpath
root
path impl pathimpl path
element path
path element element
flag indic path normal
normal
flag indic path absolut
absolut
cach hashcod path
hash
cach 'tostring' path
string string
path impl pathimpl path element element normal isnorm
element element length
illeg argument except illegalargumentexcept empti path allow
element element
absolut element denot root denotesroot
normal normal isnorm
path denotesroot
denot root denotesroot
absolut element length
path isabsolut
absolut isabsolut
absolut
path iscanon
canon iscanon
absolut normal
path isnorm
normal isnorm
normal
path getnormalizedpath
path normal path getnormalizedpath repositori except repositoryexcept
normal isnorm
link list linkedlist queue link list linkedlist
path element parent element parent element
element length
path element elem element
elem denot parent denotespar denot parent denotespar
denot root denotesroot
element root element
refer parent root
repositori except repositoryexcept path canonic unresolv element
queue remov removelast
queue empti isempti
parent element parent element
path element queue getlast
elem denot current denotescurr
elem
queue add
queue empti isempti
repositori except repositoryexcept path normal result empti path
normal isnorm
path impl pathimpl path element queue arrai toarrai element queue size normal isnorm
path getcanonicalpath
path canon path getcanonicalpath repositori except repositoryexcept
canon iscanon
absolut isabsolut
repositori except repositoryexcept absolut path canonic
normal path getnormalizedpath
path computerelativepath path
path comput rel path computerelativepath path repositori except repositoryexcept
illeg argument except illegalargumentexcept null argument
make path absolut
absolut isabsolut absolut isabsolut
repositori except repositoryexcept comput rel path rel path
make compar canon path
path canon path getcanonicalpath
path canon path getcanonicalpath
equal
path equal rel path
builder builder path element current element current element
path getpath
determin length common path fragment
length common lengthcommon
path element elems0 element getel
path element elems1 element getel
elems0 length elems1 length
elems0 equal elems1
length common lengthcommon
list arrai list arraylist
length common lengthcommon elems0 length
common path fragment ancestor path
account prepend element
rel path
tmp elems0 length length common lengthcommon
tmp
add parent element parent element
add remaind path
length common lengthcommon elems1 length
add elems1
builder path getpath
path getancestor int
path ancestor getancestor degre illeg argument except illegalargumentexcept path found except pathnotfoundexcept
degre
illeg argument except illegalargumentexcept degre
degre
length element length degre
length
path found except pathnotfoundexcept ancestor path degre degre
path element element element length
system arraycopi element element length
path impl pathimpl element normal
path getancestorcount
ancestor count getancestorcount
depth getdepth
path getlength
length getlength
element length
path getdepth
depth getdepth
depth root depth root depth
element length
element denot parent denotespar
depth
element denot current denotescurr
depth
depth
path isancestorof path
ancestor isancestorof path illeg argument except illegalargumentexcept repositori except repositoryexcept
illeg argument except illegalargumentexcept null argument
make path absolut rel
absolut isabsolut absolut isabsolut
illeg argument except illegalargumentexcept compar rel path absolut path
make compar normal path
path normal path getnormalizedpath
path normal path getnormalizedpath
equal
calcul depth path neg
depth getdepth depth getdepth
path element elems0 element getel
path element elems1 element getel
elems0 length
elems0 equal elems1
path isdescendantof path
descend isdescendantof path illeg argument except illegalargumentexcept repositori except repositoryexcept
illeg argument except illegalargumentexcept null argument
ancestor isancestorof
path subpath int int
path path subpath illeg argument except illegalargumentexcept repositori except repositoryexcept
element length
illeg argument except illegalargumentexcept
normal isnorm
repositori except repositoryexcept extract path normal path
path element dest path element
system arraycopi element dest dest length
builder builder dest
path getpath
path getnameel
element element getnameel
element element length
path getstr
string string getstr
string tostr
path getel
element element getel
element
object
return intern string represent code path code
note return string valid jcr path
namespac uri' individu path element replac
map prefix
return intern string represent code path code
string string tostr
path immut store string represent
string
string buffer stringbuff string buffer stringbuff
element length
append path delimit
path element element element
string elem element string tostr
append elem
string string tostr
string
return hash code path
return hash code path
object hashcod
hash code hashcod
path immut store comput hash code
hash
element length
element hash code hashcod
hash
compar object path equal
param obj object compar equal path
return true object equal path
equal object obj
obj
obj path impl pathimpl
path path obj
arrai equal element element getel
path element
object represent singl jcr path element
path element
element path element
qualifi path element
option index path element set
explicitli base index
index
privat constructor creat path element
qualifi index constructor directli
factori method link pathfactori createel
link pathfactori creat int
param qualifi
param index index
element index
index index
path element getnam
getnam
path element getindex
index getindex
index
path element getnormalizedindex
normal index getnormalizedindex
index path index undefin index undefin
path index default index default
index
return return fals
path element denotesroot
denot root denotesroot
return return fals
path element denotespar
denot parent denotespar
return return fals
path element denotescurr
denot current denotescurr
return return true
path element denotesnam
denot denotesnam
path element getstr
string string getstr
string tostr
return string represent path element note
path element express code uri code
syntax
return string represent path element
object tostr
string string tostr
string buffer stringbuff string buffer stringbuff
append string tostr
index
index path index default index default
append
append index
append
string tostr
comput hash code path element
return hash code
object hashcod
hash code hashcod
normal index getnormalizedindex
hash code hashcod
check path element equal return true
object pathel index
param obj object compar
return code true code path element equal
object equal object
equal object obj
obj
obj path element
path element path element obj
equal getnam
normal index getnormalizedindex normal index getnormalizedindex
object represent special jcr path element notabl root
current parent element
special element specialel element
root
current
parent
type
special element specialel
path index undefin index undefin
root root equal
type root
current current equal
type current
parent parent equal
type parent
illeg argument except illegalargumentexcept
return true link root root element
path element denotesroot
denot root denotesroot
type root
return true link parent parent element
path element denotespar
denot parent denotespar
type parent
return true link current current element
path element denotescurr
denot current denotescurr
type current
return return fals
path element denotespar
denot denotesnam
builder intern class
builder
lpath element construct path
path element element
flag indic current path normal
normal isnorm
flag indic current path lead parent element
lead parent leadingpar
creat builder initi path
element
param elemlist
throw illegalargumentexcept element arrai null
length
builder list elem list elemlist
path element elem list elemlist arrai toarrai path element elem list elemlist size
creat builder initi path
element
param element
throw illegalargumentexcept element arrai null
length
builder path element element
element element length
illeg argument except illegalargumentexcept build path null element
element element
element length
path element elem element
lead parent leadingpar elem denot parent denotespar
normal isnorm elem denot current denotescurr lead parent leadingpar elem denot parent denotespar
assembl built path return link path
return link path
path path getpath
check path format assum name correct
path impl pathimpl element normal isnorm
| 14,444 | 0.864165 | 0.862919 | 474 | 29.472574 | 21.219774 | 130 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0 | false | false | 9 |
def1f89c336f79f00c4d3fe17ef6e0ccf373f5e8 | 32,323,923,911,518 | 193d0da41af544af3a37e9c6298a7e177f35c817 | /src/GraphTest.java | 90e36e6c01c71c0635712e47779b466aa803d8ec | [] | no_license | bartuskr/Prim-s-algorithm | https://github.com/bartuskr/Prim-s-algorithm | e623c2692a45abed8bad428696f2eebe8ab3b990 | 1bfa662c6953ac9d7ebfd333be746b8fa34fa141 | refs/heads/master | 2018-07-29T14:08:05.522000 | 2018-06-13T20:42:25 | 2018-06-13T20:42:25 | 135,603,923 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
import org.junit.Before;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
public class GraphTest {
Graph graph ;
@Before
public void setUp(){
graph = new Graph();
graph.addVertex(10, 50);
graph.addVertex(200, 50);
graph.addVertex(200, 200);
graph.addVertex(350, 100);
graph.addVertex(10, 350);
graph.addVertex(200, 350);
graph.connectVertices(0, 1,3);
graph.connectVertices(0, 4,3);
graph.connectVertices(4, 5,2);
graph.connectVertices(5, 3,1);
graph.connectVertices(1, 2,1);
graph.connectVertices(2, 3,3);
graph.connectVertices(0, 5,99);
graph.connectVertices(0, 2,99);
graph.connectVertices(1, 3,7);
graph.connectVertices(0, 3,99);
graph.primSource(0);
graph.shortPath(0,3);
}
@Test
public void getNumberOfVertices() {
assertEquals(6,graph.getNumberOfVertices());
}
@Test
public void getNumberOfEdges() {
assertEquals(9,graph.getNumberOfEdges());
}
@Test
public void prims(){
assertEquals(10,graph.getNumberOfEdges());
assertEquals(6,graph.getNumberOfVertices());
//assertEquals(24,graph.getTotalWeight());
graph.prims();
assertEquals(6,graph.getNumberOfVertices());
assertEquals(5,graph.getNumberOfEdges());
//assertEquals(10,graph.getTotalWeight());
}
@Test
public void bellmanFord(){
assertEquals(10,graph.getNumberOfEdges());
assertEquals(6,graph.getNumberOfVertices());
//assertEquals(24,graph.getTotalWeight());
graph.bellmanFord();
assertEquals(6,graph.getNumberOfVertices());
assertEquals(3,graph.getNumberOfEdges());
//assertEquals(10,graph.getTotalWeight());
}
@Test
public void getWeight() {
// assertEquals(4,graph.getWeight(0,1));
// assertEquals(2,graph.getWeight(1,2));
// assertEquals(1,graph.getWeight(0,4));
// assertEquals(2,graph.getWeight(1,4));
// assertEquals(2,graph.getWeight(4,1));
// assertEquals(3,graph.getWeight(3,5));
}
}
| UTF-8 | Java | 2,185 | java | GraphTest.java | Java | [] | null | [] |
import org.junit.Before;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
public class GraphTest {
Graph graph ;
@Before
public void setUp(){
graph = new Graph();
graph.addVertex(10, 50);
graph.addVertex(200, 50);
graph.addVertex(200, 200);
graph.addVertex(350, 100);
graph.addVertex(10, 350);
graph.addVertex(200, 350);
graph.connectVertices(0, 1,3);
graph.connectVertices(0, 4,3);
graph.connectVertices(4, 5,2);
graph.connectVertices(5, 3,1);
graph.connectVertices(1, 2,1);
graph.connectVertices(2, 3,3);
graph.connectVertices(0, 5,99);
graph.connectVertices(0, 2,99);
graph.connectVertices(1, 3,7);
graph.connectVertices(0, 3,99);
graph.primSource(0);
graph.shortPath(0,3);
}
@Test
public void getNumberOfVertices() {
assertEquals(6,graph.getNumberOfVertices());
}
@Test
public void getNumberOfEdges() {
assertEquals(9,graph.getNumberOfEdges());
}
@Test
public void prims(){
assertEquals(10,graph.getNumberOfEdges());
assertEquals(6,graph.getNumberOfVertices());
//assertEquals(24,graph.getTotalWeight());
graph.prims();
assertEquals(6,graph.getNumberOfVertices());
assertEquals(5,graph.getNumberOfEdges());
//assertEquals(10,graph.getTotalWeight());
}
@Test
public void bellmanFord(){
assertEquals(10,graph.getNumberOfEdges());
assertEquals(6,graph.getNumberOfVertices());
//assertEquals(24,graph.getTotalWeight());
graph.bellmanFord();
assertEquals(6,graph.getNumberOfVertices());
assertEquals(3,graph.getNumberOfEdges());
//assertEquals(10,graph.getTotalWeight());
}
@Test
public void getWeight() {
// assertEquals(4,graph.getWeight(0,1));
// assertEquals(2,graph.getWeight(1,2));
// assertEquals(1,graph.getWeight(0,4));
// assertEquals(2,graph.getWeight(1,4));
// assertEquals(2,graph.getWeight(4,1));
// assertEquals(3,graph.getWeight(3,5));
}
}
| 2,185 | 0.613272 | 0.56476 | 77 | 27.363636 | 18.582151 | 52 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.272727 | false | false | 9 |
c8ce6204998598739d59a7ccafef7e29c3c559d6 | 30,648,886,666,552 | e0fff479cdc9188dd703c197ab2ab7dcf0628d53 | /hrms/src/main/java/com/kaya/hrms/business/concretes/CityManager.java | a08d83a160bba150f2e044e28607c4d6b243ac11 | [] | no_license | gafakaya/HRMS | https://github.com/gafakaya/HRMS | 3b427ad28a3a4c87aa12be2c316f20567a2b4d11 | 0a5ad6a82bb450015835ae44b91790f5319432ed | refs/heads/master | 2023-06-14T15:22:15.465000 | 2021-06-30T04:25:20 | 2021-06-30T04:25:20 | 369,980,126 | 19 | 2 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.kaya.hrms.business.concretes;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.kaya.hrms.business.abstracts.CityService;
import com.kaya.hrms.business.constants.Messages;
import com.kaya.hrms.core.utilities.results.DataResult;
import com.kaya.hrms.core.utilities.results.Result;
import com.kaya.hrms.core.utilities.results.SuccessDataResult;
import com.kaya.hrms.core.utilities.results.SuccessResult;
import com.kaya.hrms.dataAccess.abstracts.CityDao;
import com.kaya.hrms.entities.concretes.City;
@Service
public class CityManager implements CityService {
private CityDao cityDao;
@Autowired
public CityManager(CityDao cityDao) {
this.cityDao = cityDao;
}
@Override
public DataResult<List<City>> getAll() {
List<City> result = this.cityDao.findAll();
return new SuccessDataResult<List<City>>(
result,
Messages.CITY_LISTED);
}
@Override
public DataResult<City> getById(int cityId) {
City result = this.cityDao.getById(cityId);
return new SuccessDataResult<City>(
result,
Messages.CITY_LISTED_BY_ID);
}
@Override
public Result add(City city) {
this.cityDao.save(city);
return new SuccessResult(Messages.CITY_ADDED);
}
}
| UTF-8 | Java | 1,291 | java | CityManager.java | Java | [] | null | [] | package com.kaya.hrms.business.concretes;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.kaya.hrms.business.abstracts.CityService;
import com.kaya.hrms.business.constants.Messages;
import com.kaya.hrms.core.utilities.results.DataResult;
import com.kaya.hrms.core.utilities.results.Result;
import com.kaya.hrms.core.utilities.results.SuccessDataResult;
import com.kaya.hrms.core.utilities.results.SuccessResult;
import com.kaya.hrms.dataAccess.abstracts.CityDao;
import com.kaya.hrms.entities.concretes.City;
@Service
public class CityManager implements CityService {
private CityDao cityDao;
@Autowired
public CityManager(CityDao cityDao) {
this.cityDao = cityDao;
}
@Override
public DataResult<List<City>> getAll() {
List<City> result = this.cityDao.findAll();
return new SuccessDataResult<List<City>>(
result,
Messages.CITY_LISTED);
}
@Override
public DataResult<City> getById(int cityId) {
City result = this.cityDao.getById(cityId);
return new SuccessDataResult<City>(
result,
Messages.CITY_LISTED_BY_ID);
}
@Override
public Result add(City city) {
this.cityDao.save(city);
return new SuccessResult(Messages.CITY_ADDED);
}
}
| 1,291 | 0.769171 | 0.769171 | 53 | 23.35849 | 21.381613 | 62 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.377358 | false | false | 9 |
10c9b07b63bacffc552b6790ac94383572b205df | 7,825,430,442,507 | bc651b65d9819e4cf2229ab009129be84cc0f254 | /src/main/java/br/com/zcsistemas/financeiro/api/repository/contasBancarias/ContasBancariasRepositoryQuery.java | cec0acd90d60e1ad9f0f0ca295f2cd565233ef20 | [] | no_license | Evelynkrm/financeiro | https://github.com/Evelynkrm/financeiro | 681ec00e4115bb586a38c98da822b216141a9c71 | 12e85e625f27a453bfc8485cbffca6343fa22139 | refs/heads/master | 2020-12-15T19:09:44.360000 | 2020-01-20T20:27:38 | 2020-01-20T20:27:38 | 235,223,313 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package br.com.zcsistemas.financeiro.api.repository.contasBancarias;
import br.com.zcsistemas.financeiro.api.model.ContasBancarias;
import br.com.zcsistemas.financeiro.api.repository.filter.ContasBancariasFilter;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import java.util.List;
public interface ContasBancariasRepositoryQuery {
public Page<ContasBancarias> filtrar(ContasBancariasFilter contasBancariasFilter, Pageable pageable);
}
| UTF-8 | Java | 492 | java | ContasBancariasRepositoryQuery.java | Java | [] | null | [] | package br.com.zcsistemas.financeiro.api.repository.contasBancarias;
import br.com.zcsistemas.financeiro.api.model.ContasBancarias;
import br.com.zcsistemas.financeiro.api.repository.filter.ContasBancariasFilter;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import java.util.List;
public interface ContasBancariasRepositoryQuery {
public Page<ContasBancarias> filtrar(ContasBancariasFilter contasBancariasFilter, Pageable pageable);
}
| 492 | 0.849594 | 0.849594 | 13 | 36.846153 | 34.384357 | 105 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.615385 | false | false | 9 |
91698cbb390ef057565f642729334dbe7aad833d | 11,450,382,844,853 | 7729070e6ed572dad84c6ecaf460813e44a01862 | /src/graph/core/Provenance.java | eef19167edaaf9c9a1aa6f4af0073a5838213539 | [] | no_license | yh222/DagYo | https://github.com/yh222/DagYo | 8d113edd2062e6a21349d379948627342b6b811b | a205a4b6e8a896783ad1f635602806b7cba3b756 | refs/heads/master | 2021-01-23T01:07:39.144000 | 2013-12-03T01:23:29 | 2013-12-03T01:23:29 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package graph.core;
import java.util.Date;
/**
* An abstract class for recording provenance data.
*
* @author Sam Sarjant
*/
public abstract class Provenance {
/** The creation date. */
protected Date creation_;
/** The creator. */
protected Node creator_;
/**
* Constructor for a new Provenance
*
*/
public Provenance() {
this(null);
}
/**
* Constructor for a new Provenance
*
*/
public Provenance(Node creator) {
creator_ = creator;
creation_ = new Date();
}
public Date getCreation() {
return creation_;
}
public Node getCreator() {
return creator_;
}
@Override
public String toString() {
if (creator_ == null)
return "Created on " + creation_;
return "Created by " + creator_ + " on " + creation_;
}
}
| UTF-8 | Java | 817 | java | Provenance.java | Java | [
{
"context": "ss for recording provenance data.\r\n * \r\n * @author Sam Sarjant\r\n */\r\npublic abstract class Provenance {\r\n\t/** Th",
"end": 136,
"score": 0.9998128414154053,
"start": 125,
"tag": "NAME",
"value": "Sam Sarjant"
}
] | null | [] | package graph.core;
import java.util.Date;
/**
* An abstract class for recording provenance data.
*
* @author <NAME>
*/
public abstract class Provenance {
/** The creation date. */
protected Date creation_;
/** The creator. */
protected Node creator_;
/**
* Constructor for a new Provenance
*
*/
public Provenance() {
this(null);
}
/**
* Constructor for a new Provenance
*
*/
public Provenance(Node creator) {
creator_ = creator;
creation_ = new Date();
}
public Date getCreation() {
return creation_;
}
public Node getCreator() {
return creator_;
}
@Override
public String toString() {
if (creator_ == null)
return "Created on " + creation_;
return "Created by " + creator_ + " on " + creation_;
}
}
| 812 | 0.594859 | 0.594859 | 49 | 14.67347 | 14.56917 | 55 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.040816 | false | false | 9 |
f7bf6aa47f43e3491b5e2bd88182a5c50798cfe7 | 29,807,073,043,460 | 7e042c9aeaac235d149e45600b989a57e4a80dc2 | /gmall-manage-service/src/main/java/com/yango/gmall/manage/mapper/SkuSaleAttrValueMapper.java | 25d145b1394ec79c8828ed30fa5945be4c955d48 | [] | no_license | chenzunqing/gmall2020 | https://github.com/chenzunqing/gmall2020 | 48d6174a64f7b71207ad5baa38b750e80c85842b | 9558745cdb8739696e34a99f7ae6c9059aa889b6 | refs/heads/master | 2022-09-21T03:18:22.149000 | 2021-03-04T16:37:00 | 2021-03-04T16:37:00 | 253,745,110 | 0 | 0 | null | false | 2022-09-01T23:30:17 | 2020-04-07T09:19:41 | 2021-03-04T16:37:02 | 2022-09-01T23:30:15 | 7,622 | 0 | 0 | 5 | CSS | false | false | package com.yango.gmall.manage.mapper;
import com.yango.gmall.bean.SkuSaleAttrValue;
import tk.mybatis.mapper.common.Mapper;
import java.util.List;
/**
* @author 陈尊清
* @create 2020-04-10-21:05
*/
public interface SkuSaleAttrValueMapper extends Mapper<SkuSaleAttrValue> {
// 根据spuId 查询数据
List<SkuSaleAttrValue> selectSkuSaleAttrValueListBySpu(String spuId);
}
| UTF-8 | Java | 393 | java | SkuSaleAttrValueMapper.java | Java | [
{
"context": "n.Mapper;\n\nimport java.util.List;\n\n/**\n * @author 陈尊清\n * @create 2020-04-10-21:05\n */\npublic interface ",
"end": 169,
"score": 0.9998533725738525,
"start": 166,
"tag": "NAME",
"value": "陈尊清"
}
] | null | [] | package com.yango.gmall.manage.mapper;
import com.yango.gmall.bean.SkuSaleAttrValue;
import tk.mybatis.mapper.common.Mapper;
import java.util.List;
/**
* @author 陈尊清
* @create 2020-04-10-21:05
*/
public interface SkuSaleAttrValueMapper extends Mapper<SkuSaleAttrValue> {
// 根据spuId 查询数据
List<SkuSaleAttrValue> selectSkuSaleAttrValueListBySpu(String spuId);
}
| 393 | 0.768 | 0.736 | 16 | 22.4375 | 24.453959 | 74 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.3125 | false | false | 9 |
a044508973e4425c325462c78abe1e5bc06ca083 | 31,653,908,979,310 | 5ca19e92280812615cb649db7499bd98431c964f | /gradle/app/src/main/java/com/app/admin/sellah/view/activities/Video_capture_activity.java | 335c72d76e7cadbfcd3d8f41158ef170c07c941d | [] | no_license | geniusappdeveloper/sellah | https://github.com/geniusappdeveloper/sellah | 0f407ad575ee9013247e64c78591b71cecc059fb | 5ae97bc545254baf48121d5ef1a4d4da412dbc27 | refs/heads/master | 2020-04-01T01:36:50.558000 | 2019-04-19T12:44:12 | 2019-04-19T12:44:12 | 152,745,653 | 1 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.app.admin.sellah.view.activities;
import android.app.Activity;
import android.content.Intent;
import android.hardware.Camera;
import android.media.CamcorderProfile;
import android.media.MediaRecorder;
import android.os.Bundle;
import android.os.CountDownTimer;
import android.os.Environment;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.view.MotionEvent;
import android.view.Surface;
import android.view.SurfaceHolder;
import android.view.SurfaceView;
import android.view.View;
import android.view.Window;
import android.widget.Button;
import android.widget.ProgressBar;
import android.widget.Toast;
import com.app.admin.sellah.R;
import com.app.admin.sellah.controller.utils.Global;
import com.app.admin.sellah.controller.utils.PermissionCheckUtil;
import java.io.File;
import java.io.IOException;
import static com.app.admin.sellah.controller.utils.Global.makeTransperantStatusBar;
public class Video_capture_activity extends AppCompatActivity implements SurfaceHolder.Callback {
private SurfaceHolder surfaceHolder;
private SurfaceView surfaceView;
public MediaRecorder mrec = new MediaRecorder();
Button mbutton;
ProgressBar mProgressBar;
CountDownTimer mCountDownTimer;
int i=0;
File video;
private Camera mCamera;
boolean isActionDown,isstopped;
private int mOrientation=0;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
makeTransperantStatusBar(this, true);
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.activity_videocapture);
mbutton = (Button)findViewById(R.id.video);
mProgressBar=(ProgressBar)findViewById(R.id.progressbar);
mProgressBar.setProgress(i);
PermissionCheckUtil.create(this, new PermissionCheckUtil.onPermissionCheckCallback() {
@Override
public void onPermissionSuccess() {
Log.i(null, "Video starting");
mCamera = Camera.open();
int cameraId = -1;
int numberOfCameras = Camera.getNumberOfCameras();
for (int i = 0; i < numberOfCameras; i++) {
Camera.CameraInfo info = new Camera.CameraInfo();
Camera.getCameraInfo(i, info);
if (info.facing == Camera.CameraInfo.CAMERA_FACING_BACK) {
cameraId = i;
break;
}
}
setCameraDisplayOrientation(Video_capture_activity.this,cameraId,mCamera);
surfaceView = (SurfaceView) findViewById(R.id.surface_camera);
surfaceHolder = surfaceView.getHolder();
surfaceHolder.addCallback(Video_capture_activity.this);
surfaceHolder.setSizeFromLayout();
// surfaceHolder.l;
surfaceHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
}
});
mbutton.setOnLongClickListener(new View.OnLongClickListener() {
@Override
public boolean onLongClick(View view) {
// start recording..............
try {
isActionDown = true;
startRecording();
} catch (Exception e) {
String message = e.getMessage();
Log.i(null, "Problem Start" + message);
mrec.release();
}
mCountDownTimer=new CountDownTimer(10000,1000) {
@Override
public void onTick(long millisUntilFinished) {
Log.v("Log_tag", "Tick of Progress"+ i+ millisUntilFinished);
isstopped=false;
i++;
mProgressBar.setProgress((int)i*50/(10000/1000));
Log.v("Log_tag", ""+ (int)i*50/(10000/1000));
}
@Override
public void onFinish() {
//Do what you want
isActionDown = false;
i++;
mProgressBar.setProgress(100);
if (!isstopped){
stopRecording();
isstopped=true;
}
Log.v("Log_tag", "stop");
}
};
mCountDownTimer.start();
return false;
}
});
mbutton.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View view, MotionEvent motionEvent) {
switch (motionEvent.getAction()) {
case MotionEvent.ACTION_UP:
if (isActionDown)
{;
mCountDownTimer.cancel();
if (!isstopped){
stopRecording();
isstopped=true;
}
}
break;
}
return false;
}
});
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
menu.add(0, 0, 0, "StartRecording");
menu.add(0, 1, 0, "StopRecording");
return super.onCreateOptionsMenu(menu);
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case 0:
try {
startRecording();
} catch (Exception e) {
String message = e.getMessage();
Log.i(null, "Problem Start" + message);
mrec.release();
}
break;
case 1: //GoToAllNotes
/*mrec.stop();
mrec.release();
mrec = null;*/
stopRecording();
break;
default:
break;
}
return super.onOptionsItemSelected(item);
}
protected void startRecording() throws IOException {
mrec = new MediaRecorder(); // Works well
mCamera.unlock();
mrec.setCamera(mCamera);
mrec.setOrientationHint(mOrientation);
mrec.setPreviewDisplay(surfaceHolder.getSurface());
mrec.setVideoSource(MediaRecorder.VideoSource.CAMERA);
mrec.setAudioSource(MediaRecorder.AudioSource.MIC);
mrec.setProfile(CamcorderProfile.get(CamcorderProfile.QUALITY_LOW));
mrec.setPreviewDisplay(surfaceHolder.getSurface());
Global.videopath = Environment.getExternalStorageDirectory().getPath().concat("/"+String.valueOf(System.currentTimeMillis())+".3gp");
mrec.setOutputFile(Global.videopath);
// mrec.setOutputFile("/sdcard/zzzz.3gp");
Log.e( "startRecording: ",Global.videopath);
mrec.prepare();
mrec.start();
}
protected void stopRecording() {
mrec.stop();
mrec.release();
mCamera.release();
Intent intent = new Intent(this,Previewvideo.class);
startActivity(intent);
finish();
}
private void releaseMediaRecorder() {
if (mrec != null) {
mrec.reset(); // clear recorder configuration
mrec.release(); // release the recorder object
mrec = null;
mCamera.lock(); // lock camera for later use
}
}
private void releaseCamera() {
if (mCamera != null) {
mCamera.release(); // release the camera for other applications
mCamera = null;
}
}
@Override
public void surfaceChanged(SurfaceHolder holder, int format, int width,
int height) {
}
@Override
public void surfaceCreated(SurfaceHolder holder) {
if (mCamera != null) {
Camera.Parameters params = mCamera.getParameters();
mCamera.setParameters(params);
try {
mCamera.setPreviewDisplay(holder);
mCamera.startPreview();
} catch (IOException e) {
e.printStackTrace();
}
} else {
Toast.makeText(getApplicationContext(), "Camera not available!", Toast.LENGTH_LONG).show();
finish();
}
}
@Override
public void surfaceDestroyed(SurfaceHolder holder) {
/*mCamera.setPreviewCallback(null);
mCamera.stopPreview();
mCamera.release();*/
}
public void setCameraDisplayOrientation(Activity activity,
int cameraId, android.hardware.Camera camera) {
android.hardware.Camera.CameraInfo info =
new android.hardware.Camera.CameraInfo();
android.hardware.Camera.getCameraInfo(cameraId, info);
int rotation = activity.getWindowManager().getDefaultDisplay().getRotation();
int degrees = 0;
switch (rotation) {
case Surface.ROTATION_0:
degrees = 0;
break;
case Surface.ROTATION_90:
degrees = 90;
break;
case Surface.ROTATION_180:
degrees = 180;
break;
case Surface.ROTATION_270:
degrees = 270;
break;
}
int result;
if (info.facing == Camera.CameraInfo.CAMERA_FACING_FRONT) {
result = (info.orientation + degrees) % 360;
result = (360 - result) % 360; // compensate the mirror
} else { // back-facing
result = (info.orientation - degrees + 360) % 360;
}
camera.setDisplayOrientation(result);
mOrientation=result;
}
@Override
public void onBackPressed() {
super.onBackPressed();
Global.videopath = "no_image" ;
}
}
| UTF-8 | Java | 10,197 | java | Video_capture_activity.java | Java | [] | null | [] | package com.app.admin.sellah.view.activities;
import android.app.Activity;
import android.content.Intent;
import android.hardware.Camera;
import android.media.CamcorderProfile;
import android.media.MediaRecorder;
import android.os.Bundle;
import android.os.CountDownTimer;
import android.os.Environment;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.view.MotionEvent;
import android.view.Surface;
import android.view.SurfaceHolder;
import android.view.SurfaceView;
import android.view.View;
import android.view.Window;
import android.widget.Button;
import android.widget.ProgressBar;
import android.widget.Toast;
import com.app.admin.sellah.R;
import com.app.admin.sellah.controller.utils.Global;
import com.app.admin.sellah.controller.utils.PermissionCheckUtil;
import java.io.File;
import java.io.IOException;
import static com.app.admin.sellah.controller.utils.Global.makeTransperantStatusBar;
public class Video_capture_activity extends AppCompatActivity implements SurfaceHolder.Callback {
private SurfaceHolder surfaceHolder;
private SurfaceView surfaceView;
public MediaRecorder mrec = new MediaRecorder();
Button mbutton;
ProgressBar mProgressBar;
CountDownTimer mCountDownTimer;
int i=0;
File video;
private Camera mCamera;
boolean isActionDown,isstopped;
private int mOrientation=0;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
makeTransperantStatusBar(this, true);
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.activity_videocapture);
mbutton = (Button)findViewById(R.id.video);
mProgressBar=(ProgressBar)findViewById(R.id.progressbar);
mProgressBar.setProgress(i);
PermissionCheckUtil.create(this, new PermissionCheckUtil.onPermissionCheckCallback() {
@Override
public void onPermissionSuccess() {
Log.i(null, "Video starting");
mCamera = Camera.open();
int cameraId = -1;
int numberOfCameras = Camera.getNumberOfCameras();
for (int i = 0; i < numberOfCameras; i++) {
Camera.CameraInfo info = new Camera.CameraInfo();
Camera.getCameraInfo(i, info);
if (info.facing == Camera.CameraInfo.CAMERA_FACING_BACK) {
cameraId = i;
break;
}
}
setCameraDisplayOrientation(Video_capture_activity.this,cameraId,mCamera);
surfaceView = (SurfaceView) findViewById(R.id.surface_camera);
surfaceHolder = surfaceView.getHolder();
surfaceHolder.addCallback(Video_capture_activity.this);
surfaceHolder.setSizeFromLayout();
// surfaceHolder.l;
surfaceHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
}
});
mbutton.setOnLongClickListener(new View.OnLongClickListener() {
@Override
public boolean onLongClick(View view) {
// start recording..............
try {
isActionDown = true;
startRecording();
} catch (Exception e) {
String message = e.getMessage();
Log.i(null, "Problem Start" + message);
mrec.release();
}
mCountDownTimer=new CountDownTimer(10000,1000) {
@Override
public void onTick(long millisUntilFinished) {
Log.v("Log_tag", "Tick of Progress"+ i+ millisUntilFinished);
isstopped=false;
i++;
mProgressBar.setProgress((int)i*50/(10000/1000));
Log.v("Log_tag", ""+ (int)i*50/(10000/1000));
}
@Override
public void onFinish() {
//Do what you want
isActionDown = false;
i++;
mProgressBar.setProgress(100);
if (!isstopped){
stopRecording();
isstopped=true;
}
Log.v("Log_tag", "stop");
}
};
mCountDownTimer.start();
return false;
}
});
mbutton.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View view, MotionEvent motionEvent) {
switch (motionEvent.getAction()) {
case MotionEvent.ACTION_UP:
if (isActionDown)
{;
mCountDownTimer.cancel();
if (!isstopped){
stopRecording();
isstopped=true;
}
}
break;
}
return false;
}
});
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
menu.add(0, 0, 0, "StartRecording");
menu.add(0, 1, 0, "StopRecording");
return super.onCreateOptionsMenu(menu);
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case 0:
try {
startRecording();
} catch (Exception e) {
String message = e.getMessage();
Log.i(null, "Problem Start" + message);
mrec.release();
}
break;
case 1: //GoToAllNotes
/*mrec.stop();
mrec.release();
mrec = null;*/
stopRecording();
break;
default:
break;
}
return super.onOptionsItemSelected(item);
}
protected void startRecording() throws IOException {
mrec = new MediaRecorder(); // Works well
mCamera.unlock();
mrec.setCamera(mCamera);
mrec.setOrientationHint(mOrientation);
mrec.setPreviewDisplay(surfaceHolder.getSurface());
mrec.setVideoSource(MediaRecorder.VideoSource.CAMERA);
mrec.setAudioSource(MediaRecorder.AudioSource.MIC);
mrec.setProfile(CamcorderProfile.get(CamcorderProfile.QUALITY_LOW));
mrec.setPreviewDisplay(surfaceHolder.getSurface());
Global.videopath = Environment.getExternalStorageDirectory().getPath().concat("/"+String.valueOf(System.currentTimeMillis())+".3gp");
mrec.setOutputFile(Global.videopath);
// mrec.setOutputFile("/sdcard/zzzz.3gp");
Log.e( "startRecording: ",Global.videopath);
mrec.prepare();
mrec.start();
}
protected void stopRecording() {
mrec.stop();
mrec.release();
mCamera.release();
Intent intent = new Intent(this,Previewvideo.class);
startActivity(intent);
finish();
}
private void releaseMediaRecorder() {
if (mrec != null) {
mrec.reset(); // clear recorder configuration
mrec.release(); // release the recorder object
mrec = null;
mCamera.lock(); // lock camera for later use
}
}
private void releaseCamera() {
if (mCamera != null) {
mCamera.release(); // release the camera for other applications
mCamera = null;
}
}
@Override
public void surfaceChanged(SurfaceHolder holder, int format, int width,
int height) {
}
@Override
public void surfaceCreated(SurfaceHolder holder) {
if (mCamera != null) {
Camera.Parameters params = mCamera.getParameters();
mCamera.setParameters(params);
try {
mCamera.setPreviewDisplay(holder);
mCamera.startPreview();
} catch (IOException e) {
e.printStackTrace();
}
} else {
Toast.makeText(getApplicationContext(), "Camera not available!", Toast.LENGTH_LONG).show();
finish();
}
}
@Override
public void surfaceDestroyed(SurfaceHolder holder) {
/*mCamera.setPreviewCallback(null);
mCamera.stopPreview();
mCamera.release();*/
}
public void setCameraDisplayOrientation(Activity activity,
int cameraId, android.hardware.Camera camera) {
android.hardware.Camera.CameraInfo info =
new android.hardware.Camera.CameraInfo();
android.hardware.Camera.getCameraInfo(cameraId, info);
int rotation = activity.getWindowManager().getDefaultDisplay().getRotation();
int degrees = 0;
switch (rotation) {
case Surface.ROTATION_0:
degrees = 0;
break;
case Surface.ROTATION_90:
degrees = 90;
break;
case Surface.ROTATION_180:
degrees = 180;
break;
case Surface.ROTATION_270:
degrees = 270;
break;
}
int result;
if (info.facing == Camera.CameraInfo.CAMERA_FACING_FRONT) {
result = (info.orientation + degrees) % 360;
result = (360 - result) % 360; // compensate the mirror
} else { // back-facing
result = (info.orientation - degrees + 360) % 360;
}
camera.setDisplayOrientation(result);
mOrientation=result;
}
@Override
public void onBackPressed() {
super.onBackPressed();
Global.videopath = "no_image" ;
}
}
| 10,197 | 0.545945 | 0.537805 | 319 | 30.965517 | 24.088957 | 141 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.605016 | false | false | 9 |
5ceb20bff28299a1fee2ae181a8b80a56e9639b2 | 11,416,023,094,896 | 9c7f3c477323f986bae85ac1392b1cd5abda1c12 | /app/src/main/java/com/hackthefuture/florianzjef/loggingapp/models/Photo.java | f65de29faba689bb936db78a3b2febbdd943c14d | [] | no_license | 211260fg/LoggingTeamRocket | https://github.com/211260fg/LoggingTeamRocket | 074567fd6a37c936c2c47b4e8f6b4dc31d519103 | 43bf4fdb5587ffdd2495a6426802bd8a9fba3a34 | refs/heads/master | 2020-06-10T17:32:44.834000 | 2016-12-17T15:19:24 | 2016-12-17T15:19:24 | 75,921,133 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.hackthefuture.florianzjef.loggingapp.models;
import android.os.Environment;
import android.widget.Toast;
import java.io.File;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.Date;
/**
* Created by Zjef on 8/12/2016.
*/
public class Photo {
private String description;
private String base64imagedata;
private String datetime;
public Photo(String description, String base64imagedata, String datetime) {
this.description = description;
this.base64imagedata = base64imagedata;
this.datetime = datetime;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public String getBase64imagedata() {
return base64imagedata;
}
public void setBase64imagedata(String base64imagedata) {
this.base64imagedata = base64imagedata;
}
public String getDatetime() {
return datetime;
}
public void setDatetime(String datetime) {
this.datetime = datetime;
}
}
| UTF-8 | Java | 1,121 | java | Photo.java | Java | [
{
"context": "eFormat;\nimport java.util.Date;\n\n/**\n * Created by Zjef on 8/12/2016.\n */\n\npublic class Photo {\n\n priv",
"end": 249,
"score": 0.9982509613037109,
"start": 245,
"tag": "USERNAME",
"value": "Zjef"
}
] | null | [] | package com.hackthefuture.florianzjef.loggingapp.models;
import android.os.Environment;
import android.widget.Toast;
import java.io.File;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.Date;
/**
* Created by Zjef on 8/12/2016.
*/
public class Photo {
private String description;
private String base64imagedata;
private String datetime;
public Photo(String description, String base64imagedata, String datetime) {
this.description = description;
this.base64imagedata = base64imagedata;
this.datetime = datetime;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public String getBase64imagedata() {
return base64imagedata;
}
public void setBase64imagedata(String base64imagedata) {
this.base64imagedata = base64imagedata;
}
public String getDatetime() {
return datetime;
}
public void setDatetime(String datetime) {
this.datetime = datetime;
}
}
| 1,121 | 0.693131 | 0.669046 | 50 | 21.42 | 19.892803 | 79 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.42 | false | false | 9 |
613821ff0c3f302030d29b4e6b312949a84e7300 | 3,779,571,232,076 | 570f9b5eb59be59102a34bc84c051a4b98cb1217 | /src/main/java/com/github/lc/schema/policy/Clients.java | 141678af8b671346836b3dc52fa3a445ae109ea5 | [] | no_license | 1374250553/nbu-sdk | https://github.com/1374250553/nbu-sdk | a6d2d2ea1f49f5d7ae14b540ad92c36a102e5e57 | e6ca928264bd88de0a6a2ac55199e5d159a75f61 | refs/heads/master | 2023-05-09T01:51:10.235000 | 2021-01-05T07:13:01 | 2021-01-05T07:13:01 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.github.lc.schema.policy;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;
@Data
public class Clients {
@JsonProperty("OS")
private String OS;
@JsonProperty("OS")
public String getOS() {
return OS;
}
@JsonProperty("OS")
public void setOS(String OS) {
this.OS = OS;
}
private String databaseName;
private String hardware;
private String hostName;
private String instanceGroup;
private String instanceName;
}
| UTF-8 | Java | 516 | java | Clients.java | Java | [] | null | [] | package com.github.lc.schema.policy;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;
@Data
public class Clients {
@JsonProperty("OS")
private String OS;
@JsonProperty("OS")
public String getOS() {
return OS;
}
@JsonProperty("OS")
public void setOS(String OS) {
this.OS = OS;
}
private String databaseName;
private String hardware;
private String hostName;
private String instanceGroup;
private String instanceName;
}
| 516 | 0.670543 | 0.670543 | 26 | 18.846153 | 14.165756 | 53 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.423077 | false | false | 9 |
ddee029fd8219c821099b6431aa2fcc81a5feddf | 1,829,656,108,863 | eb5025b07a46c7ad5509ad6c9a58a9045168c494 | /src/main/java/frc/robot/subsystems/Arm.java | 590895518643c6ca84c959edce3fa7c02b2b2c87 | [] | no_license | ThePoros5554/OffSeason2019 | https://github.com/ThePoros5554/OffSeason2019 | 8c5fcb5e5b8c35868e086057e54d4a68d7f4f80d | 4cec4938c831257bfba20143e5684ddae0863d0f | refs/heads/master | 2020-08-04T13:32:26.464000 | 2019-12-28T17:14:52 | 2019-12-28T17:14:52 | 212,152,714 | 0 | 1 | null | false | 2019-12-28T17:14:53 | 2019-10-01T17:05:03 | 2019-10-18T08:46:13 | 2019-12-28T17:14:52 | 103 | 0 | 1 | 0 | Java | false | false | /*----------------------------------------------------------------------------*/
/* Copyright (c) 2018 FIRST. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project. */
/*----------------------------------------------------------------------------*/
package frc.robot.subsystems;
import com.ctre.phoenix.motorcontrol.ControlMode;
import com.ctre.phoenix.motorcontrol.FeedbackDevice;
import com.ctre.phoenix.motorcontrol.InvertType;
import com.ctre.phoenix.motorcontrol.NeutralMode;
import com.ctre.phoenix.motorcontrol.can.WPI_TalonSRX;
import edu.wpi.first.wpilibj.command.Subsystem;
import frc.robot.RobotMap;
/**
* Add your docs here.
*/
public class Arm extends Subsystem {
private WPI_TalonSRX master;
private int targetPosition;
private boolean isStoping;
//motion values
private final int kMaxAcceleration = 500;//acceleration limit
private final int kMaxVelocity = 500;//velocity limit
//PID VALUES
private final int kMagicSlot = 0;
private final double kMagicP = 1;
private final double kMagicI = 0;
private final double kMagicD = 0.1;
private final double kMagicF = 2.046;
//kF consts
private int ticksAtHorizontal = 2800;
private double ticksPerDegree = 4096/360;
public enum WristPos
{
UP(1780),
DOWN(2775),
INSIDE(1000),
COLLECT_CARGO(3100),
HIGH_CARGO(2450);
private final int position;
private WristPos(int position)
{
this.position = position;
}
public int getPosition()
{
return position;
}
}
public Arm()
{
master = new WPI_TalonSRX(RobotMap.kArmPort);
master.configSelectedFeedbackSensor(FeedbackDevice.CTRE_MagEncoder_Absolute);
master.setNeutralMode(NeutralMode.Brake);
master.set(ControlMode.PercentOutput, 0);
master.setSensorPhase(true);
master.setInverted(InvertType.InvertMotorOutput);
master.configMotionAcceleration(kMaxAcceleration);
master.configMotionCruiseVelocity(kMaxVelocity);
configProfileSlot(kMagicSlot, kMagicP, kMagicI, kMagicD, kMagicF);
isStoping = true;
}
@Override
public void initDefaultCommand() {
// Set the default command for a subsystem here.
// setDefaultCommand(new MySpecialCommand());
}
public void configProfileSlot(int profileSlot, double kP, double kI, double kD, double kF)
{
master.config_kP(profileSlot, kP, 10);
master.config_kI(profileSlot, kI, 10);
master.config_kD(profileSlot, kD, 10);
master.config_kF(profileSlot, kF, 10);
}
public void setPercentOutput(double power) {
isStoping = false;
master.set(ControlMode.PercentOutput, power);
targetPosition = getCurrentPosition() + (int)(master.getSelectedSensorVelocity()/100 * 1000 * 0.02);
}
public void stop(){
isStoping = true;
targetPosition = getCurrentPosition();
double degrees = (targetPosition - ticksAtHorizontal)/ticksPerDegree;
double radians = Math.toRadians(degrees);
double cosineScalar = Math.cos(radians);
double maxGravityFF = -0.11;
master.set(ControlMode.PercentOutput, maxGravityFF * cosineScalar);
}
public void goTo(int pos){
isStoping = false;
targetPosition = pos;
master.selectProfileSlot(kMagicSlot, 0);
master.set(ControlMode.MotionMagic, pos);
}
public int getCurrentPosition(){
return this.master.getSelectedSensorPosition();
}
public double getOutputCurrent() {
return master.getOutputCurrent();
}
public boolean atTarget() {
return Math.abs(getCurrentPosition() - targetPosition) < 8;
}
@Override
public void periodic() {
if(isStoping) {
stop();
}
}
}
| UTF-8 | Java | 3,874 | java | Arm.java | Java | [] | null | [] | /*----------------------------------------------------------------------------*/
/* Copyright (c) 2018 FIRST. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project. */
/*----------------------------------------------------------------------------*/
package frc.robot.subsystems;
import com.ctre.phoenix.motorcontrol.ControlMode;
import com.ctre.phoenix.motorcontrol.FeedbackDevice;
import com.ctre.phoenix.motorcontrol.InvertType;
import com.ctre.phoenix.motorcontrol.NeutralMode;
import com.ctre.phoenix.motorcontrol.can.WPI_TalonSRX;
import edu.wpi.first.wpilibj.command.Subsystem;
import frc.robot.RobotMap;
/**
* Add your docs here.
*/
public class Arm extends Subsystem {
private WPI_TalonSRX master;
private int targetPosition;
private boolean isStoping;
//motion values
private final int kMaxAcceleration = 500;//acceleration limit
private final int kMaxVelocity = 500;//velocity limit
//PID VALUES
private final int kMagicSlot = 0;
private final double kMagicP = 1;
private final double kMagicI = 0;
private final double kMagicD = 0.1;
private final double kMagicF = 2.046;
//kF consts
private int ticksAtHorizontal = 2800;
private double ticksPerDegree = 4096/360;
public enum WristPos
{
UP(1780),
DOWN(2775),
INSIDE(1000),
COLLECT_CARGO(3100),
HIGH_CARGO(2450);
private final int position;
private WristPos(int position)
{
this.position = position;
}
public int getPosition()
{
return position;
}
}
public Arm()
{
master = new WPI_TalonSRX(RobotMap.kArmPort);
master.configSelectedFeedbackSensor(FeedbackDevice.CTRE_MagEncoder_Absolute);
master.setNeutralMode(NeutralMode.Brake);
master.set(ControlMode.PercentOutput, 0);
master.setSensorPhase(true);
master.setInverted(InvertType.InvertMotorOutput);
master.configMotionAcceleration(kMaxAcceleration);
master.configMotionCruiseVelocity(kMaxVelocity);
configProfileSlot(kMagicSlot, kMagicP, kMagicI, kMagicD, kMagicF);
isStoping = true;
}
@Override
public void initDefaultCommand() {
// Set the default command for a subsystem here.
// setDefaultCommand(new MySpecialCommand());
}
public void configProfileSlot(int profileSlot, double kP, double kI, double kD, double kF)
{
master.config_kP(profileSlot, kP, 10);
master.config_kI(profileSlot, kI, 10);
master.config_kD(profileSlot, kD, 10);
master.config_kF(profileSlot, kF, 10);
}
public void setPercentOutput(double power) {
isStoping = false;
master.set(ControlMode.PercentOutput, power);
targetPosition = getCurrentPosition() + (int)(master.getSelectedSensorVelocity()/100 * 1000 * 0.02);
}
public void stop(){
isStoping = true;
targetPosition = getCurrentPosition();
double degrees = (targetPosition - ticksAtHorizontal)/ticksPerDegree;
double radians = Math.toRadians(degrees);
double cosineScalar = Math.cos(radians);
double maxGravityFF = -0.11;
master.set(ControlMode.PercentOutput, maxGravityFF * cosineScalar);
}
public void goTo(int pos){
isStoping = false;
targetPosition = pos;
master.selectProfileSlot(kMagicSlot, 0);
master.set(ControlMode.MotionMagic, pos);
}
public int getCurrentPosition(){
return this.master.getSelectedSensorPosition();
}
public double getOutputCurrent() {
return master.getOutputCurrent();
}
public boolean atTarget() {
return Math.abs(getCurrentPosition() - targetPosition) < 8;
}
@Override
public void periodic() {
if(isStoping) {
stop();
}
}
}
| 3,874 | 0.662881 | 0.643779 | 145 | 25.717241 | 24.964169 | 105 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.565517 | false | false | 9 |
e44ce08d9217db105978ae242e10621bf25b647a | 24,335,284,700,209 | dba34a6d2f0346e1703e28d50c675f74cd22f681 | /test/dao/SessionTest.java | 760df5fa242a4cd240a53392511fe749e3f4055b | [] | no_license | jeromeJ9/GestionCandidature | https://github.com/jeromeJ9/GestionCandidature | 1f798d1555857f5f707cd52868bd1f2d34b9238d | b52b11e579a302393302b09d95eb6ed4704e4261 | refs/heads/master | 2021-01-21T13:57:00.087000 | 2016-05-28T14:20:12 | 2016-05-28T14:20:12 | 55,766,211 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package dao;
import bean.Candidat;
import bean.UneSession;
import java.sql.Date;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.List;
import org.junit.Test;
import static org.junit.Assert.*;
public class SessionTest extends DaoTest{
public SessionTest() {
}
/**
* Test of getSessionWithCandidats method, of class Session.
*/
@Test
public void testGetCandidatsBySession() throws Exception {
System.out.println("getCandidatsBySession");
List<Candidat> listePersonne = new ArrayList<Candidat>();
Candidat p3 = new Candidat(6, "MOREAU", "Vincent", 3);
Candidat p1 = new Candidat(12, "MOSHINE", "Hajar", 3);
Candidat p2 = new Candidat(18, "DUPOND", "Dupond", 3);
listePersonne.add(p3);
listePersonne.add(p1);
listePersonne.add(p2);
Date debut = Date.valueOf( "2017-02-10" );
Date debutIns = Date.valueOf( "2017-01-14" );
Date finIns = Date.valueOf( "2017-02-01" );
UneSession expResult = new UneSession(6, "Bac S.T.I. : génie mécanique, génie électrotechnique", listePersonne, 14, debut, debutIns,finIns );
//System.out.println("expResult"+expResult.getListeDePersonnes().toString());
UneSession result = null;
result = dao.Session.getSessionWithCandidats(6);
//System.out.println("result"+result.getListeDePersonnes().toString());
assertEquals(result, expResult );
}
}
| UTF-8 | Java | 1,558 | java | SessionTest.java | Java | [
{
"context": "didat>();\r\n Candidat p3 = new Candidat(6, \"MOREAU\", \"Vincent\", 3);\r\n Candidat p1 = new Candi",
"end": 661,
"score": 0.9997138977050781,
"start": 655,
"tag": "NAME",
"value": "MOREAU"
},
{
"context": "\n Candidat p3 = new Candidat(6, \"MOREAU... | null | [] |
package dao;
import bean.Candidat;
import bean.UneSession;
import java.sql.Date;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.List;
import org.junit.Test;
import static org.junit.Assert.*;
public class SessionTest extends DaoTest{
public SessionTest() {
}
/**
* Test of getSessionWithCandidats method, of class Session.
*/
@Test
public void testGetCandidatsBySession() throws Exception {
System.out.println("getCandidatsBySession");
List<Candidat> listePersonne = new ArrayList<Candidat>();
Candidat p3 = new Candidat(6, "MOREAU", "Vincent", 3);
Candidat p1 = new Candidat(12, "MOSHINE", "Hajar", 3);
Candidat p2 = new Candidat(18, "DUPOND", "Dupond", 3);
listePersonne.add(p3);
listePersonne.add(p1);
listePersonne.add(p2);
Date debut = Date.valueOf( "2017-02-10" );
Date debutIns = Date.valueOf( "2017-01-14" );
Date finIns = Date.valueOf( "2017-02-01" );
UneSession expResult = new UneSession(6, "Bac S.T.I. : génie mécanique, génie électrotechnique", listePersonne, 14, debut, debutIns,finIns );
//System.out.println("expResult"+expResult.getListeDePersonnes().toString());
UneSession result = null;
result = dao.Session.getSessionWithCandidats(6);
//System.out.println("result"+result.getListeDePersonnes().toString());
assertEquals(result, expResult );
}
}
| 1,558 | 0.629987 | 0.60296 | 47 | 31.021276 | 29.73678 | 149 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.93617 | false | false | 9 |
0cdb85a6461b98b6344f90936305e98d5a7187a1 | 21,629,455,370,447 | fffdb643c0c3f2e88302cffa80b9ca5004848026 | /aplicacao/src/main/java/br/com/trt/aplicacao/dao/impl/ItemServicoDaoImpl.java | 51e0dd43844abe6fef33cd5524b98d724ee640b7 | [] | no_license | nenodias/sistema-vaadin | https://github.com/nenodias/sistema-vaadin | 92ed3fca7819a4dd581b9e7deb56b480d29f5b2b | a2cd44e6f948ac1d3b45a3086e5153bd08d05800 | refs/heads/master | 2016-09-08T04:36:57.840000 | 2015-09-07T23:51:18 | 2015-09-07T23:51:18 | 34,289,052 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package br.com.trt.aplicacao.dao.impl;
import java.util.List;
import org.hibernate.Query;
import org.hibernate.criterion.Restrictions;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;
import br.com.trt.aplicacao.dao.ItemServicoDao;
import br.com.trt.aplicacao.model.ItemServico;
import br.com.trt.aplicacao.model.Movimentacao;
@Transactional("default")
@Repository
public class ItemServicoDaoImpl extends GenericDaoImpl<ItemServico, Long> implements
ItemServicoDao {
@SuppressWarnings("unchecked")
@Override
public List<ItemServico> buscarPorIdMovimentacao(Long idMovimentacao) {
List<ItemServico> lista = getSession().createCriteria(ItemServico.class, "is").createAlias("is.movimentacao", "m").add(Restrictions.eq("m.id", idMovimentacao)).list();
initialize(lista);
return lista;
}
@Override
public List<ItemServico> buscarTodos() {
List<ItemServico> todos = super.buscarTodos();
initialize(todos);
return todos;
}
private void initialize(List<ItemServico> lista) {
for (ItemServico itemServico : lista) {
initialize(itemServico);
}
}
private void initialize(ItemServico itemServico) {
Movimentacao movimentacao = MovimentacaoDaoImpl.initializeAndUnproxy(itemServico.getMovimentacao());
itemServico.setMovimentacao(movimentacao);
}
@Override
public ItemServico buscaPorId(Long chave) {
ItemServico entidade = super.buscaPorId(chave);
initialize(entidade);
return entidade;
}
@Override
public void deletarPorIdMovimentacao(Long idMovimentacao) {
Query query = getSession().createQuery("DELETE FROM ItemServico it where it.movimentacao.id = :idMovimentacao ");
query.setParameter("idMovimentacao", idMovimentacao);
query.executeUpdate();
}
}
| UTF-8 | Java | 1,773 | java | ItemServicoDaoImpl.java | Java | [] | null | [] | package br.com.trt.aplicacao.dao.impl;
import java.util.List;
import org.hibernate.Query;
import org.hibernate.criterion.Restrictions;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;
import br.com.trt.aplicacao.dao.ItemServicoDao;
import br.com.trt.aplicacao.model.ItemServico;
import br.com.trt.aplicacao.model.Movimentacao;
@Transactional("default")
@Repository
public class ItemServicoDaoImpl extends GenericDaoImpl<ItemServico, Long> implements
ItemServicoDao {
@SuppressWarnings("unchecked")
@Override
public List<ItemServico> buscarPorIdMovimentacao(Long idMovimentacao) {
List<ItemServico> lista = getSession().createCriteria(ItemServico.class, "is").createAlias("is.movimentacao", "m").add(Restrictions.eq("m.id", idMovimentacao)).list();
initialize(lista);
return lista;
}
@Override
public List<ItemServico> buscarTodos() {
List<ItemServico> todos = super.buscarTodos();
initialize(todos);
return todos;
}
private void initialize(List<ItemServico> lista) {
for (ItemServico itemServico : lista) {
initialize(itemServico);
}
}
private void initialize(ItemServico itemServico) {
Movimentacao movimentacao = MovimentacaoDaoImpl.initializeAndUnproxy(itemServico.getMovimentacao());
itemServico.setMovimentacao(movimentacao);
}
@Override
public ItemServico buscaPorId(Long chave) {
ItemServico entidade = super.buscaPorId(chave);
initialize(entidade);
return entidade;
}
@Override
public void deletarPorIdMovimentacao(Long idMovimentacao) {
Query query = getSession().createQuery("DELETE FROM ItemServico it where it.movimentacao.id = :idMovimentacao ");
query.setParameter("idMovimentacao", idMovimentacao);
query.executeUpdate();
}
}
| 1,773 | 0.783418 | 0.783418 | 58 | 29.568966 | 32.426102 | 169 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.465517 | false | false | 9 |
9de492747987f693f29ce333cf30beb26ae120a0 | 2,233,383,011,685 | 804ecefdbf23b11a7c00922ff23f0b8bff8ea365 | /src/main/java/com/joenee/web/rest/UsersController.java | bf6ebcce503aef3b083c40686cc4ad6f12bc039d | [
"Apache-2.0"
] | permissive | narutoswind/wechat-web | https://github.com/narutoswind/wechat-web | 86de654abc50a68eef65fa93c9031efff62d10ce | ae0b94d8f50820a62f31219b14f22e00445f296a | refs/heads/master | 2020-02-27T22:23:03.677000 | 2017-11-27T02:45:07 | 2017-11-27T02:45:07 | 101,622,321 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.joenee.web.rest;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.joenee.common.common.result.JsonResult;
import com.joenee.common.model.User;
import com.joenee.common.service.UserService;
import com.joenee.web.enums.ResponseEnum;
import org.apache.commons.codec.digest.DigestUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.servlet.http.HttpServletRequest;
/**
* <p>
* 用户表 前端控制器
* </p>
*
* @author sylar
* @since 2017-08-27
*/
@Controller
@RequestMapping("/user")
public class UsersController extends BaseController{
@Autowired
private UserService userService;
/**
*
* @param request
* @param user
* @param model
* @return
*/
@RequestMapping(value = "index",method = RequestMethod.GET)
public String accountIndexAuthority(HttpServletRequest request, User user, Model model){
User currentUser = userService.selectById(user.getId());
model.addAttribute("user",currentUser);
return "/user_account";
}
/**
*
* @param request
* @param user
* @return
*/
@RequestMapping(value = "account",method = RequestMethod.POST)
@ResponseBody
public JsonResult modifyAccountAuthority(@RequestParam(name = "account") String account, @RequestParam(name = "pwd") String pwd,
HttpServletRequest request, User user){
if (StringUtils.isBlank(account) || StringUtils.isBlank(pwd) || account.length() != 11
|| pwd.length() > 16 || pwd.length() < 6) {
return renderError(ResponseEnum._PARAMS_ERROR);
}
User currentUser = userService.selectById(user.getId());
User accountUser = userService.selectOne(new EntityWrapper<User>().eq("login_name",account));
if (accountUser != null && !accountUser.getId().equals(currentUser.getId())) {
return renderErrorMsg("该手机号已被绑定");
}
String password = DigestUtils.md5Hex(pwd);
if (account.equals(currentUser.getLoginName()) && password.equals(currentUser.getPassword())) {
return renderSuccess();
}
currentUser.setLoginName(account);
currentUser.setPassword(password);
currentUser.setMobile(account);
userService.updateById(currentUser);
return renderSuccess();
}
@RequestMapping(value = "agreement",method = RequestMethod.POST)
public void modifyAccountAuthority(HttpServletRequest request, User user){
user.setAgreement(1);
userService.updateById(user);
}
}
| UTF-8 | Java | 3,006 | java | UsersController.java | Java | [
{
"context": "st;\n\n/**\n * <p>\n * 用户表 前端控制器\n * </p>\n *\n * @author sylar\n * @since 2017-08-27\n */\n@Controller\n@RequestMapp",
"end": 855,
"score": 0.9997194409370422,
"start": 850,
"tag": "USERNAME",
"value": "sylar"
},
{
"context": "g(\"该手机号已被绑定\");\n }\n Strin... | null | [] | package com.joenee.web.rest;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.joenee.common.common.result.JsonResult;
import com.joenee.common.model.User;
import com.joenee.common.service.UserService;
import com.joenee.web.enums.ResponseEnum;
import org.apache.commons.codec.digest.DigestUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.servlet.http.HttpServletRequest;
/**
* <p>
* 用户表 前端控制器
* </p>
*
* @author sylar
* @since 2017-08-27
*/
@Controller
@RequestMapping("/user")
public class UsersController extends BaseController{
@Autowired
private UserService userService;
/**
*
* @param request
* @param user
* @param model
* @return
*/
@RequestMapping(value = "index",method = RequestMethod.GET)
public String accountIndexAuthority(HttpServletRequest request, User user, Model model){
User currentUser = userService.selectById(user.getId());
model.addAttribute("user",currentUser);
return "/user_account";
}
/**
*
* @param request
* @param user
* @return
*/
@RequestMapping(value = "account",method = RequestMethod.POST)
@ResponseBody
public JsonResult modifyAccountAuthority(@RequestParam(name = "account") String account, @RequestParam(name = "pwd") String pwd,
HttpServletRequest request, User user){
if (StringUtils.isBlank(account) || StringUtils.isBlank(pwd) || account.length() != 11
|| pwd.length() > 16 || pwd.length() < 6) {
return renderError(ResponseEnum._PARAMS_ERROR);
}
User currentUser = userService.selectById(user.getId());
User accountUser = userService.selectOne(new EntityWrapper<User>().eq("login_name",account));
if (accountUser != null && !accountUser.getId().equals(currentUser.getId())) {
return renderErrorMsg("该手机号已被绑定");
}
String password = <PASSWORD>(pwd);
if (account.equals(currentUser.getLoginName()) && password.equals(currentUser.getPassword())) {
return renderSuccess();
}
currentUser.setLoginName(account);
currentUser.setPassword(<PASSWORD>);
currentUser.setMobile(account);
userService.updateById(currentUser);
return renderSuccess();
}
@RequestMapping(value = "agreement",method = RequestMethod.POST)
public void modifyAccountAuthority(HttpServletRequest request, User user){
user.setAgreement(1);
userService.updateById(user);
}
}
| 3,000 | 0.690989 | 0.685609 | 86 | 33.581394 | 29.262432 | 132 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.616279 | false | false | 9 |
9935369637533ca51d3ad4103c009a8e0eabd6e7 | 16,716,012,743,743 | c3b6788b594161acd4be012606df576339c7f5e3 | /Parsing/Optimiser.java | 8103a6fa8c5fda69c72b896a9c82bdb457bbdb81 | [] | no_license | navdeepsingh8/UCLJava | https://github.com/navdeepsingh8/UCLJava | 91009cdf1a5aec6b8c4aaefd644598750878e7bc | 2a4a70c08c6c5ce53e5693b5c4bbc051b700be13 | refs/heads/master | 2021-01-17T17:48:48.107000 | 2016-07-01T18:05:58 | 2016-07-01T18:05:58 | 61,048,786 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | public class Optimiser implements Interface.EmitterIF
{
Emitter Emitter;
String savedOpcode = "",
savedValue = "";
boolean DEBUG;
public Optimiser(boolean debug) {DEBUG = debug;}
public Optimiser(Emitter E, boolean debug) {Emitter = E; DEBUG = debug;}
public void peepholeOptimiser(String opcode, String value)
{
if (DEBUG) {
output(" ; " + opcode, value);
}
if (opcode == SEPARATOR && savedOpcode == SEPARATOR) {
if (value.equals(savedValue) || value == ""){
/* discard repeated or new null separator */
} else if (savedValue == "") {
savedValue = value; // discard old null separator
} else {
flush();savedOpcode = opcode; savedValue = value;
}
} else if (opcode == SEPARATOR ||
opcode == GOTO || opcode == RVALUE || opcode == PUSH) {
flush();savedOpcode = opcode; savedValue = value;
} else if (savedOpcode == "") {
output(opcode, value);
} else if (opcode == LABEL && savedOpcode == GOTO &&
value.equals(savedValue)){
clear(); output(LABEL, value);
} else if (opcode == POP &&
(savedOpcode == RVALUE || savedOpcode == PUSH)) {
clear();
} else if (opcode.equals("+")&& savedOpcode == PUSH &&
savedValue.equals("1")) {
clear(); output(INC,"");
} else if (opcode.equals("-") && savedOpcode == PUSH &&
savedValue.equals("1")) {
clear(); output(DEC,"");
} else if (opcode.equals("*") && savedOpcode == PUSH &&
savedValue.equals("2")) {
clear(); output(COPY,""); output("+","");
} else {
flush(); output(opcode, value);
}
}
void output(String opcode, String value)
{
if (Emitter != null) Emitter.output(opcode, value);
else System.out.println(opcode + " " + value);
}
void flush()
{
if (savedOpcode != "") output(savedOpcode, savedValue);
clear();
}
void clear()
{
savedOpcode = ""; savedValue = "";
}
public static void main(String[] args)
{
Optimiser O = new Optimiser(true);
O.peepholeOptimiser(GOTO, "17");
O.peepholeOptimiser(LABEL, "17");
O.peepholeOptimiser(PUSH, "2");
O.peepholeOptimiser("*", "");
O.peepholeOptimiser(PUSH, "1");
O.peepholeOptimiser("+", "");
O.peepholeOptimiser(SEPARATOR, "comment");
O.peepholeOptimiser(SEPARATOR, "comment");
O.peepholeOptimiser(RVALUE, "x");
O.peepholeOptimiser(POP, "");
O.peepholeOptimiser(PUSH, "17");
O.peepholeOptimiser(POP, "");
O.peepholeOptimiser(PUSH, "1");
O.peepholeOptimiser("-", "");
}
}
| UTF-8 | Java | 3,034 | java | Optimiser.java | Java | [] | null | [] | public class Optimiser implements Interface.EmitterIF
{
Emitter Emitter;
String savedOpcode = "",
savedValue = "";
boolean DEBUG;
public Optimiser(boolean debug) {DEBUG = debug;}
public Optimiser(Emitter E, boolean debug) {Emitter = E; DEBUG = debug;}
public void peepholeOptimiser(String opcode, String value)
{
if (DEBUG) {
output(" ; " + opcode, value);
}
if (opcode == SEPARATOR && savedOpcode == SEPARATOR) {
if (value.equals(savedValue) || value == ""){
/* discard repeated or new null separator */
} else if (savedValue == "") {
savedValue = value; // discard old null separator
} else {
flush();savedOpcode = opcode; savedValue = value;
}
} else if (opcode == SEPARATOR ||
opcode == GOTO || opcode == RVALUE || opcode == PUSH) {
flush();savedOpcode = opcode; savedValue = value;
} else if (savedOpcode == "") {
output(opcode, value);
} else if (opcode == LABEL && savedOpcode == GOTO &&
value.equals(savedValue)){
clear(); output(LABEL, value);
} else if (opcode == POP &&
(savedOpcode == RVALUE || savedOpcode == PUSH)) {
clear();
} else if (opcode.equals("+")&& savedOpcode == PUSH &&
savedValue.equals("1")) {
clear(); output(INC,"");
} else if (opcode.equals("-") && savedOpcode == PUSH &&
savedValue.equals("1")) {
clear(); output(DEC,"");
} else if (opcode.equals("*") && savedOpcode == PUSH &&
savedValue.equals("2")) {
clear(); output(COPY,""); output("+","");
} else {
flush(); output(opcode, value);
}
}
void output(String opcode, String value)
{
if (Emitter != null) Emitter.output(opcode, value);
else System.out.println(opcode + " " + value);
}
void flush()
{
if (savedOpcode != "") output(savedOpcode, savedValue);
clear();
}
void clear()
{
savedOpcode = ""; savedValue = "";
}
public static void main(String[] args)
{
Optimiser O = new Optimiser(true);
O.peepholeOptimiser(GOTO, "17");
O.peepholeOptimiser(LABEL, "17");
O.peepholeOptimiser(PUSH, "2");
O.peepholeOptimiser("*", "");
O.peepholeOptimiser(PUSH, "1");
O.peepholeOptimiser("+", "");
O.peepholeOptimiser(SEPARATOR, "comment");
O.peepholeOptimiser(SEPARATOR, "comment");
O.peepholeOptimiser(RVALUE, "x");
O.peepholeOptimiser(POP, "");
O.peepholeOptimiser(PUSH, "17");
O.peepholeOptimiser(POP, "");
O.peepholeOptimiser(PUSH, "1");
O.peepholeOptimiser("-", "");
}
}
| 3,034 | 0.496045 | 0.49209 | 83 | 34.554218 | 21.639017 | 76 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.048193 | false | false | 9 |
6562819ecb587d5aede76ced7a44725139b6a7b3 | 4,303,557,242,503 | f69ebb51c96950d2abca85a94ac745a47dac4e43 | /microservice-consumer-search/src/main/java/cn/guolei007/cloud/scheduled/KeywordRecordScheduled.java | dbd8a3819cb6250ea91b645f0c2f9d32d1ae9749 | [] | no_license | guolifen/spring-cloud-parent | https://github.com/guolifen/spring-cloud-parent | 1c47ea65410dbd5f0126638ca8aba3e6b59ce98e | f7da772f30814368b42e3aa9637b48dfc090de3b | refs/heads/master | 2018-09-28T15:50:29.541000 | 2018-09-26T02:37:35 | 2018-09-26T02:37:35 | 122,466,581 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package cn.guolei007.cloud.scheduled;
import cn.guolei007.cloud.core.service.KeywordRecordService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
/**
* 关键词持久化定时任务
* @Scheduled(fixedRate = 5000) :上一次开始执行时间点之后5秒再执行
* @Scheduled(fixedDelay = 5000) :上一次执行完毕时间点之后5秒再执行
* @Scheduled(initialDelay=1000, fixedRate=5000) :第一次延迟1秒后执行,之后按fixedRate的规则每5秒执行一次
* Created By 祭酒
* Date: 2018/8/21
* Time: 上午10:13
*/
@Component
public class KeywordRecordScheduled {
@Autowired
private KeywordRecordService keywordRecordService;
@Scheduled(fixedRate = 60000)
public void reportCurrentTime() {
// System.out.println("现在时间:" + DateUtils.getConvertDateString(new Date()));
}
@Scheduled(cron="0 0 1 1/5 * ?")
public void saveKeywordRecord() {
// System.out.println("现在时间:" + DateUtils.getConvertDateString(new Date()));
//插入热门电影列表
keywordRecordService.hotSearchKeywordListV2(0, 10);
}
}
| UTF-8 | Java | 1,250 | java | KeywordRecordScheduled.java | Java | [
{
"context": " :第一次延迟1秒后执行,之后按fixedRate的规则每5秒执行一次\n * Created By 祭酒\n * Date: 2018/8/21\n * Time: 上午10:13\n */\n\n@Compone",
"end": 494,
"score": 0.7116236090660095,
"start": 492,
"tag": "USERNAME",
"value": "祭酒"
}
] | null | [] | package cn.guolei007.cloud.scheduled;
import cn.guolei007.cloud.core.service.KeywordRecordService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
/**
* 关键词持久化定时任务
* @Scheduled(fixedRate = 5000) :上一次开始执行时间点之后5秒再执行
* @Scheduled(fixedDelay = 5000) :上一次执行完毕时间点之后5秒再执行
* @Scheduled(initialDelay=1000, fixedRate=5000) :第一次延迟1秒后执行,之后按fixedRate的规则每5秒执行一次
* Created By 祭酒
* Date: 2018/8/21
* Time: 上午10:13
*/
@Component
public class KeywordRecordScheduled {
@Autowired
private KeywordRecordService keywordRecordService;
@Scheduled(fixedRate = 60000)
public void reportCurrentTime() {
// System.out.println("现在时间:" + DateUtils.getConvertDateString(new Date()));
}
@Scheduled(cron="0 0 1 1/5 * ?")
public void saveKeywordRecord() {
// System.out.println("现在时间:" + DateUtils.getConvertDateString(new Date()));
//插入热门电影列表
keywordRecordService.hotSearchKeywordListV2(0, 10);
}
}
| 1,250 | 0.733645 | 0.685981 | 39 | 26.435898 | 26.647552 | 83 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.25641 | false | false | 9 |
595484fd82e45396d3c61cffcecd0947f3efbb0c | 6,184,752,919,029 | 8d9faa6b340b012a046883d5b9e62371e79f9264 | /ejms/src/nexti/ejms/inputing/action/InputingListAction.java | 33875ae629d0c8e7661a8d81ddc231335c5b8138 | [] | no_license | kimnamgu/GangNamGu | https://github.com/kimnamgu/GangNamGu | 8b5ff312b1b293e67b924af962e4a051d49f848c | 6bee17d600c09fb563dbb01990e6ec10a8ca79ae | refs/heads/master | 2023-01-09T16:19:32.626000 | 2020-11-11T07:36:32 | 2020-11-11T07:36:32 | 311,894,918 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | /**
* 작성일: 2009.09.09
* 작성자: 대리 서동찬
* 모듈명: 입력하기 목록 action
* 설명:
*/
package nexti.ejms.inputing.action;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import nexti.ejms.common.rootAction;
import nexti.ejms.inputing.form.InputingForm;
import nexti.ejms.inputing.model.InputingManager;
import nexti.ejms.util.Utils;
import nexti.ejms.util.commfunction;
public class InputingListAction extends rootAction {
public ActionForward doService(
ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response) throws Exception {
//세션정보 가져오기
HttpSession session = request.getSession();
String userid = "";
String deptcd = "";
userid = session.getAttribute("user_id").toString();
deptcd = session.getAttribute("dept_code").toString();
String isSysMgr = (String)session.getAttribute("isSysMgr");
//Form에서 넘어온 값 가져오기
InputingForm inputingForm = (InputingForm)form;
String initentry = inputingForm.getInitentry();
String sch_deptcd = inputingForm.getSch_old_deptcd();
String sch_userid = inputingForm.getSch_old_userid();
String sch_deptnm = inputingForm.getSch_deptnm();
String sch_usernm = inputingForm.getSch_usernm();
int gubun = inputingForm.getGubun();
//데이터 범위 결정
int pageSize = 10; //한번에 표시한 리스트의 갯수
int start = commfunction.startIndex(inputingForm.getPage(), pageSize);
int end = commfunction.endIndex(inputingForm.getPage(), pageSize);
//입력하기 목록 가져오기
InputingManager manager = InputingManager.instance();
String orgid = manager.getSearchInputing(gubun, sch_deptcd, sch_userid);
List inputList = manager.inputingList(userid, deptcd, gubun, initentry, isSysMgr, sch_deptcd, sch_deptnm, sch_userid, sch_usernm, start, end);
inputingForm.setInputList(inputList);
int totalCount = manager.inputingCnt(userid, deptcd, gubun, initentry, isSysMgr, sch_deptcd, sch_deptnm, sch_userid, sch_usernm);
int totalPage = (int)Math.ceil((double)totalCount/(double)pageSize);
request.setAttribute("totalPage", new Integer(totalPage));
request.setAttribute("totalCount", new Integer(totalCount));
request.setAttribute("currpage", new Integer(inputingForm.getPage()));
request.setAttribute("initentry", initentry);
request.setAttribute("orgid", Utils.nullToEmptyString(orgid));
session.removeAttribute("originuserid");
return mapping.findForward("list");
}
} | UHC | Java | 2,777 | java | InputingListAction.java | Java | [
{
"context": "/**\n * 작성일: 2009.09.09\n * 작성자: 대리 서동찬\n * 모듈명: 입력하기 목록 action\n * 설명:\n */\npackage nexti.e",
"end": 37,
"score": 0.9998843669891357,
"start": 31,
"tag": "NAME",
"value": "대리 서동찬"
}
] | null | [] | /**
* 작성일: 2009.09.09
* 작성자: <NAME>
* 모듈명: 입력하기 목록 action
* 설명:
*/
package nexti.ejms.inputing.action;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import nexti.ejms.common.rootAction;
import nexti.ejms.inputing.form.InputingForm;
import nexti.ejms.inputing.model.InputingManager;
import nexti.ejms.util.Utils;
import nexti.ejms.util.commfunction;
public class InputingListAction extends rootAction {
public ActionForward doService(
ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response) throws Exception {
//세션정보 가져오기
HttpSession session = request.getSession();
String userid = "";
String deptcd = "";
userid = session.getAttribute("user_id").toString();
deptcd = session.getAttribute("dept_code").toString();
String isSysMgr = (String)session.getAttribute("isSysMgr");
//Form에서 넘어온 값 가져오기
InputingForm inputingForm = (InputingForm)form;
String initentry = inputingForm.getInitentry();
String sch_deptcd = inputingForm.getSch_old_deptcd();
String sch_userid = inputingForm.getSch_old_userid();
String sch_deptnm = inputingForm.getSch_deptnm();
String sch_usernm = inputingForm.getSch_usernm();
int gubun = inputingForm.getGubun();
//데이터 범위 결정
int pageSize = 10; //한번에 표시한 리스트의 갯수
int start = commfunction.startIndex(inputingForm.getPage(), pageSize);
int end = commfunction.endIndex(inputingForm.getPage(), pageSize);
//입력하기 목록 가져오기
InputingManager manager = InputingManager.instance();
String orgid = manager.getSearchInputing(gubun, sch_deptcd, sch_userid);
List inputList = manager.inputingList(userid, deptcd, gubun, initentry, isSysMgr, sch_deptcd, sch_deptnm, sch_userid, sch_usernm, start, end);
inputingForm.setInputList(inputList);
int totalCount = manager.inputingCnt(userid, deptcd, gubun, initentry, isSysMgr, sch_deptcd, sch_deptnm, sch_userid, sch_usernm);
int totalPage = (int)Math.ceil((double)totalCount/(double)pageSize);
request.setAttribute("totalPage", new Integer(totalPage));
request.setAttribute("totalCount", new Integer(totalCount));
request.setAttribute("currpage", new Integer(inputingForm.getPage()));
request.setAttribute("initentry", initentry);
request.setAttribute("orgid", Utils.nullToEmptyString(orgid));
session.removeAttribute("originuserid");
return mapping.findForward("list");
}
} | 2,767 | 0.753695 | 0.749905 | 75 | 34.200001 | 28.592773 | 144 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 2.386667 | false | false | 9 |
55a3585a3f18d651ca82140d9bf9d6379057a2d1 | 34,686,155,926,706 | e39147a275d88dba1410b768932787cabca0dcdf | /myPro/WifiGuard/app/src/main/java/com/wifiguarder/wifi/ui/activity/WifiListActivity.java | bb03934c0ffdd26f37055ec75349c513d742d9f1 | [] | no_license | xuyongfine/.myrepository | https://github.com/xuyongfine/.myrepository | 84fcf67f1aa4a287a9a6d4b877a11fbec3d12395 | 86522de4e187f63b70e581ce0a5f263b3cd5565d | refs/heads/master | 2020-01-21T01:18:28.701000 | 2017-03-20T02:33:29 | 2017-03-20T02:33:29 | 54,005,760 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.wifiguarder.wifi.ui.activity;
import android.content.BroadcastReceiver;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.res.Configuration;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.net.wifi.WifiInfo;
import android.net.wifi.WifiManager;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.os.Parcelable;
import android.support.v4.app.FragmentTransaction;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.View;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;
import com.wifiguarder.wifi.R;
import com.wifiguarder.wifi.data.WifiGuardScanResult;
import com.wifiguarder.wifi.data.download.DownloadManager;
import com.wifiguarder.wifi.data.googleanalytic.AnalyticsConstants;
import com.wifiguarder.wifi.data.googleanalytic.AnalyticsCreator;
import com.wifiguarder.wifi.ui.fragment.WifiClosedFragment;
import com.wifiguarder.wifi.ui.fragment.WifiOpenedFragment;
import com.wifiguarder.wifi.ui.view.onetouch.OneTouchDialog;
import com.wifiguarder.wifi.ui.view.onetouch.OneTouchDialogCreator;
import com.wifiguarder.wifi.ui.view.shared.SharedDialog;
import com.wifiguarder.wifi.ui.view.shared.SharedHostspotDialog;
import com.wifiguarder.wifi.util.LogUtil;
import com.wifiguarder.wifi.util.WifiUtil;
import java.lang.reflect.Method;
import java.util.List;
/**
* Created by zhengzujia on 16-7-19:38
* Merged by xuyong
* mail: zhengzujia@kaka888.com
* version 1.0
*/
public class WifiListActivity extends AppCompatActivity {
public static final String TAG = "WifiListActivity";
private ImageButton mWifiSettingBt;
private CheckBox mWifiStatusCb;
private Toolbar mToolbar;
private WifiManager mWifiManager;
private WifiClosedFragment mWifiClosedFragment;
private WifiOpenedFragment mWifiOpenedFragment;
private WifiReferenceNetworkChangedReceiver mWifiReferenceNetworkChangedReceiver;
private OneTouchDialogCreator mOneTouchDialogCreator;
public final static int UPDATE_CONNECTED_UI = 0x1;
// WifiGuarder xuyong 2016-09-08 deleted for new feature start
// public final static int UPDATE_CONNECTED_SSID = 0x2;
// WifiGuarder xuyong 2016-09-08 deleted for new feature end
public final static int UPDATE_CONNECTED_DISBALING_UI = 0x3;
public final static int UPDATE_CONNECTING_UI = 0x4;
public final static int SHOW_WIFI_CONNECT_ERROR = 0x5;
public final static int DELAY_UPDATE_CONNECTED_UI = 0x6;
public final static int UPDATE_CONNECTED_UI_IN_SCHEDULE = 0x7;
public final static int UPDATE_CONNECTED_UI_REMOVE = 0x8;
//WifiGuarder zhengzujia 2016-09-19 Added for new security request start
public final static int START_SECURITY = 0x9;
//WifiGuarder zhengzujia 2016-10-08 added for shared hostspot start
public final static int OPEN_SHARED_HOSTSPOT = 0x10;
public final static int UPDATE_SHARED_LIST = 0x11;
public final static int CLOSE_SHARED_HOSTSPOT = 0x12;
//WifiGuarder zhengzujia 2016-10-08 added for shared hostspot end
public boolean START_SECURITY_FLAG = true;
public final static int AUTO_START_SECURITY = 1;
//WifiGuarder zhengzujia 2016-09-19 Added for new security request end
private final static int DELAY_DURATION = 3000;
private final static int DISABLE_BTN = 0x1;
private final static int ENABLE_BTN = 0x2;
private boolean mInit = false;
private boolean mAfterClostBroadcast = false;
//WifiGuarder zhengzujia 2016-10-08 added for shared hostspot start
public static boolean isOpenHostspot;
//WifiGuarder zhengzujia 2016-08-10 added for shared hostspot end
//WifiGuarder zhengzujia 2016-09-29 added for shared hotspot start
private RelativeLayout mSharedLayout;
private ImageView sharedLayoutSmallLeftIV;
private TextView sharedLayoutTip1;
private TextView sharedLayoutTip2;
private ImageView sharedLayoutSmallRightIV;
//WifiGuarder zhengzujia 2016-09-29 added for shared hotspot end
private Handler mHandler = new Handler() {
@Override
public void handleMessage(Message msg) {
FragmentTransaction transaction = WifiListActivity.this.getFragmentTransaction();
switch(msg.what) {
case UPDATE_CONNECTED_UI_REMOVE:
case UPDATE_CONNECTED_UI_IN_SCHEDULE:
if (mWifiOpenedFragment != null && mWifiOpenedFragment.isAdded()) {
mWifiOpenedFragment.scanWiFi();
}
break;
case DELAY_UPDATE_CONNECTED_UI:
case UPDATE_CONNECTED_UI:
if (mWifiStatusCb != null) {
if (!mWifiStatusCb.isChecked()) {
mWifiStatusCb.setChecked(true);
}
AnalyticsCreator.handleScreenHit(AnalyticsConstants.Fragment.WIFI_OPENED_FRAGMENT);
transaction.show(mWifiOpenedFragment);
transaction.hide(mWifiClosedFragment);
//WifiGuarder zhengzujia 2016-09-18 Added for bug #40 start
if (mWifiOpenedFragment != null && mWifiOpenedFragment.mTimer == null) {
//WifiGuarder zhengzujia 2016-09-18 Added for bug #40 end
mWifiOpenedFragment.initTask();
}
transaction.commitAllowingStateLoss();
//WifiGuarder zhengzujia 2016-09-19 Added for new security request start
// WiFiGuarder xuyong 2016-11-14 modified for bug #64 start
/*WifiInfo wifiInfo = WifiUtil.getInstance(getApplicationContext()).getConnectedWifiInfo();
if(wifiInfo != null && wifiInfo.getNetworkId() != -1){
int isCheck = WifiUtil.getInstance(getApplicationContext()).getIsCheckSecurityFromDbCache();
if (isCheck != 1 && START_SECURITY_FLAG == true){
START_SECURITY_FLAG = false;
msg = new Message();
msg.what = WifiListActivity.START_SECURITY;
mHandler.sendMessage(msg);
}
}*/
// WiFiGuarder xuyong 2016-11-14 modified for bug #64 end
//WifiGuarder zhengzujia 2016-09-19 Added for new security request end
}
if (mWifiOpenedFragment != null && mWifiOpenedFragment.isAdded()) {
// WifiGuarder xuyong 2016-09-08 added for new feature start
mWifiOpenedFragment.changeUi(true);
// WifiGuarder xuyong 2016-09-08 added for new feature end
mWifiOpenedFragment.scanWiFi();
}
changeNotification();
break;
// WifiGuarder xuyong 2016-09-08 deleted for new feature start
/*case UPDATE_CONNECTED_SSID:
if (mWifiOpenedFragment != null) {
mWifiOpenedFragment.changeConnectedWifiSSID((WifiGuardScanResult)msg.obj);
}
break;*/
// WifiGuarder xuyong 2016-09-08 deleted for new feature end
case UPDATE_CONNECTED_DISBALING_UI:
if (mWifiClosedFragment != null) {
AnalyticsCreator.handleScreenHit(AnalyticsConstants.Fragment.WIFI_CLOSED_FRAGMENT);
transaction.show(mWifiClosedFragment);
transaction.hide(mWifiOpenedFragment);
if (mWifiOpenedFragment != null) {
mWifiOpenedFragment.cancelTask();
}
transaction.commitAllowingStateLoss();
}
if (mWifiClosedFragment != null && mWifiClosedFragment.isAdded()) {
mWifiClosedFragment.stopWifiAnimation();
if (msg.arg1 == ENABLE_BTN || !mInit) {
mWifiClosedFragment.setBtnEnabled(true);
} else if (msg.arg1 == DISABLE_BTN && !mAfterClostBroadcast) {
mWifiClosedFragment.setBtnEnabled(false);
mAfterClostBroadcast = false;
}
mInit = true;
}
if (mWifiStatusCb != null) {
if (mWifiStatusCb.isChecked()) {
mWifiStatusCb.setChecked(false);
}
}
changeNotification();
break;
case UPDATE_CONNECTING_UI:
if (mWifiOpenedFragment != null) {
// WifiGuarder xuyong 2016-09-08 added for new feature start
mWifiOpenedFragment.changeUi(false);
// WifiGuarder xuyong 2016-09-08 added for new feature end
mWifiOpenedFragment.changeToConnectingView((WifiGuardScanResult)msg.obj);
}
break;
case SHOW_WIFI_CONNECT_ERROR:
// WifiGuarder xuyong 2016-09-08 added for new feature start
if (mWifiOpenedFragment != null) {
mWifiOpenedFragment.changeUi(true);
}
// WifiGuarder xuyong 2016-09-08 added for new feature end
if (msg.obj != null) {
WifiGuardScanResult result = (WifiGuardScanResult) msg.obj;
final OneTouchDialog otdlg = mOneTouchDialogCreator.getDialog(result);
if (otdlg != null) {
otdlg.setFragment(mWifiOpenedFragment);
otdlg.setHandler(mHandler);
otdlg.setContext(WifiListActivity.this);
otdlg.setShowErrorTip(true);
otdlg.show(mWifiOpenedFragment.getFragmentManager(), "One Touch");
}
removeScanResult(result);
} else {
Toast.makeText(WifiListActivity.this, R.string.wifi_connect_failed, Toast.LENGTH_LONG).show();
}
break;
//WifiGuarder zhengzujia 2016-09-19 Added for new security request start
case START_SECURITY:
WifiInfo wifiInfo = WifiUtil.getInstance(getApplicationContext()).getConnectedWifiInfo();
Intent intent = new Intent(WifiSecurityActivity.INTENT_ACTION);
intent.putExtra("index", AUTO_START_SECURITY);
intent.putExtra("ssidName", wifiInfo.getSSID().substring(1, wifiInfo.getSSID().length() - 1));
startActivity(intent);
START_SECURITY_FLAG = true;
break;
//WifiGuarder zhengzujia 2016-09-19 Added for new security request end
//WifiGuarder zhengzujia 2016-10-08 added for shared hostspot start
case OPEN_SHARED_HOSTSPOT:
//WifiGuarder zhengzujia 2016-10-12 added for shared hotspot start
AnalyticsCreator.handleEvent(AnalyticsConstants.ActionKeys.CLICK, AnalyticsConstants.ActionView.HOSTSPOT_OPENED);
//WifiGuarder zhengzujia 2016-10-12 added for shared hotspot end
mWifiOpenedFragment.cancelTask();
if (mWifiStatusCb != null) {
mWifiStatusCb.setVisibility(View.INVISIBLE);
}
if (mWifiSettingBt != null){
mWifiSettingBt.setVisibility(View.INVISIBLE);
}
transaction.show(mWifiOpenedFragment);
transaction.hide(mWifiClosedFragment);
mWifiOpenedFragment.showSharedHostspotUI();
transaction.commitAllowingStateLoss();
mWifiOpenedFragment.scanSharedConnectedDivice();
mWifiOpenedFragment.initTaskRefreshShared();
sharedLayoutSmallLeftIV.setImageResource(R.drawable.wifi_strength_lv4);
sharedLayoutTip1.setText(R.string.title1_open_hostspot);
sharedLayoutTip2.setText(R.string.title2_open_hostspot);
sharedLayoutSmallRightIV.setVisibility(View.INVISIBLE);
break;
case CLOSE_SHARED_HOSTSPOT:
//WifiGuarder zhengzujia 2016-10-12 added for shared hotspot start
AnalyticsCreator.handleEvent(AnalyticsConstants.ActionKeys.CLICK, AnalyticsConstants.ActionView.HOSTSPOT_CLOSED);
//WifiGuarder zhengzujia 2016-10-12 added for shared hotspot end
if (mWifiStatusCb != null) {
//WifiGuarder zhengzujia 2016-10-12 deleted for shared hotspot start
//mWifiStatusCb.setChecked(true);
//WifiGuarder zhengzujia 2016-10-12 deleted for shared hotspot start
mWifiStatusCb.setVisibility(View.VISIBLE);
}
mWifiOpenedFragment.reSetWifiOpenAdapter();
mWifiOpenedFragment.canceSharedTask();
sharedLayoutSmallLeftIV.setImageResource(R.drawable.shared_hotspot_left);
sharedLayoutTip1.setText(R.string.title1);
sharedLayoutTip2.setText(R.string.title2);
sharedLayoutSmallRightIV.setVisibility(View.INVISIBLE);
break;
case UPDATE_SHARED_LIST:
if (mWifiOpenedFragment != null && mWifiOpenedFragment.isAdded()) {
mWifiOpenedFragment.scanSharedConnectedDivice();
}
break;
//WifiGuarder zhengzujia 2016-10-08 added for shared hostspot end
default:
break;
}
}
};
private void changeNotification() {
Intent intent = new Intent(WifiStatusChangeReceiver.NOTIFICATION_SHOW_ACTION);
sendBroadcast(intent);
}
private void removeScanResult(WifiGuardScanResult result) {
WifiUtil.getInstance(this).removeNetwork(result);
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.wifi_list_layout);
//WifiGuarder zhengzujia 2016-10-08 added for shared hostspot start
checkIsOpenHostspot();
//WifiGuarder zhengzujia 2016-10-08 added for shared hostspot end
initFragmentRelated();
initWifiManager();
initImitateActionBar();
//WifiGuarder zhengzujia 2016-10-11 added for shared hotspot start
initializedSharedLayout();
//WifiGuarder zhengzujia 2016-10-11 added for shared hotspot end
registerWifiBroadcastReceiver();
mOneTouchDialogCreator = new OneTouchDialogCreator();
//WifiGuarder zhengzujia add for OtherApp Start by Interface start
Intent intent = getIntent();
int index = intent.getIntExtra("StartSpeedActivity", 0);
if (index == 1){
Intent intentSpeed = new Intent("com.wifiguarder.wifi.android.intent.WifiSpeedActivity");
intentSpeed.putExtra("index", 1);
startActivity(intentSpeed);
}
//WifiGuarder zhengzujia add for OtherApp Start by Interface end
}
//WifiGuarder zhengzujia 2016-10-11 added for shared hotspot start
private void initializedSharedLayout(){
mSharedLayout = (RelativeLayout)findViewById(R.id.shared_hotspot_layout);
mSharedLayout.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (isOpenHostspot == true){
SharedHostspotDialog dialog = new SharedHostspotDialog();
dialog.show(getFragmentManager(), "SharedHostspotDialog");
}else {
try {
Intent mIntent = new Intent("/");
ComponentName comp = new ComponentName("com.android.settings", "com.android.settings.TetherSettings");
mIntent.setComponent(comp);
startActivityForResult(mIntent, 0);
} catch (Exception e) {
}
}
}
});
sharedLayoutSmallLeftIV = (ImageView)findViewById(R.id.shared_left_iv);
sharedLayoutTip1 = (TextView)findViewById(R.id.text1);
sharedLayoutTip2 = (TextView)findViewById(R.id.text2);
sharedLayoutSmallRightIV = (ImageView)findViewById(R.id.shared_right_iv);
}
//WifiGuarder zhengzujia 2016-10-11 added for shared hotspot end
//WifiGuarder zhengzujia 2016-10-08 added shared hostspot start
private void checkIsOpenHostspot() {
if (getWifiApState() == WIFI_AP_STATE.WIFI_AP_STATE_ENABLED || getWifiApState() == WIFI_AP_STATE.WIFI_AP_STATE_ENABLING){
isOpenHostspot = true;
}else {
isOpenHostspot = false;
}
}
//WifiGuarder zhengzujia 2016-10-08 added shared hostspot end
@Override
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
}
private void registerWifiBroadcastReceiver() {
IntentFilter filter = new IntentFilter();
filter.addAction(WifiManager.NETWORK_STATE_CHANGED_ACTION);
filter.addAction(WifiManager.WIFI_STATE_CHANGED_ACTION);
filter.addAction(ConnectivityManager.CONNECTIVITY_ACTION);
//WifiGuarder zhengzujia 2016-10-08 add for shared hostspot start
filter.addAction("android.net.conn.TETHER_STATE_CHANGED");
//WifiGuarder zhengzujia 2016-10-08 add for shared hostsopt end
mWifiReferenceNetworkChangedReceiver = new WifiReferenceNetworkChangedReceiver();
registerReceiver(mWifiReferenceNetworkChangedReceiver, filter);
}
private void initFragmentRelated() {
mWifiClosedFragment = new WifiClosedFragment();
mWifiOpenedFragment = new WifiOpenedFragment();
mWifiOpenedFragment.setHandler(mHandler);
}
private FragmentTransaction getFragmentTransaction() {
return getSupportFragmentManager().beginTransaction();
}
private void initWifiManager() {
mWifiManager = (WifiManager)this.getSystemService(WIFI_SERVICE);
}
private void initImitateActionBar() {
mToolbar = (Toolbar) findViewById(R.id.wifi_list_toolbar);
setSupportActionBar(mToolbar);
mWifiSettingBt = (ImageButton) findViewById(R.id.wifi_setting_btn);
mWifiSettingBt.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
AnalyticsCreator.handleEvent(AnalyticsConstants.ActionKeys.CLICK, AnalyticsConstants.ActionView.ENTER_SETTING_BTN, "enter");
Intent intent = new Intent(WifiListActivity.this, WifiSettingActivity.class);
startActivity(intent);
}
});
mWifiStatusCb = (CheckBox) findViewById(R.id.wifi_status_cb);
mWifiStatusCb.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
if (checked) {
if (mWifiSettingBt != null) {
mWifiSettingBt.setVisibility(View.VISIBLE);
}
if (mWifiClosedFragment != null) {
mWifiClosedFragment.openWifiAnimation();
}
WifiUtil.getInstance(WifiListActivity.this).openWifi();
AnalyticsCreator.handleEvent(AnalyticsConstants.ActionKeys.CLICK, AnalyticsConstants.ActionView.OPEN_CLOSE_CB, "open");
} else {
if (mWifiSettingBt != null) {
mWifiSettingBt.setVisibility(View.GONE);
}
WifiUtil.getInstance(WifiListActivity.this).closeWifi();
Message msg = mHandler.obtainMessage(UPDATE_CONNECTED_DISBALING_UI);
msg.arg1 = DISABLE_BTN;
msg.sendToTarget();
AnalyticsCreator.handleEvent(AnalyticsConstants.ActionKeys.CLICK, AnalyticsConstants.ActionView.OPEN_CLOSE_CB, "close");
}
}
});
}
public void changedWiFiStatusCbChecked() {
if (mWifiStatusCb != null) {
if (mWifiStatusCb.isChecked()) {
AnalyticsCreator.handleEvent(AnalyticsConstants.ActionKeys.CLICK, AnalyticsConstants.ActionView.OPEN_CLOSE_BTN, "close");
} else {
AnalyticsCreator.handleEvent(AnalyticsConstants.ActionKeys.CLICK, AnalyticsConstants.ActionView.OPEN_CLOSE_BTN, "open");
}
mWifiStatusCb.setChecked(!mWifiStatusCb.isChecked());
mWifiStatusCb.setClickable(false);
}
}
public boolean isWiFiStatusCbClickable() {
if (mWifiStatusCb != null) {
return mWifiStatusCb.isClickable();
}
return true;
}
private void handleWifiOpened() {
if (mWifiOpenedFragment != null && !mWifiOpenedFragment.isAdded()) {
FragmentTransaction transaction = getFragmentTransaction();
mWifiOpenedFragment.setHandler(mHandler);
transaction.add(R.id.wifi_list_content, mWifiOpenedFragment);
transaction.commitAllowingStateLoss();
}
}
private void handleWifiClosed() {
if (mWifiClosedFragment != null && !mWifiClosedFragment.isAdded()) {
FragmentTransaction transaction = getFragmentTransaction();
mWifiClosedFragment = new WifiClosedFragment();
transaction.add(R.id.wifi_list_content, mWifiClosedFragment);
transaction.commitAllowingStateLoss();
}
}
@Override
protected void onRestart() {
super.onRestart();
}
@Override
protected void onStart() {
super.onStart();
handleWifiOpened();
handleWifiClosed();
//WifiGuarder zhengzujia 2016-10-08 added for shared hostspot start
if (isOpenHostspot == false){
FragmentTransaction transaction = WifiListActivity.this.getFragmentTransaction();
if (mWifiManager.isWifiEnabled()) {
mWifiStatusCb.setChecked(true);
if (mWifiClosedFragment != null) {
transaction.show(mWifiOpenedFragment);
transaction.hide(mWifiClosedFragment);
transaction.commitAllowingStateLoss();
}
} else {
mWifiStatusCb.setChecked(false);
if (mWifiClosedFragment != null) {
transaction.show(mWifiClosedFragment);
transaction.hide(mWifiOpenedFragment);
transaction.commitAllowingStateLoss();
}
}
if (mWifiOpenedFragment != null && mWifiOpenedFragment.isAdded()) {
mWifiOpenedFragment.initTask();
}
}
//WifiGuarder zhengzujia 2016-10-08 added for shared hostspot end
//WifiGuarder zhengzujia 2016-10-08 deleted for shared hostspot start
// FragmentTransaction transaction = WifiListActivity.this.getFragmentTransaction();
// if (mWifiManager.isWifiEnabled()) {
// mWifiStatusCb.setChecked(true);
// if (mWifiClosedFragment != null) {
// transaction.show(mWifiOpenedFragment);
// transaction.hide(mWifiClosedFragment);
// transaction.commitAllowingStateLoss();
// }
// } else {
// mWifiStatusCb.setChecked(false);
// if (mWifiClosedFragment != null) {
// transaction.show(mWifiClosedFragment);
// transaction.hide(mWifiOpenedFragment);
// transaction.commitAllowingStateLoss();
// }
// }
// if (mWifiOpenedFragment != null && mWifiOpenedFragment.isAdded()) {
// mWifiOpenedFragment.initTask();
// }
//WifiGuarder zhengzujia 2016-10-08 deleted for shared hostspot end
}
@Override
protected void onResume() {
super.onResume();
AnalyticsCreator.handleScreenHit(AnalyticsConstants.Activity.WIFI_LIST_ACTIVITY);
}
@Override
protected void onPause() {
super.onPause();
}
@Override
protected void onStop() {
super.onStop();
if (mWifiOpenedFragment != null && mWifiOpenedFragment.isAdded()) {
mWifiOpenedFragment.cancelTask();
}
}
private void removeFragments() {
FragmentTransaction transaction = WifiListActivity.this.getFragmentTransaction();
transaction.remove(mWifiOpenedFragment);
transaction.remove(mWifiClosedFragment);
}
@Override
protected void onDestroy() {
unregisterReceiver(mWifiReferenceNetworkChangedReceiver);
//DownloadManager.getInstance(this).deleteURLConfigurationCache();
removeFragments();
// WiFiGuarder xuyong 2016-11-14 added for bug #64 start
mHandler = null;
// WiFiGuarder xuyong 2016-11-14 added for bug #64 end
super.onDestroy();
}
public class WifiReferenceNetworkChangedReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
if (WifiManager.WIFI_STATE_CHANGED_ACTION.equals(intent.getAction())) {
int wifiState = intent.getIntExtra(WifiManager.EXTRA_WIFI_STATE, WifiManager.WIFI_STATE_DISABLED);
Message msg = null;
switch (wifiState) {
case WifiManager.WIFI_STATE_DISABLING:
if (mWifiStatusCb != null) {
mWifiStatusCb.setClickable(false);
}
break;
case WifiManager.WIFI_STATE_DISABLED:
mAfterClostBroadcast = true;
if (mWifiStatusCb != null) {
mWifiStatusCb.setClickable(true);
}
msg = mHandler.obtainMessage(UPDATE_CONNECTED_DISBALING_UI);
msg.arg1 = ENABLE_BTN;
msg.sendToTarget();
break;
case WifiManager.WIFI_STATE_ENABLING:
if (mWifiStatusCb != null) {
mWifiStatusCb.setClickable(false);
}
if (mWifiClosedFragment != null && mWifiClosedFragment.isAdded()) {
mWifiClosedFragment.startWifiAnimation();
}
break;
case WifiManager.WIFI_STATE_ENABLED:
List<WifiGuardScanResult> list = WifiUtil.getInstance(WifiListActivity.this).getWifiGuardScanResult();
if (list == null || list.size() <= 0) {
new Thread(new Runnable() {
@Override
public void run() {
try {
Thread.currentThread().sleep(DELAY_DURATION);
} catch (InterruptedException e) {
e.printStackTrace();
}
if (mWifiStatusCb != null) {
mWifiStatusCb.setClickable(true);
}
Message delaymsg = mHandler.obtainMessage(DELAY_UPDATE_CONNECTED_UI);
delaymsg.sendToTarget();
}
}).start();
} else {
if (mWifiStatusCb != null) {
mWifiStatusCb.setClickable(true);
}
// WiFiGuarder xuyong 2016-11-14 modified for bug #64 start
if (mHandler != null) {
msg = mHandler.obtainMessage(UPDATE_CONNECTED_UI);
msg.sendToTarget();
}
// WiFiGuarder xuyong 2016-11-14 modified for bug #64 end
}
break;
}
}
if (ConnectivityManager.CONNECTIVITY_ACTION.equals(intent.getAction())) {
Parcelable parcelableExtra = intent.getParcelableExtra(WifiManager.EXTRA_NETWORK_INFO);
NetworkInfo.State wifiState = null;
if (null != parcelableExtra) {
ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
wifiState = cm.getNetworkInfo(ConnectivityManager.TYPE_WIFI).getState();
if (wifiState == NetworkInfo.State.CONNECTED) {
Message msg = mHandler.obtainMessage(UPDATE_CONNECTED_UI);
msg.sendToTarget();
} else {
// do nothing
}
}
}
//WifiGuarder zhengzujia 2016-10-08 added for shared hostspot start
if (intent.getAction().equals("android.net.conn.TETHER_STATE_CHANGED")) {
ConnectivityManager connMgr = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
Message msg = null;
switch (getWifiApState()){
case WIFI_AP_STATE_DISABLING:
isOpenHostspot = false;
msg = mHandler.obtainMessage(CLOSE_SHARED_HOSTSPOT);
msg.sendToTarget();
break;
case WIFI_AP_STATE_DISABLED:
isOpenHostspot = false;
msg = mHandler.obtainMessage(CLOSE_SHARED_HOSTSPOT);
msg.sendToTarget();
break;
case WIFI_AP_STATE_ENABLING:
isOpenHostspot = true;
mAfterClostBroadcast = true;
if (mWifiStatusCb != null) {
mWifiStatusCb.setClickable(true);
}
break;
case WIFI_AP_STATE_ENABLED:
isOpenHostspot = true;
mAfterClostBroadcast = true;
if (mWifiStatusCb != null) {
mWifiStatusCb.setClickable(true);
}
msg = mHandler.obtainMessage(OPEN_SHARED_HOSTSPOT);
msg.sendToTarget();
break;
}
}
//WifiGuarder zhengzujia 2016-10-08 added for shared hostspot end
}
}
//WifiGuarder zhengzujia 2016-10-08 added for shared hostspot start
private WIFI_AP_STATE getWifiApState() {
int tmp;
try {
Method method = mWifiManager.getClass().getMethod("getWifiApState");
tmp = ((Integer) method.invoke(mWifiManager));
// Fix for Android 4
if (tmp > 9) {
tmp = tmp - 10;
}
return WIFI_AP_STATE.class.getEnumConstants()[tmp];
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return WIFI_AP_STATE.WIFI_AP_STATE_FAILED;
}
public enum WIFI_AP_STATE {
WIFI_AP_STATE_DISABLING, WIFI_AP_STATE_DISABLED, WIFI_AP_STATE_ENABLING, WIFI_AP_STATE_ENABLED, WIFI_AP_STATE_FAILED
}
//WifiGuarder zhengzujia 2016-10-08 added for shared hostspot end
}
| UTF-8 | Java | 33,048 | java | WifiListActivity.java | Java | [
{
"context": ".Method;\nimport java.util.List;\n\n/**\n * Created by zhengzujia on 16-7-19:38\n * Merged by xuyong\n * mail: zhengz",
"end": 1744,
"score": 0.9991756677627563,
"start": 1734,
"tag": "USERNAME",
"value": "zhengzujia"
},
{
"context": "* Created by zhengzujia on 16-7-19:... | null | [] | package com.wifiguarder.wifi.ui.activity;
import android.content.BroadcastReceiver;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.res.Configuration;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.net.wifi.WifiInfo;
import android.net.wifi.WifiManager;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.os.Parcelable;
import android.support.v4.app.FragmentTransaction;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.View;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;
import com.wifiguarder.wifi.R;
import com.wifiguarder.wifi.data.WifiGuardScanResult;
import com.wifiguarder.wifi.data.download.DownloadManager;
import com.wifiguarder.wifi.data.googleanalytic.AnalyticsConstants;
import com.wifiguarder.wifi.data.googleanalytic.AnalyticsCreator;
import com.wifiguarder.wifi.ui.fragment.WifiClosedFragment;
import com.wifiguarder.wifi.ui.fragment.WifiOpenedFragment;
import com.wifiguarder.wifi.ui.view.onetouch.OneTouchDialog;
import com.wifiguarder.wifi.ui.view.onetouch.OneTouchDialogCreator;
import com.wifiguarder.wifi.ui.view.shared.SharedDialog;
import com.wifiguarder.wifi.ui.view.shared.SharedHostspotDialog;
import com.wifiguarder.wifi.util.LogUtil;
import com.wifiguarder.wifi.util.WifiUtil;
import java.lang.reflect.Method;
import java.util.List;
/**
* Created by zhengzujia on 16-7-19:38
* Merged by xuyong
* mail: <EMAIL>
* version 1.0
*/
public class WifiListActivity extends AppCompatActivity {
public static final String TAG = "WifiListActivity";
private ImageButton mWifiSettingBt;
private CheckBox mWifiStatusCb;
private Toolbar mToolbar;
private WifiManager mWifiManager;
private WifiClosedFragment mWifiClosedFragment;
private WifiOpenedFragment mWifiOpenedFragment;
private WifiReferenceNetworkChangedReceiver mWifiReferenceNetworkChangedReceiver;
private OneTouchDialogCreator mOneTouchDialogCreator;
public final static int UPDATE_CONNECTED_UI = 0x1;
// WifiGuarder xuyong 2016-09-08 deleted for new feature start
// public final static int UPDATE_CONNECTED_SSID = 0x2;
// WifiGuarder xuyong 2016-09-08 deleted for new feature end
public final static int UPDATE_CONNECTED_DISBALING_UI = 0x3;
public final static int UPDATE_CONNECTING_UI = 0x4;
public final static int SHOW_WIFI_CONNECT_ERROR = 0x5;
public final static int DELAY_UPDATE_CONNECTED_UI = 0x6;
public final static int UPDATE_CONNECTED_UI_IN_SCHEDULE = 0x7;
public final static int UPDATE_CONNECTED_UI_REMOVE = 0x8;
//WifiGuarder zhengzujia 2016-09-19 Added for new security request start
public final static int START_SECURITY = 0x9;
//WifiGuarder zhengzujia 2016-10-08 added for shared hostspot start
public final static int OPEN_SHARED_HOSTSPOT = 0x10;
public final static int UPDATE_SHARED_LIST = 0x11;
public final static int CLOSE_SHARED_HOSTSPOT = 0x12;
//WifiGuarder zhengzujia 2016-10-08 added for shared hostspot end
public boolean START_SECURITY_FLAG = true;
public final static int AUTO_START_SECURITY = 1;
//WifiGuarder zhengzujia 2016-09-19 Added for new security request end
private final static int DELAY_DURATION = 3000;
private final static int DISABLE_BTN = 0x1;
private final static int ENABLE_BTN = 0x2;
private boolean mInit = false;
private boolean mAfterClostBroadcast = false;
//WifiGuarder zhengzujia 2016-10-08 added for shared hostspot start
public static boolean isOpenHostspot;
//WifiGuarder zhengzujia 2016-08-10 added for shared hostspot end
//WifiGuarder zhengzujia 2016-09-29 added for shared hotspot start
private RelativeLayout mSharedLayout;
private ImageView sharedLayoutSmallLeftIV;
private TextView sharedLayoutTip1;
private TextView sharedLayoutTip2;
private ImageView sharedLayoutSmallRightIV;
//WifiGuarder zhengzujia 2016-09-29 added for shared hotspot end
private Handler mHandler = new Handler() {
@Override
public void handleMessage(Message msg) {
FragmentTransaction transaction = WifiListActivity.this.getFragmentTransaction();
switch(msg.what) {
case UPDATE_CONNECTED_UI_REMOVE:
case UPDATE_CONNECTED_UI_IN_SCHEDULE:
if (mWifiOpenedFragment != null && mWifiOpenedFragment.isAdded()) {
mWifiOpenedFragment.scanWiFi();
}
break;
case DELAY_UPDATE_CONNECTED_UI:
case UPDATE_CONNECTED_UI:
if (mWifiStatusCb != null) {
if (!mWifiStatusCb.isChecked()) {
mWifiStatusCb.setChecked(true);
}
AnalyticsCreator.handleScreenHit(AnalyticsConstants.Fragment.WIFI_OPENED_FRAGMENT);
transaction.show(mWifiOpenedFragment);
transaction.hide(mWifiClosedFragment);
//WifiGuarder zhengzujia 2016-09-18 Added for bug #40 start
if (mWifiOpenedFragment != null && mWifiOpenedFragment.mTimer == null) {
//WifiGuarder zhengzujia 2016-09-18 Added for bug #40 end
mWifiOpenedFragment.initTask();
}
transaction.commitAllowingStateLoss();
//WifiGuarder zhengzujia 2016-09-19 Added for new security request start
// WiFiGuarder xuyong 2016-11-14 modified for bug #64 start
/*WifiInfo wifiInfo = WifiUtil.getInstance(getApplicationContext()).getConnectedWifiInfo();
if(wifiInfo != null && wifiInfo.getNetworkId() != -1){
int isCheck = WifiUtil.getInstance(getApplicationContext()).getIsCheckSecurityFromDbCache();
if (isCheck != 1 && START_SECURITY_FLAG == true){
START_SECURITY_FLAG = false;
msg = new Message();
msg.what = WifiListActivity.START_SECURITY;
mHandler.sendMessage(msg);
}
}*/
// WiFiGuarder xuyong 2016-11-14 modified for bug #64 end
//WifiGuarder zhengzujia 2016-09-19 Added for new security request end
}
if (mWifiOpenedFragment != null && mWifiOpenedFragment.isAdded()) {
// WifiGuarder xuyong 2016-09-08 added for new feature start
mWifiOpenedFragment.changeUi(true);
// WifiGuarder xuyong 2016-09-08 added for new feature end
mWifiOpenedFragment.scanWiFi();
}
changeNotification();
break;
// WifiGuarder xuyong 2016-09-08 deleted for new feature start
/*case UPDATE_CONNECTED_SSID:
if (mWifiOpenedFragment != null) {
mWifiOpenedFragment.changeConnectedWifiSSID((WifiGuardScanResult)msg.obj);
}
break;*/
// WifiGuarder xuyong 2016-09-08 deleted for new feature end
case UPDATE_CONNECTED_DISBALING_UI:
if (mWifiClosedFragment != null) {
AnalyticsCreator.handleScreenHit(AnalyticsConstants.Fragment.WIFI_CLOSED_FRAGMENT);
transaction.show(mWifiClosedFragment);
transaction.hide(mWifiOpenedFragment);
if (mWifiOpenedFragment != null) {
mWifiOpenedFragment.cancelTask();
}
transaction.commitAllowingStateLoss();
}
if (mWifiClosedFragment != null && mWifiClosedFragment.isAdded()) {
mWifiClosedFragment.stopWifiAnimation();
if (msg.arg1 == ENABLE_BTN || !mInit) {
mWifiClosedFragment.setBtnEnabled(true);
} else if (msg.arg1 == DISABLE_BTN && !mAfterClostBroadcast) {
mWifiClosedFragment.setBtnEnabled(false);
mAfterClostBroadcast = false;
}
mInit = true;
}
if (mWifiStatusCb != null) {
if (mWifiStatusCb.isChecked()) {
mWifiStatusCb.setChecked(false);
}
}
changeNotification();
break;
case UPDATE_CONNECTING_UI:
if (mWifiOpenedFragment != null) {
// WifiGuarder xuyong 2016-09-08 added for new feature start
mWifiOpenedFragment.changeUi(false);
// WifiGuarder xuyong 2016-09-08 added for new feature end
mWifiOpenedFragment.changeToConnectingView((WifiGuardScanResult)msg.obj);
}
break;
case SHOW_WIFI_CONNECT_ERROR:
// WifiGuarder xuyong 2016-09-08 added for new feature start
if (mWifiOpenedFragment != null) {
mWifiOpenedFragment.changeUi(true);
}
// WifiGuarder xuyong 2016-09-08 added for new feature end
if (msg.obj != null) {
WifiGuardScanResult result = (WifiGuardScanResult) msg.obj;
final OneTouchDialog otdlg = mOneTouchDialogCreator.getDialog(result);
if (otdlg != null) {
otdlg.setFragment(mWifiOpenedFragment);
otdlg.setHandler(mHandler);
otdlg.setContext(WifiListActivity.this);
otdlg.setShowErrorTip(true);
otdlg.show(mWifiOpenedFragment.getFragmentManager(), "One Touch");
}
removeScanResult(result);
} else {
Toast.makeText(WifiListActivity.this, R.string.wifi_connect_failed, Toast.LENGTH_LONG).show();
}
break;
//WifiGuarder zhengzujia 2016-09-19 Added for new security request start
case START_SECURITY:
WifiInfo wifiInfo = WifiUtil.getInstance(getApplicationContext()).getConnectedWifiInfo();
Intent intent = new Intent(WifiSecurityActivity.INTENT_ACTION);
intent.putExtra("index", AUTO_START_SECURITY);
intent.putExtra("ssidName", wifiInfo.getSSID().substring(1, wifiInfo.getSSID().length() - 1));
startActivity(intent);
START_SECURITY_FLAG = true;
break;
//WifiGuarder zhengzujia 2016-09-19 Added for new security request end
//WifiGuarder zhengzujia 2016-10-08 added for shared hostspot start
case OPEN_SHARED_HOSTSPOT:
//WifiGuarder zhengzujia 2016-10-12 added for shared hotspot start
AnalyticsCreator.handleEvent(AnalyticsConstants.ActionKeys.CLICK, AnalyticsConstants.ActionView.HOSTSPOT_OPENED);
//WifiGuarder zhengzujia 2016-10-12 added for shared hotspot end
mWifiOpenedFragment.cancelTask();
if (mWifiStatusCb != null) {
mWifiStatusCb.setVisibility(View.INVISIBLE);
}
if (mWifiSettingBt != null){
mWifiSettingBt.setVisibility(View.INVISIBLE);
}
transaction.show(mWifiOpenedFragment);
transaction.hide(mWifiClosedFragment);
mWifiOpenedFragment.showSharedHostspotUI();
transaction.commitAllowingStateLoss();
mWifiOpenedFragment.scanSharedConnectedDivice();
mWifiOpenedFragment.initTaskRefreshShared();
sharedLayoutSmallLeftIV.setImageResource(R.drawable.wifi_strength_lv4);
sharedLayoutTip1.setText(R.string.title1_open_hostspot);
sharedLayoutTip2.setText(R.string.title2_open_hostspot);
sharedLayoutSmallRightIV.setVisibility(View.INVISIBLE);
break;
case CLOSE_SHARED_HOSTSPOT:
//WifiGuarder zhengzujia 2016-10-12 added for shared hotspot start
AnalyticsCreator.handleEvent(AnalyticsConstants.ActionKeys.CLICK, AnalyticsConstants.ActionView.HOSTSPOT_CLOSED);
//WifiGuarder zhengzujia 2016-10-12 added for shared hotspot end
if (mWifiStatusCb != null) {
//WifiGuarder zhengzujia 2016-10-12 deleted for shared hotspot start
//mWifiStatusCb.setChecked(true);
//WifiGuarder zhengzujia 2016-10-12 deleted for shared hotspot start
mWifiStatusCb.setVisibility(View.VISIBLE);
}
mWifiOpenedFragment.reSetWifiOpenAdapter();
mWifiOpenedFragment.canceSharedTask();
sharedLayoutSmallLeftIV.setImageResource(R.drawable.shared_hotspot_left);
sharedLayoutTip1.setText(R.string.title1);
sharedLayoutTip2.setText(R.string.title2);
sharedLayoutSmallRightIV.setVisibility(View.INVISIBLE);
break;
case UPDATE_SHARED_LIST:
if (mWifiOpenedFragment != null && mWifiOpenedFragment.isAdded()) {
mWifiOpenedFragment.scanSharedConnectedDivice();
}
break;
//WifiGuarder zhengzujia 2016-10-08 added for shared hostspot end
default:
break;
}
}
};
private void changeNotification() {
Intent intent = new Intent(WifiStatusChangeReceiver.NOTIFICATION_SHOW_ACTION);
sendBroadcast(intent);
}
private void removeScanResult(WifiGuardScanResult result) {
WifiUtil.getInstance(this).removeNetwork(result);
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.wifi_list_layout);
//WifiGuarder zhengzujia 2016-10-08 added for shared hostspot start
checkIsOpenHostspot();
//WifiGuarder zhengzujia 2016-10-08 added for shared hostspot end
initFragmentRelated();
initWifiManager();
initImitateActionBar();
//WifiGuarder zhengzujia 2016-10-11 added for shared hotspot start
initializedSharedLayout();
//WifiGuarder zhengzujia 2016-10-11 added for shared hotspot end
registerWifiBroadcastReceiver();
mOneTouchDialogCreator = new OneTouchDialogCreator();
//WifiGuarder zhengzujia add for OtherApp Start by Interface start
Intent intent = getIntent();
int index = intent.getIntExtra("StartSpeedActivity", 0);
if (index == 1){
Intent intentSpeed = new Intent("com.wifiguarder.wifi.android.intent.WifiSpeedActivity");
intentSpeed.putExtra("index", 1);
startActivity(intentSpeed);
}
//WifiGuarder zhengzujia add for OtherApp Start by Interface end
}
//WifiGuarder zhengzujia 2016-10-11 added for shared hotspot start
private void initializedSharedLayout(){
mSharedLayout = (RelativeLayout)findViewById(R.id.shared_hotspot_layout);
mSharedLayout.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (isOpenHostspot == true){
SharedHostspotDialog dialog = new SharedHostspotDialog();
dialog.show(getFragmentManager(), "SharedHostspotDialog");
}else {
try {
Intent mIntent = new Intent("/");
ComponentName comp = new ComponentName("com.android.settings", "com.android.settings.TetherSettings");
mIntent.setComponent(comp);
startActivityForResult(mIntent, 0);
} catch (Exception e) {
}
}
}
});
sharedLayoutSmallLeftIV = (ImageView)findViewById(R.id.shared_left_iv);
sharedLayoutTip1 = (TextView)findViewById(R.id.text1);
sharedLayoutTip2 = (TextView)findViewById(R.id.text2);
sharedLayoutSmallRightIV = (ImageView)findViewById(R.id.shared_right_iv);
}
//WifiGuarder zhengzujia 2016-10-11 added for shared hotspot end
//WifiGuarder zhengzujia 2016-10-08 added shared hostspot start
private void checkIsOpenHostspot() {
if (getWifiApState() == WIFI_AP_STATE.WIFI_AP_STATE_ENABLED || getWifiApState() == WIFI_AP_STATE.WIFI_AP_STATE_ENABLING){
isOpenHostspot = true;
}else {
isOpenHostspot = false;
}
}
//WifiGuarder zhengzujia 2016-10-08 added shared hostspot end
@Override
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
}
private void registerWifiBroadcastReceiver() {
IntentFilter filter = new IntentFilter();
filter.addAction(WifiManager.NETWORK_STATE_CHANGED_ACTION);
filter.addAction(WifiManager.WIFI_STATE_CHANGED_ACTION);
filter.addAction(ConnectivityManager.CONNECTIVITY_ACTION);
//WifiGuarder zhengzujia 2016-10-08 add for shared hostspot start
filter.addAction("android.net.conn.TETHER_STATE_CHANGED");
//WifiGuarder zhengzujia 2016-10-08 add for shared hostsopt end
mWifiReferenceNetworkChangedReceiver = new WifiReferenceNetworkChangedReceiver();
registerReceiver(mWifiReferenceNetworkChangedReceiver, filter);
}
private void initFragmentRelated() {
mWifiClosedFragment = new WifiClosedFragment();
mWifiOpenedFragment = new WifiOpenedFragment();
mWifiOpenedFragment.setHandler(mHandler);
}
private FragmentTransaction getFragmentTransaction() {
return getSupportFragmentManager().beginTransaction();
}
private void initWifiManager() {
mWifiManager = (WifiManager)this.getSystemService(WIFI_SERVICE);
}
private void initImitateActionBar() {
mToolbar = (Toolbar) findViewById(R.id.wifi_list_toolbar);
setSupportActionBar(mToolbar);
mWifiSettingBt = (ImageButton) findViewById(R.id.wifi_setting_btn);
mWifiSettingBt.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
AnalyticsCreator.handleEvent(AnalyticsConstants.ActionKeys.CLICK, AnalyticsConstants.ActionView.ENTER_SETTING_BTN, "enter");
Intent intent = new Intent(WifiListActivity.this, WifiSettingActivity.class);
startActivity(intent);
}
});
mWifiStatusCb = (CheckBox) findViewById(R.id.wifi_status_cb);
mWifiStatusCb.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
if (checked) {
if (mWifiSettingBt != null) {
mWifiSettingBt.setVisibility(View.VISIBLE);
}
if (mWifiClosedFragment != null) {
mWifiClosedFragment.openWifiAnimation();
}
WifiUtil.getInstance(WifiListActivity.this).openWifi();
AnalyticsCreator.handleEvent(AnalyticsConstants.ActionKeys.CLICK, AnalyticsConstants.ActionView.OPEN_CLOSE_CB, "open");
} else {
if (mWifiSettingBt != null) {
mWifiSettingBt.setVisibility(View.GONE);
}
WifiUtil.getInstance(WifiListActivity.this).closeWifi();
Message msg = mHandler.obtainMessage(UPDATE_CONNECTED_DISBALING_UI);
msg.arg1 = DISABLE_BTN;
msg.sendToTarget();
AnalyticsCreator.handleEvent(AnalyticsConstants.ActionKeys.CLICK, AnalyticsConstants.ActionView.OPEN_CLOSE_CB, "close");
}
}
});
}
public void changedWiFiStatusCbChecked() {
if (mWifiStatusCb != null) {
if (mWifiStatusCb.isChecked()) {
AnalyticsCreator.handleEvent(AnalyticsConstants.ActionKeys.CLICK, AnalyticsConstants.ActionView.OPEN_CLOSE_BTN, "close");
} else {
AnalyticsCreator.handleEvent(AnalyticsConstants.ActionKeys.CLICK, AnalyticsConstants.ActionView.OPEN_CLOSE_BTN, "open");
}
mWifiStatusCb.setChecked(!mWifiStatusCb.isChecked());
mWifiStatusCb.setClickable(false);
}
}
public boolean isWiFiStatusCbClickable() {
if (mWifiStatusCb != null) {
return mWifiStatusCb.isClickable();
}
return true;
}
private void handleWifiOpened() {
if (mWifiOpenedFragment != null && !mWifiOpenedFragment.isAdded()) {
FragmentTransaction transaction = getFragmentTransaction();
mWifiOpenedFragment.setHandler(mHandler);
transaction.add(R.id.wifi_list_content, mWifiOpenedFragment);
transaction.commitAllowingStateLoss();
}
}
private void handleWifiClosed() {
if (mWifiClosedFragment != null && !mWifiClosedFragment.isAdded()) {
FragmentTransaction transaction = getFragmentTransaction();
mWifiClosedFragment = new WifiClosedFragment();
transaction.add(R.id.wifi_list_content, mWifiClosedFragment);
transaction.commitAllowingStateLoss();
}
}
@Override
protected void onRestart() {
super.onRestart();
}
@Override
protected void onStart() {
super.onStart();
handleWifiOpened();
handleWifiClosed();
//WifiGuarder zhengzujia 2016-10-08 added for shared hostspot start
if (isOpenHostspot == false){
FragmentTransaction transaction = WifiListActivity.this.getFragmentTransaction();
if (mWifiManager.isWifiEnabled()) {
mWifiStatusCb.setChecked(true);
if (mWifiClosedFragment != null) {
transaction.show(mWifiOpenedFragment);
transaction.hide(mWifiClosedFragment);
transaction.commitAllowingStateLoss();
}
} else {
mWifiStatusCb.setChecked(false);
if (mWifiClosedFragment != null) {
transaction.show(mWifiClosedFragment);
transaction.hide(mWifiOpenedFragment);
transaction.commitAllowingStateLoss();
}
}
if (mWifiOpenedFragment != null && mWifiOpenedFragment.isAdded()) {
mWifiOpenedFragment.initTask();
}
}
//WifiGuarder zhengzujia 2016-10-08 added for shared hostspot end
//WifiGuarder zhengzujia 2016-10-08 deleted for shared hostspot start
// FragmentTransaction transaction = WifiListActivity.this.getFragmentTransaction();
// if (mWifiManager.isWifiEnabled()) {
// mWifiStatusCb.setChecked(true);
// if (mWifiClosedFragment != null) {
// transaction.show(mWifiOpenedFragment);
// transaction.hide(mWifiClosedFragment);
// transaction.commitAllowingStateLoss();
// }
// } else {
// mWifiStatusCb.setChecked(false);
// if (mWifiClosedFragment != null) {
// transaction.show(mWifiClosedFragment);
// transaction.hide(mWifiOpenedFragment);
// transaction.commitAllowingStateLoss();
// }
// }
// if (mWifiOpenedFragment != null && mWifiOpenedFragment.isAdded()) {
// mWifiOpenedFragment.initTask();
// }
//WifiGuarder zhengzujia 2016-10-08 deleted for shared hostspot end
}
@Override
protected void onResume() {
super.onResume();
AnalyticsCreator.handleScreenHit(AnalyticsConstants.Activity.WIFI_LIST_ACTIVITY);
}
@Override
protected void onPause() {
super.onPause();
}
@Override
protected void onStop() {
super.onStop();
if (mWifiOpenedFragment != null && mWifiOpenedFragment.isAdded()) {
mWifiOpenedFragment.cancelTask();
}
}
private void removeFragments() {
FragmentTransaction transaction = WifiListActivity.this.getFragmentTransaction();
transaction.remove(mWifiOpenedFragment);
transaction.remove(mWifiClosedFragment);
}
@Override
protected void onDestroy() {
unregisterReceiver(mWifiReferenceNetworkChangedReceiver);
//DownloadManager.getInstance(this).deleteURLConfigurationCache();
removeFragments();
// WiFiGuarder xuyong 2016-11-14 added for bug #64 start
mHandler = null;
// WiFiGuarder xuyong 2016-11-14 added for bug #64 end
super.onDestroy();
}
public class WifiReferenceNetworkChangedReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
if (WifiManager.WIFI_STATE_CHANGED_ACTION.equals(intent.getAction())) {
int wifiState = intent.getIntExtra(WifiManager.EXTRA_WIFI_STATE, WifiManager.WIFI_STATE_DISABLED);
Message msg = null;
switch (wifiState) {
case WifiManager.WIFI_STATE_DISABLING:
if (mWifiStatusCb != null) {
mWifiStatusCb.setClickable(false);
}
break;
case WifiManager.WIFI_STATE_DISABLED:
mAfterClostBroadcast = true;
if (mWifiStatusCb != null) {
mWifiStatusCb.setClickable(true);
}
msg = mHandler.obtainMessage(UPDATE_CONNECTED_DISBALING_UI);
msg.arg1 = ENABLE_BTN;
msg.sendToTarget();
break;
case WifiManager.WIFI_STATE_ENABLING:
if (mWifiStatusCb != null) {
mWifiStatusCb.setClickable(false);
}
if (mWifiClosedFragment != null && mWifiClosedFragment.isAdded()) {
mWifiClosedFragment.startWifiAnimation();
}
break;
case WifiManager.WIFI_STATE_ENABLED:
List<WifiGuardScanResult> list = WifiUtil.getInstance(WifiListActivity.this).getWifiGuardScanResult();
if (list == null || list.size() <= 0) {
new Thread(new Runnable() {
@Override
public void run() {
try {
Thread.currentThread().sleep(DELAY_DURATION);
} catch (InterruptedException e) {
e.printStackTrace();
}
if (mWifiStatusCb != null) {
mWifiStatusCb.setClickable(true);
}
Message delaymsg = mHandler.obtainMessage(DELAY_UPDATE_CONNECTED_UI);
delaymsg.sendToTarget();
}
}).start();
} else {
if (mWifiStatusCb != null) {
mWifiStatusCb.setClickable(true);
}
// WiFiGuarder xuyong 2016-11-14 modified for bug #64 start
if (mHandler != null) {
msg = mHandler.obtainMessage(UPDATE_CONNECTED_UI);
msg.sendToTarget();
}
// WiFiGuarder xuyong 2016-11-14 modified for bug #64 end
}
break;
}
}
if (ConnectivityManager.CONNECTIVITY_ACTION.equals(intent.getAction())) {
Parcelable parcelableExtra = intent.getParcelableExtra(WifiManager.EXTRA_NETWORK_INFO);
NetworkInfo.State wifiState = null;
if (null != parcelableExtra) {
ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
wifiState = cm.getNetworkInfo(ConnectivityManager.TYPE_WIFI).getState();
if (wifiState == NetworkInfo.State.CONNECTED) {
Message msg = mHandler.obtainMessage(UPDATE_CONNECTED_UI);
msg.sendToTarget();
} else {
// do nothing
}
}
}
//WifiGuarder zhengzujia 2016-10-08 added for shared hostspot start
if (intent.getAction().equals("android.net.conn.TETHER_STATE_CHANGED")) {
ConnectivityManager connMgr = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
Message msg = null;
switch (getWifiApState()){
case WIFI_AP_STATE_DISABLING:
isOpenHostspot = false;
msg = mHandler.obtainMessage(CLOSE_SHARED_HOSTSPOT);
msg.sendToTarget();
break;
case WIFI_AP_STATE_DISABLED:
isOpenHostspot = false;
msg = mHandler.obtainMessage(CLOSE_SHARED_HOSTSPOT);
msg.sendToTarget();
break;
case WIFI_AP_STATE_ENABLING:
isOpenHostspot = true;
mAfterClostBroadcast = true;
if (mWifiStatusCb != null) {
mWifiStatusCb.setClickable(true);
}
break;
case WIFI_AP_STATE_ENABLED:
isOpenHostspot = true;
mAfterClostBroadcast = true;
if (mWifiStatusCb != null) {
mWifiStatusCb.setClickable(true);
}
msg = mHandler.obtainMessage(OPEN_SHARED_HOSTSPOT);
msg.sendToTarget();
break;
}
}
//WifiGuarder zhengzujia 2016-10-08 added for shared hostspot end
}
}
//WifiGuarder zhengzujia 2016-10-08 added for shared hostspot start
private WIFI_AP_STATE getWifiApState() {
int tmp;
try {
Method method = mWifiManager.getClass().getMethod("getWifiApState");
tmp = ((Integer) method.invoke(mWifiManager));
// Fix for Android 4
if (tmp > 9) {
tmp = tmp - 10;
}
return WIFI_AP_STATE.class.getEnumConstants()[tmp];
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return WIFI_AP_STATE.WIFI_AP_STATE_FAILED;
}
public enum WIFI_AP_STATE {
WIFI_AP_STATE_DISABLING, WIFI_AP_STATE_DISABLED, WIFI_AP_STATE_ENABLING, WIFI_AP_STATE_ENABLED, WIFI_AP_STATE_FAILED
}
//WifiGuarder zhengzujia 2016-10-08 added for shared hostspot end
}
| 33,033 | 0.580489 | 0.563937 | 710 | 45.546478 | 29.537848 | 140 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.522535 | false | false | 9 |
5da761b726fa8fe42202fdeeef81d341e8887107 | 36,867,999,293,751 | d0d05eb2eb2de9a14b6e51d8e841678d3a57fe7e | /src/source2.java | aa1a081e295061adf622140e319dc33f933bd602 | [] | no_license | cratana/git_test1 | https://github.com/cratana/git_test1 | a1e619d5cb6c355171c5679625ad977ee4aeaa24 | f16ad6e09f9eb72cffaae9e806678255924b542f | refs/heads/master | 2021-01-06T20:39:14.859000 | 2017-08-07T04:42:38 | 2017-08-07T04:42:38 | 99,535,994 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | //source2.java
| UTF-8 | Java | 15 | java | source2.java | Java | [] | null | [] | //source2.java
| 15 | 0.733333 | 0.666667 | 1 | 14 | 0 | 14 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0 | false | false | 9 |
c1c4db336c06089c3f3f0c190430e2d95a481864 | 35,244,501,676,849 | a4613fd78de07f40efcb40c1ca6add05fcea4f63 | /src/Utility/MainSystem.java | f1b583d8f86b07021b085e1093ef5551d2ee463c | [] | no_license | Dwape/rUBERn-grupo4 | https://github.com/Dwape/rUBERn-grupo4 | 91096b4fd37f3926cd24616a6fe645429d614012 | a26e6d9eb0895389f3fe897a929075c7fd5c0136 | refs/heads/master | 2021-05-04T08:46:12.263000 | 2016-11-04T15:53:32 | 2016-11-04T15:53:32 | 70,426,243 | 4 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package Utility;
import DriverAndClient.AbstractClient;
import DriverAndClient.AbstractDriver;
import DriverAndClient.Coordinates;
import DriverAndClient.Driver;
import Exceptions.NoAvailableDriverExc;
import java.util.ArrayList;
/**
* Created by Gianni on 10/9/2016.
*/
public class MainSystem {
private ArrayList<Driver> driverList;
public MainSystem(){
driverList = new ArrayList<>();
}
public void addDriver(Driver newDriver){
driverList.add(newDriver);
}
public void transaction(AbstractClient aClient, AbstractDriver aDriver, Coordinates startCoords, Coordinates finishCoords, Invoice anInvoice){
double cost = 15+getDistance(startCoords, finishCoords)*0.01;
double uberBalance = cost*0.10;
double driverBalance = cost*0.90;
double clientBalance = cost*(-1);
aDriver.addFunds(driverBalance);
aClient.spend(cost);
Transaction driverTransaction = new Transaction("Trip", "Driver charges money", aDriver.getCreditCard().getCreditCardNumber(), "A description", driverBalance);
Transaction uberTransaction = new Transaction("Trip", "Uber charges commission", aClient.getCreditCardNumber(), "A description", uberBalance);
Transaction clientTransaction = new Transaction("Trip", "Client pays for service", aClient.getCreditCardNumber(), "A description", clientBalance);
anInvoice.add(driverTransaction);
anInvoice.add(uberTransaction);
anInvoice.add(clientTransaction);
}
public double calculateCost(Coordinates start, Coordinates finish){
double distance = getDistance(start, finish);
return 15 + 0.01*distance;
}
public double getDistance(Coordinates startCoords, Coordinates finishCoords){
return Math.sqrt((finishCoords.getValueX() - startCoords.getValueX())+(finishCoords.getValueY() - startCoords.getValueY()));
}
public Driver chooseDriver(Coordinates startCoordinates,Coordinates finishCoords, int numberOfPeople){
ArrayList<Driver> candidates = new ArrayList<>();
for (int i=0; i<driverList.size(); i++){
candidates.add(driverList.get(i));
}
int i1=0;
while (i1<candidates.size()){
if (candidates.get(i1).getCar().getSpace() < numberOfPeople){
candidates.remove(i1);
}else{
i1++;
}
}
int i2=0;
while (i2<candidates.size()){
if (!candidates.get(i2).getAvailability()){
candidates.remove(i2);
}else{
i2++;
}
}
int i3=0;
while (i3<candidates.size()){
if (getDistance(startCoordinates, candidates.get(i3).getCoordinates())>10000){
candidates.remove(i3);
}else{
i3++;
}
}
int i4=0;
while (i4<candidates.size()){
Driver bestCandidate = getLowestImgCost(candidates, startCoordinates);
if (bestCandidate.requestDriver(finishCoords)){
i4++;
return bestCandidate;
}else{
candidates.remove(bestCandidate);
}
}
throw new NoAvailableDriverExc();
}
private Driver getLowestImgCost(ArrayList<Driver> candidates, Coordinates startCoordinates){
double initDistanceCost = getDistance(startCoordinates, candidates.get(0).getCoordinates())*0.004;
double costAd = initDistanceCost+(initDistanceCost*(candidates.get(0).getCar().getaCategory().getExtraPercentageCost()*0.01));
Driver cheapestDriver = candidates.get(0);
for (int i=1; i< candidates.size(); i++){
double currentCostAd;
double distanceCost = getDistance(startCoordinates, candidates.get(i).getCoordinates())*0.004;
currentCostAd = distanceCost+(distanceCost*(candidates.get(i).getCar().getaCategory().getExtraPercentageCost()*0.01));
if (currentCostAd<costAd){
cheapestDriver = candidates.get(i);
costAd=currentCostAd;
}
}
return cheapestDriver;
}
public ArrayList<Driver> getDriverList() {
return driverList;
}
}
| UTF-8 | Java | 4,271 | java | MainSystem.java | Java | [
{
"context": "c;\n\nimport java.util.ArrayList;\n\n/**\n * Created by Gianni on 10/9/2016.\n */\npublic class MainSystem {\n p",
"end": 257,
"score": 0.9978362321853638,
"start": 251,
"tag": "NAME",
"value": "Gianni"
}
] | null | [] | package Utility;
import DriverAndClient.AbstractClient;
import DriverAndClient.AbstractDriver;
import DriverAndClient.Coordinates;
import DriverAndClient.Driver;
import Exceptions.NoAvailableDriverExc;
import java.util.ArrayList;
/**
* Created by Gianni on 10/9/2016.
*/
public class MainSystem {
private ArrayList<Driver> driverList;
public MainSystem(){
driverList = new ArrayList<>();
}
public void addDriver(Driver newDriver){
driverList.add(newDriver);
}
public void transaction(AbstractClient aClient, AbstractDriver aDriver, Coordinates startCoords, Coordinates finishCoords, Invoice anInvoice){
double cost = 15+getDistance(startCoords, finishCoords)*0.01;
double uberBalance = cost*0.10;
double driverBalance = cost*0.90;
double clientBalance = cost*(-1);
aDriver.addFunds(driverBalance);
aClient.spend(cost);
Transaction driverTransaction = new Transaction("Trip", "Driver charges money", aDriver.getCreditCard().getCreditCardNumber(), "A description", driverBalance);
Transaction uberTransaction = new Transaction("Trip", "Uber charges commission", aClient.getCreditCardNumber(), "A description", uberBalance);
Transaction clientTransaction = new Transaction("Trip", "Client pays for service", aClient.getCreditCardNumber(), "A description", clientBalance);
anInvoice.add(driverTransaction);
anInvoice.add(uberTransaction);
anInvoice.add(clientTransaction);
}
public double calculateCost(Coordinates start, Coordinates finish){
double distance = getDistance(start, finish);
return 15 + 0.01*distance;
}
public double getDistance(Coordinates startCoords, Coordinates finishCoords){
return Math.sqrt((finishCoords.getValueX() - startCoords.getValueX())+(finishCoords.getValueY() - startCoords.getValueY()));
}
public Driver chooseDriver(Coordinates startCoordinates,Coordinates finishCoords, int numberOfPeople){
ArrayList<Driver> candidates = new ArrayList<>();
for (int i=0; i<driverList.size(); i++){
candidates.add(driverList.get(i));
}
int i1=0;
while (i1<candidates.size()){
if (candidates.get(i1).getCar().getSpace() < numberOfPeople){
candidates.remove(i1);
}else{
i1++;
}
}
int i2=0;
while (i2<candidates.size()){
if (!candidates.get(i2).getAvailability()){
candidates.remove(i2);
}else{
i2++;
}
}
int i3=0;
while (i3<candidates.size()){
if (getDistance(startCoordinates, candidates.get(i3).getCoordinates())>10000){
candidates.remove(i3);
}else{
i3++;
}
}
int i4=0;
while (i4<candidates.size()){
Driver bestCandidate = getLowestImgCost(candidates, startCoordinates);
if (bestCandidate.requestDriver(finishCoords)){
i4++;
return bestCandidate;
}else{
candidates.remove(bestCandidate);
}
}
throw new NoAvailableDriverExc();
}
private Driver getLowestImgCost(ArrayList<Driver> candidates, Coordinates startCoordinates){
double initDistanceCost = getDistance(startCoordinates, candidates.get(0).getCoordinates())*0.004;
double costAd = initDistanceCost+(initDistanceCost*(candidates.get(0).getCar().getaCategory().getExtraPercentageCost()*0.01));
Driver cheapestDriver = candidates.get(0);
for (int i=1; i< candidates.size(); i++){
double currentCostAd;
double distanceCost = getDistance(startCoordinates, candidates.get(i).getCoordinates())*0.004;
currentCostAd = distanceCost+(distanceCost*(candidates.get(i).getCar().getaCategory().getExtraPercentageCost()*0.01));
if (currentCostAd<costAd){
cheapestDriver = candidates.get(i);
costAd=currentCostAd;
}
}
return cheapestDriver;
}
public ArrayList<Driver> getDriverList() {
return driverList;
}
}
| 4,271 | 0.635917 | 0.619527 | 113 | 36.796459 | 37.241417 | 167 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.734513 | false | false | 9 |
5852586bb5914369f1e851b1e4f3f8f394e92e78 | 39,152,921,872,418 | 2c891dde4f756e7bab7196405d3c7df70fc9fdf8 | /rocket-notifymsg-demo-bank1/src/main/java/com/yibo/notify/feign/PayClient.java | 654ecabbd3f53ca73bcc3d115c05b9def9a35c4d | [] | no_license | wangyongpan-928/distributed-transaction | https://github.com/wangyongpan-928/distributed-transaction | b8c0deb5bc60c369547aca5583f770d4eb57ae67 | f07fe8c23a33572d01c5761e14922d70a89a7ba4 | refs/heads/master | 2023-01-29T12:03:09.776000 | 2020-12-13T17:57:22 | 2020-12-13T17:57:22 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.yibo.notify.feign;
import com.yibo.notify.domain.entity.AccountPay;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
/**
* @Author: huangyibo
* @Date: 2020/10/17 19:46
* @Description:
*/
@FeignClient(value = "notify-msg-pay")
public interface PayClient {
//远程调用充值系统的接口查询充值结果
@GetMapping(value = "account/payResult/{txNo}")
public AccountPay payresult(@PathVariable("txNo") String txNo);
}
| UTF-8 | Java | 582 | java | PayClient.java | Java | [
{
"context": "web.bind.annotation.PathVariable;\n\n/**\n * @Author: huangyibo\n * @Date: 2020/10/17 19:46\n * @Description:\n */\n\n",
"end": 283,
"score": 0.9995249509811401,
"start": 274,
"tag": "USERNAME",
"value": "huangyibo"
}
] | null | [] | package com.yibo.notify.feign;
import com.yibo.notify.domain.entity.AccountPay;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
/**
* @Author: huangyibo
* @Date: 2020/10/17 19:46
* @Description:
*/
@FeignClient(value = "notify-msg-pay")
public interface PayClient {
//远程调用充值系统的接口查询充值结果
@GetMapping(value = "account/payResult/{txNo}")
public AccountPay payresult(@PathVariable("txNo") String txNo);
}
| 582 | 0.759124 | 0.737226 | 20 | 26.4 | 22.905022 | 67 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.3 | false | false | 9 |
3434762c163f26b72f419d051de4e3ffffabb539 | 37,503,654,454,556 | 84a2642fc9b03f5f1014456ee3427a18ec23afcd | /src/com/company/backjoon/efjava/Cloth.java | ea8937f331bd311a49ee6a71e6660d6934291544 | [] | no_license | jephyros/JavaStudy | https://github.com/jephyros/JavaStudy | 33306ff578f983cebeed196a90a92839bc9b5de4 | 176743cbe0440bb2fe7a1ab8947d9cf644e35d89 | refs/heads/master | 2023-06-22T02:47:13.283000 | 2023-06-15T01:12:50 | 2023-06-15T01:12:50 | 223,829,503 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.company.backjoon.efjava;
/**
* @author InSeok
* Date : 2021-11-30
* Remark :
*/
public class Cloth {
private String name;
private String type;
public Cloth(Builder builder) {
this.name = builder.name;
this.type = builder.type;
}
@Override
public String toString() {
return "Cloth{" +
"name='" + name + '\'' +
", type='" + type + '\'' +
'}';
}
public static class Builder {
private String name;
private String type;
public Builder name(String name){
this.name= name;
return this;
}
public Builder type(String type){
this.type= type;
return this;
}
public Cloth build(){
return new Cloth(this);
}
}
}
| UTF-8 | Java | 862 | java | Cloth.java | Java | [
{
"context": "ckage com.company.backjoon.efjava;\n\n/**\n * @author InSeok\n * Date : 2021-11-30\n * Remark :\n */\n\npublic clas",
"end": 59,
"score": 0.9900162816047668,
"start": 53,
"tag": "USERNAME",
"value": "InSeok"
}
] | null | [] | package com.company.backjoon.efjava;
/**
* @author InSeok
* Date : 2021-11-30
* Remark :
*/
public class Cloth {
private String name;
private String type;
public Cloth(Builder builder) {
this.name = builder.name;
this.type = builder.type;
}
@Override
public String toString() {
return "Cloth{" +
"name='" + name + '\'' +
", type='" + type + '\'' +
'}';
}
public static class Builder {
private String name;
private String type;
public Builder name(String name){
this.name= name;
return this;
}
public Builder type(String type){
this.type= type;
return this;
}
public Cloth build(){
return new Cloth(this);
}
}
}
| 862 | 0.486079 | 0.476798 | 51 | 15.90196 | 14.528208 | 42 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.27451 | false | false | 9 |
5b79f7bdfa280f664cbd48bb45b430f037efbbab | 31,026,843,803,169 | f9e88006608d2cfd2754caeb9668b13b00294d18 | /tests/ballerina-tools-integration-test/src/test/java/org/ballerinalang/test/packaging/TestExecutionTestCase.java | ee7bce367372fe5b150d1689231017c51e36099d | [
"Apache-2.0",
"BSD-3-Clause",
"LicenseRef-scancode-mit-old-style",
"MPL-2.0",
"LicenseRef-scancode-unicode",
"MIT"
] | permissive | ballerina-platform/ballerina-lang | https://github.com/ballerina-platform/ballerina-lang | b7b1615268514a08f28662a0ccae38d409d11e6d | 2ab049574ef483e580e0dfbced5b0038debf25c0 | refs/heads/master | 2023-09-04T03:01:52.671000 | 2023-08-26T02:00:54 | 2023-08-26T02:00:54 | 73,930,305 | 3,370 | 642 | Apache-2.0 | false | 2023-09-14T12:38:45 | 2016-11-16T14:58:44 | 2023-09-14T08:01:15 | 2023-09-14T11:36:56 | 787,827 | 3,357 | 708 | 1,253 | Ballerina | false | false | /*
* Copyright (c) 2018, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
* WSO2 Inc. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.ballerinalang.test.packaging;
import org.ballerinalang.test.BaseTest;
import org.ballerinalang.test.context.LogLeecher;
import org.ballerinalang.test.utils.TestUtils;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Ignore;
import org.testng.annotations.Test;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.StandardCopyOption;
import java.nio.file.StandardOpenOption;
import java.util.Map;
/**
* Testing executing tests in a project using the test command.
*
* @since 0.982.0
*/
@Ignore
public class TestExecutionTestCase extends BaseTest {
private Path tempProjectDirectory;
private Map<String, String> envVariables;
@BeforeClass()
public void setUp() throws IOException {
tempProjectDirectory = Files.createTempDirectory("bal-test-integration-packaging-project-");
envVariables = TestUtils.getEnvVariables();
}
@Test(description = "Test creating a project")
public void testInitProject() throws Exception {
String[] clientArgsForInit = {"-i"};
String[] options = {"\n", "integrationtests\n", "\n", "m\n", "foo\n", "s\n", "bar\n", "f\n"};
balClient.runMain("init", clientArgsForInit, envVariables, options, new LogLeecher[0],
tempProjectDirectory.toString());
}
@Test(description = "Test executing tests in a main module", dependsOnMethods = "testInitProject")
public void testExecutionOfMainModule() throws Exception {
String[] clientArgs = {"foo"};
String msg = "Compiling tests\n" +
" integrationtests/foo:0.0.1\n" +
"\n" +
"Running tests\n" +
" integrationtests/foo:0.0.1\n" +
"I'm the before suite function!\n" +
"I'm the before function!\n" +
"I'm in test function!\n" +
"I'm the after function!\n" +
"I'm the after suite function!\n" +
"\t[pass] testFunction\n" +
"\n" +
"\t1 passing\n" +
"\t0 failing\n" +
"\t0 skipped\n";
LogLeecher clientLeecher = new LogLeecher(msg);
balClient.runMain("test", clientArgs, envVariables, new String[0],
new LogLeecher[]{clientLeecher}, tempProjectDirectory.toString());
clientLeecher.waitForText(3000);
}
@Test(description = "Test executing tests in a service module", dependsOnMethods = "testInitProject")
public void testExecutionOfServiceModule() throws Exception {
String[] clientArgs = {"bar"};
String msg = "Compiling tests\n" +
" integrationtests/bar:0.0.1\n" +
"\n" +
"Running tests\n" +
" integrationtests/bar:0.0.1\n" +
"ballerina: started HTTP/WS listener 0.0.0.0:9090\n" +
"I'm the before suite service function!\n" +
"Do your service Tests!\n" +
"I'm the after suite service function!\n" +
"\t[pass] testServiceFunction\n" +
"\n" +
"\t1 passing\n" +
"\t0 failing\n" +
"\t0 skipped\n";
LogLeecher clientLeecher = new LogLeecher(msg);
balClient.runMain("test", clientArgs, envVariables, new String[0],
new LogLeecher[]{clientLeecher}, tempProjectDirectory.toString());
clientLeecher.waitForText(3000);
}
@Test(description = "Test executing tests in a project", dependsOnMethods = "testInitProject")
public void testExecutionOfProject() throws Exception {
String msg = "Compiling tests\n" +
" integrationtests/foo:0.0.1\n" +
" integrationtests/bar:0.0.1\n" +
"\n" +
"Running tests\n" +
" integrationtests/foo:0.0.1\n" +
"I'm the before suite function!\n" +
"I'm the before function!\n" +
"I'm in test function!\n" +
"I'm the after function!\n" +
"I'm the after suite function!\n" +
"\t[pass] testFunction\n" +
"\n" +
"\t1 passing\n" +
"\t0 failing\n" +
"\t0 skipped\n" +
"\n" +
" integrationtests/bar:0.0.1\n" +
"ballerina: started HTTP/WS listener 0.0.0.0:9090\n" +
"I'm the before suite service function!\n" +
"Do your service Tests!\n" +
"I'm the after suite service function!\n" +
"\t[pass] testServiceFunction\n" +
"\n" +
"\t1 passing\n" +
"\t0 failing\n" +
"\t0 skipped\n";
LogLeecher clientLeecher = new LogLeecher(msg);
balClient.runMain("test", new String[0], envVariables, new String[0],
new LogLeecher[]{clientLeecher}, tempProjectDirectory.toString());
clientLeecher.waitForText(3000);
}
@Test(description = "Test executing tests in a ballerina file with main", dependsOnMethods = "testInitProject")
public void testExecutionMain() throws Exception {
Path modulePath = tempProjectDirectory.resolve("foo").resolve("tests");
// Test ballerina test
String[] clientArgs = {"main_test.bal"};
String msg = "Compiling tests\n" +
" main_test.bal\n" +
"\n" +
"Running tests\n" +
" main_test.bal\n" +
"I'm the before suite function!\n" +
"I'm the before function!\n" +
"I'm in test function!\n" +
"I'm the after function!\n" +
"I'm the after suite function!\n" +
"\t[pass] testFunction\n" +
"\n" +
"\t1 passing\n" +
"\t0 failing\n" +
"\t0 skipped\n";
LogLeecher clientLeecher = new LogLeecher(msg);
balClient.runMain("test", clientArgs, envVariables, new String[0],
new LogLeecher[]{clientLeecher}, modulePath.toString());
clientLeecher.waitForText(3000);
}
@Test(description = "Test executing tests in a ballerina file with a service", dependsOnMethods = "testInitProject")
public void testExecutionService() throws Exception {
Path modulePath = tempProjectDirectory.resolve("bar").resolve("tests");
// Test ballerina test
String[] clientArgs = {"hello_service_test.bal"};
String msg = "Compiling tests\n" +
" hello_service_test.bal\n" +
"\n" +
"Running tests\n" +
" hello_service_test.bal\n" +
"I'm the before suite service function!\n" +
"Do your service Tests!\n" +
"I'm the after suite service function!\n" +
"\t[pass] testServiceFunction\n" +
"\n" +
"\t1 passing\n" +
"\t0 failing\n" +
"\t0 skipped\n";
LogLeecher clientLeecher = new LogLeecher(msg);
balClient.runMain("test", clientArgs, envVariables, new String[0],
new LogLeecher[]{clientLeecher}, modulePath.toString());
clientLeecher.waitForText(3000);
}
@Test(description = "Test executing tests in file without tests", dependsOnMethods = "testInitProject")
public void testExecutionWithoutTests() throws Exception {
Path modulePath = tempProjectDirectory.resolve("foo");
// Test ballerina test
String[] clientArgs = {"main.bal"};
String msg = "Compiling tests\n" +
" main.bal\n" +
"\n" +
"Running tests\n" +
" main.bal\n" +
"\tNo tests found\n" +
"\n";
LogLeecher clientLeecher = new LogLeecher(msg);
balClient.runMain("test", clientArgs, envVariables, new String[0],
new LogLeecher[]{clientLeecher}, modulePath.toString());
clientLeecher.waitForText(3000);
}
@Test(description = "Test executing tests in a module without tests", dependsOnMethods = "testInitProject")
public void testExecutionEmptyModule() throws Exception {
Path modulePath = tempProjectDirectory.resolve("noTests");
Files.createDirectories(modulePath);
Files.createDirectories(modulePath.resolve("tests"));
Files.copy(tempProjectDirectory.resolve("foo").resolve("main.bal"), modulePath.resolve("main.bal"),
StandardCopyOption.REPLACE_EXISTING);
// Test ballerina test
String[] clientArgs = {"noTests"};
String msg = "Compiling tests\n" +
" integrationtests/noTests:0.0.1\n" +
"\n" +
"Running tests\n" +
" integrationtests/noTests:0.0.1\n" +
"\tNo tests found\n";
LogLeecher clientLeecher = new LogLeecher(msg);
balClient.runMain("test", clientArgs, envVariables, new String[0],
new LogLeecher[]{clientLeecher}, tempProjectDirectory.toString());
clientLeecher.waitForText(3000);
TestUtils.deleteFiles(modulePath);
}
@Test(description = "Test executing tests in a module with test failures", dependsOnMethods = "testInitProject")
public void testExecutionWithTestFailures() throws Exception {
Path modulePath = tempProjectDirectory.resolve("testFailures");
Files.createDirectories(modulePath);
Path testPath = modulePath.resolve("tests");
Files.createDirectories(testPath);
String incorrectContent = "import ballerina/test;\n" +
"\n" +
"function beforeFunc () {\n" +
" io:println(\"I'm the before function!\");\n" +
"}\n" +
"@test:Config{\n" +
" before:\"beforeFunc\",\n" +
" after:\"afterFunc\"\n" +
"}\n" +
"function testFunction () {\n" +
" io:println(\"I'm in test function!\");\n" +
" test:assertTrue(false , msg = \"Failed!\");\n" +
"}\n" +
"function afterFunc () {\n" +
" io:println(\"I'm the after function!\");\n" +
"}\n";
Files.write(testPath.resolve("main_test.bal"), incorrectContent.getBytes(), StandardOpenOption.CREATE_NEW);
String[] clientArgs = {"testFailures"};
String msg = "Compiling tests\n" +
" integrationtests/testFailures:0.0.1\n" +
"\n" +
"Running tests\n" +
" integrationtests/testFailures:0.0.1\n" +
"I'm the before function!\n" +
"I'm in test function!\n" +
"I'm the after function!\n" +
"\t[fail] testFunction:\n" +
"\t error: ballerina/runtime:CallFailedException, message: call failed\n" +
"\t \tat integrationtests/testFailures:0.0.1:testFunction(main_test.bal:12)\n" +
"\t \tcaused by error, message: failed!\n" +
"\t \tat ballerina/test:assertTrue(assert.bal:31)\n" +
"\n" +
"\t0 passing\n" +
"\t1 failing\n" +
"\t0 skipped\n";
LogLeecher clientLeecher = new LogLeecher(msg);
balClient.runMain("test", clientArgs, envVariables, new String[0],
new LogLeecher[]{clientLeecher}, tempProjectDirectory.toString());
clientLeecher.waitForText(3000);
TestUtils.deleteFiles(modulePath);
}
@Test(description = "Test executing grouped tests", dependsOnMethods = "testInitProject")
public void testGroupTestsExecution() throws Exception {
Path modulePath = tempProjectDirectory.resolve("grouptests");
Files.createDirectories(modulePath);
Path testPath = modulePath.resolve("tests");
Files.createDirectories(testPath);
String testContent = "import ballerina/test;\n" +
"import ballerina/io;\n" +
"@test:Config {\n" +
" groups: [\"g1\"]\n" +
"}\n" +
"function testFunction1() {\n" +
" io:println(\"I'm in test belonging to g1!\");\n" +
" test:assertTrue(true, msg = \"Failed!\");\n" +
"}\n" +
"@test:Config {\n" +
" groups: [\"g1\", \"g2\"]\n" +
"}\n" +
"function testFunction2() {\n" +
" io:println(\"I'm in test belonging to g1 and g2!\");\n" +
" test:assertTrue(true, msg = \"Failed!\");\n" +
"}\n" +
"@test:Config\n" +
"function testFunction3() {\n" +
" io:println(\"I'm the ungrouped test\");\n" +
" test:assertTrue(true, msg = \"Failed!\");\n" +
"}\n";
Files.write(testPath.resolve("main_test.bal"), testContent.getBytes(), StandardOpenOption.CREATE_NEW);
// --groups g1
String msg = "Compiling tests\n" +
" main_test.bal\n" +
"Running tests\n" +
" main_test.bal\n" +
"I'm in test belonging to g1 and g2!\n" +
"I'm in test belonging to g1!\n" +
"\t [pass] testFunction2\n" +
"\t [pass] testFunction1\n" +
"\t 2 passing\n" +
"\t 0 failing\n" +
"\t 0 skipped";
LogLeecher clientLeecher = new LogLeecher(msg);
balClient.runMain("test", new String[] {"--groups" , "g1", "main_test.bal"}, envVariables,
new String[0], new LogLeecher[]{clientLeecher}, testPath.toString());
clientLeecher.waitForText(3000);
// --disable-groups g1
msg = "Compiling tests\n" +
" main_test.bal\n" +
"Running tests\n" +
" main_test.bal\n" +
"I'm the ungrouped test\n" +
"\t [pass] testFunction3\n" +
"\t 1 passing\n" +
"\t 0 failing\n" +
"\t 0 skipped";
clientLeecher = new LogLeecher(msg);
balClient.runMain("test", new String[] {"--disable-groups" , "g1" , "main_test.bal"}, envVariables,
new String[0], new LogLeecher[]{clientLeecher}, testPath.toString());
clientLeecher.waitForText(3000);
// --disable-groups g2
msg = "Compiling tests\n" +
" main_test.bal\n" +
"Running tests\n" +
" main_test.bal\n" +
"I'm the ungrouped test\n" +
"I'm in test belonging to g1!\n" +
"\t [pass] testFunction3\n" +
"\t [pass] testFunction1\n" +
"\t 2 passing\n" +
"\t 0 failing\n" +
"\t 0 skipped";
clientLeecher = new LogLeecher(msg);
balClient.runMain("test", new String[] {"--disable-groups" , "g2", "main_test.bal"}, envVariables,
new String[0], new LogLeecher[]{clientLeecher}, testPath.toString());
clientLeecher.waitForText(3000);
TestUtils.deleteFiles(modulePath);
}
@Test(description = "Test executing multiple grouped tests", dependsOnMethods = "testInitProject")
public void testMultipleGroupTestsExecution() throws Exception {
Path modulePath = tempProjectDirectory.resolve("grouptests");
Files.createDirectories(modulePath);
Path testPath = modulePath.resolve("tests");
Files.createDirectories(testPath);
String testContent = "import ballerina/test;\n" +
"import ballerina/io;\n" +
"@test:Config {\n" +
" groups: [\"g1\"]\n" +
"}\n" +
"function testFunction1() {\n" +
" io:println(\"I'm in test belonging to g1!\");\n" +
" test:assertTrue(true, msg = \"Failed!\");\n" +
"}\n" +
"@test:Config {\n" +
" groups: [\"g1\", \"g2\"]\n" +
"}\n" +
"function testFunction2() {\n" +
" io:println(\"I'm in test belonging to g1 and g2!\");\n" +
" test:assertTrue(true, msg = \"Failed!\");\n" +
"}\n" +
"@test:Config\n" +
"function testFunction3() {\n" +
" io:println(\"I'm the ungrouped test\");\n" +
" test:assertTrue(true, msg = \"Failed!\");\n" +
"}\n";
Files.write(testPath.resolve("main_test.bal"), testContent.getBytes(), StandardOpenOption.CREATE_NEW);
// --groups g1,g2
String msg = "Compiling tests\n" +
" main_test.bal\n" +
"Running tests\n" +
" main_test.bal\n" +
"I'm in test belonging to g1 and g2!\n" +
"I'm in test belonging to g1!\n" +
"\t [pass] testFunction2\n" +
"\t [pass] testFunction1\n" +
"\t 2 passing\n" +
"\t 0 failing\n" +
"\t 0 skipped";
LogLeecher clientLeecher = new LogLeecher(msg);
balClient.runMain("test", new String[] {"--groups" , "g1,g2", "main_test.bal"}, envVariables,
new String[0], new LogLeecher[]{clientLeecher}, testPath.toString());
clientLeecher.waitForText(3000);
// --disable-groups g1,g2
msg = "Compiling tests\n" +
" main_test.bal\n" +
"Running tests\n" +
" main_test.bal\n" +
"I'm the ungrouped test\n" +
"\t [pass] testFunction3\n" +
"\t 1 passing\n" +
"\t 0 failing\n" +
"\t 0 skipped";
clientLeecher = new LogLeecher(msg);
balClient.runMain("test", new String[] {"--disable-groups" , "g1,g2" , "main_test.bal"}, envVariables,
new String[0], new LogLeecher[]{clientLeecher}, testPath.toString());
clientLeecher.waitForText(3000);
TestUtils.deleteFiles(modulePath);
}
@Test(description = "Test executing data driven tests", dependsOnMethods = "testInitProject")
public void testDataDrivenTestExecution() throws Exception {
Path modulePath = tempProjectDirectory.resolve("dataDriven");
Files.createDirectories(modulePath);
Path testPath = modulePath.resolve("tests");
Files.createDirectories(testPath);
String testContent = "import ballerina/test;\n" +
"import ballerina/io;\n" +
"@test:Config {\n" +
" dataProvider: \"ValueProvider\"\n" +
"}\n" +
"function testAddingValues(string fValue, string sValue, string result) { " +
" int value1 = check <int>fValue;\n" +
" int value2 = check <int>sValue;\n" +
" int result1 = check <int>result;\n" +
" io:println(\"Input : [\" + fValue + \",\" + sValue + \",\" + result + \"]\");\n" +
" test:assertEquals(value1 + value2, result1, msg = \"Incorrect Sum\");\n" +
"}\n" +
"function ValueProvider() returns (string[][]) {\n" +
" return [[\"1\", \"2\", \"3\"], [\"10\", \"20\", \"30\"], [\"5\", \"6\", \"11\"]];\n" +
"}\n" +
"@test:Config {\n" +
" dataProvider: \"jsonDataProvider\"\n" +
"}\n" +
"function testJsonObjects(json fValue, json sValue, json result) {\n" +
" json a = { \"a\": \"a\" };\n" +
" json b = { \"b\": \"b\" };\n" +
" json c = { \"c\": \"c\" };\n" +
" test:assertEquals(fValue, a, msg = \"json data provider failed\");\n" +
" test:assertEquals(sValue, b, msg = \"json data provider failed\");\n" +
" test:assertEquals(result, c, msg = \"json data provider failed\");\n" +
"}\n" +
"function jsonDataProvider() returns (json[][]) {\n" +
" return [[{ \"a\": \"a\" }, { \"b\": \"b\" }, { \"c\": \"c\" }]];\n" +
"}\n";
Files.write(testPath.resolve("main_test.bal"), testContent.getBytes(), StandardOpenOption.CREATE_NEW);
String msg = "Compiling tests\n" +
" main_test.bal\n" +
"\n" +
"Running tests\n" +
" main_test.bal\n" +
"Input : [1,2,3]\n" +
"Input : [10,20,30]\n" +
"Input : [5,6,11]\n" +
"\t [pass] testJsonObjects\n" +
"\t [pass] testAddingValues\n" +
"\t [pass] testAddingValues\n" +
"\t [pass] testAddingValues\n" +
"\t 4 passing\n" +
"\t 0 failing\n" +
"\t 0 skipped";
LogLeecher clientLeecher = new LogLeecher(msg);
balClient.runMain("test", new String[]{"main_test.bal"}, envVariables, new String[0],
new LogLeecher[]{clientLeecher}, testPath.toString());
clientLeecher.waitForText(3000);
TestUtils.deleteFiles(modulePath);
}
@Test(description = "Test execution order of tests", dependsOnMethods = "testInitProject")
public void testExecutionOrder() throws Exception {
Path modulePath = tempProjectDirectory.resolve("executionOrder");
Files.createDirectories(modulePath);
Path testPath = modulePath.resolve("tests");
Files.createDirectories(testPath);
String testContent = "import ballerina/test;\n" +
"import ballerina/io;\n" +
"@test:Config {\n" +
" dependsOn: [\"testFunction3\"]\n" +
"}\n" +
"function testFunction1() {\n" +
" io:println(\"I'm in test function 1!\");\n" +
" test:assertTrue(true, msg = \"Failed!\");\n" +
"}\n" +
"@test:Config {\n" +
" dependsOn: [\"testFunction1\"]\n" +
"}\n" +
"function testFunction2() {\n" +
" io:println(\"I'm in test function 2!\");\n" +
" test:assertTrue(true, msg = \"Failed!\");\n" +
"}\n" +
"@test:Config\n" +
"function testFunction3() {\n" +
" io:println(\"I'm in test function 3!\");\n" +
" test:assertTrue(true, msg = \"Failed!\");\n" +
"}\n";
Files.write(testPath.resolve("main_test.bal"), testContent.getBytes(), StandardOpenOption.CREATE_NEW);
String msg = "Compiling tests\n" +
" main_test.bal\n" +
"\n" +
"Running tests\n" +
" main_test.bal\n" +
"I'm in test function 3!\n" +
"I'm in test function 1!\n" +
"I'm in test function 2!\n" +
"\t [pass] testFunction3\n" +
"\t [pass] testFunction1\n" +
"\t [pass] testFunction2\n" +
"\t 3 passing\n" +
"\t 0 failing\n" +
"\t 0 skipped";
LogLeecher clientLeecher = new LogLeecher(msg);
balClient.runMain("test", new String[]{"main_test.bal"}, envVariables, new String[0],
new LogLeecher[]{clientLeecher}, testPath.toString());
clientLeecher.waitForText(3000);
TestUtils.deleteFiles(modulePath);
}
@Test(description = "Test execution of function mock tests", dependsOnMethods = "testInitProject")
public void testFunctionMockTests() throws Exception {
Path modulePath = tempProjectDirectory.resolve("functionMock");
Files.createDirectories(modulePath);
Path testPath = modulePath.resolve("tests");
Files.createDirectories(testPath);
String testContent = "import ballerina/test;\n" +
"import ballerina/io;\n" +
"@test:Mock {\n" +
" moduleName: \".\",\n" +
" functionName: \"intAdd\"\n" +
"}\n" +
"public function mockIntAdd(int a, int b) returns int {\n" +
" io:println(\"I'm the mock function!\");\n" +
" return (a - b);\n" +
"}\n" +
"@test:Config\n" +
"function testAssertIntEquals() {\n" +
" int answer = 0;\n" +
" answer = intAdd(5, 3);\n" +
" io:println(\"Function mocking test\");\n" +
" test:assertEquals(answer, 2, msg = \"function mocking failed\");\n" +
"}\n" +
"public function intAdd(int a, int b) returns int {\n" +
" return (a + b);\n" +
"}\n";
Files.write(testPath.resolve("main_test.bal"), testContent.getBytes(), StandardOpenOption.CREATE_NEW);
String msg = "Compiling tests\n" +
" main_test.bal\n" +
"\n" +
"Running tests\n" +
" main_test.bal\n" +
"I'm the mock function!\n" +
"Function mocking test\n" +
"\t [pass] testAssertIntEquals\n" +
"\t 1 passing\n" +
"\t 0 failing\n" +
"\t 0 skipped";
LogLeecher clientLeecher = new LogLeecher(msg);
balClient.runMain("test", new String[]{"main_test.bal"}, envVariables, new String[0],
new LogLeecher[]{clientLeecher}, testPath.toString());
clientLeecher.waitForText(3000);
TestUtils.deleteFiles(modulePath);
}
@AfterClass
private void cleanup() throws Exception {
TestUtils.deleteFiles(tempProjectDirectory);
}
}
| UTF-8 | Java | 28,410 | java | TestExecutionTestCase.java | Java | [
{
"context": " \"ballerina: started HTTP/WS listener 0.0.0.0:9090\\n\" +\n \"I'm the before su",
"end": 3662,
"score": 0.5844767093658447,
"start": 3662,
"tag": "IP_ADDRESS",
"value": ""
},
{
"context": " \"ballerina: started HTTP/WS listener 0.0.0.... | null | [] | /*
* Copyright (c) 2018, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
* WSO2 Inc. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.ballerinalang.test.packaging;
import org.ballerinalang.test.BaseTest;
import org.ballerinalang.test.context.LogLeecher;
import org.ballerinalang.test.utils.TestUtils;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Ignore;
import org.testng.annotations.Test;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.StandardCopyOption;
import java.nio.file.StandardOpenOption;
import java.util.Map;
/**
* Testing executing tests in a project using the test command.
*
* @since 0.982.0
*/
@Ignore
public class TestExecutionTestCase extends BaseTest {
private Path tempProjectDirectory;
private Map<String, String> envVariables;
@BeforeClass()
public void setUp() throws IOException {
tempProjectDirectory = Files.createTempDirectory("bal-test-integration-packaging-project-");
envVariables = TestUtils.getEnvVariables();
}
@Test(description = "Test creating a project")
public void testInitProject() throws Exception {
String[] clientArgsForInit = {"-i"};
String[] options = {"\n", "integrationtests\n", "\n", "m\n", "foo\n", "s\n", "bar\n", "f\n"};
balClient.runMain("init", clientArgsForInit, envVariables, options, new LogLeecher[0],
tempProjectDirectory.toString());
}
@Test(description = "Test executing tests in a main module", dependsOnMethods = "testInitProject")
public void testExecutionOfMainModule() throws Exception {
String[] clientArgs = {"foo"};
String msg = "Compiling tests\n" +
" integrationtests/foo:0.0.1\n" +
"\n" +
"Running tests\n" +
" integrationtests/foo:0.0.1\n" +
"I'm the before suite function!\n" +
"I'm the before function!\n" +
"I'm in test function!\n" +
"I'm the after function!\n" +
"I'm the after suite function!\n" +
"\t[pass] testFunction\n" +
"\n" +
"\t1 passing\n" +
"\t0 failing\n" +
"\t0 skipped\n";
LogLeecher clientLeecher = new LogLeecher(msg);
balClient.runMain("test", clientArgs, envVariables, new String[0],
new LogLeecher[]{clientLeecher}, tempProjectDirectory.toString());
clientLeecher.waitForText(3000);
}
@Test(description = "Test executing tests in a service module", dependsOnMethods = "testInitProject")
public void testExecutionOfServiceModule() throws Exception {
String[] clientArgs = {"bar"};
String msg = "Compiling tests\n" +
" integrationtests/bar:0.0.1\n" +
"\n" +
"Running tests\n" +
" integrationtests/bar:0.0.1\n" +
"ballerina: started HTTP/WS listener 0.0.0.0:9090\n" +
"I'm the before suite service function!\n" +
"Do your service Tests!\n" +
"I'm the after suite service function!\n" +
"\t[pass] testServiceFunction\n" +
"\n" +
"\t1 passing\n" +
"\t0 failing\n" +
"\t0 skipped\n";
LogLeecher clientLeecher = new LogLeecher(msg);
balClient.runMain("test", clientArgs, envVariables, new String[0],
new LogLeecher[]{clientLeecher}, tempProjectDirectory.toString());
clientLeecher.waitForText(3000);
}
@Test(description = "Test executing tests in a project", dependsOnMethods = "testInitProject")
public void testExecutionOfProject() throws Exception {
String msg = "Compiling tests\n" +
" integrationtests/foo:0.0.1\n" +
" integrationtests/bar:0.0.1\n" +
"\n" +
"Running tests\n" +
" integrationtests/foo:0.0.1\n" +
"I'm the before suite function!\n" +
"I'm the before function!\n" +
"I'm in test function!\n" +
"I'm the after function!\n" +
"I'm the after suite function!\n" +
"\t[pass] testFunction\n" +
"\n" +
"\t1 passing\n" +
"\t0 failing\n" +
"\t0 skipped\n" +
"\n" +
" integrationtests/bar:0.0.1\n" +
"ballerina: started HTTP/WS listener 0.0.0.0:9090\n" +
"I'm the before suite service function!\n" +
"Do your service Tests!\n" +
"I'm the after suite service function!\n" +
"\t[pass] testServiceFunction\n" +
"\n" +
"\t1 passing\n" +
"\t0 failing\n" +
"\t0 skipped\n";
LogLeecher clientLeecher = new LogLeecher(msg);
balClient.runMain("test", new String[0], envVariables, new String[0],
new LogLeecher[]{clientLeecher}, tempProjectDirectory.toString());
clientLeecher.waitForText(3000);
}
@Test(description = "Test executing tests in a ballerina file with main", dependsOnMethods = "testInitProject")
public void testExecutionMain() throws Exception {
Path modulePath = tempProjectDirectory.resolve("foo").resolve("tests");
// Test ballerina test
String[] clientArgs = {"main_test.bal"};
String msg = "Compiling tests\n" +
" main_test.bal\n" +
"\n" +
"Running tests\n" +
" main_test.bal\n" +
"I'm the before suite function!\n" +
"I'm the before function!\n" +
"I'm in test function!\n" +
"I'm the after function!\n" +
"I'm the after suite function!\n" +
"\t[pass] testFunction\n" +
"\n" +
"\t1 passing\n" +
"\t0 failing\n" +
"\t0 skipped\n";
LogLeecher clientLeecher = new LogLeecher(msg);
balClient.runMain("test", clientArgs, envVariables, new String[0],
new LogLeecher[]{clientLeecher}, modulePath.toString());
clientLeecher.waitForText(3000);
}
@Test(description = "Test executing tests in a ballerina file with a service", dependsOnMethods = "testInitProject")
public void testExecutionService() throws Exception {
Path modulePath = tempProjectDirectory.resolve("bar").resolve("tests");
// Test ballerina test
String[] clientArgs = {"hello_service_test.bal"};
String msg = "Compiling tests\n" +
" hello_service_test.bal\n" +
"\n" +
"Running tests\n" +
" hello_service_test.bal\n" +
"I'm the before suite service function!\n" +
"Do your service Tests!\n" +
"I'm the after suite service function!\n" +
"\t[pass] testServiceFunction\n" +
"\n" +
"\t1 passing\n" +
"\t0 failing\n" +
"\t0 skipped\n";
LogLeecher clientLeecher = new LogLeecher(msg);
balClient.runMain("test", clientArgs, envVariables, new String[0],
new LogLeecher[]{clientLeecher}, modulePath.toString());
clientLeecher.waitForText(3000);
}
@Test(description = "Test executing tests in file without tests", dependsOnMethods = "testInitProject")
public void testExecutionWithoutTests() throws Exception {
Path modulePath = tempProjectDirectory.resolve("foo");
// Test ballerina test
String[] clientArgs = {"main.bal"};
String msg = "Compiling tests\n" +
" main.bal\n" +
"\n" +
"Running tests\n" +
" main.bal\n" +
"\tNo tests found\n" +
"\n";
LogLeecher clientLeecher = new LogLeecher(msg);
balClient.runMain("test", clientArgs, envVariables, new String[0],
new LogLeecher[]{clientLeecher}, modulePath.toString());
clientLeecher.waitForText(3000);
}
@Test(description = "Test executing tests in a module without tests", dependsOnMethods = "testInitProject")
public void testExecutionEmptyModule() throws Exception {
Path modulePath = tempProjectDirectory.resolve("noTests");
Files.createDirectories(modulePath);
Files.createDirectories(modulePath.resolve("tests"));
Files.copy(tempProjectDirectory.resolve("foo").resolve("main.bal"), modulePath.resolve("main.bal"),
StandardCopyOption.REPLACE_EXISTING);
// Test ballerina test
String[] clientArgs = {"noTests"};
String msg = "Compiling tests\n" +
" integrationtests/noTests:0.0.1\n" +
"\n" +
"Running tests\n" +
" integrationtests/noTests:0.0.1\n" +
"\tNo tests found\n";
LogLeecher clientLeecher = new LogLeecher(msg);
balClient.runMain("test", clientArgs, envVariables, new String[0],
new LogLeecher[]{clientLeecher}, tempProjectDirectory.toString());
clientLeecher.waitForText(3000);
TestUtils.deleteFiles(modulePath);
}
@Test(description = "Test executing tests in a module with test failures", dependsOnMethods = "testInitProject")
public void testExecutionWithTestFailures() throws Exception {
Path modulePath = tempProjectDirectory.resolve("testFailures");
Files.createDirectories(modulePath);
Path testPath = modulePath.resolve("tests");
Files.createDirectories(testPath);
String incorrectContent = "import ballerina/test;\n" +
"\n" +
"function beforeFunc () {\n" +
" io:println(\"I'm the before function!\");\n" +
"}\n" +
"@test:Config{\n" +
" before:\"beforeFunc\",\n" +
" after:\"afterFunc\"\n" +
"}\n" +
"function testFunction () {\n" +
" io:println(\"I'm in test function!\");\n" +
" test:assertTrue(false , msg = \"Failed!\");\n" +
"}\n" +
"function afterFunc () {\n" +
" io:println(\"I'm the after function!\");\n" +
"}\n";
Files.write(testPath.resolve("main_test.bal"), incorrectContent.getBytes(), StandardOpenOption.CREATE_NEW);
String[] clientArgs = {"testFailures"};
String msg = "Compiling tests\n" +
" integrationtests/testFailures:0.0.1\n" +
"\n" +
"Running tests\n" +
" integrationtests/testFailures:0.0.1\n" +
"I'm the before function!\n" +
"I'm in test function!\n" +
"I'm the after function!\n" +
"\t[fail] testFunction:\n" +
"\t error: ballerina/runtime:CallFailedException, message: call failed\n" +
"\t \tat integrationtests/testFailures:0.0.1:testFunction(main_test.bal:12)\n" +
"\t \tcaused by error, message: failed!\n" +
"\t \tat ballerina/test:assertTrue(assert.bal:31)\n" +
"\n" +
"\t0 passing\n" +
"\t1 failing\n" +
"\t0 skipped\n";
LogLeecher clientLeecher = new LogLeecher(msg);
balClient.runMain("test", clientArgs, envVariables, new String[0],
new LogLeecher[]{clientLeecher}, tempProjectDirectory.toString());
clientLeecher.waitForText(3000);
TestUtils.deleteFiles(modulePath);
}
@Test(description = "Test executing grouped tests", dependsOnMethods = "testInitProject")
public void testGroupTestsExecution() throws Exception {
Path modulePath = tempProjectDirectory.resolve("grouptests");
Files.createDirectories(modulePath);
Path testPath = modulePath.resolve("tests");
Files.createDirectories(testPath);
String testContent = "import ballerina/test;\n" +
"import ballerina/io;\n" +
"@test:Config {\n" +
" groups: [\"g1\"]\n" +
"}\n" +
"function testFunction1() {\n" +
" io:println(\"I'm in test belonging to g1!\");\n" +
" test:assertTrue(true, msg = \"Failed!\");\n" +
"}\n" +
"@test:Config {\n" +
" groups: [\"g1\", \"g2\"]\n" +
"}\n" +
"function testFunction2() {\n" +
" io:println(\"I'm in test belonging to g1 and g2!\");\n" +
" test:assertTrue(true, msg = \"Failed!\");\n" +
"}\n" +
"@test:Config\n" +
"function testFunction3() {\n" +
" io:println(\"I'm the ungrouped test\");\n" +
" test:assertTrue(true, msg = \"Failed!\");\n" +
"}\n";
Files.write(testPath.resolve("main_test.bal"), testContent.getBytes(), StandardOpenOption.CREATE_NEW);
// --groups g1
String msg = "Compiling tests\n" +
" main_test.bal\n" +
"Running tests\n" +
" main_test.bal\n" +
"I'm in test belonging to g1 and g2!\n" +
"I'm in test belonging to g1!\n" +
"\t [pass] testFunction2\n" +
"\t [pass] testFunction1\n" +
"\t 2 passing\n" +
"\t 0 failing\n" +
"\t 0 skipped";
LogLeecher clientLeecher = new LogLeecher(msg);
balClient.runMain("test", new String[] {"--groups" , "g1", "main_test.bal"}, envVariables,
new String[0], new LogLeecher[]{clientLeecher}, testPath.toString());
clientLeecher.waitForText(3000);
// --disable-groups g1
msg = "Compiling tests\n" +
" main_test.bal\n" +
"Running tests\n" +
" main_test.bal\n" +
"I'm the ungrouped test\n" +
"\t [pass] testFunction3\n" +
"\t 1 passing\n" +
"\t 0 failing\n" +
"\t 0 skipped";
clientLeecher = new LogLeecher(msg);
balClient.runMain("test", new String[] {"--disable-groups" , "g1" , "main_test.bal"}, envVariables,
new String[0], new LogLeecher[]{clientLeecher}, testPath.toString());
clientLeecher.waitForText(3000);
// --disable-groups g2
msg = "Compiling tests\n" +
" main_test.bal\n" +
"Running tests\n" +
" main_test.bal\n" +
"I'm the ungrouped test\n" +
"I'm in test belonging to g1!\n" +
"\t [pass] testFunction3\n" +
"\t [pass] testFunction1\n" +
"\t 2 passing\n" +
"\t 0 failing\n" +
"\t 0 skipped";
clientLeecher = new LogLeecher(msg);
balClient.runMain("test", new String[] {"--disable-groups" , "g2", "main_test.bal"}, envVariables,
new String[0], new LogLeecher[]{clientLeecher}, testPath.toString());
clientLeecher.waitForText(3000);
TestUtils.deleteFiles(modulePath);
}
@Test(description = "Test executing multiple grouped tests", dependsOnMethods = "testInitProject")
public void testMultipleGroupTestsExecution() throws Exception {
Path modulePath = tempProjectDirectory.resolve("grouptests");
Files.createDirectories(modulePath);
Path testPath = modulePath.resolve("tests");
Files.createDirectories(testPath);
String testContent = "import ballerina/test;\n" +
"import ballerina/io;\n" +
"@test:Config {\n" +
" groups: [\"g1\"]\n" +
"}\n" +
"function testFunction1() {\n" +
" io:println(\"I'm in test belonging to g1!\");\n" +
" test:assertTrue(true, msg = \"Failed!\");\n" +
"}\n" +
"@test:Config {\n" +
" groups: [\"g1\", \"g2\"]\n" +
"}\n" +
"function testFunction2() {\n" +
" io:println(\"I'm in test belonging to g1 and g2!\");\n" +
" test:assertTrue(true, msg = \"Failed!\");\n" +
"}\n" +
"@test:Config\n" +
"function testFunction3() {\n" +
" io:println(\"I'm the ungrouped test\");\n" +
" test:assertTrue(true, msg = \"Failed!\");\n" +
"}\n";
Files.write(testPath.resolve("main_test.bal"), testContent.getBytes(), StandardOpenOption.CREATE_NEW);
// --groups g1,g2
String msg = "Compiling tests\n" +
" main_test.bal\n" +
"Running tests\n" +
" main_test.bal\n" +
"I'm in test belonging to g1 and g2!\n" +
"I'm in test belonging to g1!\n" +
"\t [pass] testFunction2\n" +
"\t [pass] testFunction1\n" +
"\t 2 passing\n" +
"\t 0 failing\n" +
"\t 0 skipped";
LogLeecher clientLeecher = new LogLeecher(msg);
balClient.runMain("test", new String[] {"--groups" , "g1,g2", "main_test.bal"}, envVariables,
new String[0], new LogLeecher[]{clientLeecher}, testPath.toString());
clientLeecher.waitForText(3000);
// --disable-groups g1,g2
msg = "Compiling tests\n" +
" main_test.bal\n" +
"Running tests\n" +
" main_test.bal\n" +
"I'm the ungrouped test\n" +
"\t [pass] testFunction3\n" +
"\t 1 passing\n" +
"\t 0 failing\n" +
"\t 0 skipped";
clientLeecher = new LogLeecher(msg);
balClient.runMain("test", new String[] {"--disable-groups" , "g1,g2" , "main_test.bal"}, envVariables,
new String[0], new LogLeecher[]{clientLeecher}, testPath.toString());
clientLeecher.waitForText(3000);
TestUtils.deleteFiles(modulePath);
}
@Test(description = "Test executing data driven tests", dependsOnMethods = "testInitProject")
public void testDataDrivenTestExecution() throws Exception {
Path modulePath = tempProjectDirectory.resolve("dataDriven");
Files.createDirectories(modulePath);
Path testPath = modulePath.resolve("tests");
Files.createDirectories(testPath);
String testContent = "import ballerina/test;\n" +
"import ballerina/io;\n" +
"@test:Config {\n" +
" dataProvider: \"ValueProvider\"\n" +
"}\n" +
"function testAddingValues(string fValue, string sValue, string result) { " +
" int value1 = check <int>fValue;\n" +
" int value2 = check <int>sValue;\n" +
" int result1 = check <int>result;\n" +
" io:println(\"Input : [\" + fValue + \",\" + sValue + \",\" + result + \"]\");\n" +
" test:assertEquals(value1 + value2, result1, msg = \"Incorrect Sum\");\n" +
"}\n" +
"function ValueProvider() returns (string[][]) {\n" +
" return [[\"1\", \"2\", \"3\"], [\"10\", \"20\", \"30\"], [\"5\", \"6\", \"11\"]];\n" +
"}\n" +
"@test:Config {\n" +
" dataProvider: \"jsonDataProvider\"\n" +
"}\n" +
"function testJsonObjects(json fValue, json sValue, json result) {\n" +
" json a = { \"a\": \"a\" };\n" +
" json b = { \"b\": \"b\" };\n" +
" json c = { \"c\": \"c\" };\n" +
" test:assertEquals(fValue, a, msg = \"json data provider failed\");\n" +
" test:assertEquals(sValue, b, msg = \"json data provider failed\");\n" +
" test:assertEquals(result, c, msg = \"json data provider failed\");\n" +
"}\n" +
"function jsonDataProvider() returns (json[][]) {\n" +
" return [[{ \"a\": \"a\" }, { \"b\": \"b\" }, { \"c\": \"c\" }]];\n" +
"}\n";
Files.write(testPath.resolve("main_test.bal"), testContent.getBytes(), StandardOpenOption.CREATE_NEW);
String msg = "Compiling tests\n" +
" main_test.bal\n" +
"\n" +
"Running tests\n" +
" main_test.bal\n" +
"Input : [1,2,3]\n" +
"Input : [10,20,30]\n" +
"Input : [5,6,11]\n" +
"\t [pass] testJsonObjects\n" +
"\t [pass] testAddingValues\n" +
"\t [pass] testAddingValues\n" +
"\t [pass] testAddingValues\n" +
"\t 4 passing\n" +
"\t 0 failing\n" +
"\t 0 skipped";
LogLeecher clientLeecher = new LogLeecher(msg);
balClient.runMain("test", new String[]{"main_test.bal"}, envVariables, new String[0],
new LogLeecher[]{clientLeecher}, testPath.toString());
clientLeecher.waitForText(3000);
TestUtils.deleteFiles(modulePath);
}
@Test(description = "Test execution order of tests", dependsOnMethods = "testInitProject")
public void testExecutionOrder() throws Exception {
Path modulePath = tempProjectDirectory.resolve("executionOrder");
Files.createDirectories(modulePath);
Path testPath = modulePath.resolve("tests");
Files.createDirectories(testPath);
String testContent = "import ballerina/test;\n" +
"import ballerina/io;\n" +
"@test:Config {\n" +
" dependsOn: [\"testFunction3\"]\n" +
"}\n" +
"function testFunction1() {\n" +
" io:println(\"I'm in test function 1!\");\n" +
" test:assertTrue(true, msg = \"Failed!\");\n" +
"}\n" +
"@test:Config {\n" +
" dependsOn: [\"testFunction1\"]\n" +
"}\n" +
"function testFunction2() {\n" +
" io:println(\"I'm in test function 2!\");\n" +
" test:assertTrue(true, msg = \"Failed!\");\n" +
"}\n" +
"@test:Config\n" +
"function testFunction3() {\n" +
" io:println(\"I'm in test function 3!\");\n" +
" test:assertTrue(true, msg = \"Failed!\");\n" +
"}\n";
Files.write(testPath.resolve("main_test.bal"), testContent.getBytes(), StandardOpenOption.CREATE_NEW);
String msg = "Compiling tests\n" +
" main_test.bal\n" +
"\n" +
"Running tests\n" +
" main_test.bal\n" +
"I'm in test function 3!\n" +
"I'm in test function 1!\n" +
"I'm in test function 2!\n" +
"\t [pass] testFunction3\n" +
"\t [pass] testFunction1\n" +
"\t [pass] testFunction2\n" +
"\t 3 passing\n" +
"\t 0 failing\n" +
"\t 0 skipped";
LogLeecher clientLeecher = new LogLeecher(msg);
balClient.runMain("test", new String[]{"main_test.bal"}, envVariables, new String[0],
new LogLeecher[]{clientLeecher}, testPath.toString());
clientLeecher.waitForText(3000);
TestUtils.deleteFiles(modulePath);
}
@Test(description = "Test execution of function mock tests", dependsOnMethods = "testInitProject")
public void testFunctionMockTests() throws Exception {
Path modulePath = tempProjectDirectory.resolve("functionMock");
Files.createDirectories(modulePath);
Path testPath = modulePath.resolve("tests");
Files.createDirectories(testPath);
String testContent = "import ballerina/test;\n" +
"import ballerina/io;\n" +
"@test:Mock {\n" +
" moduleName: \".\",\n" +
" functionName: \"intAdd\"\n" +
"}\n" +
"public function mockIntAdd(int a, int b) returns int {\n" +
" io:println(\"I'm the mock function!\");\n" +
" return (a - b);\n" +
"}\n" +
"@test:Config\n" +
"function testAssertIntEquals() {\n" +
" int answer = 0;\n" +
" answer = intAdd(5, 3);\n" +
" io:println(\"Function mocking test\");\n" +
" test:assertEquals(answer, 2, msg = \"function mocking failed\");\n" +
"}\n" +
"public function intAdd(int a, int b) returns int {\n" +
" return (a + b);\n" +
"}\n";
Files.write(testPath.resolve("main_test.bal"), testContent.getBytes(), StandardOpenOption.CREATE_NEW);
String msg = "Compiling tests\n" +
" main_test.bal\n" +
"\n" +
"Running tests\n" +
" main_test.bal\n" +
"I'm the mock function!\n" +
"Function mocking test\n" +
"\t [pass] testAssertIntEquals\n" +
"\t 1 passing\n" +
"\t 0 failing\n" +
"\t 0 skipped";
LogLeecher clientLeecher = new LogLeecher(msg);
balClient.runMain("test", new String[]{"main_test.bal"}, envVariables, new String[0],
new LogLeecher[]{clientLeecher}, testPath.toString());
clientLeecher.waitForText(3000);
TestUtils.deleteFiles(modulePath);
}
@AfterClass
private void cleanup() throws Exception {
TestUtils.deleteFiles(tempProjectDirectory);
}
}
| 28,410 | 0.492855 | 0.48233 | 620 | 44.822582 | 26.84593 | 120 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.624194 | false | false | 9 |
679b664d80cd3693599a89d4606577859a2c217a | 39,075,612,462,686 | 10a6abad4ce649b89264b86678350fd37a9be41e | /Face_Detection/src/main/java/com/example/demo/model/CourseAssign.java | 1ad3a14b9a90c880c23a7157edf626b527712340 | [] | no_license | mirajulislam/Final-Year-Project | https://github.com/mirajulislam/Final-Year-Project | e3a204a58e6ae965eecb5c61061244b0eac9903a | 9321bd78367acdf85cde03754facef105259ca17 | refs/heads/master | 2020-07-26T10:33:52.309000 | 2020-03-13T17:01:54 | 2020-03-13T17:01:54 | 208,618,012 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.example.demo.model;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
@Entity
@Table(name = "student_course_assign")
public class CourseAssign {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private int id;
private int studentId;
private String courseCode;
private String departmentShortName;
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public int getStudentId() {
return studentId;
}
public void setStudentId(int studentId) {
this.studentId = studentId;
}
public String getCourseCode() {
return courseCode;
}
public void setCourseCode(String courseCode) {
this.courseCode = courseCode;
}
public String getDepartmentShortName() {
return departmentShortName;
}
public void setDepartmentShortName(String departmentShortName) {
this.departmentShortName = departmentShortName;
}
}
| UTF-8 | Java | 1,046 | java | CourseAssign.java | Java | [] | null | [] | package com.example.demo.model;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
@Entity
@Table(name = "student_course_assign")
public class CourseAssign {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private int id;
private int studentId;
private String courseCode;
private String departmentShortName;
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public int getStudentId() {
return studentId;
}
public void setStudentId(int studentId) {
this.studentId = studentId;
}
public String getCourseCode() {
return courseCode;
}
public void setCourseCode(String courseCode) {
this.courseCode = courseCode;
}
public String getDepartmentShortName() {
return departmentShortName;
}
public void setDepartmentShortName(String departmentShortName) {
this.departmentShortName = departmentShortName;
}
}
| 1,046 | 0.736138 | 0.736138 | 44 | 21.772728 | 17.151548 | 65 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.295455 | false | false | 9 |
bd28ac5292ec16881c48ca7161013e3e34fb7561 | 39,075,612,464,260 | 8cbd3e4ab0556e757590c69986dfc7e8eb8a13e9 | /src/main/java/com/example/storefrontdemo/services/OrderDetailService.java | f53ec45520ba894f142ccf41556c68fbfc95e541 | [] | no_license | KarenLatsch/store-demo | https://github.com/KarenLatsch/store-demo | 6d01b95168b4dea24eaaaec5ef40ce6af2e38569 | 28714f2e91f6208757582b23a863cab8fee5c24b | refs/heads/master | 2021-07-12T02:44:39.022000 | 2020-10-26T17:53:21 | 2020-10-26T17:53:21 | 215,146,866 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.example.storefrontdemo.services;
import com.example.storefrontdemo.domain.entities.OrderDetail;
import java.util.List;
public interface OrderDetailService extends CRUDService<OrderDetail> {
List<OrderDetail> findByOrderId(Integer orderId);
}
| UTF-8 | Java | 264 | java | OrderDetailService.java | Java | [] | null | [] | package com.example.storefrontdemo.services;
import com.example.storefrontdemo.domain.entities.OrderDetail;
import java.util.List;
public interface OrderDetailService extends CRUDService<OrderDetail> {
List<OrderDetail> findByOrderId(Integer orderId);
}
| 264 | 0.818182 | 0.818182 | 10 | 25.4 | 27.626799 | 70 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.4 | false | false | 9 |
6017164649137d580089cc7fa823a05c53b6109d | 39,350,490,371,324 | 6f2f4f2eac6f2b6d00f1dd438bf25dd0b65d6f25 | /exeframe-elastic-common/src/main/java/com/asiainfo/exeframe/elastic/config/tf/TFDefinition.java | 380494dd993edb5a7bfc2602ddd7732a2083be44 | [] | no_license | qiangyuannice/exeframe-elastic | https://github.com/qiangyuannice/exeframe-elastic | 7f3cf2bbd2db39b274d96e2862e000c5743aa6ac | 8190e11886b9a3b0e90d762b8f083f1e56f82fc6 | refs/heads/master | 2021-09-25T20:44:42.072000 | 2018-10-25T07:36:20 | 2018-10-25T07:36:20 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.asiainfo.exeframe.elastic.config.tf;
import com.asiainfo.exeframe.elastic.config.ProcessDefinition;
import com.asiainfo.exeframe.elastic.config.ProcessType;
public class TFDefinition implements ProcessDefinition {
@Override
public ProcessType getProcessType() {
return ProcessType.TF;
}
}
| UTF-8 | Java | 323 | java | TFDefinition.java | Java | [] | null | [] | package com.asiainfo.exeframe.elastic.config.tf;
import com.asiainfo.exeframe.elastic.config.ProcessDefinition;
import com.asiainfo.exeframe.elastic.config.ProcessType;
public class TFDefinition implements ProcessDefinition {
@Override
public ProcessType getProcessType() {
return ProcessType.TF;
}
}
| 323 | 0.783282 | 0.783282 | 11 | 28.363636 | 24.019964 | 62 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.363636 | false | false | 9 |
ba2cb0f1f7544a4dd21cd0675ae8a877e34d0183 | 14,491,219,721,164 | f9dc394bcbcf30b494bc1a035df8e8754b8786b3 | /GymMaster/app/src/main/java/com/example/gymmaster/StopwatchFragment.java | 5de310a876be0b6ddeb757bd0d6bb4bac18d9d69 | [] | no_license | eskeemos/JAVA-ANDROID_APPS | https://github.com/eskeemos/JAVA-ANDROID_APPS | 47f218b97934f4727db9e0cc506418c7ad9f94d9 | aeb1e01f10307ce28f412b8bc106629c10d53cfd | refs/heads/master | 2023-08-14T07:22:57.473000 | 2021-10-21T08:07:52 | 2021-10-21T08:07:52 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.example.gymmaster;
import android.annotation.SuppressLint;
import android.app.Fragment;
import android.os.Bundle;
import android.os.Handler;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.TextView;
import androidx.annotation.NonNull;
public class StopwatchFragment extends Fragment {
private int seconds = 0;
private boolean running = false;
private boolean wasRunning = false;
public StopwatchFragment() {
super();
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if(savedInstanceState != null) {
seconds = savedInstanceState.getInt("seconds");
running = savedInstanceState.getBoolean("running");
wasRunning = savedInstanceState.getBoolean("wasRunning");
}
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_stopwatch, container, false);
runTimer(view);
Button bStart = view.findViewById(R.id.bStart);
bStart.setOnClickListener(this::StartTimer);
Button bStop = view.findViewById(R.id.bStop);
bStop.setOnClickListener(this::StopTimer);
Button bRestart = view.findViewById(R.id.bRestart);
bRestart.setOnClickListener(this::RestartTimer);
return view;
}
private void runTimer(View view) {
TextView tvTime = view.findViewById(R.id.tvTime);
Handler handler = new Handler();
handler.post(new Runnable() {
@Override
public void run() {
int h = seconds / 3600;
int m = (seconds / 3600) / 60;
int s = seconds % 60;
@SuppressLint("DefaultLocale") String time = String.format("%d:%02d:%02d",h,m,s);
tvTime.setText(time);
if(running) seconds++;
handler.postDelayed(this, 1000);
}
});
}
private void RestartTimer(View view) {
seconds = 0;
}
private void StopTimer(View view) {
running = false;
}
private void StartTimer(View view) {
running = true;
}
@Override
public void onSaveInstanceState(@NonNull Bundle outState) {
super.onSaveInstanceState(outState);
outState.putInt("seconds", seconds);
outState.putBoolean("running", running);
outState.putBoolean("wasRunning", wasRunning);
}
@Override
public void onPause() {
super.onPause();
wasRunning = running;
running = false;
}
@Override
public void onStop() {
super.onStop();
}
@Override
public void onResume() {
super.onResume();
running = wasRunning;
}
} | UTF-8 | Java | 2,939 | java | StopwatchFragment.java | Java | [] | null | [] | package com.example.gymmaster;
import android.annotation.SuppressLint;
import android.app.Fragment;
import android.os.Bundle;
import android.os.Handler;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.TextView;
import androidx.annotation.NonNull;
public class StopwatchFragment extends Fragment {
private int seconds = 0;
private boolean running = false;
private boolean wasRunning = false;
public StopwatchFragment() {
super();
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if(savedInstanceState != null) {
seconds = savedInstanceState.getInt("seconds");
running = savedInstanceState.getBoolean("running");
wasRunning = savedInstanceState.getBoolean("wasRunning");
}
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_stopwatch, container, false);
runTimer(view);
Button bStart = view.findViewById(R.id.bStart);
bStart.setOnClickListener(this::StartTimer);
Button bStop = view.findViewById(R.id.bStop);
bStop.setOnClickListener(this::StopTimer);
Button bRestart = view.findViewById(R.id.bRestart);
bRestart.setOnClickListener(this::RestartTimer);
return view;
}
private void runTimer(View view) {
TextView tvTime = view.findViewById(R.id.tvTime);
Handler handler = new Handler();
handler.post(new Runnable() {
@Override
public void run() {
int h = seconds / 3600;
int m = (seconds / 3600) / 60;
int s = seconds % 60;
@SuppressLint("DefaultLocale") String time = String.format("%d:%02d:%02d",h,m,s);
tvTime.setText(time);
if(running) seconds++;
handler.postDelayed(this, 1000);
}
});
}
private void RestartTimer(View view) {
seconds = 0;
}
private void StopTimer(View view) {
running = false;
}
private void StartTimer(View view) {
running = true;
}
@Override
public void onSaveInstanceState(@NonNull Bundle outState) {
super.onSaveInstanceState(outState);
outState.putInt("seconds", seconds);
outState.putBoolean("running", running);
outState.putBoolean("wasRunning", wasRunning);
}
@Override
public void onPause() {
super.onPause();
wasRunning = running;
running = false;
}
@Override
public void onStop() {
super.onStop();
}
@Override
public void onResume() {
super.onResume();
running = wasRunning;
}
} | 2,939 | 0.622661 | 0.615175 | 116 | 24.344828 | 22.632408 | 103 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.534483 | false | false | 9 |
2e2d53ff37b99b55cb4ead544fda9a22102ca5c0 | 7,129,645,749,631 | ab316f5c4864787b57fb44a2864d48e9d2985a30 | /app/src/main/java/com/obimilitaryfragments/MainModule/fragments/fragmentChooseStoreHandlyOrAutomaticly/fragmentsOfViewPager/ChooseStoreAutomaticlyFragment/ChooseStoreAutomaticlyFragment.java | 7c124c650d59eafa500fcc158e3348ca2b17544f | [] | no_license | sizikoff/militaryobi-master | https://github.com/sizikoff/militaryobi-master | c2a90db4be40603fd3c4da1a2d737de2492ece44 | 41a4b3e2121d9929cb9c1018bf2b338b21490c26 | refs/heads/master | 2020-04-30T10:02:30.825000 | 2019-03-20T15:37:52 | 2019-03-20T15:37:52 | 176,765,233 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.obimilitaryfragments.MainModule.fragments.fragmentChooseStoreHandlyOrAutomaticly.fragmentsOfViewPager.ChooseStoreAutomaticlyFragment;
import android.Manifest;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.net.Uri;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v4.content.ContextCompat;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import android.widget.Toast;
import com.google.android.gms.maps.CameraUpdateFactory;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.MapView;
import com.google.android.gms.maps.OnMapReadyCallback;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.Marker;
import com.google.android.gms.maps.model.MarkerOptions;
import com.obimilitaryfragments.R;
import java.util.ArrayList;
public class ChooseStoreAutomaticlyFragment extends Fragment implements OnMapReadyCallback, ContractChooseStoreAutomaticlyFragment.MainView {
public GoogleMap googleMap = null;
private MapView mapView;
public static final String TAG = "ChooseStoreAutomaticlyFragmentk";
private ContractChooseStoreAutomaticlyFragment.Presenter presenter;
public static final int REQUEST_CODE_GET_ACCSES_LOCATION = 013542;
TextView textView;
@Override
public void onAttach(Context context) {
super.onAttach(context);
presenter = new Presenter(this, new Model(), getContext());
askPermissionLocation();
}
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_choose_store_automaticly_in_view_pager, null);
textView = view.findViewById(R.id.textViewInFragChooseStoreAuto);
textView.setVisibility(View.INVISIBLE);
mapView = view.findViewById(R.id.viewMapInFragChooseStoreAuto);
mapView.getMapAsync(this);
mapView.onCreate(getArguments());
return view;
}
public static ChooseStoreAutomaticlyFragment newInstance(String text) {
ChooseStoreAutomaticlyFragment f = new ChooseStoreAutomaticlyFragment();
// Bundle b = new Bundle();
// b.putString("msg", text);
// f.setArguments(b);
return f;
}
public void onMapReady(GoogleMap googleMap) {
this.googleMap = googleMap;
presenter.moveTheGoogleMapToPresenter(googleMap);
presenter.requestDataFromSystem();
}
@Override
public void onResume() {
super.onResume();
if (mapView != null)
mapView.onResume();
}
@Override
public void onDestroy() {
super.onDestroy();
if (mapView != null)
mapView.onDestroy();
}
@Override
public void onStart() {
super.onStart();
if (mapView != null)
mapView.onStart();
}
@Override
public void onStop() {
super.onStop();
if (mapView != null)
mapView.onStop();
}
@Override
public void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
if (mapView != null)
mapView.onSaveInstanceState(outState);
}
//запрашиваем у юзера разрешение
private void askPermissionLocation() {
int permissionStatus = ContextCompat.checkSelfPermission(getContext(), Manifest.permission.ACCESS_FINE_LOCATION);
if (permissionStatus == PackageManager.PERMISSION_GRANTED) {
presenter.getCoordinates();
} else {
this.requestPermissions(new String[]{Manifest.permission.ACCESS_FINE_LOCATION}, REQUEST_CODE_GET_ACCSES_LOCATION);
}
}
//а в этом методе видно, дано разрешение на местоположение или нет
@Override
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
switch (requestCode){
case REQUEST_CODE_GET_ACCSES_LOCATION: {
if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
presenter.getCoordinates();
} else {
Toast.makeText(getContext(), "без разрешения работа карты не возможна", Toast.LENGTH_SHORT).show();
}
return;
}
}
}
@Override
public void onResponseFailure(Throwable throwable) {
Log.i(TAG, "ошибка: " + throwable);
}
@Override
public void showTheNavigatorsWays(Marker marker) {
Uri uri = Uri.parse("geo:0,0?q=" + marker.getPosition().latitude + "," + marker.getPosition().longitude );
Intent intent = new Intent(Intent.ACTION_VIEW, uri);
this.startActivity(intent);
Log.i(TAG, "uri: " + uri);
}
@Override
public void setTextToTextView(String name, String distance) {
textView.setVisibility(View.VISIBLE);
textView.setText("Ближайший магазин: " + name + "; расстояние: " + distance + "км.");
}
}
| UTF-8 | Java | 5,572 | java | ChooseStoreAutomaticlyFragment.java | Java | [] | null | [] | package com.obimilitaryfragments.MainModule.fragments.fragmentChooseStoreHandlyOrAutomaticly.fragmentsOfViewPager.ChooseStoreAutomaticlyFragment;
import android.Manifest;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.net.Uri;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v4.content.ContextCompat;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import android.widget.Toast;
import com.google.android.gms.maps.CameraUpdateFactory;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.MapView;
import com.google.android.gms.maps.OnMapReadyCallback;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.Marker;
import com.google.android.gms.maps.model.MarkerOptions;
import com.obimilitaryfragments.R;
import java.util.ArrayList;
public class ChooseStoreAutomaticlyFragment extends Fragment implements OnMapReadyCallback, ContractChooseStoreAutomaticlyFragment.MainView {
public GoogleMap googleMap = null;
private MapView mapView;
public static final String TAG = "ChooseStoreAutomaticlyFragmentk";
private ContractChooseStoreAutomaticlyFragment.Presenter presenter;
public static final int REQUEST_CODE_GET_ACCSES_LOCATION = 013542;
TextView textView;
@Override
public void onAttach(Context context) {
super.onAttach(context);
presenter = new Presenter(this, new Model(), getContext());
askPermissionLocation();
}
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_choose_store_automaticly_in_view_pager, null);
textView = view.findViewById(R.id.textViewInFragChooseStoreAuto);
textView.setVisibility(View.INVISIBLE);
mapView = view.findViewById(R.id.viewMapInFragChooseStoreAuto);
mapView.getMapAsync(this);
mapView.onCreate(getArguments());
return view;
}
public static ChooseStoreAutomaticlyFragment newInstance(String text) {
ChooseStoreAutomaticlyFragment f = new ChooseStoreAutomaticlyFragment();
// Bundle b = new Bundle();
// b.putString("msg", text);
// f.setArguments(b);
return f;
}
public void onMapReady(GoogleMap googleMap) {
this.googleMap = googleMap;
presenter.moveTheGoogleMapToPresenter(googleMap);
presenter.requestDataFromSystem();
}
@Override
public void onResume() {
super.onResume();
if (mapView != null)
mapView.onResume();
}
@Override
public void onDestroy() {
super.onDestroy();
if (mapView != null)
mapView.onDestroy();
}
@Override
public void onStart() {
super.onStart();
if (mapView != null)
mapView.onStart();
}
@Override
public void onStop() {
super.onStop();
if (mapView != null)
mapView.onStop();
}
@Override
public void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
if (mapView != null)
mapView.onSaveInstanceState(outState);
}
//запрашиваем у юзера разрешение
private void askPermissionLocation() {
int permissionStatus = ContextCompat.checkSelfPermission(getContext(), Manifest.permission.ACCESS_FINE_LOCATION);
if (permissionStatus == PackageManager.PERMISSION_GRANTED) {
presenter.getCoordinates();
} else {
this.requestPermissions(new String[]{Manifest.permission.ACCESS_FINE_LOCATION}, REQUEST_CODE_GET_ACCSES_LOCATION);
}
}
//а в этом методе видно, дано разрешение на местоположение или нет
@Override
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
switch (requestCode){
case REQUEST_CODE_GET_ACCSES_LOCATION: {
if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
presenter.getCoordinates();
} else {
Toast.makeText(getContext(), "без разрешения работа карты не возможна", Toast.LENGTH_SHORT).show();
}
return;
}
}
}
@Override
public void onResponseFailure(Throwable throwable) {
Log.i(TAG, "ошибка: " + throwable);
}
@Override
public void showTheNavigatorsWays(Marker marker) {
Uri uri = Uri.parse("geo:0,0?q=" + marker.getPosition().latitude + "," + marker.getPosition().longitude );
Intent intent = new Intent(Intent.ACTION_VIEW, uri);
this.startActivity(intent);
Log.i(TAG, "uri: " + uri);
}
@Override
public void setTextToTextView(String name, String distance) {
textView.setVisibility(View.VISIBLE);
textView.setText("Ближайший магазин: " + name + "; расстояние: " + distance + "км.");
}
}
| 5,572 | 0.686763 | 0.68455 | 162 | 32.48148 | 31.422689 | 145 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.592593 | false | false | 9 |
17369f041c05219c6cae614dca06ab4a2e6483ac | 9,199,819,980,822 | fee8efe8cc636b6b52850b2bd2ff004578ef45d9 | /src/main/java/com/mitewater/copy/exception/OutOfBufferPoolSizeException.java | 14e816c11b75e9056c83c3943d25a1712db64ccc | [] | no_license | error523/copydir | https://github.com/error523/copydir | 0911bc0016ae55480cb4bac864545f0a6820269a | ba469d3312dd509b5872851afb053bf0dbc7b4cf | refs/heads/master | 2020-05-27T02:46:21.749000 | 2017-10-24T07:14:32 | 2017-10-24T07:14:32 | 82,515,009 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.mitewater.copy.exception;
/**
* Created with IntelliJ IDEA.
* User: MiteWater
* Date: 2017/2/16
* Time: 11:00
* Description: class for copydir try it self
*/
public class OutOfBufferPoolSizeException extends Exception{
}
| UTF-8 | Java | 240 | java | OutOfBufferPoolSizeException.java | Java | [
{
"context": "tion;\n\n/**\n * Created with IntelliJ IDEA.\n * User: MiteWater\n * Date: 2017/2/16\n * Time: 11:00\n * Description:",
"end": 92,
"score": 0.9996040463447571,
"start": 83,
"tag": "USERNAME",
"value": "MiteWater"
}
] | null | [] | package com.mitewater.copy.exception;
/**
* Created with IntelliJ IDEA.
* User: MiteWater
* Date: 2017/2/16
* Time: 11:00
* Description: class for copydir try it self
*/
public class OutOfBufferPoolSizeException extends Exception{
}
| 240 | 0.7375 | 0.691667 | 11 | 20.818182 | 19.044533 | 60 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.090909 | false | false | 9 |
c0f778f3379a130d615d500184b4de9ce028e4a8 | 29,257,317,276,066 | dd903c26467fe108e4521028ab50c20e87286e7a | /app/src/main/java/com/example/i/letterheadmaker/first.java | 68c5b5e1db9d170c1c1919a239dd4b684949d55a | [] | no_license | nishit-popat/LetterHeadMaker | https://github.com/nishit-popat/LetterHeadMaker | 6ab3d91242970946d67f2feed7b9bb4b99783595 | 8e96486f80a26213b8c373c40995af6128040912 | refs/heads/master | 2022-12-29T15:02:03.252000 | 2020-10-19T18:16:40 | 2020-10-19T18:16:40 | 305,474,708 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.example.i.letterheadmaker;
import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.support.v7.widget.CardView;
import android.view.View;
public class first extends AppCompatActivity {
CardView c2;
@Override
protected void onCreate(final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_first);
c2=(CardView)findViewById(R.id.card2);
c2.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent intent =new Intent(first.this,GridView.class);
startActivity(intent);
}
});
}
}
| UTF-8 | Java | 771 | java | first.java | Java | [] | null | [] | package com.example.i.letterheadmaker;
import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.support.v7.widget.CardView;
import android.view.View;
public class first extends AppCompatActivity {
CardView c2;
@Override
protected void onCreate(final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_first);
c2=(CardView)findViewById(R.id.card2);
c2.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent intent =new Intent(first.this,GridView.class);
startActivity(intent);
}
});
}
}
| 771 | 0.673152 | 0.66537 | 28 | 26.535715 | 21.460066 | 69 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.5 | false | false | 9 |
f9b1b9746f10d59510df247380c6144074d92a28 | 29,257,317,277,141 | d19cbb7eab78e2576af535d508260896f75bef0b | /app/src/main/java/mortimer/l/footballmanagement/TeamCalendar.java | 625ad5f64d87798d8d0856640b39541b3fe7bf4f | [] | no_license | LDM97/FootballManagementApp | https://github.com/LDM97/FootballManagementApp | 4eb518505b3b708f293d0dd673919f6c10840f13 | 59d2ccc8956ad40777d84a1cc69ded64bb2aac32 | refs/heads/master | 2021-03-31T02:01:42.008000 | 2018-04-28T21:39:14 | 2018-04-28T21:39:14 | 124,813,777 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
// Class for handling the TeamCalendar activity. Dynamically displays any events a team has
// Dynamically displays attendance for a given event on click and allows users to set their
// attendance for any event
package mortimer.l.footballmanagement;
// Android imports
import android.content.Intent;
import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.NavigationView;
import android.support.v4.view.GravityCompat;
import android.support.v4.widget.DrawerLayout;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.support.v7.widget.Toolbar;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.PopupWindow;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;
// Firebase imports
import com.google.firebase.auth.FirebaseAuth;
import com.google.firebase.auth.FirebaseUser;
import com.google.firebase.database.DataSnapshot;
import com.google.firebase.database.DatabaseError;
import com.google.firebase.database.DatabaseReference;
import com.google.firebase.database.FirebaseDatabase;
import com.google.firebase.database.ValueEventListener;
// Java imports
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import static android.view.View.GONE;
public class TeamCalendar extends AppCompatActivity implements View.OnClickListener
{
// Get string resources for pointers to database directories
private String userTeamPointer;
private String teamsPointer;
private String playersPointer;
private String eventsPointer;
private FirebaseAuth auth;
private final NavDrawerHandler navDrawerHandler= new NavDrawerHandler();
private DrawerLayout navDraw;
private ViewGroup linearLayout;
private PopupWindow popupWindow;
private final Map<View,CalendarItem> attendanceBtnToEvent = new HashMap<>();
private final Map<View,CalendarItem> goingBtnToEvent = new HashMap<>();
private final Map<View,CalendarItem> notGoingBtnToEvent = new HashMap<>();
private String teamId = "";
@Override
protected void onCreate( Bundle savedInstanceState )
{
super.onCreate( savedInstanceState );
setContentView( R.layout.activity_team_calendar );
// Get string resources for pointers to database directories
teamsPointer = getString( R.string.teams_pointer );
eventsPointer = getString( R.string.events_pointer );
userTeamPointer = getString( R.string.user_pointers );
playersPointer = getString( R.string.players_pointer );
// Custom toolbar setup
Toolbar custToolBar = (Toolbar) findViewById( R.id.my_toolbar );
setSupportActionBar( custToolBar );
android.support.v7.app.ActionBar actionBar = getSupportActionBar();
actionBar.setDisplayShowTitleEnabled( false );
TextView actionBarTitle = (TextView) findViewById( R.id.toolbarTitle );
actionBarTitle.setText( getString( R.string.team_calendar_title ) );
actionBar.setDisplayHomeAsUpEnabled( true );
actionBar.setHomeAsUpIndicator( R.drawable.menu_icon );
// Setup logout button and home button
findViewById( R.id.navLogout ).setOnClickListener( this );
findViewById( R.id.homeBtn ).setOnClickListener( this );
// Get Firebase authenticator
auth = FirebaseAuth.getInstance();
// Set listener for FAB add event click
FloatingActionButton myFab = (FloatingActionButton) findViewById( R.id.addEvent );
myFab.setOnClickListener(new View.OnClickListener()
{
public void onClick(View v)
{ // Send user to the add event screen to create a new event
Intent addEventActivity = new Intent( getApplicationContext(), AddEvent.class );
startActivity( addEventActivity );
}
});
// Nav drawer code
navDraw = findViewById( R.id.drawer_layout );
NavigationView navigationView = findViewById( R.id.nav_view );
navigationView.setNavigationItemSelectedListener
(
new NavigationView.OnNavigationItemSelectedListener()
{
@Override
public boolean onNavigationItemSelected( MenuItem menuItem ) {
// close drawer when item is tapped
navDraw.closeDrawers();
// Pass selected item and context to handle view
View thisView = findViewById(android.R.id.content);
navDrawerHandler.itemSelectHandler( menuItem, thisView.getContext() );
return true;
}
});
// Get a reference to the database
FirebaseDatabase database = FirebaseDatabase.getInstance();
DatabaseReference databaseRef = database.getReference();
databaseRef.addListenerForSingleValueEvent( new ValueEventListener()
{
@Override
public void onDataChange( DataSnapshot snapshot )
{
// Get user id, used to locate the team this user plays for
FirebaseUser currentUser = auth.getCurrentUser();
final String userId = currentUser.getUid();
// Get the current team id
UserTeamPointer pointer = snapshot.child( userTeamPointer ).child( userId ).getValue( UserTeamPointer.class );
String teamId = pointer.getTeamId();
for( DataSnapshot userSnapshot : snapshot.child( teamsPointer ).child( teamId ).child( playersPointer ).getChildren() )
{ // Get the current user and check if they are an organiser
User user = userSnapshot.getValue( User.class );
if( user.getUserID().equals( userId ) )
{ // Current user found
if( !user.getTeamOrganiser() )
{ // User is not the team organiser, hide the add event button
findViewById( R.id.addEvent ).setVisibility( GONE );
}
break; // Operation done if required, break
}
}
// Display the calendar items that already exist
LinkedList<CalendarItem> events = new LinkedList<>();
LinkedList<String> dates = new LinkedList<>();
HashMap<String,CalendarItem> dateToObj = new HashMap<>();
// Check if date in the past, if it is delete this date
Date currentDate = new Date();
SimpleDateFormat dateFormat = new SimpleDateFormat( "dd.MM.yyyy" );
for( DataSnapshot eventSnapshot : snapshot.child( teamsPointer ).child( teamId ).child( eventsPointer ).getChildren() )
{
// Get the calendar items from the snapshot
CalendarItem event = eventSnapshot.getValue(CalendarItem.class);
Date eventDate = null;
try { // Set event date to Date obj for comparison
eventDate = dateFormat.parse( event.getDate() );
} catch (ParseException e) {
e.printStackTrace();
}
if( currentDate.compareTo( eventDate ) > 0 )
{ // Current date is after the event date, event past delete it
DatabaseReference eventRef = eventSnapshot.getRef();
eventRef.removeValue();
}
else { // Setup the event for date ordering
events.add(event);
dateToObj.put(event.getDate(), event);
dates.add(event.getDate());
}
}
// Sort the events based on date
Collections.sort( dates, new StringDateComparator() );
for( String date : dates )
{ // Append items based on date order
CalendarItem event = dateToObj.get( date );
// Add calendarItem
linearLayout = (ViewGroup) findViewById( R.id.content_frame );
View calendarItem = LayoutInflater.from( getApplicationContext() ).inflate( R.layout.calendar_item_layout, linearLayout, false);
// Display the title for the event
TextView title = calendarItem.findViewById( R.id.eventTitle );
title.setText( event.getEventTitle() );
// Display the notes for the event
TextView notes = calendarItem.findViewById( R.id.eventNotes );
notes.setText( event.getNotes() );
// Display the time for the event
TextView time = calendarItem.findViewById( R.id.eventTime );
time.setText( event.getTime() );
// Display the date for the event
TextView eventDate = calendarItem.findViewById( R.id.eventDate );
eventDate.setText( event.getDate() );
// Display the location for the event
TextView location = calendarItem.findViewById( R.id.eventLocation );
location.setText( event.getLocation() );
// Set listener on the attendance button
Button attendanceBtn = calendarItem.findViewById( R.id.viewAttendanceBtn );
setListener( attendanceBtn );
// Map attendance button to the calendar item
attendanceBtnToEvent.put( (View) attendanceBtn, event );
// Add the view to the screen w all the event data
linearLayout.addView( calendarItem );
}
}
@Override
public void onCancelled( DatabaseError databaseError) {
System.out.println( "The read failed: " + databaseError.getCode() );
}
} );
}
private void setListener( Button btn )
{ // Given a button, set the listener.
// Used to set the listeners for dynamically generated buttons inside a calendar item View
btn.setOnClickListener( this );
}
@Override
public boolean onOptionsItemSelected( MenuItem item )
{ // Open the navigation drawer if the navigation icon is clicked
if ( item.getItemId() == android.R.id.home ) {
navDraw.openDrawer( GravityCompat.START );
return true;
}
return super.onOptionsItemSelected( item );
}
@Override
public void onStart()
{
super.onStart();
// Check if user is signed in (non-null) and update UI accordingly
FirebaseUser currentUser = auth.getCurrentUser();
if( currentUser == null )
{
// User not logged in, bad navigation attempt, return user to login screen
Intent loginActivity = new Intent( getApplicationContext(), Login.class );
startActivity( loginActivity );
}
}
@Override
public void onBackPressed()
{ // Take user back to the home screen
Intent intent = new Intent(this, DefaultHome.class);
startActivity(intent);
}
private List<CalendarItem> deleteEvent( List<CalendarItem> events, CalendarItem event )
{ // Auxillary function to delete an event from the current events list based on its hash code
for( CalendarItem item : events )
{
if( item.getDate().equals( event.getDate() ) && item.getTime().equals( event.getTime() ) )
{ // Remove the item
events.remove( item );
break;
}
}
return events;
}
@Override
public void onClick( View v )
{
if( v.getId() == R.id.navLogout )
{ // If logout clicked on nav drawer, run the signout function
View thisView = findViewById(android.R.id.content);
navDrawerHandler.signOut( thisView.getContext() );
}
if( v.getId() == R.id.homeBtn )
{ // Return the user to the home screen if the home icon is selected
Intent homeScreenActivity = new Intent( getApplicationContext(), DefaultHome.class );
startActivity( homeScreenActivity );
}
if( v.getId() == R.id.closePopup )
{ // close the popup
popupWindow.dismiss();
}
if( v.getId() == R.id.goingBtn || v.getId() == R.id.notGoingBtn )
{ // Handle attendance selection event
final View view = v;
// Get a reference to the database
FirebaseDatabase database = FirebaseDatabase.getInstance();
DatabaseReference databaseRef = database.getReference();
databaseRef.addListenerForSingleValueEvent( new ValueEventListener()
{
@Override
public void onDataChange( DataSnapshot snapshot )
{
// Get team ref for overwrite
Team team = snapshot.child( teamsPointer ).child( teamId ).getValue( Team.class );
List<CalendarItem> events = ( team.getEvents() == null ) ? new ArrayList<CalendarItem>() : team.getEvents();
String userId = auth.getUid();
// If going button, add to calendar item using method, write to database
if( view.getId() == R.id.goingBtn )
{
CalendarItem event = goingBtnToEvent.get( view );
events = deleteEvent( events, event );
event.setPlayerGoing( auth.getUid() );
events.add( event );
// Add the newly made event to the list of events for this team
// Notify user they are attending event
Toast.makeText( TeamCalendar.this, "You are attending this event",
Toast.LENGTH_SHORT).show();
}
// If not going button, add to calendar item using method, write to database
if( view.getId() == R.id.notGoingBtn )
{
CalendarItem event = notGoingBtnToEvent.get( view );
events = deleteEvent( events, event );
event.setPlayerNotGoing( auth.getUid() );
events.add( event );
// Add the newly made event to the list of events for this team
// Notify user they are not attending the event
Toast.makeText( TeamCalendar.this, "You are not attending this event",
Toast.LENGTH_SHORT).show();
}
// Get DB instance and reference to the team's events list in the database
FirebaseDatabase database = FirebaseDatabase.getInstance();
DatabaseReference teamRef = database.getReference().child( teamsPointer ).child( teamId ).child( eventsPointer );
// Update the events list w the list that has the new event added to it
teamRef.setValue( events );
}
@Override
public void onCancelled(DatabaseError databaseError)
{
System.out.println("The read failed: " + databaseError.getCode());
}
});
}
if( v.getId() == R.id.viewAttendanceBtn )
{ // Create the popup to display attendance
// Get layout container and inflate it
LayoutInflater popupLayout = (LayoutInflater) getApplicationContext().getSystemService( LAYOUT_INFLATER_SERVICE );
final ViewGroup popupContainer = (ViewGroup) popupLayout.inflate( R.layout.attendance_popup, null );
// Set listener for close button
popupContainer.findViewById( R.id.closePopup ).setOnClickListener( this );
// Get parent layout
RelativeLayout parentLayout = findViewById( R.id.calendarRelLayout );
// Display popup window
popupWindow = new PopupWindow( popupContainer, ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT, true );
popupWindow.showAtLocation( parentLayout, Gravity.CENTER, 0, 35 );
// Get the corresponding event based on which attendance button is pressed
CalendarItem event = attendanceBtnToEvent.get( v );
// Set the event title on the popup
TextView popupTitle = popupContainer.findViewById( R.id.popupTitle );
popupTitle.setText( event.getEventTitle() );
final List<String> playersGoing = ( event.getPlayersGoing() == null ) ? new ArrayList<String>() : event.getPlayersGoing();
final List<String> playersNotGoing = ( event.getPlayersNotGoing() == null ) ? new ArrayList<String>() : event.getPlayersNotGoing();
// Assign button mappings to map the button to the event
final Button goingBtn = popupContainer.findViewById( R.id.goingBtn );
goingBtnToEvent.put( (View) goingBtn, event );
goingBtn.setOnClickListener( this );
if( playersGoing.contains( auth.getUid() ) )
{ // If player is going to event already, cannot see going button
goingBtn.setVisibility( View.GONE );
}
final Button notGoingBtn = popupContainer.findViewById( R.id.notGoingBtn );
notGoingBtnToEvent.put( (View) notGoingBtn, event );
notGoingBtn.setOnClickListener( this );
if( playersNotGoing.contains( auth.getUid() ) )
{ // Player not going, hide not going button
notGoingBtn.setVisibility( View.GONE );
}
// Get a reference to the database
FirebaseDatabase database = FirebaseDatabase.getInstance();
DatabaseReference databaseRef = database.getReference();
databaseRef.addListenerForSingleValueEvent( new ValueEventListener()
{
@Override
public void onDataChange( DataSnapshot snapshot ) {
// Get user id, used to locate the team this user plays for
FirebaseUser currentUser = auth.getCurrentUser();
final String userId = currentUser.getUid();
// Get the current team id
UserTeamPointer pointer = snapshot.child( userTeamPointer ).child(userId).getValue(UserTeamPointer.class);
teamId = pointer.getTeamId();
for (DataSnapshot userSnapshot : snapshot.child( teamsPointer ).child( teamId ).child( playersPointer ).getChildren() )
{
User player = userSnapshot.getValue(User.class);
LinearLayout attendanceList;
if( playersGoing.contains( player.getUserID() ) )
{ // Set list as the going list
attendanceList = popupContainer.findViewById( R.id.playersGoingContainer );
}
else if( playersNotGoing.contains( player.getUserID() ) )
{ // Set list as the not going list
attendanceList = popupContainer.findViewById( R.id.playersNotGoingContainer );
}
else { // Set the list as no response
attendanceList = popupContainer.findViewById( R.id.playersNotRespondedContainer );
}
// Draw the player item into the selected list
View playerListItem = LayoutInflater.from(getApplicationContext()).inflate(R.layout.players_list_item_layout, attendanceList, false);
// Display the player's name
TextView playerNameText = playerListItem.findViewById(R.id.playerName);
playerNameText.setText(player.getName());
// Display the player's positions
TextView playerPositionsText = playerListItem.findViewById(R.id.playerPositions);
playerPositionsText.setText(player.getPreferredPositions());
// Set the image for the user's icon
ImageView playerImage = playerListItem.findViewById( R.id.playerProfileImage );
playerImage.setBackgroundResource(R.drawable.profile_icon_default);
playerImage.setMaxWidth( 10 );
playerImage.setMaxHeight( 5 );
// Add the view to the screen w all the event data
attendanceList.addView(playerListItem);
}
}
@Override
public void onCancelled( DatabaseError databaseError )
{
System.out.println("The read failed: " + databaseError.getCode());
}
});
}
}
}
| UTF-8 | Java | 23,615 | java | TeamCalendar.java | Java | [] | null | [] |
// Class for handling the TeamCalendar activity. Dynamically displays any events a team has
// Dynamically displays attendance for a given event on click and allows users to set their
// attendance for any event
package mortimer.l.footballmanagement;
// Android imports
import android.content.Intent;
import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.NavigationView;
import android.support.v4.view.GravityCompat;
import android.support.v4.widget.DrawerLayout;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.support.v7.widget.Toolbar;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.PopupWindow;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;
// Firebase imports
import com.google.firebase.auth.FirebaseAuth;
import com.google.firebase.auth.FirebaseUser;
import com.google.firebase.database.DataSnapshot;
import com.google.firebase.database.DatabaseError;
import com.google.firebase.database.DatabaseReference;
import com.google.firebase.database.FirebaseDatabase;
import com.google.firebase.database.ValueEventListener;
// Java imports
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import static android.view.View.GONE;
public class TeamCalendar extends AppCompatActivity implements View.OnClickListener
{
// Get string resources for pointers to database directories
private String userTeamPointer;
private String teamsPointer;
private String playersPointer;
private String eventsPointer;
private FirebaseAuth auth;
private final NavDrawerHandler navDrawerHandler= new NavDrawerHandler();
private DrawerLayout navDraw;
private ViewGroup linearLayout;
private PopupWindow popupWindow;
private final Map<View,CalendarItem> attendanceBtnToEvent = new HashMap<>();
private final Map<View,CalendarItem> goingBtnToEvent = new HashMap<>();
private final Map<View,CalendarItem> notGoingBtnToEvent = new HashMap<>();
private String teamId = "";
@Override
protected void onCreate( Bundle savedInstanceState )
{
super.onCreate( savedInstanceState );
setContentView( R.layout.activity_team_calendar );
// Get string resources for pointers to database directories
teamsPointer = getString( R.string.teams_pointer );
eventsPointer = getString( R.string.events_pointer );
userTeamPointer = getString( R.string.user_pointers );
playersPointer = getString( R.string.players_pointer );
// Custom toolbar setup
Toolbar custToolBar = (Toolbar) findViewById( R.id.my_toolbar );
setSupportActionBar( custToolBar );
android.support.v7.app.ActionBar actionBar = getSupportActionBar();
actionBar.setDisplayShowTitleEnabled( false );
TextView actionBarTitle = (TextView) findViewById( R.id.toolbarTitle );
actionBarTitle.setText( getString( R.string.team_calendar_title ) );
actionBar.setDisplayHomeAsUpEnabled( true );
actionBar.setHomeAsUpIndicator( R.drawable.menu_icon );
// Setup logout button and home button
findViewById( R.id.navLogout ).setOnClickListener( this );
findViewById( R.id.homeBtn ).setOnClickListener( this );
// Get Firebase authenticator
auth = FirebaseAuth.getInstance();
// Set listener for FAB add event click
FloatingActionButton myFab = (FloatingActionButton) findViewById( R.id.addEvent );
myFab.setOnClickListener(new View.OnClickListener()
{
public void onClick(View v)
{ // Send user to the add event screen to create a new event
Intent addEventActivity = new Intent( getApplicationContext(), AddEvent.class );
startActivity( addEventActivity );
}
});
// Nav drawer code
navDraw = findViewById( R.id.drawer_layout );
NavigationView navigationView = findViewById( R.id.nav_view );
navigationView.setNavigationItemSelectedListener
(
new NavigationView.OnNavigationItemSelectedListener()
{
@Override
public boolean onNavigationItemSelected( MenuItem menuItem ) {
// close drawer when item is tapped
navDraw.closeDrawers();
// Pass selected item and context to handle view
View thisView = findViewById(android.R.id.content);
navDrawerHandler.itemSelectHandler( menuItem, thisView.getContext() );
return true;
}
});
// Get a reference to the database
FirebaseDatabase database = FirebaseDatabase.getInstance();
DatabaseReference databaseRef = database.getReference();
databaseRef.addListenerForSingleValueEvent( new ValueEventListener()
{
@Override
public void onDataChange( DataSnapshot snapshot )
{
// Get user id, used to locate the team this user plays for
FirebaseUser currentUser = auth.getCurrentUser();
final String userId = currentUser.getUid();
// Get the current team id
UserTeamPointer pointer = snapshot.child( userTeamPointer ).child( userId ).getValue( UserTeamPointer.class );
String teamId = pointer.getTeamId();
for( DataSnapshot userSnapshot : snapshot.child( teamsPointer ).child( teamId ).child( playersPointer ).getChildren() )
{ // Get the current user and check if they are an organiser
User user = userSnapshot.getValue( User.class );
if( user.getUserID().equals( userId ) )
{ // Current user found
if( !user.getTeamOrganiser() )
{ // User is not the team organiser, hide the add event button
findViewById( R.id.addEvent ).setVisibility( GONE );
}
break; // Operation done if required, break
}
}
// Display the calendar items that already exist
LinkedList<CalendarItem> events = new LinkedList<>();
LinkedList<String> dates = new LinkedList<>();
HashMap<String,CalendarItem> dateToObj = new HashMap<>();
// Check if date in the past, if it is delete this date
Date currentDate = new Date();
SimpleDateFormat dateFormat = new SimpleDateFormat( "dd.MM.yyyy" );
for( DataSnapshot eventSnapshot : snapshot.child( teamsPointer ).child( teamId ).child( eventsPointer ).getChildren() )
{
// Get the calendar items from the snapshot
CalendarItem event = eventSnapshot.getValue(CalendarItem.class);
Date eventDate = null;
try { // Set event date to Date obj for comparison
eventDate = dateFormat.parse( event.getDate() );
} catch (ParseException e) {
e.printStackTrace();
}
if( currentDate.compareTo( eventDate ) > 0 )
{ // Current date is after the event date, event past delete it
DatabaseReference eventRef = eventSnapshot.getRef();
eventRef.removeValue();
}
else { // Setup the event for date ordering
events.add(event);
dateToObj.put(event.getDate(), event);
dates.add(event.getDate());
}
}
// Sort the events based on date
Collections.sort( dates, new StringDateComparator() );
for( String date : dates )
{ // Append items based on date order
CalendarItem event = dateToObj.get( date );
// Add calendarItem
linearLayout = (ViewGroup) findViewById( R.id.content_frame );
View calendarItem = LayoutInflater.from( getApplicationContext() ).inflate( R.layout.calendar_item_layout, linearLayout, false);
// Display the title for the event
TextView title = calendarItem.findViewById( R.id.eventTitle );
title.setText( event.getEventTitle() );
// Display the notes for the event
TextView notes = calendarItem.findViewById( R.id.eventNotes );
notes.setText( event.getNotes() );
// Display the time for the event
TextView time = calendarItem.findViewById( R.id.eventTime );
time.setText( event.getTime() );
// Display the date for the event
TextView eventDate = calendarItem.findViewById( R.id.eventDate );
eventDate.setText( event.getDate() );
// Display the location for the event
TextView location = calendarItem.findViewById( R.id.eventLocation );
location.setText( event.getLocation() );
// Set listener on the attendance button
Button attendanceBtn = calendarItem.findViewById( R.id.viewAttendanceBtn );
setListener( attendanceBtn );
// Map attendance button to the calendar item
attendanceBtnToEvent.put( (View) attendanceBtn, event );
// Add the view to the screen w all the event data
linearLayout.addView( calendarItem );
}
}
@Override
public void onCancelled( DatabaseError databaseError) {
System.out.println( "The read failed: " + databaseError.getCode() );
}
} );
}
private void setListener( Button btn )
{ // Given a button, set the listener.
// Used to set the listeners for dynamically generated buttons inside a calendar item View
btn.setOnClickListener( this );
}
@Override
public boolean onOptionsItemSelected( MenuItem item )
{ // Open the navigation drawer if the navigation icon is clicked
if ( item.getItemId() == android.R.id.home ) {
navDraw.openDrawer( GravityCompat.START );
return true;
}
return super.onOptionsItemSelected( item );
}
@Override
public void onStart()
{
super.onStart();
// Check if user is signed in (non-null) and update UI accordingly
FirebaseUser currentUser = auth.getCurrentUser();
if( currentUser == null )
{
// User not logged in, bad navigation attempt, return user to login screen
Intent loginActivity = new Intent( getApplicationContext(), Login.class );
startActivity( loginActivity );
}
}
@Override
public void onBackPressed()
{ // Take user back to the home screen
Intent intent = new Intent(this, DefaultHome.class);
startActivity(intent);
}
private List<CalendarItem> deleteEvent( List<CalendarItem> events, CalendarItem event )
{ // Auxillary function to delete an event from the current events list based on its hash code
for( CalendarItem item : events )
{
if( item.getDate().equals( event.getDate() ) && item.getTime().equals( event.getTime() ) )
{ // Remove the item
events.remove( item );
break;
}
}
return events;
}
@Override
public void onClick( View v )
{
if( v.getId() == R.id.navLogout )
{ // If logout clicked on nav drawer, run the signout function
View thisView = findViewById(android.R.id.content);
navDrawerHandler.signOut( thisView.getContext() );
}
if( v.getId() == R.id.homeBtn )
{ // Return the user to the home screen if the home icon is selected
Intent homeScreenActivity = new Intent( getApplicationContext(), DefaultHome.class );
startActivity( homeScreenActivity );
}
if( v.getId() == R.id.closePopup )
{ // close the popup
popupWindow.dismiss();
}
if( v.getId() == R.id.goingBtn || v.getId() == R.id.notGoingBtn )
{ // Handle attendance selection event
final View view = v;
// Get a reference to the database
FirebaseDatabase database = FirebaseDatabase.getInstance();
DatabaseReference databaseRef = database.getReference();
databaseRef.addListenerForSingleValueEvent( new ValueEventListener()
{
@Override
public void onDataChange( DataSnapshot snapshot )
{
// Get team ref for overwrite
Team team = snapshot.child( teamsPointer ).child( teamId ).getValue( Team.class );
List<CalendarItem> events = ( team.getEvents() == null ) ? new ArrayList<CalendarItem>() : team.getEvents();
String userId = auth.getUid();
// If going button, add to calendar item using method, write to database
if( view.getId() == R.id.goingBtn )
{
CalendarItem event = goingBtnToEvent.get( view );
events = deleteEvent( events, event );
event.setPlayerGoing( auth.getUid() );
events.add( event );
// Add the newly made event to the list of events for this team
// Notify user they are attending event
Toast.makeText( TeamCalendar.this, "You are attending this event",
Toast.LENGTH_SHORT).show();
}
// If not going button, add to calendar item using method, write to database
if( view.getId() == R.id.notGoingBtn )
{
CalendarItem event = notGoingBtnToEvent.get( view );
events = deleteEvent( events, event );
event.setPlayerNotGoing( auth.getUid() );
events.add( event );
// Add the newly made event to the list of events for this team
// Notify user they are not attending the event
Toast.makeText( TeamCalendar.this, "You are not attending this event",
Toast.LENGTH_SHORT).show();
}
// Get DB instance and reference to the team's events list in the database
FirebaseDatabase database = FirebaseDatabase.getInstance();
DatabaseReference teamRef = database.getReference().child( teamsPointer ).child( teamId ).child( eventsPointer );
// Update the events list w the list that has the new event added to it
teamRef.setValue( events );
}
@Override
public void onCancelled(DatabaseError databaseError)
{
System.out.println("The read failed: " + databaseError.getCode());
}
});
}
if( v.getId() == R.id.viewAttendanceBtn )
{ // Create the popup to display attendance
// Get layout container and inflate it
LayoutInflater popupLayout = (LayoutInflater) getApplicationContext().getSystemService( LAYOUT_INFLATER_SERVICE );
final ViewGroup popupContainer = (ViewGroup) popupLayout.inflate( R.layout.attendance_popup, null );
// Set listener for close button
popupContainer.findViewById( R.id.closePopup ).setOnClickListener( this );
// Get parent layout
RelativeLayout parentLayout = findViewById( R.id.calendarRelLayout );
// Display popup window
popupWindow = new PopupWindow( popupContainer, ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT, true );
popupWindow.showAtLocation( parentLayout, Gravity.CENTER, 0, 35 );
// Get the corresponding event based on which attendance button is pressed
CalendarItem event = attendanceBtnToEvent.get( v );
// Set the event title on the popup
TextView popupTitle = popupContainer.findViewById( R.id.popupTitle );
popupTitle.setText( event.getEventTitle() );
final List<String> playersGoing = ( event.getPlayersGoing() == null ) ? new ArrayList<String>() : event.getPlayersGoing();
final List<String> playersNotGoing = ( event.getPlayersNotGoing() == null ) ? new ArrayList<String>() : event.getPlayersNotGoing();
// Assign button mappings to map the button to the event
final Button goingBtn = popupContainer.findViewById( R.id.goingBtn );
goingBtnToEvent.put( (View) goingBtn, event );
goingBtn.setOnClickListener( this );
if( playersGoing.contains( auth.getUid() ) )
{ // If player is going to event already, cannot see going button
goingBtn.setVisibility( View.GONE );
}
final Button notGoingBtn = popupContainer.findViewById( R.id.notGoingBtn );
notGoingBtnToEvent.put( (View) notGoingBtn, event );
notGoingBtn.setOnClickListener( this );
if( playersNotGoing.contains( auth.getUid() ) )
{ // Player not going, hide not going button
notGoingBtn.setVisibility( View.GONE );
}
// Get a reference to the database
FirebaseDatabase database = FirebaseDatabase.getInstance();
DatabaseReference databaseRef = database.getReference();
databaseRef.addListenerForSingleValueEvent( new ValueEventListener()
{
@Override
public void onDataChange( DataSnapshot snapshot ) {
// Get user id, used to locate the team this user plays for
FirebaseUser currentUser = auth.getCurrentUser();
final String userId = currentUser.getUid();
// Get the current team id
UserTeamPointer pointer = snapshot.child( userTeamPointer ).child(userId).getValue(UserTeamPointer.class);
teamId = pointer.getTeamId();
for (DataSnapshot userSnapshot : snapshot.child( teamsPointer ).child( teamId ).child( playersPointer ).getChildren() )
{
User player = userSnapshot.getValue(User.class);
LinearLayout attendanceList;
if( playersGoing.contains( player.getUserID() ) )
{ // Set list as the going list
attendanceList = popupContainer.findViewById( R.id.playersGoingContainer );
}
else if( playersNotGoing.contains( player.getUserID() ) )
{ // Set list as the not going list
attendanceList = popupContainer.findViewById( R.id.playersNotGoingContainer );
}
else { // Set the list as no response
attendanceList = popupContainer.findViewById( R.id.playersNotRespondedContainer );
}
// Draw the player item into the selected list
View playerListItem = LayoutInflater.from(getApplicationContext()).inflate(R.layout.players_list_item_layout, attendanceList, false);
// Display the player's name
TextView playerNameText = playerListItem.findViewById(R.id.playerName);
playerNameText.setText(player.getName());
// Display the player's positions
TextView playerPositionsText = playerListItem.findViewById(R.id.playerPositions);
playerPositionsText.setText(player.getPreferredPositions());
// Set the image for the user's icon
ImageView playerImage = playerListItem.findViewById( R.id.playerProfileImage );
playerImage.setBackgroundResource(R.drawable.profile_icon_default);
playerImage.setMaxWidth( 10 );
playerImage.setMaxHeight( 5 );
// Add the view to the screen w all the event data
attendanceList.addView(playerListItem);
}
}
@Override
public void onCancelled( DatabaseError databaseError )
{
System.out.println("The read failed: " + databaseError.getCode());
}
});
}
}
}
| 23,615 | 0.545755 | 0.545247 | 505 | 45.752476 | 34.858299 | 161 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.50099 | false | false | 9 |
50dfb17d144c2846a263808f743bb1c93cd54fd1 | 10,737,418,307,710 | 1c1832dc51bce325b6866f07b8ffc3f8e30569a1 | /EGHelper/src/view/NewConfigDialog.java | dc681627dce1c29eb5efecd8ae06e8e2bc6aa2ca | [] | no_license | webfd/eghelper | https://github.com/webfd/eghelper | 73bfbd9d57afcddb407c6c8ba85f7ee650f962a1 | 3155827fb847701ca2e57d362bf3c7c6499d8b62 | refs/heads/master | 2021-01-10T01:39:18.386000 | 2013-09-22T13:04:38 | 2013-09-22T13:04:38 | 36,601,506 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package view;
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.Toolkit;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;
import control.EGMessenger;
import control.NewConfigListener;
/**
* This code was edited or generated using CloudGarden's Jigloo
* SWT/Swing GUI Builder, which is free for non-commercial
* use. If Jigloo is being used commercially (ie, by a corporation,
* company or business for any purpose whatever) then you
* should purchase a license for each developer using Jigloo.
* Please visit www.cloudgarden.com for details.
* Use of Jigloo implies acceptance of these licensing terms.
* A COMMERCIAL LICENSE HAS NOT BEEN PURCHASED FOR
* THIS MACHINE, SO JIGLOO OR THIS CODE CANNOT BE USED
* LEGALLY FOR ANY CORPORATE OR COMMERCIAL PURPOSE.
*/
public class NewConfigDialog extends javax.swing.JDialog {
/**
*
*/
private static final long serialVersionUID = -4931944315952342100L;
private JPanel jPanelContaint;
private JTextField jTextFieldUID;
private JLabel jLabelUID;
private JTextField jTextFieldAID3;
private JLabel jLabelMaxLine;
private JLabel jLabelAdvanceInfo;
private JLabel jLabelBasicInfo;
private JTextField jTextFieldSTUp;
private JLabel jLabelST2;
private JTextField jTextFieldSTDown;
private JLabel jLabelST1;
private JTextField jTextFieldMaxLine;
private JCheckBox jCheckBoxShowRank;
private JTextField jTextFieldAID2;
private JLabel jLabelAID3;
private JLabel jLabelAID2;
private JTextField jTextFieldAID1;
private JLabel jLabelAID1;
private JButton jButtonCancel;
private JButton jButtonConfirm;
private JPanel jPanelButtons;
private NewConfigListener ncl;
public StartMenuFrame frame;
public JTextField getjTextFieldUID() {
return jTextFieldUID;
}
public JTextField getjTextFieldAID3() {
return jTextFieldAID3;
}
public JTextField getjTextFieldAID2() {
return jTextFieldAID2;
}
public JTextField getjTextFieldAID1() {
return jTextFieldAID1;
}
public JButton getjButtonCancel() {
return jButtonCancel;
}
public JButton getjButtonConfirm() {
return jButtonConfirm;
}
{
//Set Look & Feel
try {
javax.swing.UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
} catch(Exception e) {
e.printStackTrace();
}
}
public NewConfigDialog(StartMenuFrame frame, EGMessenger carrier) {
super(frame, "新建配置文件");
this.frame = frame;
ncl = new NewConfigListener(this, carrier);
initGUI();
}
private void initGUI() {
try {
{
}
BorderLayout thisLayout = new BorderLayout();
getContentPane().setLayout(thisLayout);
{
jPanelContaint = new JPanel();
FlowLayout jPanelContaintLayout = new FlowLayout();
getContentPane().add(jPanelContaint, BorderLayout.CENTER);
jPanelContaint.setLayout(jPanelContaintLayout);
jPanelContaint.setPreferredSize(new java.awt.Dimension(344, 226));
{
jLabelBasicInfo = new JLabel();
jPanelContaint.add(jLabelBasicInfo);
jLabelBasicInfo.setText("--------------------Basic Infomation--------------------");
}
{
jLabelAID1 = new JLabel();
jPanelContaint.add(jLabelAID1);
jLabelAID1.setText("APP-ID-1: ");
}
{
jTextFieldAID1 = new JTextField();
jPanelContaint.add(jTextFieldAID1);
jTextFieldAID1.setText("YOUR ID1");
jTextFieldAID1.setPreferredSize(new java.awt.Dimension(250, 21));
}
{
jLabelAID2 = new JLabel();
jPanelContaint.add(jLabelAID2);
jLabelAID2.setText("APP-ID-2: ");
}
{
jTextFieldAID2 = new JTextField();
jPanelContaint.add(jTextFieldAID2);
jTextFieldAID2.setText("YOUR ID2");
jTextFieldAID2.setPreferredSize(new java.awt.Dimension(250, 21));
}
{
jLabelAID3 = new JLabel();
jPanelContaint.add(jLabelAID3);
jLabelAID3.setText("APP-ID-3: ");
}
{
jTextFieldAID3 = new JTextField();
jPanelContaint.add(jTextFieldAID3);
jTextFieldAID3.setText("YOUR ID3");
jTextFieldAID3.setPreferredSize(new java.awt.Dimension(250, 21));
}
{
jLabelUID = new JLabel();
jPanelContaint.add(jLabelUID);
jLabelUID.setText("UID: ");
}
{
jTextFieldUID = new JTextField();
jPanelContaint.add(jTextFieldUID);
jTextFieldUID.setText("YOUR UID");
jTextFieldUID.setPreferredSize(new java.awt.Dimension(280, 21));
}
{
jLabelAdvanceInfo = new JLabel();
jPanelContaint.add(jLabelAdvanceInfo);
jLabelAdvanceInfo.setText("-------------------Advance Infomation-------------------");
}
{
jLabelST1 = new JLabel();
jPanelContaint.add(jLabelST1);
jLabelST1.setText("Keep stamia points in the range: ");
}
{
jTextFieldSTDown = new JTextField();
jPanelContaint.add(jTextFieldSTDown);
jTextFieldSTDown.setText("20");
jTextFieldSTDown.setPreferredSize(new java.awt.Dimension(30, 21));
}
{
jLabelST2 = new JLabel();
jPanelContaint.add(jLabelST2);
jLabelST2.setText("to Max ST-");
}
{
jTextFieldSTUp = new JTextField();
jPanelContaint.add(jTextFieldSTUp);
jTextFieldSTUp.setText("30");
jTextFieldSTUp.setPreferredSize(new java.awt.Dimension(30, 21));
}
{
jLabelMaxLine = new JLabel();
jPanelContaint.add(jLabelMaxLine);
jLabelMaxLine.setText("MaxLine of histroy: ");
}
{
jTextFieldMaxLine = new JTextField();
jPanelContaint.add(getJTextFieldMaxLine());
jTextFieldMaxLine.setText("1000");
jTextFieldMaxLine.setPreferredSize(new java.awt.Dimension(70, 21));
}
{
jCheckBoxShowRank = new JCheckBox();
jPanelContaint.add(getJCheckBoxShowRank());
jCheckBoxShowRank.setText("ShowRank");
jCheckBoxShowRank.setSelected(true);
}
}
{
jPanelButtons = new JPanel();
getContentPane().add(jPanelButtons, BorderLayout.SOUTH);
jPanelButtons.setPreferredSize(new java.awt.Dimension(355, 35));
{
jButtonConfirm = new JButton();
jPanelButtons.add(jButtonConfirm);
jButtonConfirm.setText("\u786e\u5b9a");
jButtonConfirm.setPreferredSize(new java.awt.Dimension(80, 25));
jButtonConfirm.addActionListener(ncl);
}
{
jButtonCancel = new JButton();
jPanelButtons.add(jButtonCancel);
jButtonCancel.setText("\u53d6\u6d88");
jButtonCancel.setPreferredSize(new java.awt.Dimension(80, 25));
jButtonCancel.addActionListener(ncl);
}
}
this.setSize(360, 260);
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
setBounds((screenSize.width - this.getWidth()) / 2, (screenSize.height - this.getHeight()) / 2, this.getWidth(), this.getHeight());
this.setResizable(false);
} catch (Exception e) {
e.printStackTrace();
}
}
public JCheckBox getJCheckBoxShowRank() {
return jCheckBoxShowRank;
}
public JTextField getJTextFieldMaxLine() {
return jTextFieldMaxLine;
}
public JTextField getJTextFieldSTDown() {
return jTextFieldSTDown;
}
public JTextField getJTextFieldSTUp() {
return jTextFieldSTUp;
}
}
| UTF-8 | Java | 7,162 | java | NewConfigDialog.java | Java | [] | null | [] | package view;
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.Toolkit;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;
import control.EGMessenger;
import control.NewConfigListener;
/**
* This code was edited or generated using CloudGarden's Jigloo
* SWT/Swing GUI Builder, which is free for non-commercial
* use. If Jigloo is being used commercially (ie, by a corporation,
* company or business for any purpose whatever) then you
* should purchase a license for each developer using Jigloo.
* Please visit www.cloudgarden.com for details.
* Use of Jigloo implies acceptance of these licensing terms.
* A COMMERCIAL LICENSE HAS NOT BEEN PURCHASED FOR
* THIS MACHINE, SO JIGLOO OR THIS CODE CANNOT BE USED
* LEGALLY FOR ANY CORPORATE OR COMMERCIAL PURPOSE.
*/
public class NewConfigDialog extends javax.swing.JDialog {
/**
*
*/
private static final long serialVersionUID = -4931944315952342100L;
private JPanel jPanelContaint;
private JTextField jTextFieldUID;
private JLabel jLabelUID;
private JTextField jTextFieldAID3;
private JLabel jLabelMaxLine;
private JLabel jLabelAdvanceInfo;
private JLabel jLabelBasicInfo;
private JTextField jTextFieldSTUp;
private JLabel jLabelST2;
private JTextField jTextFieldSTDown;
private JLabel jLabelST1;
private JTextField jTextFieldMaxLine;
private JCheckBox jCheckBoxShowRank;
private JTextField jTextFieldAID2;
private JLabel jLabelAID3;
private JLabel jLabelAID2;
private JTextField jTextFieldAID1;
private JLabel jLabelAID1;
private JButton jButtonCancel;
private JButton jButtonConfirm;
private JPanel jPanelButtons;
private NewConfigListener ncl;
public StartMenuFrame frame;
public JTextField getjTextFieldUID() {
return jTextFieldUID;
}
public JTextField getjTextFieldAID3() {
return jTextFieldAID3;
}
public JTextField getjTextFieldAID2() {
return jTextFieldAID2;
}
public JTextField getjTextFieldAID1() {
return jTextFieldAID1;
}
public JButton getjButtonCancel() {
return jButtonCancel;
}
public JButton getjButtonConfirm() {
return jButtonConfirm;
}
{
//Set Look & Feel
try {
javax.swing.UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
} catch(Exception e) {
e.printStackTrace();
}
}
public NewConfigDialog(StartMenuFrame frame, EGMessenger carrier) {
super(frame, "新建配置文件");
this.frame = frame;
ncl = new NewConfigListener(this, carrier);
initGUI();
}
private void initGUI() {
try {
{
}
BorderLayout thisLayout = new BorderLayout();
getContentPane().setLayout(thisLayout);
{
jPanelContaint = new JPanel();
FlowLayout jPanelContaintLayout = new FlowLayout();
getContentPane().add(jPanelContaint, BorderLayout.CENTER);
jPanelContaint.setLayout(jPanelContaintLayout);
jPanelContaint.setPreferredSize(new java.awt.Dimension(344, 226));
{
jLabelBasicInfo = new JLabel();
jPanelContaint.add(jLabelBasicInfo);
jLabelBasicInfo.setText("--------------------Basic Infomation--------------------");
}
{
jLabelAID1 = new JLabel();
jPanelContaint.add(jLabelAID1);
jLabelAID1.setText("APP-ID-1: ");
}
{
jTextFieldAID1 = new JTextField();
jPanelContaint.add(jTextFieldAID1);
jTextFieldAID1.setText("YOUR ID1");
jTextFieldAID1.setPreferredSize(new java.awt.Dimension(250, 21));
}
{
jLabelAID2 = new JLabel();
jPanelContaint.add(jLabelAID2);
jLabelAID2.setText("APP-ID-2: ");
}
{
jTextFieldAID2 = new JTextField();
jPanelContaint.add(jTextFieldAID2);
jTextFieldAID2.setText("YOUR ID2");
jTextFieldAID2.setPreferredSize(new java.awt.Dimension(250, 21));
}
{
jLabelAID3 = new JLabel();
jPanelContaint.add(jLabelAID3);
jLabelAID3.setText("APP-ID-3: ");
}
{
jTextFieldAID3 = new JTextField();
jPanelContaint.add(jTextFieldAID3);
jTextFieldAID3.setText("YOUR ID3");
jTextFieldAID3.setPreferredSize(new java.awt.Dimension(250, 21));
}
{
jLabelUID = new JLabel();
jPanelContaint.add(jLabelUID);
jLabelUID.setText("UID: ");
}
{
jTextFieldUID = new JTextField();
jPanelContaint.add(jTextFieldUID);
jTextFieldUID.setText("YOUR UID");
jTextFieldUID.setPreferredSize(new java.awt.Dimension(280, 21));
}
{
jLabelAdvanceInfo = new JLabel();
jPanelContaint.add(jLabelAdvanceInfo);
jLabelAdvanceInfo.setText("-------------------Advance Infomation-------------------");
}
{
jLabelST1 = new JLabel();
jPanelContaint.add(jLabelST1);
jLabelST1.setText("Keep stamia points in the range: ");
}
{
jTextFieldSTDown = new JTextField();
jPanelContaint.add(jTextFieldSTDown);
jTextFieldSTDown.setText("20");
jTextFieldSTDown.setPreferredSize(new java.awt.Dimension(30, 21));
}
{
jLabelST2 = new JLabel();
jPanelContaint.add(jLabelST2);
jLabelST2.setText("to Max ST-");
}
{
jTextFieldSTUp = new JTextField();
jPanelContaint.add(jTextFieldSTUp);
jTextFieldSTUp.setText("30");
jTextFieldSTUp.setPreferredSize(new java.awt.Dimension(30, 21));
}
{
jLabelMaxLine = new JLabel();
jPanelContaint.add(jLabelMaxLine);
jLabelMaxLine.setText("MaxLine of histroy: ");
}
{
jTextFieldMaxLine = new JTextField();
jPanelContaint.add(getJTextFieldMaxLine());
jTextFieldMaxLine.setText("1000");
jTextFieldMaxLine.setPreferredSize(new java.awt.Dimension(70, 21));
}
{
jCheckBoxShowRank = new JCheckBox();
jPanelContaint.add(getJCheckBoxShowRank());
jCheckBoxShowRank.setText("ShowRank");
jCheckBoxShowRank.setSelected(true);
}
}
{
jPanelButtons = new JPanel();
getContentPane().add(jPanelButtons, BorderLayout.SOUTH);
jPanelButtons.setPreferredSize(new java.awt.Dimension(355, 35));
{
jButtonConfirm = new JButton();
jPanelButtons.add(jButtonConfirm);
jButtonConfirm.setText("\u786e\u5b9a");
jButtonConfirm.setPreferredSize(new java.awt.Dimension(80, 25));
jButtonConfirm.addActionListener(ncl);
}
{
jButtonCancel = new JButton();
jPanelButtons.add(jButtonCancel);
jButtonCancel.setText("\u53d6\u6d88");
jButtonCancel.setPreferredSize(new java.awt.Dimension(80, 25));
jButtonCancel.addActionListener(ncl);
}
}
this.setSize(360, 260);
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
setBounds((screenSize.width - this.getWidth()) / 2, (screenSize.height - this.getHeight()) / 2, this.getWidth(), this.getHeight());
this.setResizable(false);
} catch (Exception e) {
e.printStackTrace();
}
}
public JCheckBox getJCheckBoxShowRank() {
return jCheckBoxShowRank;
}
public JTextField getJTextFieldMaxLine() {
return jTextFieldMaxLine;
}
public JTextField getJTextFieldSTDown() {
return jTextFieldSTDown;
}
public JTextField getJTextFieldSTUp() {
return jTextFieldSTUp;
}
}
| 7,162 | 0.706154 | 0.686014 | 249 | 27.714859 | 22.457167 | 134 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 3.353414 | false | false | 9 |
97829c8c9702777d86e153a7af4dde35f3f1b978 | 231,928,295,355 | a31bf5502d61df221781a0227e298f14abc09a20 | /src/main/java/cz/cvut/fel/aos/resources/ReservationResource.java | fc0d1c3410d74f6f8be5f78a80f4b209143b031a | [] | no_license | horakmi2/Semestralka | https://github.com/horakmi2/Semestralka | 9a518fa03717a34e33c1d0c1265f4897923ba14b | adf9fd8fe54e2f972518a268748f67b83f5bbda7 | refs/heads/master | 2016-09-09T22:59:55.183000 | 2013-10-08T19:40:47 | 2013-10-08T19:40:47 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | /*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package cz.cvut.fel.aos.resources;
/**
*
* @author buben
*/
public class ReservationResource {
}
| UTF-8 | Java | 206 | java | ReservationResource.java | Java | [
{
"context": "kage cz.cvut.fel.aos.resources;\n\n/**\n *\n * @author buben\n */\npublic class ReservationResource {\n \n}\n",
"end": 159,
"score": 0.9992240071296692,
"start": 154,
"tag": "USERNAME",
"value": "buben"
}
] | null | [] | /*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package cz.cvut.fel.aos.resources;
/**
*
* @author buben
*/
public class ReservationResource {
}
| 206 | 0.669903 | 0.669903 | 13 | 14.846154 | 17.496576 | 52 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.230769 | false | false | 9 |
196a8cab1024026ff1934de773b2ccdcf9a4f4ab | 4,844,723,110,255 | 26b7f30c6640b8017a06786e4a2414ad8a4d71dd | /src/number_of_direct_superinterfaces/i54612.java | 0ae486696d13d9aecc9a8a75d0eea09e54290817 | [] | no_license | vincentclee/jvm-limits | https://github.com/vincentclee/jvm-limits | b72a2f2dcc18caa458f1e77924221d585f23316b | 2fd1c26d1f7984ea8163bc103ad14b6d72282281 | refs/heads/master | 2020-05-18T11:18:41.711000 | 2014-09-14T04:25:18 | 2014-09-14T04:25:18 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package number_of_direct_superinterfaces;
public interface i54612 {} | UTF-8 | Java | 69 | java | i54612.java | Java | [] | null | [] | package number_of_direct_superinterfaces;
public interface i54612 {} | 69 | 0.826087 | 0.753623 | 3 | 22.333334 | 16.937796 | 41 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.333333 | false | false | 9 |
d65085e7fbb96b1e0891683dce126871473a220c | 22,187,801,103,099 | 2bfad754c27f96f98d195ba3395172bbbcd8d12f | /src/main/java/org/azienda/Confluent_Controller/MainClass.java | 2121adcc5c1f8d95891ee6a98897e7fb11d7d4a1 | [] | no_license | Reizel90/Confluent_Controller | https://github.com/Reizel90/Confluent_Controller | 9276c2e19d3331405ed551430186a9f3445b42e2 | 5760255bdfbddf26b38b79a7edc0e0a029d68b64 | refs/heads/master | 2022-11-18T12:39:42.699000 | 2019-11-13T19:24:22 | 2019-11-13T19:24:22 | 205,336,457 | 0 | 1 | null | false | 2023-02-15T06:20:30 | 2019-08-30T08:12:46 | 2019-11-13T19:24:25 | 2022-11-16T09:21:13 | 113 | 0 | 0 | 3 | Java | false | false | package org.azienda.Confluent_Controller;
import javafx.application.Application;
import javafx.application.Platform;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.stage.Stage;
import kafka.RunnableConsumer;
import org.apache.kafka.clients.consumer.ConsumerConfig;
import org.apache.kafka.common.serialization.LongDeserializer;
import org.apache.kafka.common.serialization.StringDeserializer;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.Properties;
import java.util.concurrent.TimeUnit;
/**
* Hello world!
*/
public class MainClass extends Application implements EventHandler<ActionEvent> {
public static final String testconnection = "192.168.1.189";
// 9092 for confluent,
// 8082 for kafka api (https://docs.confluent.io/current/kafka-rest/api.html),
// 8083 Kafka Connect REST API (https://mapr.com/docs/52/Kafka/Connect-rest-api.html).
public static String connection = "192.168.1.189"; //"host:9092,anotherhost:9092"
public static final String group = "myTestGroup"; //better use a groupname foreach stream
//"test-json-ZONE" "test-json-AAAEsempio"
private static String topic = "test-json-AAAEsempio";
public static void main(String[] args) throws IOException, InterruptedException {
System.out.println("inizio");
try {
// **************************** IDE ********************************************
// *************** pass an argument in run_configuration *****************************
// if(args.length != 0){
// System.out.println("lanciato da IDE");
//
// String resource_path = "src/main/resources/";
//
// SparkMain.conf = new SparkConf()
// .setMaster("local[*]")
// .setAppName("Calculator");
//
// SparkMain.sparkContext = new JavaSparkContext(SparkMain.conf);
// SparkMain.streamingContext = new JavaStreamingContext(SparkMain.sparkContext, Durations.seconds(30));
//
// // ******************************************************************************************************
// }
// else{
// System.out.println("commandline with jar");
// // *************************** launching a jar without arguments **********************************************
//
// Prendo la directory del jar
// File jarDir = new File(ClassLoader.getSystemClassLoader().getResource(".").getPath());
// System.out.println(jarDir.getAbsolutePath());
// // Spark
// SparkMain.conf = new SparkConf();
// SparkMain.sparkContext = new JavaSparkContext(SparkMain.conf);
// SparkMain.streamingContext = new JavaStreamingContext(SparkMain.sparkContext, Durations.seconds(30));
//
// // ******************************************************************************************************
// }
// System.out only ERROR level INFO
//SparkMain.sparkContext.setLogLevel("ERROR");
launch(args); // javafx-call start(Stage primaryStage)
// String base_path = System.getProperty("user.dir");
// String resources_path = base_path + "\\src\\main\\resources";
// System.out.println(resources_path);
//C:\Users\DaNdE\IdeaProjects\Confluent_Controller\src\main\resources
TimeUnit.MINUTES.sleep(5);
} catch (Exception e) {
System.out.println("inizializing error \n");
e.printStackTrace();
}
}
@Override
public void start(Stage primaryStage) throws Exception {
System.out.println("getClass: " + getClass().toString() + "\n\n");
URL x = getClass().getResource("Connector/connectors.fxml");
System.out.println("getClass.getResource: " + x.toString() + "\n\n");
//file:/C:/Users/DaNdE/IdeaProjects/Confluent_Controller/target/classes/org/azienda/Confluent_Controller/
System.out.println( "mainclass class loader res: " + getClass().getResource("index.fxml") + "\n");
Parent root = FXMLLoader.load(getClass().getResource("index.fxml")); //org/azienda/Confluent_Controller/sample.fxml
primaryStage.setTitle("Confluent Controller");
primaryStage.setOnCloseRequest(e->{
close();
});
primaryStage.setScene(new Scene(root));
primaryStage.show();
}
public static void close() {
System.out.println("closing");
Platform.exit();
System.exit(0);
}
// public static void jsonExample() throws IOException {
// ObjectMapper objectMapper = new ObjectMapper();
// objectMapper.enable(DeserializationFeature.ACCEPT_EMPTY_STRING_AS_NULL_OBJECT);
// AAAEsempio example = new AAAEsempio(11, 184, "PALAZZO A");
// //scrivo su file ma è sempre un nuovo file trovare comando per appendere
// objectMapper.writeValue(new File("target/example.json"), example);
//
// String exampleAsString = objectMapper.writeValueAsString(example);
// //stampa due volte, una con i key maiuscoli e una con i key minuscoli
// System.out.println("exampleAsString " + exampleAsString);
// //exampleAsString {"ID":12,"DATE":"0","VALORE":184,"CLASSE":"PALAZZO A","id":12,"date":"0","classe":"PALAZZO A","valore":184}
//
// AAAEsempio esempio0 = objectMapper.readValue(exampleAsString, AAAEsempio.class);
// System.out.println("esempio0 " + esempio0.toString() + " - id vlaue: " + esempio0.getID() );
// //esempio0 db.entity.AAAEsempio@7d0587f1 - id vlaue: 12
//
// String json = "{\"ID\":12,\"DATE\":\"0\",\"VALORE\":185,\"CLASSE\":\"PALAZZO B\"}";
// AAAEsempio esempio = objectMapper.readValue(json, AAAEsempio.class);
// System.out.println(esempio.toString() + " ESEMPIO ID VALUE " + esempio.getID());
// //db.entity.AAAEsempio@5d76b067 ESEMPIO ID VALUE 12
// }
public static void local_consumer() {
Properties props0 = propes("localhost:9092");
RunnableConsumer test_local = new RunnableConsumer(props0, "demo");
test_local.run();
}
public static void remote_consumer(String topic){
Properties props0 = propes(connection +":9092");
RunnableConsumer test = new RunnableConsumer(props0, topic);
test.run();
}
public static Properties propes(String connection){
Properties props0 = new Properties();
props0.put(ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG, connection);
props0.put(ConsumerConfig.GROUP_ID_CONFIG, group);
props0.put(ConsumerConfig.KEY_DESERIALIZER_CLASS_CONFIG, LongDeserializer.class.getName());
props0.put(ConsumerConfig.VALUE_DESERIALIZER_CLASS_CONFIG, StringDeserializer.class.getName());
props0.put(ConsumerConfig.MAX_POLL_RECORDS_CONFIG, 5);
props0.put(ConsumerConfig.ENABLE_AUTO_COMMIT_CONFIG, "false");
props0.put(ConsumerConfig.AUTO_OFFSET_RESET_CONFIG, "earliest");
return props0;
}
public static void rest_request() throws IOException {
// https://debezium.io/docs/connectors/sqlserver/
// TODO create a configuration file for the SQL Server Connector and
// use the Kafka Connect REST API to add that connector to your Kafka Connect cluster.
//rest_request(); //java.net.ConnectException: Connection timed out: connect //at "getresponsecode()" line
URL urlForGetRequest = new URL("https://"+ testconnection + ":9092/connectors" );
//URL urlForGetRequest = new URL("https://jsonplaceholder.typicode.com/posts/1");
String readLine = null;
HttpURLConnection conection = (HttpURLConnection) urlForGetRequest.openConnection();
conection.setRequestMethod("GET");
conection.setRequestProperty("userId", "a1bcdef"); // set userId its a sample here
int responseCode = conection.getResponseCode();
System.out.println(responseCode);
if (responseCode == HttpURLConnection.HTTP_OK) {
BufferedReader in = new BufferedReader(
new InputStreamReader(conection.getInputStream()));
StringBuffer response = new StringBuffer();
while ((readLine = in .readLine()) != null) {
response.append(readLine);
} in .close();
// print result
System.out.println("JSON String Result " + response.toString());
//GetAndPost.POSTRequest(response.toString());
} else {
System.out.println("GET NOT WORKED");
}
}
@Override
public void handle(ActionEvent event) {
}
}
| UTF-8 | Java | 8,745 | java | MainClass.java | Java | [
{
"context": "\n public static final String testconnection = \"192.168.1.189\";\n\n // 9092 for confluent,\n // 8082 for kaf",
"end": 901,
"score": 0.9996616840362549,
"start": 888,
"tag": "IP_ADDRESS",
"value": "192.168.1.189"
},
{
"context": "api.html).\n public static ... | null | [] | package org.azienda.Confluent_Controller;
import javafx.application.Application;
import javafx.application.Platform;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.stage.Stage;
import kafka.RunnableConsumer;
import org.apache.kafka.clients.consumer.ConsumerConfig;
import org.apache.kafka.common.serialization.LongDeserializer;
import org.apache.kafka.common.serialization.StringDeserializer;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.Properties;
import java.util.concurrent.TimeUnit;
/**
* Hello world!
*/
public class MainClass extends Application implements EventHandler<ActionEvent> {
public static final String testconnection = "192.168.1.189";
// 9092 for confluent,
// 8082 for kafka api (https://docs.confluent.io/current/kafka-rest/api.html),
// 8083 Kafka Connect REST API (https://mapr.com/docs/52/Kafka/Connect-rest-api.html).
public static String connection = "192.168.1.189"; //"host:9092,anotherhost:9092"
public static final String group = "myTestGroup"; //better use a groupname foreach stream
//"test-json-ZONE" "test-json-AAAEsempio"
private static String topic = "test-json-AAAEsempio";
public static void main(String[] args) throws IOException, InterruptedException {
System.out.println("inizio");
try {
// **************************** IDE ********************************************
// *************** pass an argument in run_configuration *****************************
// if(args.length != 0){
// System.out.println("lanciato da IDE");
//
// String resource_path = "src/main/resources/";
//
// SparkMain.conf = new SparkConf()
// .setMaster("local[*]")
// .setAppName("Calculator");
//
// SparkMain.sparkContext = new JavaSparkContext(SparkMain.conf);
// SparkMain.streamingContext = new JavaStreamingContext(SparkMain.sparkContext, Durations.seconds(30));
//
// // ******************************************************************************************************
// }
// else{
// System.out.println("commandline with jar");
// // *************************** launching a jar without arguments **********************************************
//
// Prendo la directory del jar
// File jarDir = new File(ClassLoader.getSystemClassLoader().getResource(".").getPath());
// System.out.println(jarDir.getAbsolutePath());
// // Spark
// SparkMain.conf = new SparkConf();
// SparkMain.sparkContext = new JavaSparkContext(SparkMain.conf);
// SparkMain.streamingContext = new JavaStreamingContext(SparkMain.sparkContext, Durations.seconds(30));
//
// // ******************************************************************************************************
// }
// System.out only ERROR level INFO
//SparkMain.sparkContext.setLogLevel("ERROR");
launch(args); // javafx-call start(Stage primaryStage)
// String base_path = System.getProperty("user.dir");
// String resources_path = base_path + "\\src\\main\\resources";
// System.out.println(resources_path);
//C:\Users\DaNdE\IdeaProjects\Confluent_Controller\src\main\resources
TimeUnit.MINUTES.sleep(5);
} catch (Exception e) {
System.out.println("inizializing error \n");
e.printStackTrace();
}
}
@Override
public void start(Stage primaryStage) throws Exception {
System.out.println("getClass: " + getClass().toString() + "\n\n");
URL x = getClass().getResource("Connector/connectors.fxml");
System.out.println("getClass.getResource: " + x.toString() + "\n\n");
//file:/C:/Users/DaNdE/IdeaProjects/Confluent_Controller/target/classes/org/azienda/Confluent_Controller/
System.out.println( "mainclass class loader res: " + getClass().getResource("index.fxml") + "\n");
Parent root = FXMLLoader.load(getClass().getResource("index.fxml")); //org/azienda/Confluent_Controller/sample.fxml
primaryStage.setTitle("Confluent Controller");
primaryStage.setOnCloseRequest(e->{
close();
});
primaryStage.setScene(new Scene(root));
primaryStage.show();
}
public static void close() {
System.out.println("closing");
Platform.exit();
System.exit(0);
}
// public static void jsonExample() throws IOException {
// ObjectMapper objectMapper = new ObjectMapper();
// objectMapper.enable(DeserializationFeature.ACCEPT_EMPTY_STRING_AS_NULL_OBJECT);
// AAAEsempio example = new AAAEsempio(11, 184, "PALAZZO A");
// //scrivo su file ma è sempre un nuovo file trovare comando per appendere
// objectMapper.writeValue(new File("target/example.json"), example);
//
// String exampleAsString = objectMapper.writeValueAsString(example);
// //stampa due volte, una con i key maiuscoli e una con i key minuscoli
// System.out.println("exampleAsString " + exampleAsString);
// //exampleAsString {"ID":12,"DATE":"0","VALORE":184,"CLASSE":"PALAZZO A","id":12,"date":"0","classe":"PALAZZO A","valore":184}
//
// AAAEsempio esempio0 = objectMapper.readValue(exampleAsString, AAAEsempio.class);
// System.out.println("esempio0 " + esempio0.toString() + " - id vlaue: " + esempio0.getID() );
// //esempio0 db.entity.AAAEsempio@7d0587f1 - id vlaue: 12
//
// String json = "{\"ID\":12,\"DATE\":\"0\",\"VALORE\":185,\"CLASSE\":\"PALAZZO B\"}";
// AAAEsempio esempio = objectMapper.readValue(json, AAAEsempio.class);
// System.out.println(esempio.toString() + " ESEMPIO ID VALUE " + esempio.getID());
// //db.entity.AAAEsempio@5d76b067 ESEMPIO ID VALUE 12
// }
public static void local_consumer() {
Properties props0 = propes("localhost:9092");
RunnableConsumer test_local = new RunnableConsumer(props0, "demo");
test_local.run();
}
public static void remote_consumer(String topic){
Properties props0 = propes(connection +":9092");
RunnableConsumer test = new RunnableConsumer(props0, topic);
test.run();
}
public static Properties propes(String connection){
Properties props0 = new Properties();
props0.put(ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG, connection);
props0.put(ConsumerConfig.GROUP_ID_CONFIG, group);
props0.put(ConsumerConfig.KEY_DESERIALIZER_CLASS_CONFIG, LongDeserializer.class.getName());
props0.put(ConsumerConfig.VALUE_DESERIALIZER_CLASS_CONFIG, StringDeserializer.class.getName());
props0.put(ConsumerConfig.MAX_POLL_RECORDS_CONFIG, 5);
props0.put(ConsumerConfig.ENABLE_AUTO_COMMIT_CONFIG, "false");
props0.put(ConsumerConfig.AUTO_OFFSET_RESET_CONFIG, "earliest");
return props0;
}
public static void rest_request() throws IOException {
// https://debezium.io/docs/connectors/sqlserver/
// TODO create a configuration file for the SQL Server Connector and
// use the Kafka Connect REST API to add that connector to your Kafka Connect cluster.
//rest_request(); //java.net.ConnectException: Connection timed out: connect //at "getresponsecode()" line
URL urlForGetRequest = new URL("https://"+ testconnection + ":9092/connectors" );
//URL urlForGetRequest = new URL("https://jsonplaceholder.typicode.com/posts/1");
String readLine = null;
HttpURLConnection conection = (HttpURLConnection) urlForGetRequest.openConnection();
conection.setRequestMethod("GET");
conection.setRequestProperty("userId", "a1bcdef"); // set userId its a sample here
int responseCode = conection.getResponseCode();
System.out.println(responseCode);
if (responseCode == HttpURLConnection.HTTP_OK) {
BufferedReader in = new BufferedReader(
new InputStreamReader(conection.getInputStream()));
StringBuffer response = new StringBuffer();
while ((readLine = in .readLine()) != null) {
response.append(readLine);
} in .close();
// print result
System.out.println("JSON String Result " + response.toString());
//GetAndPost.POSTRequest(response.toString());
} else {
System.out.println("GET NOT WORKED");
}
}
@Override
public void handle(ActionEvent event) {
}
}
| 8,745 | 0.631976 | 0.618138 | 203 | 42.073891 | 34.52763 | 135 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.990148 | false | false | 9 |
dfc5946db97bd955ca28ea74d02e702eb30241f1 | 22,187,801,103,269 | fe5b610f0ded630462e9f98806edc7b24dcc2ef0 | /Downloads/AyoKeMasjid_v0.3_apkpure.com_source_from_JADX/org/bpmikc/akm/MainActivity.java | 64d93eef6f1a91504b79332ab9d801c292ab88e1 | [] | no_license | rayga/n4rut0 | https://github.com/rayga/n4rut0 | 328303f0adcb28140b05c0a18e54abecf21ef778 | e1f706aeb6085ee3752cb92187bf339c6dfddef0 | refs/heads/master | 2020-12-25T15:18:25.346000 | 2016-08-29T22:51:25 | 2016-08-29T22:51:25 | 66,826,428 | 1 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package org.bpmikc.akm;
import android.app.AlertDialog.Builder;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
import android.os.Build.VERSION;
import android.os.Bundle;
import android.os.Handler;
import android.support.v4.app.FragmentManager;
import android.support.v4.view.MotionEventCompat;
import android.support.v4.view.ViewPager;
import android.support.v4.widget.DrawerLayout;
import android.support.v7.app.ActionBarDrawerToggle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.RecyclerView.Adapter;
import android.support.v7.widget.RecyclerView.OnItemTouchListener;
import android.support.v7.widget.Toolbar;
import android.util.TypedValue;
import android.view.GestureDetector;
import android.view.GestureDetector.SimpleOnGestureListener;
import android.view.Menu;
import android.view.MenuItem;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.View.OnTouchListener;
import android.view.ViewTreeObserver;
import android.view.ViewTreeObserver.OnGlobalLayoutListener;
import android.view.ViewTreeObserver.OnScrollChangedListener;
import android.view.animation.AccelerateInterpolator;
import android.view.animation.Animation;
import android.view.animation.DecelerateInterpolator;
import android.view.animation.RotateAnimation;
import android.widget.Button;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.ScrollView;
import android.widget.TextView;
import android.widget.Toast;
import android.widget.ToggleButton;
import com.android.volley.Response.ErrorListener;
import com.android.volley.Response.Listener;
import com.android.volley.VolleyError;
import com.android.volley.toolbox.JsonObjectRequest;
import com.android.volley.toolbox.Volley;
import com.bumptech.glide.Glide;
import com.google.android.gms.drive.events.CompletionEvent;
import com.google.android.gms.games.Games;
import com.google.android.gms.maps.model.BitmapDescriptorFactory;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Timer;
import org.bpmikc.akm.Database.MySQLiteHelper;
import org.bpmikc.akm.Fragment.Frg_Add_Masjid_Gmap;
import org.bpmikc.akm.Fragment.Frg_Artikel;
import org.bpmikc.akm.Fragment.Frg_Bantuan;
import org.bpmikc.akm.Fragment.Frg_Cari_Masjid;
import org.bpmikc.akm.Fragment.Frg_Donasi;
import org.bpmikc.akm.Fragment.Frg_Faq_Masukan;
import org.bpmikc.akm.Fragment.Frg_Home;
import org.bpmikc.akm.Fragment.Frg_Iklan;
import org.bpmikc.akm.Fragment.Frg_Info_Aplikasi;
import org.bpmikc.akm.Fragment.Frg_Jadwal_Sholat;
import org.bpmikc.akm.Fragment.Frg_Kewanitaan;
import org.bpmikc.akm.Fragment.Frg_Kompas_Muazzin;
import org.bpmikc.akm.Fragment.Frg_Lokasi_Masjid;
import org.bpmikc.akm.Fragment.Frg_Qiblat_Map;
import org.bpmikc.akm.Fragment.Frg_Setting;
import org.bpmikc.akm.Fragment.Frg_Transaksi_Online;
import org.bpmikc.akm.RecyclerView.Adapters.DrawerAdapter;
import org.bpmikc.akm.RecyclerView.Classes.DrawerItem;
import org.bpmikc.akm.RecyclerView.Utils.ItemClickSupport;
import org.bpmikc.akm.RecyclerView.Utils.ItemClickSupport.OnItemClickListener;
import org.bpmikc.akm.Utils.CropCircleTransform;
import org.bpmikc.akm.Utils.CustomSwipeAdapter;
import org.bpmikc.akm.Widget.Preferences;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
public class MainActivity extends AppCompatActivity implements OnClickListener {
public int f12a;
CustomSwipeAdapter adapter;
private Bundle bundle;
Button buttonIndigoDark;
Button buttonIndigoLight;
Button buttonRedDark;
Button buttonRedLight;
int colorBackground;
int colorControlHighlight;
int colorPrimary;
private int count;
Adapter drawerAdapter1;
Adapter drawerAdapter2;
Adapter drawerAdapter3;
Adapter drawerAdapterSettings;
float drawerHeight;
ArrayList<DrawerItem> drawerItems1;
ArrayList<DrawerItem> drawerItems2;
ArrayList<DrawerItem> drawerItems3;
ArrayList<DrawerItem> drawerItemsSettings;
DrawerLayout drawerLayout;
ActionBarDrawerToggle drawerToggle;
private String durasi;
private String flag_01;
private String flag_02;
private String flag_03;
private FragmentManager fm;
FrameLayout frameLayoutSetting1;
final Handler handler;
private String id_rec;
private int ik;
public final String[] imageArray_url;
ImageView imageViewDrawerArrowUpDown;
private String image_iklan;
ItemClickSupport itemClickSupport1;
ItemClickSupport itemClickSupport2;
ItemClickSupport itemClickSupport3;
ItemClickSupport itemClickSupportSettings;
LinearLayout linearLayoutDrawerAccount;
LinearLayout linearLayoutDrawerMain;
LinearLayoutManager linearLayoutManager;
LinearLayoutManager linearLayoutManager2;
LinearLayoutManager linearLayoutManager3;
LinearLayoutManager linearLayoutManagerSettings;
private Preferences mPreferences;
private String menu;
OnScrollChangedListener onScrollChangedListener;
RecyclerView recyclerViewDrawer1;
RecyclerView recyclerViewDrawer2;
RecyclerView recyclerViewDrawer3;
RecyclerView recyclerViewDrawerSettings;
int recyclerViewHeight;
RelativeLayout relativeLayoutScrollViewChild;
float scrollViewHeight;
ScrollView scrollViewNavigationDrawerContent;
private String server_path;
private String server_path_target;
SharedPreferences sharedPreferences;
private String status;
FrameLayout statusBar;
int textColorPrimary;
private Timer timer;
ToggleButton toggleButtonDrawer;
Toolbar toolbar;
TypedValue typedValueColorBackground;
TypedValue typedValueColorPrimary;
TypedValue typedValueTextColorControlHighlight;
TypedValue typedValueTextColorPrimary;
private String url_iklan;
ViewPager viewPager;
ViewTreeObserver viewTreeObserverNavigationDrawerScrollView;
/* renamed from: org.bpmikc.akm.MainActivity.1 */
class C06091 implements DialogInterface.OnClickListener {
C06091() {
}
public void onClick(DialogInterface dialog, int which) {
switch (which) {
case GridLayoutManager.DEFAULT_SPAN_COUNT /*-1*/:
MainActivity.this.finish();
default:
}
}
}
/* renamed from: org.bpmikc.akm.MainActivity.2 */
class C06102 implements OnGlobalLayoutListener {
C06102() {
}
public void onGlobalLayout() {
if (VERSION.SDK_INT > 16) {
MainActivity.this.relativeLayoutScrollViewChild.getViewTreeObserver().removeOnGlobalLayoutListener(this);
} else {
MainActivity.this.relativeLayoutScrollViewChild.getViewTreeObserver().removeGlobalOnLayoutListener(this);
}
MainActivity.this.drawerHeight = (float) MainActivity.this.relativeLayoutScrollViewChild.getHeight();
MainActivity.this.scrollViewHeight = (float) MainActivity.this.scrollViewNavigationDrawerContent.getHeight();
if (MainActivity.this.drawerHeight > MainActivity.this.scrollViewHeight) {
MainActivity.this.frameLayoutSetting1.setVisibility(0);
}
if (MainActivity.this.drawerHeight < MainActivity.this.scrollViewHeight) {
MainActivity.this.frameLayoutSetting1.setVisibility(8);
}
}
}
/* renamed from: org.bpmikc.akm.MainActivity.3 */
class C06123 implements OnScrollChangedListener {
/* renamed from: org.bpmikc.akm.MainActivity.3.1 */
class C06111 implements OnTouchListener {
C06111() {
}
public boolean onTouch(View v, MotionEvent event) {
switch (event.getAction()) {
case CompletionEvent.STATUS_FAILURE /*1*/:
if (MainActivity.this.scrollViewNavigationDrawerContent.getScrollY() != 0) {
MainActivity.this.frameLayoutSetting1.animate().translationY((float) MainActivity.this.frameLayoutSetting1.getHeight()).setInterpolator(new AccelerateInterpolator(5.0f)).setDuration(400);
break;
}
break;
case CompletionEvent.STATUS_CONFLICT /*2*/:
if (MainActivity.this.scrollViewNavigationDrawerContent.getScrollY() != 0) {
MainActivity.this.frameLayoutSetting1.animate().translationY((float) MainActivity.this.frameLayoutSetting1.getHeight()).setInterpolator(new AccelerateInterpolator(5.0f)).setDuration(400);
break;
}
break;
}
return false;
}
}
C06123() {
}
public void onScrollChanged() {
MainActivity.this.scrollViewNavigationDrawerContent.setOnTouchListener(new C06111());
if (MainActivity.this.scrollViewNavigationDrawerContent.getScrollY() == 0) {
MainActivity.this.frameLayoutSetting1.animate().translationY(0.0f).setInterpolator(new DecelerateInterpolator(5.0f)).setDuration(600);
}
}
}
/* renamed from: org.bpmikc.akm.MainActivity.4 */
class C06134 implements OnTouchListener {
C06134() {
}
public boolean onTouch(View v, MotionEvent event) {
switch (event.getAction()) {
case CompletionEvent.STATUS_FAILURE /*1*/:
MainActivity.this.scrollViewNavigationDrawerContent.getViewTreeObserver().addOnScrollChangedListener(MainActivity.this.onScrollChangedListener);
break;
case CompletionEvent.STATUS_CONFLICT /*2*/:
MainActivity.this.scrollViewNavigationDrawerContent.getViewTreeObserver().addOnScrollChangedListener(MainActivity.this.onScrollChangedListener);
break;
}
return false;
}
}
/* renamed from: org.bpmikc.akm.MainActivity.5 */
class C06145 extends SimpleOnGestureListener {
C06145() {
}
public boolean onSingleTapUp(MotionEvent e) {
return true;
}
}
/* renamed from: org.bpmikc.akm.MainActivity.14 */
class AnonymousClass14 implements Listener<JSONObject> {
final /* synthetic */ ImageView val$img_iklan;
final /* synthetic */ String val$server_path;
/* renamed from: org.bpmikc.akm.MainActivity.14.1 */
class C06071 implements Runnable {
int f4b;
final /* synthetic */ String[] val$image_resources;
C06071(String[] strArr) {
this.val$image_resources = strArr;
this.f4b = 0;
}
public void run() {
Glide.with(MainActivity.this.getApplication()).load(this.val$image_resources[this.f4b]).into(AnonymousClass14.this.val$img_iklan);
MainActivity.this.f12a = this.f4b;
this.f4b++;
if (this.f4b > this.val$image_resources.length - 1) {
this.f4b = 0;
}
MainActivity.this.handler.postDelayed(this, (long) Integer.decode(MainActivity.this.durasi).intValue());
}
}
/* renamed from: org.bpmikc.akm.MainActivity.14.2 */
class C06082 implements OnClickListener {
final /* synthetic */ String[] val$imageArray_url;
C06082(String[] strArr) {
this.val$imageArray_url = strArr;
}
public void onClick(View arg0) {
String url_proses = this.val$imageArray_url[MainActivity.this.f12a];
Bundle bundlex = new Bundle();
bundlex.putString("url_iklan", url_proses);
MainActivity.this.getSupportFragmentManager().beginTransaction().replace(C0615R.id.main_activity_content_frame, Frg_Iklan.newInstance(bundlex)).commit();
}
}
AnonymousClass14(String str, ImageView imageView) {
this.val$server_path = str;
this.val$img_iklan = imageView;
}
public void onResponse(JSONObject response) {
try {
JSONArray ja = response.getJSONArray("iklan");
String[] image_resources = new String[ja.length()];
String[] imageArray_url = new String[ja.length()];
Arrays.fill(image_resources, null);
Arrays.fill(imageArray_url, null);
for (int i = 0; i < ja.length(); i++) {
JSONObject c = ja.getJSONObject(i);
MainActivity.this.id_rec = c.getString("id_rec");
MainActivity.this.menu = c.getString("menu");
MainActivity.this.status = c.getString(Games.EXTRA_STATUS);
MainActivity.this.url_iklan = c.getString("url_iklan");
MainActivity.this.flag_01 = c.getString("flag_01");
MainActivity.this.flag_02 = c.getString("flag_02");
MainActivity.this.flag_03 = c.getString("flag_03");
MainActivity.this.image_iklan = c.getString("image_iklan");
MainActivity.this.durasi = c.getString("durasi");
image_resources[i] = this.val$server_path + "/app_files/" + MainActivity.this.image_iklan;
imageArray_url[i] = MainActivity.this.url_iklan;
}
MainActivity.this.handler.removeCallbacksAndMessages(null);
MainActivity.this.handler.postDelayed(new C06071(image_resources), 500);
this.val$img_iklan.setOnClickListener(new C06082(imageArray_url));
} catch (JSONException e) {
e.printStackTrace();
}
}
}
/* renamed from: org.bpmikc.akm.MainActivity.6 */
class C08836 implements OnItemTouchListener {
final /* synthetic */ GestureDetector val$mGestureDetector;
C08836(GestureDetector gestureDetector) {
this.val$mGestureDetector = gestureDetector;
}
public boolean onInterceptTouchEvent(RecyclerView recyclerView, MotionEvent motionEvent) {
View child = recyclerView.findChildViewUnder(motionEvent.getX(), motionEvent.getY());
if (child == null || !this.val$mGestureDetector.onTouchEvent(motionEvent)) {
return false;
}
int i;
MainActivity.this.drawerLayout.closeDrawers();
for (i = 0; i < MainActivity.this.recyclerViewDrawer2.getChildCount(); i++) {
LinearLayout linearLayoutItem = (LinearLayout) MainActivity.this.recyclerViewDrawer2.getChildAt(i).findViewById(C0615R.id.linearLayoutItem);
((TextView) MainActivity.this.recyclerViewDrawer2.getChildAt(i).findViewById(C0615R.id.textViewDrawerItemTitle)).setTextColor(MainActivity.this.textColorPrimary);
linearLayoutItem.setBackgroundColor(MainActivity.this.colorBackground);
}
for (i = 0; i < MainActivity.this.recyclerViewDrawer3.getChildCount(); i++) {
linearLayoutItem = (LinearLayout) MainActivity.this.recyclerViewDrawer3.getChildAt(i).findViewById(C0615R.id.linearLayoutItem);
((TextView) MainActivity.this.recyclerViewDrawer3.getChildAt(i).findViewById(C0615R.id.textViewDrawerItemTitle)).setTextColor(MainActivity.this.textColorPrimary);
linearLayoutItem.setBackgroundColor(MainActivity.this.colorBackground);
}
for (i = 0; i < MainActivity.this.recyclerViewDrawerSettings.getChildCount(); i++) {
linearLayoutItem = (LinearLayout) MainActivity.this.recyclerViewDrawerSettings.getChildAt(i).findViewById(C0615R.id.linearLayoutItem);
((TextView) MainActivity.this.recyclerViewDrawerSettings.getChildAt(i).findViewById(C0615R.id.textViewDrawerItemTitle)).setTextColor(MainActivity.this.textColorPrimary);
linearLayoutItem.setBackgroundColor(MainActivity.this.colorBackground);
}
TextView textViewDrawerItemTitle;
Bundle bundle;
switch (recyclerView.getChildPosition(child)) {
case SpinnerCompat.MODE_DIALOG /*0*/:
for (i = 0; i < MainActivity.this.recyclerViewDrawer1.getChildCount(); i++) {
textViewDrawerItemTitle = (TextView) MainActivity.this.recyclerViewDrawer1.getChildAt(i).findViewById(C0615R.id.textViewDrawerItemTitle);
linearLayoutItem = (LinearLayout) MainActivity.this.recyclerViewDrawer1.getChildAt(i).findViewById(C0615R.id.linearLayoutItem);
if (i == 0) {
textViewDrawerItemTitle.setTextColor(MainActivity.this.colorPrimary);
linearLayoutItem.setBackgroundColor(MainActivity.this.colorControlHighlight);
} else {
textViewDrawerItemTitle.setTextColor(MainActivity.this.textColorPrimary);
linearLayoutItem.setBackgroundColor(MainActivity.this.colorBackground);
}
}
Toast.makeText(MainActivity.this, "Menu Home ", 0).show();
if (MainActivity.this.getSupportActionBar() != null) {
MainActivity.this.getSupportActionBar().setTitle((CharSequence) "Assalamu'alaikum");
}
MainActivity.this.timer_iklan("home");
bundle = new Bundle();
bundle.putString("judul", "Home");
MainActivity.this.getSupportFragmentManager().beginTransaction().replace(C0615R.id.main_activity_content_frame, Frg_Home.newInstance(bundle)).commit();
break;
case CompletionEvent.STATUS_FAILURE /*1*/:
for (i = 0; i < MainActivity.this.recyclerViewDrawer1.getChildCount(); i++) {
textViewDrawerItemTitle = (TextView) MainActivity.this.recyclerViewDrawer1.getChildAt(i).findViewById(C0615R.id.textViewDrawerItemTitle);
linearLayoutItem = (LinearLayout) MainActivity.this.recyclerViewDrawer1.getChildAt(i).findViewById(C0615R.id.linearLayoutItem);
if (i == 1) {
textViewDrawerItemTitle.setTextColor(MainActivity.this.colorPrimary);
linearLayoutItem.setBackgroundColor(MainActivity.this.colorControlHighlight);
} else {
textViewDrawerItemTitle.setTextColor(MainActivity.this.textColorPrimary);
linearLayoutItem.setBackgroundColor(MainActivity.this.colorBackground);
}
}
Toast.makeText(MainActivity.this, "Menu Lokasi Masjid ", 0).show();
if (MainActivity.this.getSupportActionBar() != null) {
MainActivity.this.getSupportActionBar().setTitle((CharSequence) "Masjid");
}
MainActivity.this.timer_iklan("lokasi_masjid");
bundle = new Bundle();
bundle.putInt(Frg_Qiblat_Map.sARGUMENT_IMAGE_CODE, 2);
MainActivity.this.getSupportFragmentManager().beginTransaction().replace(C0615R.id.main_activity_content_frame, Frg_Lokasi_Masjid.newInstance(bundle)).commit();
break;
case CompletionEvent.STATUS_CONFLICT /*2*/:
for (i = 0; i < MainActivity.this.recyclerViewDrawer1.getChildCount(); i++) {
textViewDrawerItemTitle = (TextView) MainActivity.this.recyclerViewDrawer1.getChildAt(i).findViewById(C0615R.id.textViewDrawerItemTitle);
linearLayoutItem = (LinearLayout) MainActivity.this.recyclerViewDrawer1.getChildAt(i).findViewById(C0615R.id.linearLayoutItem);
if (i == 2) {
textViewDrawerItemTitle.setTextColor(MainActivity.this.colorPrimary);
linearLayoutItem.setBackgroundColor(MainActivity.this.colorControlHighlight);
} else {
textViewDrawerItemTitle.setTextColor(MainActivity.this.textColorPrimary);
linearLayoutItem.setBackgroundColor(MainActivity.this.colorBackground);
}
}
Toast.makeText(MainActivity.this, "Menu Tambah Masjid ", 0).show();
if (MainActivity.this.getSupportActionBar() != null) {
MainActivity.this.getSupportActionBar().setTitle((CharSequence) "Tambah Masjid");
}
MainActivity.this.timer_iklan("tambah_masjid");
bundle = new Bundle();
bundle.putInt(Frg_Qiblat_Map.sARGUMENT_IMAGE_CODE, 2);
MainActivity.this.getSupportFragmentManager().beginTransaction().replace(C0615R.id.main_activity_content_frame, Frg_Add_Masjid_Gmap.newInstance(bundle)).commit();
break;
case CompletionEvent.STATUS_CANCELED /*3*/:
for (i = 0; i < MainActivity.this.recyclerViewDrawer1.getChildCount(); i++) {
textViewDrawerItemTitle = (TextView) MainActivity.this.recyclerViewDrawer1.getChildAt(i).findViewById(C0615R.id.textViewDrawerItemTitle);
linearLayoutItem = (LinearLayout) MainActivity.this.recyclerViewDrawer1.getChildAt(i).findViewById(C0615R.id.linearLayoutItem);
if (i == 3) {
textViewDrawerItemTitle.setTextColor(MainActivity.this.colorPrimary);
linearLayoutItem.setBackgroundColor(MainActivity.this.colorControlHighlight);
} else {
textViewDrawerItemTitle.setTextColor(MainActivity.this.textColorPrimary);
linearLayoutItem.setBackgroundColor(MainActivity.this.colorBackground);
}
}
Toast.makeText(MainActivity.this, "Menu Cari Masjid ", 0).show();
if (MainActivity.this.getSupportActionBar() != null) {
MainActivity.this.getSupportActionBar().setTitle((CharSequence) "Cari Masjid");
}
MainActivity.this.timer_iklan("cari_masjid");
bundle = new Bundle();
bundle.putInt(Frg_Qiblat_Map.sARGUMENT_IMAGE_CODE, 2);
MainActivity.this.getSupportFragmentManager().beginTransaction().replace(C0615R.id.main_activity_content_frame, Frg_Cari_Masjid.newInstance(bundle)).commit();
break;
}
return true;
}
public void onTouchEvent(RecyclerView recyclerView, MotionEvent motionEvent) {
}
}
/* renamed from: org.bpmikc.akm.MainActivity.7 */
class C08847 implements OnItemTouchListener {
final /* synthetic */ GestureDetector val$mGestureDetector;
C08847(GestureDetector gestureDetector) {
this.val$mGestureDetector = gestureDetector;
}
public boolean onInterceptTouchEvent(RecyclerView recyclerView, MotionEvent motionEvent) {
View child = recyclerView.findChildViewUnder(motionEvent.getX(), motionEvent.getY());
if (child == null || !this.val$mGestureDetector.onTouchEvent(motionEvent)) {
return false;
}
int i;
MainActivity.this.drawerLayout.closeDrawers();
for (i = 0; i < MainActivity.this.recyclerViewDrawer1.getChildCount(); i++) {
LinearLayout linearLayoutItem = (LinearLayout) MainActivity.this.recyclerViewDrawer1.getChildAt(i).findViewById(C0615R.id.linearLayoutItem);
((TextView) MainActivity.this.recyclerViewDrawer1.getChildAt(i).findViewById(C0615R.id.textViewDrawerItemTitle)).setTextColor(MainActivity.this.textColorPrimary);
linearLayoutItem.setBackgroundColor(MainActivity.this.colorBackground);
}
for (i = 0; i < MainActivity.this.recyclerViewDrawer3.getChildCount(); i++) {
linearLayoutItem = (LinearLayout) MainActivity.this.recyclerViewDrawer3.getChildAt(i).findViewById(C0615R.id.linearLayoutItem);
((TextView) MainActivity.this.recyclerViewDrawer3.getChildAt(i).findViewById(C0615R.id.textViewDrawerItemTitle)).setTextColor(MainActivity.this.textColorPrimary);
linearLayoutItem.setBackgroundColor(MainActivity.this.colorBackground);
}
for (i = 0; i < MainActivity.this.recyclerViewDrawerSettings.getChildCount(); i++) {
linearLayoutItem = (LinearLayout) MainActivity.this.recyclerViewDrawerSettings.getChildAt(i).findViewById(C0615R.id.linearLayoutItem);
((TextView) MainActivity.this.recyclerViewDrawerSettings.getChildAt(i).findViewById(C0615R.id.textViewDrawerItemTitle)).setTextColor(MainActivity.this.textColorPrimary);
linearLayoutItem.setBackgroundColor(MainActivity.this.colorBackground);
}
TextView textViewDrawerItemTitle;
Bundle bundle;
switch (recyclerView.getChildPosition(child)) {
case SpinnerCompat.MODE_DIALOG /*0*/:
for (i = 0; i < MainActivity.this.recyclerViewDrawer2.getChildCount(); i++) {
textViewDrawerItemTitle = (TextView) MainActivity.this.recyclerViewDrawer2.getChildAt(i).findViewById(C0615R.id.textViewDrawerItemTitle);
linearLayoutItem = (LinearLayout) MainActivity.this.recyclerViewDrawer2.getChildAt(i).findViewById(C0615R.id.linearLayoutItem);
if (i == 0) {
textViewDrawerItemTitle.setTextColor(MainActivity.this.colorPrimary);
linearLayoutItem.setBackgroundColor(MainActivity.this.colorControlHighlight);
} else {
textViewDrawerItemTitle.setTextColor(MainActivity.this.textColorPrimary);
linearLayoutItem.setBackgroundColor(MainActivity.this.colorBackground);
}
}
Toast.makeText(MainActivity.this, "Menu Artikel ", 0).show();
MainActivity.this.timer_iklan("artikel");
if (MainActivity.this.getSupportActionBar() != null) {
MainActivity.this.getSupportActionBar().setTitle((CharSequence) "Artikel");
}
bundle = new Bundle();
MainActivity.this.timer_iklan("artikel");
MainActivity.this.getSupportFragmentManager().beginTransaction().replace(C0615R.id.main_activity_content_frame, Frg_Artikel.newInstance(bundle)).commit();
return true;
case CompletionEvent.STATUS_FAILURE /*1*/:
for (i = 0; i < MainActivity.this.recyclerViewDrawer2.getChildCount(); i++) {
textViewDrawerItemTitle = (TextView) MainActivity.this.recyclerViewDrawer2.getChildAt(i).findViewById(C0615R.id.textViewDrawerItemTitle);
linearLayoutItem = (LinearLayout) MainActivity.this.recyclerViewDrawer2.getChildAt(i).findViewById(C0615R.id.linearLayoutItem);
if (i == 1) {
textViewDrawerItemTitle.setTextColor(MainActivity.this.colorPrimary);
linearLayoutItem.setBackgroundColor(MainActivity.this.colorControlHighlight);
} else {
textViewDrawerItemTitle.setTextColor(MainActivity.this.textColorPrimary);
linearLayoutItem.setBackgroundColor(MainActivity.this.colorBackground);
}
}
Toast.makeText(MainActivity.this, "Menu Jadwal Sholat ", 0).show();
if (MainActivity.this.getSupportActionBar() != null) {
MainActivity.this.getSupportActionBar().setTitle((CharSequence) "Jadwal Sholat");
}
MainActivity.this.timer_iklan("jadwal_sholat");
MainActivity.this.getSupportFragmentManager().beginTransaction().replace(C0615R.id.main_activity_content_frame, Frg_Jadwal_Sholat.newInstance(new Bundle())).commit();
return true;
case CompletionEvent.STATUS_CONFLICT /*2*/:
for (i = 0; i < MainActivity.this.recyclerViewDrawer2.getChildCount(); i++) {
textViewDrawerItemTitle = (TextView) MainActivity.this.recyclerViewDrawer2.getChildAt(i).findViewById(C0615R.id.textViewDrawerItemTitle);
linearLayoutItem = (LinearLayout) MainActivity.this.recyclerViewDrawer2.getChildAt(i).findViewById(C0615R.id.linearLayoutItem);
if (i == 2) {
textViewDrawerItemTitle.setTextColor(MainActivity.this.colorPrimary);
linearLayoutItem.setBackgroundColor(MainActivity.this.colorControlHighlight);
} else {
textViewDrawerItemTitle.setTextColor(MainActivity.this.textColorPrimary);
linearLayoutItem.setBackgroundColor(MainActivity.this.colorBackground);
}
}
Toast.makeText(MainActivity.this, "Klik Button LOKASI untuk set kordinat lokasi saat ini ... ", 0).show();
if (MainActivity.this.getSupportActionBar() != null) {
MainActivity.this.getSupportActionBar().setTitle((CharSequence) "Arah Qiblat");
}
bundle = new Bundle();
MainActivity.this.timer_iklan("arah_qiblat");
MainActivity.this.getSupportFragmentManager().beginTransaction().replace(C0615R.id.main_activity_content_frame, Frg_Kompas_Muazzin.newInstance(bundle)).commit();
return true;
default:
return true;
}
}
public void onTouchEvent(RecyclerView recyclerView, MotionEvent motionEvent) {
}
}
/* renamed from: org.bpmikc.akm.MainActivity.8 */
class C08858 implements OnItemTouchListener {
final /* synthetic */ GestureDetector val$mGestureDetector;
C08858(GestureDetector gestureDetector) {
this.val$mGestureDetector = gestureDetector;
}
public boolean onInterceptTouchEvent(RecyclerView recyclerView, MotionEvent motionEvent) {
View child = recyclerView.findChildViewUnder(motionEvent.getX(), motionEvent.getY());
if (child == null || !this.val$mGestureDetector.onTouchEvent(motionEvent)) {
return false;
}
int i;
MainActivity.this.drawerLayout.closeDrawers();
for (i = 0; i < MainActivity.this.recyclerViewDrawer1.getChildCount(); i++) {
LinearLayout linearLayoutItem = (LinearLayout) MainActivity.this.recyclerViewDrawer1.getChildAt(i).findViewById(C0615R.id.linearLayoutItem);
((TextView) MainActivity.this.recyclerViewDrawer1.getChildAt(i).findViewById(C0615R.id.textViewDrawerItemTitle)).setTextColor(MainActivity.this.textColorPrimary);
linearLayoutItem.setBackgroundColor(MainActivity.this.colorBackground);
}
for (i = 0; i < MainActivity.this.recyclerViewDrawer2.getChildCount(); i++) {
linearLayoutItem = (LinearLayout) MainActivity.this.recyclerViewDrawer2.getChildAt(i).findViewById(C0615R.id.linearLayoutItem);
((TextView) MainActivity.this.recyclerViewDrawer2.getChildAt(i).findViewById(C0615R.id.textViewDrawerItemTitle)).setTextColor(MainActivity.this.textColorPrimary);
linearLayoutItem.setBackgroundColor(MainActivity.this.colorBackground);
}
for (i = 0; i < MainActivity.this.recyclerViewDrawerSettings.getChildCount(); i++) {
linearLayoutItem = (LinearLayout) MainActivity.this.recyclerViewDrawerSettings.getChildAt(i).findViewById(C0615R.id.linearLayoutItem);
((TextView) MainActivity.this.recyclerViewDrawerSettings.getChildAt(i).findViewById(C0615R.id.textViewDrawerItemTitle)).setTextColor(MainActivity.this.textColorPrimary);
linearLayoutItem.setBackgroundColor(MainActivity.this.colorBackground);
}
TextView textViewDrawerItemTitle;
switch (recyclerView.getChildPosition(child)) {
case SpinnerCompat.MODE_DIALOG /*0*/:
for (i = 0; i < MainActivity.this.recyclerViewDrawer3.getChildCount(); i++) {
textViewDrawerItemTitle = (TextView) MainActivity.this.recyclerViewDrawer3.getChildAt(i).findViewById(C0615R.id.textViewDrawerItemTitle);
linearLayoutItem = (LinearLayout) MainActivity.this.recyclerViewDrawer3.getChildAt(i).findViewById(C0615R.id.linearLayoutItem);
if (i == 0) {
textViewDrawerItemTitle.setTextColor(MainActivity.this.colorPrimary);
linearLayoutItem.setBackgroundColor(MainActivity.this.colorControlHighlight);
} else {
textViewDrawerItemTitle.setTextColor(MainActivity.this.textColorPrimary);
linearLayoutItem.setBackgroundColor(MainActivity.this.colorBackground);
}
}
Toast.makeText(MainActivity.this, "Menu Kewanitaan ", 0).show();
if (MainActivity.this.getSupportActionBar() != null) {
MainActivity.this.getSupportActionBar().setTitle((CharSequence) "Kewanitaan");
}
MainActivity.this.timer_iklan("kewanitaan");
MainActivity.this.getSupportFragmentManager().beginTransaction().replace(C0615R.id.main_activity_content_frame, Frg_Kewanitaan.newInstance(new Bundle())).commit();
return true;
case CompletionEvent.STATUS_FAILURE /*1*/:
for (i = 0; i < MainActivity.this.recyclerViewDrawer3.getChildCount(); i++) {
textViewDrawerItemTitle = (TextView) MainActivity.this.recyclerViewDrawer3.getChildAt(i).findViewById(C0615R.id.textViewDrawerItemTitle);
linearLayoutItem = (LinearLayout) MainActivity.this.recyclerViewDrawer3.getChildAt(i).findViewById(C0615R.id.linearLayoutItem);
if (i == 1) {
textViewDrawerItemTitle.setTextColor(MainActivity.this.colorPrimary);
linearLayoutItem.setBackgroundColor(MainActivity.this.colorControlHighlight);
} else {
textViewDrawerItemTitle.setTextColor(MainActivity.this.textColorPrimary);
linearLayoutItem.setBackgroundColor(MainActivity.this.colorBackground);
}
}
Toast.makeText(MainActivity.this, "Menu Donasi dan Iklan ", 0).show();
if (MainActivity.this.getSupportActionBar() != null) {
MainActivity.this.getSupportActionBar().setTitle((CharSequence) "Donasi dan Iklan");
}
MainActivity.this.timer_iklan("donasi_iklan");
MainActivity.this.getSupportFragmentManager().beginTransaction().replace(C0615R.id.main_activity_content_frame, Frg_Donasi.newInstance(new Bundle())).commit();
return true;
case CompletionEvent.STATUS_CONFLICT /*2*/:
for (i = 0; i < MainActivity.this.recyclerViewDrawer3.getChildCount(); i++) {
textViewDrawerItemTitle = (TextView) MainActivity.this.recyclerViewDrawer3.getChildAt(i).findViewById(C0615R.id.textViewDrawerItemTitle);
linearLayoutItem = (LinearLayout) MainActivity.this.recyclerViewDrawer3.getChildAt(i).findViewById(C0615R.id.linearLayoutItem);
if (i == 2) {
textViewDrawerItemTitle.setTextColor(MainActivity.this.colorPrimary);
linearLayoutItem.setBackgroundColor(MainActivity.this.colorControlHighlight);
} else {
textViewDrawerItemTitle.setTextColor(MainActivity.this.textColorPrimary);
linearLayoutItem.setBackgroundColor(MainActivity.this.colorBackground);
}
}
Toast.makeText(MainActivity.this, "Menu Info Transaksi Online ", 0).show();
if (MainActivity.this.getSupportActionBar() != null) {
MainActivity.this.getSupportActionBar().setTitle((CharSequence) "Transaksi Online");
}
MainActivity.this.timer_iklan("transaksi_online");
MainActivity.this.getSupportFragmentManager().beginTransaction().replace(C0615R.id.main_activity_content_frame, Frg_Transaksi_Online.newInstance(new Bundle())).commit();
return true;
default:
return true;
}
}
public void onTouchEvent(RecyclerView recyclerView, MotionEvent motionEvent) {
}
}
/* renamed from: org.bpmikc.akm.MainActivity.9 */
class C08869 implements OnItemTouchListener {
final /* synthetic */ GestureDetector val$mGestureDetector;
C08869(GestureDetector gestureDetector) {
this.val$mGestureDetector = gestureDetector;
}
public boolean onInterceptTouchEvent(RecyclerView recyclerView, MotionEvent motionEvent) {
View child = recyclerView.findChildViewUnder(motionEvent.getX(), motionEvent.getY());
if (child == null || !this.val$mGestureDetector.onTouchEvent(motionEvent)) {
return false;
}
int i;
MainActivity.this.drawerLayout.closeDrawers();
for (i = 0; i < MainActivity.this.recyclerViewDrawer1.getChildCount(); i++) {
LinearLayout linearLayoutItem = (LinearLayout) MainActivity.this.recyclerViewDrawer1.getChildAt(i).findViewById(C0615R.id.linearLayoutItem);
((TextView) MainActivity.this.recyclerViewDrawer1.getChildAt(i).findViewById(C0615R.id.textViewDrawerItemTitle)).setTextColor(MainActivity.this.textColorPrimary);
linearLayoutItem.setBackgroundColor(MainActivity.this.colorBackground);
}
for (i = 0; i < MainActivity.this.recyclerViewDrawer2.getChildCount(); i++) {
linearLayoutItem = (LinearLayout) MainActivity.this.recyclerViewDrawer3.getChildAt(i).findViewById(C0615R.id.linearLayoutItem);
((TextView) MainActivity.this.recyclerViewDrawer2.getChildAt(i).findViewById(C0615R.id.textViewDrawerItemTitle)).setTextColor(MainActivity.this.textColorPrimary);
linearLayoutItem.setBackgroundColor(MainActivity.this.colorBackground);
}
for (i = 0; i < MainActivity.this.recyclerViewDrawer3.getChildCount(); i++) {
linearLayoutItem = (LinearLayout) MainActivity.this.recyclerViewDrawer3.getChildAt(i).findViewById(C0615R.id.linearLayoutItem);
((TextView) MainActivity.this.recyclerViewDrawer3.getChildAt(i).findViewById(C0615R.id.textViewDrawerItemTitle)).setTextColor(MainActivity.this.textColorPrimary);
linearLayoutItem.setBackgroundColor(MainActivity.this.colorBackground);
}
TextView textViewDrawerItemTitle;
Bundle bundle;
switch (recyclerView.getChildPosition(child)) {
case SpinnerCompat.MODE_DIALOG /*0*/:
for (i = 0; i < MainActivity.this.recyclerViewDrawerSettings.getChildCount(); i++) {
textViewDrawerItemTitle = (TextView) MainActivity.this.recyclerViewDrawerSettings.getChildAt(i).findViewById(C0615R.id.textViewDrawerItemTitle);
linearLayoutItem = (LinearLayout) MainActivity.this.recyclerViewDrawerSettings.getChildAt(i).findViewById(C0615R.id.linearLayoutItem);
if (i == 0) {
textViewDrawerItemTitle.setTextColor(MainActivity.this.colorPrimary);
linearLayoutItem.setBackgroundColor(MainActivity.this.colorControlHighlight);
} else {
textViewDrawerItemTitle.setTextColor(MainActivity.this.textColorPrimary);
linearLayoutItem.setBackgroundColor(MainActivity.this.colorBackground);
}
}
Toast.makeText(MainActivity.this, "Menu Tampilan ", 0).show();
if (MainActivity.this.getSupportActionBar() != null) {
MainActivity.this.getSupportActionBar().setTitle((CharSequence) "Tampilan");
}
bundle = new Bundle();
MainActivity.this.timer_iklan("option_tampilan");
MainActivity.this.getSupportFragmentManager().beginTransaction().replace(C0615R.id.main_activity_content_frame, Frg_Setting.newInstance(bundle)).commit();
return true;
case CompletionEvent.STATUS_FAILURE /*1*/:
for (i = 0; i < MainActivity.this.recyclerViewDrawerSettings.getChildCount(); i++) {
textViewDrawerItemTitle = (TextView) MainActivity.this.recyclerViewDrawerSettings.getChildAt(i).findViewById(C0615R.id.textViewDrawerItemTitle);
linearLayoutItem = (LinearLayout) MainActivity.this.recyclerViewDrawerSettings.getChildAt(i).findViewById(C0615R.id.linearLayoutItem);
if (i == 1) {
textViewDrawerItemTitle.setTextColor(MainActivity.this.colorPrimary);
linearLayoutItem.setBackgroundColor(MainActivity.this.colorControlHighlight);
} else {
textViewDrawerItemTitle.setTextColor(MainActivity.this.textColorPrimary);
linearLayoutItem.setBackgroundColor(MainActivity.this.colorBackground);
}
}
Toast.makeText(MainActivity.this, "Menu Beri Masukan ", 0).show();
if (MainActivity.this.getSupportActionBar() != null) {
MainActivity.this.getSupportActionBar().setTitle((CharSequence) "Saran & Masukan");
}
bundle = new Bundle();
MainActivity.this.timer_iklan("beri_masukan");
MainActivity.this.getSupportFragmentManager().beginTransaction().replace(C0615R.id.main_activity_content_frame, Frg_Faq_Masukan.newInstance(bundle)).commit();
return true;
default:
return true;
}
}
public void onTouchEvent(RecyclerView recyclerView, MotionEvent motionEvent) {
}
}
public MainActivity() {
this.server_path = "http://195.110.58.111/ikcv20";
this.server_path_target = "http://195.110.58.111/ikcv20";
this.count = 0;
this.f12a = 0;
this.imageArray_url = new String[0];
this.id_rec = BuildConfig.FLAVOR;
this.menu = BuildConfig.FLAVOR;
this.status = BuildConfig.FLAVOR;
this.url_iklan = BuildConfig.FLAVOR;
this.durasi = BuildConfig.FLAVOR;
this.flag_01 = BuildConfig.FLAVOR;
this.flag_02 = BuildConfig.FLAVOR;
this.flag_03 = BuildConfig.FLAVOR;
this.image_iklan = BuildConfig.FLAVOR;
this.ik = 0;
this.handler = new Handler();
}
protected void onCreate(Bundle savedInstanceState) {
setupTheme();
super.onCreate(savedInstanceState);
setContentView((int) C0615R.layout.activity_main);
this.mPreferences = Preferences.getInstance(this);
this.toolbar = (Toolbar) findViewById(C0615R.id.toolbar);
setSupportActionBar(this.toolbar);
getSupportActionBar().setTitle((CharSequence) "Masjid v2.1");
this.statusBar = (FrameLayout) findViewById(C0615R.id.statusBar);
MySQLiteHelper db = new MySQLiteHelper(getApplicationContext());
setupNavigationDrawer();
setupButtons();
SharedPreferences pref = getSharedPreferences("MyPrefs", 0);
Editor edit = pref.edit();
edit.putString("server_path", this.server_path_target);
edit.commit();
this.server_path = pref.getString("server_path", BuildConfig.FLAVOR);
getSupportFragmentManager().beginTransaction().replace(C0615R.id.main_activity_content_frame, Frg_Home.newInstance(this.bundle)).commit();
timer_iklan("home");
}
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(C0615R.menu.menu_main, menu);
return true;
}
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case C0615R.id.action_settings:
showToast("Mengubah Tampilan Warna Aplikasi ...");
if (getSupportActionBar() != null) {
getSupportActionBar().setTitle((CharSequence) "Tampilan");
}
Bundle bundle = new Bundle();
timer_iklan("option_tampilan");
getSupportFragmentManager().beginTransaction().setCustomAnimations(C0615R.anim.enter_from_right, C0615R.anim.exit_to_right, C0615R.anim.enter_from_right, C0615R.anim.exit_to_right).replace(C0615R.id.main_activity_content_frame, Frg_Setting.newInstance(bundle)).commit();
break;
case C0615R.id.action_help:
showToast("Bantuan Penggunaan Aplikasi ...");
if (getSupportActionBar() != null) {
getSupportActionBar().setTitle((CharSequence) "Bantuan");
}
timer_iklan("option_bantuan");
getSupportFragmentManager().beginTransaction().setCustomAnimations(C0615R.anim.enter_from_right, C0615R.anim.exit_to_right, C0615R.anim.enter_from_right, C0615R.anim.exit_to_right).replace(C0615R.id.main_activity_content_frame, Frg_Bantuan.newInstance(new Bundle())).commit();
break;
case C0615R.id.action_about:
showToast("Info Terkait Aplikasi ...");
if (getSupportActionBar() != null) {
getSupportActionBar().setTitle((CharSequence) "Info Aplikasi");
}
timer_iklan("option_aplikasi");
getSupportFragmentManager().beginTransaction().setCustomAnimations(C0615R.anim.enter_from_right, C0615R.anim.exit_to_right, C0615R.anim.enter_from_right, C0615R.anim.exit_to_right).replace(C0615R.id.main_activity_content_frame, Frg_Info_Aplikasi.newInstance(new Bundle())).commit();
break;
case C0615R.id.action_exit:
DialogInterface.OnClickListener dialogClickListener = new C06091();
new Builder(this).setMessage("Akan Keluar Aplikasi Masjid ?").setPositiveButton("Ya", dialogClickListener).setNegativeButton("Tidak", dialogClickListener).show();
break;
}
return super.onOptionsItemSelected(item);
}
/* JADX WARNING: inconsistent code. */
/* Code decompiled incorrectly, please refer to instructions dump. */
public void setupTheme() {
/*
r4 = this;
r0 = 0;
r1 = "VALUES";
r1 = r4.getSharedPreferences(r1, r0);
r4.sharedPreferences = r1;
r1 = r4.sharedPreferences;
r2 = "THEME";
r3 = "REDLIGHT";
r2 = r1.getString(r2, r3);
r1 = -1;
r3 = r2.hashCode();
switch(r3) {
case 8986405: goto L_0x0020;
case 14885192: goto L_0x003d;
case 469056868: goto L_0x0033;
case 1801159527: goto L_0x0029;
default: goto L_0x001b;
};
L_0x001b:
r0 = r1;
L_0x001c:
switch(r0) {
case 0: goto L_0x0047;
case 1: goto L_0x004e;
case 2: goto L_0x0055;
case 3: goto L_0x005c;
default: goto L_0x001f;
};
L_0x001f:
return;
L_0x0020:
r3 = "REDLIGHT";
r2 = r2.equals(r3);
if (r2 == 0) goto L_0x001b;
L_0x0028:
goto L_0x001c;
L_0x0029:
r0 = "REDDARK";
r0 = r2.equals(r0);
if (r0 == 0) goto L_0x001b;
L_0x0031:
r0 = 1;
goto L_0x001c;
L_0x0033:
r0 = "INDIGOLIGHT";
r0 = r2.equals(r0);
if (r0 == 0) goto L_0x001b;
L_0x003b:
r0 = 2;
goto L_0x001c;
L_0x003d:
r0 = "INDIGODARK";
r0 = r2.equals(r0);
if (r0 == 0) goto L_0x001b;
L_0x0045:
r0 = 3;
goto L_0x001c;
L_0x0047:
r0 = 2131296306; // 0x7f090032 float:1.8210525E38 double:1.053000286E-314;
r4.setTheme(r0);
goto L_0x001f;
L_0x004e:
r0 = 2131296305; // 0x7f090031 float:1.8210523E38 double:1.0530002854E-314;
r4.setTheme(r0);
goto L_0x001f;
L_0x0055:
r0 = 2131296304; // 0x7f090030 float:1.821052E38 double:1.053000285E-314;
r4.setTheme(r0);
goto L_0x001f;
L_0x005c:
r0 = 2131296303; // 0x7f09002f float:1.8210519E38 double:1.0530002844E-314;
r4.setTheme(r0);
goto L_0x001f;
*/
throw new UnsupportedOperationException("Method not decompiled: org.bpmikc.akm.MainActivity.setupTheme():void");
}
public void setupNavigationDrawer() {
this.drawerLayout = (DrawerLayout) findViewById(C0615R.id.drawerLayout);
this.drawerToggle = new ActionBarDrawerToggle(this, this.drawerLayout, this.toolbar, C0615R.string.drawer_open, C0615R.string.drawer_close);
this.drawerLayout.setDrawerListener(this.drawerToggle);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setHomeButtonEnabled(true);
this.drawerToggle.syncState();
String server_path = getSharedPreferences("MyPrefs", 0).getString("server_path", BuildConfig.FLAVOR);
String urlPictureMain = server_path + "/app_files/sujud.png";
String urlCoverMain = server_path + "/app_files/masjid.jpg";
String urlPictureSecond = server_path + "/app_files/bulanbintang.jpg";
ImageView imageViewPictureMain = (ImageView) findViewById(C0615R.id.imageViewPictureMain);
ImageView imageViewPictureSecond = (ImageView) findViewById(C0615R.id.imageViewPictureSecond);
Glide.with(getApplicationContext()).load(urlCoverMain).into((ImageView) findViewById(C0615R.id.imageViewCover));
Glide.with(getApplicationContext()).load(urlPictureMain).asBitmap().transform(new CropCircleTransform(getApplicationContext())).into(imageViewPictureMain);
Glide.with(getApplicationContext()).load(urlPictureSecond).asBitmap().transform(new CropCircleTransform(getApplicationContext())).into(imageViewPictureSecond);
TypedValue typedValue = new TypedValue();
getTheme().resolveAttribute(C0615R.attr.colorPrimaryDark, typedValue, true);
this.drawerLayout.setStatusBarBackgroundColor(typedValue.data);
this.toggleButtonDrawer = (ToggleButton) findViewById(C0615R.id.toggleButtonDrawer);
this.toggleButtonDrawer.setOnClickListener(this);
hideNavigationDrawerSettingsAndFeedbackOnScroll();
setupNavigationDrawerRecyclerViews();
}
public void setupButtons() {
}
private void hideNavigationDrawerSettingsAndFeedbackOnScroll() {
this.scrollViewNavigationDrawerContent = (ScrollView) findViewById(C0615R.id.scrollViewNavigationDrawerContent);
this.relativeLayoutScrollViewChild = (RelativeLayout) findViewById(C0615R.id.relativeLayoutScrollViewChild);
this.frameLayoutSetting1 = (FrameLayout) findViewById(C0615R.id.frameLayoutSettings1);
this.viewTreeObserverNavigationDrawerScrollView = this.relativeLayoutScrollViewChild.getViewTreeObserver();
if (this.viewTreeObserverNavigationDrawerScrollView.isAlive()) {
this.viewTreeObserverNavigationDrawerScrollView.addOnGlobalLayoutListener(new C06102());
}
this.onScrollChangedListener = new C06123();
this.scrollViewNavigationDrawerContent.setOnTouchListener(new C06134());
}
private void setupNavigationDrawerRecyclerViews() {
if (getSupportActionBar() != null) {
getSupportActionBar().setTitle((CharSequence) "Assalamu'alaikum");
}
this.recyclerViewDrawer1 = (RecyclerView) findViewById(C0615R.id.recyclerViewDrawer1);
this.linearLayoutManager = new LinearLayoutManager(this);
this.recyclerViewDrawer1.setLayoutManager(this.linearLayoutManager);
this.drawerItems1 = new ArrayList();
this.drawerItems1.add(new DrawerItem(getResources().getDrawable(C0615R.drawable.ic_action_home), "Home"));
this.drawerItems1.add(new DrawerItem(getResources().getDrawable(C0615R.drawable.ic_action_lokasi_masjid), "Lokasi Masjid"));
this.drawerItems1.add(new DrawerItem(getResources().getDrawable(C0615R.drawable.ic_action_tambah), "Tambah Masjid"));
this.drawerItems1.add(new DrawerItem(getResources().getDrawable(C0615R.drawable.ic_cari_masjid), "Cari Masjid"));
this.drawerAdapter1 = new DrawerAdapter(this.drawerItems1);
this.recyclerViewDrawer1.setAdapter(this.drawerAdapter1);
this.recyclerViewDrawer1.setMinimumHeight(convertDpToPx(200));
this.recyclerViewDrawer1.setHasFixedSize(true);
GestureDetector mGestureDetector = new GestureDetector(this, new C06145());
this.recyclerViewDrawer1.addOnItemTouchListener(new C08836(mGestureDetector));
this.recyclerViewDrawer2 = (RecyclerView) findViewById(C0615R.id.recyclerViewDrawer2);
this.linearLayoutManager2 = new LinearLayoutManager(this);
this.recyclerViewDrawer2.setLayoutManager(this.linearLayoutManager2);
this.drawerItems2 = new ArrayList();
this.drawerItems2.add(new DrawerItem(getResources().getDrawable(C0615R.drawable.ic_action_content_drafts), "Artikel"));
this.drawerItems2.add(new DrawerItem(getResources().getDrawable(C0615R.drawable.ic_action_content_send), "Jadwal Sholat"));
this.drawerItems2.add(new DrawerItem(getResources().getDrawable(C0615R.drawable.ic_action_social_notifications_on), "Qiblat"));
this.drawerAdapter2 = new DrawerAdapter(this.drawerItems2);
this.recyclerViewDrawer2.setAdapter(this.drawerAdapter2);
this.recyclerViewDrawer2.setMinimumHeight(convertDpToPx(144));
this.recyclerViewDrawer2.setHasFixedSize(true);
this.recyclerViewDrawer2.addOnItemTouchListener(new C08847(mGestureDetector));
this.recyclerViewDrawer3 = (RecyclerView) findViewById(C0615R.id.recyclerViewDrawer3);
this.linearLayoutManager3 = new LinearLayoutManager(this);
this.recyclerViewDrawer3.setLayoutManager(this.linearLayoutManager3);
this.drawerItems3 = new ArrayList();
this.drawerItems3.add(new DrawerItem(getResources().getDrawable(C0615R.drawable.ic_action_kewanitaan), "Kewanitaan"));
this.drawerItems3.add(new DrawerItem(getResources().getDrawable(C0615R.drawable.ic_action_action_label), "Donasi dan Iklan "));
this.drawerItems3.add(new DrawerItem(getResources().getDrawable(C0615R.drawable.ic_action_online), "Transaksi Online"));
this.drawerAdapter3 = new DrawerAdapter(this.drawerItems3);
this.recyclerViewDrawer3.setAdapter(this.drawerAdapter3);
this.recyclerViewDrawer3.setMinimumHeight(convertDpToPx(144));
this.recyclerViewDrawer3.setHasFixedSize(true);
this.recyclerViewDrawer3.addOnItemTouchListener(new C08858(mGestureDetector));
this.recyclerViewDrawerSettings = (RecyclerView) findViewById(C0615R.id.recyclerViewDrawerSettings);
this.linearLayoutManagerSettings = new LinearLayoutManager(this);
this.recyclerViewDrawerSettings.setLayoutManager(this.linearLayoutManagerSettings);
this.drawerItemsSettings = new ArrayList();
this.drawerItemsSettings.add(new DrawerItem(getResources().getDrawable(C0615R.drawable.ic_action_action_settings), "Tampilan"));
this.drawerItemsSettings.add(new DrawerItem(getResources().getDrawable(C0615R.drawable.ic_action_action_help), "Beri Masukan"));
this.drawerAdapterSettings = new DrawerAdapter(this.drawerItemsSettings);
this.recyclerViewDrawerSettings.setAdapter(this.drawerAdapterSettings);
this.recyclerViewDrawerSettings.setMinimumHeight(convertDpToPx(96));
this.recyclerViewDrawerSettings.setHasFixedSize(true);
this.recyclerViewDrawerSettings.addOnItemTouchListener(new C08869(mGestureDetector));
this.typedValueColorPrimary = new TypedValue();
getTheme().resolveAttribute(C0615R.attr.colorPrimary, this.typedValueColorPrimary, true);
this.colorPrimary = this.typedValueColorPrimary.data;
this.typedValueTextColorPrimary = new TypedValue();
getTheme().resolveAttribute(16842806, this.typedValueTextColorPrimary, true);
this.textColorPrimary = this.typedValueTextColorPrimary.data;
this.typedValueTextColorControlHighlight = new TypedValue();
getTheme().resolveAttribute(C0615R.attr.colorControlHighlight, this.typedValueTextColorControlHighlight, true);
this.colorControlHighlight = this.typedValueTextColorControlHighlight.data;
this.typedValueColorBackground = new TypedValue();
getTheme().resolveAttribute(16842801, this.typedValueColorBackground, true);
this.colorBackground = this.typedValueColorBackground.data;
new Handler().postDelayed(new Runnable() {
public void run() {
int i;
for (i = 0; i < MainActivity.this.recyclerViewDrawer1.getChildCount(); i++) {
ImageView imageViewDrawerItemIcon = (ImageView) MainActivity.this.recyclerViewDrawer1.getChildAt(i).findViewById(C0615R.id.imageViewDrawerItemIcon);
TextView textViewDrawerItemTitle = (TextView) MainActivity.this.recyclerViewDrawer1.getChildAt(i).findViewById(C0615R.id.textViewDrawerItemTitle);
LinearLayout linearLayoutItem = (LinearLayout) MainActivity.this.recyclerViewDrawer1.getChildAt(i).findViewById(C0615R.id.linearLayoutItem);
if (i == 0) {
imageViewDrawerItemIcon.setColorFilter(MainActivity.this.colorPrimary);
if (VERSION.SDK_INT > 15) {
imageViewDrawerItemIcon.setImageAlpha(MotionEventCompat.ACTION_MASK);
} else {
imageViewDrawerItemIcon.setAlpha(MotionEventCompat.ACTION_MASK);
}
textViewDrawerItemTitle.setTextColor(MainActivity.this.colorPrimary);
linearLayoutItem.setBackgroundColor(MainActivity.this.colorControlHighlight);
} else {
imageViewDrawerItemIcon.setColorFilter(MainActivity.this.textColorPrimary);
if (VERSION.SDK_INT > 15) {
imageViewDrawerItemIcon.setImageAlpha(138);
} else {
imageViewDrawerItemIcon.setAlpha(138);
}
textViewDrawerItemTitle.setTextColor(MainActivity.this.textColorPrimary);
linearLayoutItem.setBackgroundColor(MainActivity.this.colorBackground);
}
}
for (i = 0; i < MainActivity.this.recyclerViewDrawer2.getChildCount(); i++) {
imageViewDrawerItemIcon = (ImageView) MainActivity.this.recyclerViewDrawer2.getChildAt(i).findViewById(C0615R.id.imageViewDrawerItemIcon);
textViewDrawerItemTitle = (TextView) MainActivity.this.recyclerViewDrawer2.getChildAt(i).findViewById(C0615R.id.textViewDrawerItemTitle);
linearLayoutItem = (LinearLayout) MainActivity.this.recyclerViewDrawer2.getChildAt(i).findViewById(C0615R.id.linearLayoutItem);
imageViewDrawerItemIcon.setColorFilter(MainActivity.this.textColorPrimary);
if (VERSION.SDK_INT > 15) {
imageViewDrawerItemIcon.setImageAlpha(138);
} else {
imageViewDrawerItemIcon.setAlpha(138);
}
textViewDrawerItemTitle.setTextColor(MainActivity.this.textColorPrimary);
linearLayoutItem.setBackgroundColor(MainActivity.this.colorBackground);
}
for (i = 0; i < MainActivity.this.recyclerViewDrawer3.getChildCount(); i++) {
imageViewDrawerItemIcon = (ImageView) MainActivity.this.recyclerViewDrawer3.getChildAt(i).findViewById(C0615R.id.imageViewDrawerItemIcon);
textViewDrawerItemTitle = (TextView) MainActivity.this.recyclerViewDrawer3.getChildAt(i).findViewById(C0615R.id.textViewDrawerItemTitle);
linearLayoutItem = (LinearLayout) MainActivity.this.recyclerViewDrawer3.getChildAt(i).findViewById(C0615R.id.linearLayoutItem);
imageViewDrawerItemIcon.setColorFilter(MainActivity.this.textColorPrimary);
if (VERSION.SDK_INT > 15) {
imageViewDrawerItemIcon.setImageAlpha(67);
} else {
imageViewDrawerItemIcon.setAlpha(67);
}
textViewDrawerItemTitle.setTextColor(MainActivity.this.textColorPrimary);
linearLayoutItem.setBackgroundColor(MainActivity.this.colorBackground);
}
for (i = 0; i < MainActivity.this.recyclerViewDrawerSettings.getChildCount(); i++) {
imageViewDrawerItemIcon = (ImageView) MainActivity.this.recyclerViewDrawerSettings.getChildAt(i).findViewById(C0615R.id.imageViewDrawerItemIcon);
textViewDrawerItemTitle = (TextView) MainActivity.this.recyclerViewDrawerSettings.getChildAt(i).findViewById(C0615R.id.textViewDrawerItemTitle);
linearLayoutItem = (LinearLayout) MainActivity.this.recyclerViewDrawerSettings.getChildAt(i).findViewById(C0615R.id.linearLayoutItem);
imageViewDrawerItemIcon.setColorFilter(MainActivity.this.textColorPrimary);
if (VERSION.SDK_INT > 15) {
imageViewDrawerItemIcon.setImageAlpha(138);
} else {
imageViewDrawerItemIcon.setAlpha(138);
}
textViewDrawerItemTitle.setTextColor(MainActivity.this.textColorPrimary);
linearLayoutItem.setBackgroundColor(MainActivity.this.colorBackground);
}
ImageView imageViewSettingsIcon = (ImageView) MainActivity.this.findViewById(C0615R.id.imageViewSettingsIcon);
TextView textViewSettingsTitle = (TextView) MainActivity.this.findViewById(C0615R.id.textViewSettingsTitle);
imageViewSettingsIcon.setColorFilter(MainActivity.this.textColorPrimary);
if (VERSION.SDK_INT > 15) {
imageViewSettingsIcon.setImageAlpha(138);
} else {
imageViewSettingsIcon.setAlpha(138);
}
textViewSettingsTitle.setTextColor(MainActivity.this.textColorPrimary);
ImageView imageViewHelpIcon = (ImageView) MainActivity.this.findViewById(C0615R.id.imageViewHelpIcon);
TextView textViewHelpTitle = (TextView) MainActivity.this.findViewById(C0615R.id.textViewHelpTitle);
imageViewHelpIcon.setColorFilter(MainActivity.this.textColorPrimary);
if (VERSION.SDK_INT > 15) {
imageViewHelpIcon.setImageAlpha(138);
} else {
imageViewHelpIcon.setAlpha(138);
}
textViewHelpTitle.setTextColor(MainActivity.this.textColorPrimary);
}
}, 250);
this.itemClickSupport1 = ItemClickSupport.addTo(this.recyclerViewDrawer1);
this.itemClickSupport1.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(RecyclerView parent, View view, int position, long id) {
int i;
for (i = 0; i < MainActivity.this.recyclerViewDrawer1.getChildCount(); i++) {
ImageView imageViewDrawerItemIcon = (ImageView) MainActivity.this.recyclerViewDrawer1.getChildAt(i).findViewById(C0615R.id.imageViewDrawerItemIcon);
TextView textViewDrawerItemTitle = (TextView) MainActivity.this.recyclerViewDrawer1.getChildAt(i).findViewById(C0615R.id.textViewDrawerItemTitle);
LinearLayout linearLayoutItem = (LinearLayout) MainActivity.this.recyclerViewDrawer1.getChildAt(i).findViewById(C0615R.id.linearLayoutItem);
if (i == position) {
imageViewDrawerItemIcon.setColorFilter(MainActivity.this.colorPrimary);
if (VERSION.SDK_INT > 15) {
imageViewDrawerItemIcon.setImageAlpha(MotionEventCompat.ACTION_MASK);
} else {
imageViewDrawerItemIcon.setAlpha(MotionEventCompat.ACTION_MASK);
}
textViewDrawerItemTitle.setTextColor(MainActivity.this.colorPrimary);
linearLayoutItem.setBackgroundColor(MainActivity.this.colorControlHighlight);
} else {
imageViewDrawerItemIcon.setColorFilter(MainActivity.this.textColorPrimary);
if (VERSION.SDK_INT > 15) {
imageViewDrawerItemIcon.setImageAlpha(138);
} else {
imageViewDrawerItemIcon.setAlpha(138);
}
textViewDrawerItemTitle.setTextColor(MainActivity.this.textColorPrimary);
linearLayoutItem.setBackgroundColor(MainActivity.this.colorBackground);
}
}
for (i = 0; i < MainActivity.this.recyclerViewDrawer2.getChildCount(); i++) {
imageViewDrawerItemIcon = (ImageView) MainActivity.this.recyclerViewDrawer2.getChildAt(i).findViewById(C0615R.id.imageViewDrawerItemIcon);
textViewDrawerItemTitle = (TextView) MainActivity.this.recyclerViewDrawer2.getChildAt(i).findViewById(C0615R.id.textViewDrawerItemTitle);
linearLayoutItem = (LinearLayout) MainActivity.this.recyclerViewDrawer2.getChildAt(i).findViewById(C0615R.id.linearLayoutItem);
imageViewDrawerItemIcon.setColorFilter(MainActivity.this.textColorPrimary);
if (VERSION.SDK_INT > 15) {
imageViewDrawerItemIcon.setImageAlpha(138);
} else {
imageViewDrawerItemIcon.setAlpha(138);
}
textViewDrawerItemTitle.setTextColor(MainActivity.this.textColorPrimary);
linearLayoutItem.setBackgroundColor(MainActivity.this.colorBackground);
}
for (i = 0; i < MainActivity.this.recyclerViewDrawer3.getChildCount(); i++) {
imageViewDrawerItemIcon = (ImageView) MainActivity.this.recyclerViewDrawer3.getChildAt(i).findViewById(C0615R.id.imageViewDrawerItemIcon);
textViewDrawerItemTitle = (TextView) MainActivity.this.recyclerViewDrawer3.getChildAt(i).findViewById(C0615R.id.textViewDrawerItemTitle);
linearLayoutItem = (LinearLayout) MainActivity.this.recyclerViewDrawer3.getChildAt(i).findViewById(C0615R.id.linearLayoutItem);
imageViewDrawerItemIcon.setColorFilter(MainActivity.this.textColorPrimary);
textViewDrawerItemTitle.setTextColor(MainActivity.this.textColorPrimary);
if (VERSION.SDK_INT > 15) {
imageViewDrawerItemIcon.setImageAlpha(67);
} else {
imageViewDrawerItemIcon.setAlpha(67);
}
linearLayoutItem.setBackgroundColor(MainActivity.this.colorBackground);
}
}
});
this.itemClickSupport2 = ItemClickSupport.addTo(this.recyclerViewDrawer2);
this.itemClickSupport2.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(RecyclerView parent, View view, int position, long id) {
int i;
for (i = 0; i < MainActivity.this.recyclerViewDrawer2.getChildCount(); i++) {
ImageView imageViewDrawerItemIcon = (ImageView) MainActivity.this.recyclerViewDrawer2.getChildAt(i).findViewById(C0615R.id.imageViewDrawerItemIcon);
TextView textViewDrawerItemTitle = (TextView) MainActivity.this.recyclerViewDrawer2.getChildAt(i).findViewById(C0615R.id.textViewDrawerItemTitle);
LinearLayout linearLayoutItem = (LinearLayout) MainActivity.this.recyclerViewDrawer2.getChildAt(i).findViewById(C0615R.id.linearLayoutItem);
if (i == position) {
imageViewDrawerItemIcon.setColorFilter(MainActivity.this.colorPrimary);
if (VERSION.SDK_INT > 15) {
imageViewDrawerItemIcon.setImageAlpha(MotionEventCompat.ACTION_MASK);
} else {
imageViewDrawerItemIcon.setAlpha(MotionEventCompat.ACTION_MASK);
}
textViewDrawerItemTitle.setTextColor(MainActivity.this.colorPrimary);
linearLayoutItem.setBackgroundColor(MainActivity.this.colorControlHighlight);
} else {
imageViewDrawerItemIcon.setColorFilter(MainActivity.this.textColorPrimary);
if (VERSION.SDK_INT > 15) {
imageViewDrawerItemIcon.setImageAlpha(138);
} else {
imageViewDrawerItemIcon.setAlpha(138);
}
textViewDrawerItemTitle.setTextColor(MainActivity.this.textColorPrimary);
linearLayoutItem.setBackgroundColor(MainActivity.this.colorBackground);
}
}
for (i = 0; i < MainActivity.this.recyclerViewDrawer1.getChildCount(); i++) {
imageViewDrawerItemIcon = (ImageView) MainActivity.this.recyclerViewDrawer1.getChildAt(i).findViewById(C0615R.id.imageViewDrawerItemIcon);
textViewDrawerItemTitle = (TextView) MainActivity.this.recyclerViewDrawer1.getChildAt(i).findViewById(C0615R.id.textViewDrawerItemTitle);
linearLayoutItem = (LinearLayout) MainActivity.this.recyclerViewDrawer1.getChildAt(i).findViewById(C0615R.id.linearLayoutItem);
imageViewDrawerItemIcon.setColorFilter(MainActivity.this.textColorPrimary);
if (VERSION.SDK_INT > 15) {
imageViewDrawerItemIcon.setImageAlpha(138);
} else {
imageViewDrawerItemIcon.setAlpha(138);
}
textViewDrawerItemTitle.setTextColor(MainActivity.this.textColorPrimary);
linearLayoutItem.setBackgroundColor(MainActivity.this.colorBackground);
}
for (i = 0; i < MainActivity.this.recyclerViewDrawer3.getChildCount(); i++) {
imageViewDrawerItemIcon = (ImageView) MainActivity.this.recyclerViewDrawer3.getChildAt(i).findViewById(C0615R.id.imageViewDrawerItemIcon);
textViewDrawerItemTitle = (TextView) MainActivity.this.recyclerViewDrawer3.getChildAt(i).findViewById(C0615R.id.textViewDrawerItemTitle);
linearLayoutItem = (LinearLayout) MainActivity.this.recyclerViewDrawer3.getChildAt(i).findViewById(C0615R.id.linearLayoutItem);
imageViewDrawerItemIcon.setColorFilter(MainActivity.this.textColorPrimary);
if (VERSION.SDK_INT > 15) {
imageViewDrawerItemIcon.setImageAlpha(67);
} else {
imageViewDrawerItemIcon.setAlpha(67);
}
textViewDrawerItemTitle.setTextColor(MainActivity.this.textColorPrimary);
linearLayoutItem.setBackgroundColor(MainActivity.this.colorBackground);
}
}
});
this.itemClickSupport3 = ItemClickSupport.addTo(this.recyclerViewDrawer3);
this.itemClickSupport3.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(RecyclerView parent, View view, int position, long id) {
int i;
for (i = 0; i < MainActivity.this.recyclerViewDrawer3.getChildCount(); i++) {
ImageView imageViewDrawerItemIcon = (ImageView) MainActivity.this.recyclerViewDrawer3.getChildAt(i).findViewById(C0615R.id.imageViewDrawerItemIcon);
TextView textViewDrawerItemTitle = (TextView) MainActivity.this.recyclerViewDrawer3.getChildAt(i).findViewById(C0615R.id.textViewDrawerItemTitle);
LinearLayout linearLayoutItem = (LinearLayout) MainActivity.this.recyclerViewDrawer3.getChildAt(i).findViewById(C0615R.id.linearLayoutItem);
if (i == position) {
imageViewDrawerItemIcon.setColorFilter(MainActivity.this.colorPrimary);
if (VERSION.SDK_INT > 15) {
imageViewDrawerItemIcon.setImageAlpha(138);
} else {
imageViewDrawerItemIcon.setAlpha(138);
}
textViewDrawerItemTitle.setTextColor(MainActivity.this.colorPrimary);
linearLayoutItem.setBackgroundColor(MainActivity.this.colorControlHighlight);
} else {
imageViewDrawerItemIcon.setColorFilter(MainActivity.this.textColorPrimary);
if (VERSION.SDK_INT > 15) {
imageViewDrawerItemIcon.setImageAlpha(67);
} else {
imageViewDrawerItemIcon.setAlpha(67);
}
textViewDrawerItemTitle.setTextColor(MainActivity.this.textColorPrimary);
linearLayoutItem.setBackgroundColor(MainActivity.this.colorBackground);
}
}
for (i = 0; i < MainActivity.this.recyclerViewDrawer1.getChildCount(); i++) {
imageViewDrawerItemIcon = (ImageView) MainActivity.this.recyclerViewDrawer1.getChildAt(i).findViewById(C0615R.id.imageViewDrawerItemIcon);
textViewDrawerItemTitle = (TextView) MainActivity.this.recyclerViewDrawer1.getChildAt(i).findViewById(C0615R.id.textViewDrawerItemTitle);
linearLayoutItem = (LinearLayout) MainActivity.this.recyclerViewDrawer1.getChildAt(i).findViewById(C0615R.id.linearLayoutItem);
imageViewDrawerItemIcon.setColorFilter(MainActivity.this.textColorPrimary);
if (VERSION.SDK_INT > 15) {
imageViewDrawerItemIcon.setImageAlpha(138);
} else {
imageViewDrawerItemIcon.setAlpha(138);
}
textViewDrawerItemTitle.setTextColor(MainActivity.this.textColorPrimary);
linearLayoutItem.setBackgroundColor(MainActivity.this.colorBackground);
}
for (i = 0; i < MainActivity.this.recyclerViewDrawer2.getChildCount(); i++) {
imageViewDrawerItemIcon = (ImageView) MainActivity.this.recyclerViewDrawer2.getChildAt(i).findViewById(C0615R.id.imageViewDrawerItemIcon);
textViewDrawerItemTitle = (TextView) MainActivity.this.recyclerViewDrawer2.getChildAt(i).findViewById(C0615R.id.textViewDrawerItemTitle);
linearLayoutItem = (LinearLayout) MainActivity.this.recyclerViewDrawer2.getChildAt(i).findViewById(C0615R.id.linearLayoutItem);
imageViewDrawerItemIcon.setColorFilter(MainActivity.this.textColorPrimary);
if (VERSION.SDK_INT > 15) {
imageViewDrawerItemIcon.setImageAlpha(138);
} else {
imageViewDrawerItemIcon.setAlpha(138);
}
textViewDrawerItemTitle.setTextColor(MainActivity.this.textColorPrimary);
linearLayoutItem.setBackgroundColor(MainActivity.this.colorBackground);
}
}
});
}
public void onClick(View v) {
this.sharedPreferences = getSharedPreferences("VALUES", 0);
Intent intent = new Intent(this, MainActivity.class);
switch (v.getId()) {
case C0615R.id.buttonRedLight:
this.sharedPreferences.edit().putString("THEME", "REDLIGHT").apply();
startActivity(intent);
case C0615R.id.buttonIndigoLight:
this.sharedPreferences.edit().putString("THEME", "INDIGOLIGHT").apply();
startActivity(intent);
case C0615R.id.buttonRedDark:
this.sharedPreferences.edit().putString("THEME", "REDDARK").apply();
startActivity(intent);
case C0615R.id.buttonIndigoDark:
this.sharedPreferences.edit().putString("THEME", "INDIGODARK").apply();
startActivity(intent);
case C0615R.id.toggleButtonDrawer:
this.linearLayoutDrawerAccount = (LinearLayout) findViewById(C0615R.id.linearLayoutDrawerAccounts);
this.linearLayoutDrawerMain = (LinearLayout) findViewById(C0615R.id.linearLayoutDrawerMain);
this.imageViewDrawerArrowUpDown = (ImageView) findViewById(C0615R.id.imageViewDrawerArrowUpDown);
this.frameLayoutSetting1 = (FrameLayout) findViewById(C0615R.id.frameLayoutSettings1);
Animation animation;
if (this.linearLayoutDrawerAccount.getVisibility() == 0) {
this.linearLayoutDrawerAccount.setVisibility(8);
this.linearLayoutDrawerMain.setVisibility(0);
if (this.frameLayoutSetting1.getVisibility() == 0) {
this.frameLayoutSetting1.setVisibility(8);
} else {
hideNavigationDrawerSettingsAndFeedbackOnScroll();
}
animation = new RotateAnimation(0.0f, -180.0f, 1, 0.5f, 1, 0.5f);
animation.setFillAfter(true);
animation.setDuration(500);
this.imageViewDrawerArrowUpDown.startAnimation(animation);
this.imageViewDrawerArrowUpDown.setBackgroundResource(C0615R.drawable.ic_navigation_arrow_drop_up);
} else {
this.linearLayoutDrawerAccount.setVisibility(0);
this.linearLayoutDrawerMain.setVisibility(8);
animation = new RotateAnimation(0.0f, BitmapDescriptorFactory.HUE_CYAN, 1, 0.5f, 1, 0.5f);
animation.setFillAfter(true);
animation.setDuration(500);
this.imageViewDrawerArrowUpDown.startAnimation(animation);
this.imageViewDrawerArrowUpDown.setBackgroundResource(C0615R.drawable.ic_navigation_arrow_drop_down);
}
if (this.frameLayoutSetting1.getVisibility() == 0) {
this.frameLayoutSetting1.setVisibility(8);
} else {
hideNavigationDrawerSettingsAndFeedbackOnScroll();
}
default:
}
}
public int convertDpToPx(int dp) {
return (int) ((((float) dp) * getResources().getDisplayMetrics().density) + 0.5f);
}
private void showToast(String message) {
Toast.makeText(getApplicationContext(), message, 0).show();
}
private void timer_iklan(String smenu) {
String fsmenu = smenu;
String server_path = getApplication().getSharedPreferences("MyPrefs", 0).getString("server_path", BuildConfig.FLAVOR);
Volley.newRequestQueue(getApplication()).add(new JsonObjectRequest(0, server_path + "/app_mobiles/get_kriteria_iklan.php?kriteria=" + smenu, null, new AnonymousClass14(server_path, (ImageView) findViewById(C0615R.id.view_iklan)), new ErrorListener() {
public void onErrorResponse(VolleyError error) {
error.printStackTrace();
}
}));
}
}
| UTF-8 | Java | 82,294 | java | MainActivity.java | Java | [
{
"context": "is.getSupportActionBar().setTitle((CharSequence) \"Arah Qiblat\");\n }\n bund",
"end": 30410,
"score": 0.9606241583824158,
"start": 30399,
"tag": "NAME",
"value": "Arah Qiblat"
},
{
"context": "inActivity() {\n this.server_pa... | null | [] | package org.bpmikc.akm;
import android.app.AlertDialog.Builder;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
import android.os.Build.VERSION;
import android.os.Bundle;
import android.os.Handler;
import android.support.v4.app.FragmentManager;
import android.support.v4.view.MotionEventCompat;
import android.support.v4.view.ViewPager;
import android.support.v4.widget.DrawerLayout;
import android.support.v7.app.ActionBarDrawerToggle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.RecyclerView.Adapter;
import android.support.v7.widget.RecyclerView.OnItemTouchListener;
import android.support.v7.widget.Toolbar;
import android.util.TypedValue;
import android.view.GestureDetector;
import android.view.GestureDetector.SimpleOnGestureListener;
import android.view.Menu;
import android.view.MenuItem;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.View.OnTouchListener;
import android.view.ViewTreeObserver;
import android.view.ViewTreeObserver.OnGlobalLayoutListener;
import android.view.ViewTreeObserver.OnScrollChangedListener;
import android.view.animation.AccelerateInterpolator;
import android.view.animation.Animation;
import android.view.animation.DecelerateInterpolator;
import android.view.animation.RotateAnimation;
import android.widget.Button;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.ScrollView;
import android.widget.TextView;
import android.widget.Toast;
import android.widget.ToggleButton;
import com.android.volley.Response.ErrorListener;
import com.android.volley.Response.Listener;
import com.android.volley.VolleyError;
import com.android.volley.toolbox.JsonObjectRequest;
import com.android.volley.toolbox.Volley;
import com.bumptech.glide.Glide;
import com.google.android.gms.drive.events.CompletionEvent;
import com.google.android.gms.games.Games;
import com.google.android.gms.maps.model.BitmapDescriptorFactory;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Timer;
import org.bpmikc.akm.Database.MySQLiteHelper;
import org.bpmikc.akm.Fragment.Frg_Add_Masjid_Gmap;
import org.bpmikc.akm.Fragment.Frg_Artikel;
import org.bpmikc.akm.Fragment.Frg_Bantuan;
import org.bpmikc.akm.Fragment.Frg_Cari_Masjid;
import org.bpmikc.akm.Fragment.Frg_Donasi;
import org.bpmikc.akm.Fragment.Frg_Faq_Masukan;
import org.bpmikc.akm.Fragment.Frg_Home;
import org.bpmikc.akm.Fragment.Frg_Iklan;
import org.bpmikc.akm.Fragment.Frg_Info_Aplikasi;
import org.bpmikc.akm.Fragment.Frg_Jadwal_Sholat;
import org.bpmikc.akm.Fragment.Frg_Kewanitaan;
import org.bpmikc.akm.Fragment.Frg_Kompas_Muazzin;
import org.bpmikc.akm.Fragment.Frg_Lokasi_Masjid;
import org.bpmikc.akm.Fragment.Frg_Qiblat_Map;
import org.bpmikc.akm.Fragment.Frg_Setting;
import org.bpmikc.akm.Fragment.Frg_Transaksi_Online;
import org.bpmikc.akm.RecyclerView.Adapters.DrawerAdapter;
import org.bpmikc.akm.RecyclerView.Classes.DrawerItem;
import org.bpmikc.akm.RecyclerView.Utils.ItemClickSupport;
import org.bpmikc.akm.RecyclerView.Utils.ItemClickSupport.OnItemClickListener;
import org.bpmikc.akm.Utils.CropCircleTransform;
import org.bpmikc.akm.Utils.CustomSwipeAdapter;
import org.bpmikc.akm.Widget.Preferences;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
public class MainActivity extends AppCompatActivity implements OnClickListener {
public int f12a;
CustomSwipeAdapter adapter;
private Bundle bundle;
Button buttonIndigoDark;
Button buttonIndigoLight;
Button buttonRedDark;
Button buttonRedLight;
int colorBackground;
int colorControlHighlight;
int colorPrimary;
private int count;
Adapter drawerAdapter1;
Adapter drawerAdapter2;
Adapter drawerAdapter3;
Adapter drawerAdapterSettings;
float drawerHeight;
ArrayList<DrawerItem> drawerItems1;
ArrayList<DrawerItem> drawerItems2;
ArrayList<DrawerItem> drawerItems3;
ArrayList<DrawerItem> drawerItemsSettings;
DrawerLayout drawerLayout;
ActionBarDrawerToggle drawerToggle;
private String durasi;
private String flag_01;
private String flag_02;
private String flag_03;
private FragmentManager fm;
FrameLayout frameLayoutSetting1;
final Handler handler;
private String id_rec;
private int ik;
public final String[] imageArray_url;
ImageView imageViewDrawerArrowUpDown;
private String image_iklan;
ItemClickSupport itemClickSupport1;
ItemClickSupport itemClickSupport2;
ItemClickSupport itemClickSupport3;
ItemClickSupport itemClickSupportSettings;
LinearLayout linearLayoutDrawerAccount;
LinearLayout linearLayoutDrawerMain;
LinearLayoutManager linearLayoutManager;
LinearLayoutManager linearLayoutManager2;
LinearLayoutManager linearLayoutManager3;
LinearLayoutManager linearLayoutManagerSettings;
private Preferences mPreferences;
private String menu;
OnScrollChangedListener onScrollChangedListener;
RecyclerView recyclerViewDrawer1;
RecyclerView recyclerViewDrawer2;
RecyclerView recyclerViewDrawer3;
RecyclerView recyclerViewDrawerSettings;
int recyclerViewHeight;
RelativeLayout relativeLayoutScrollViewChild;
float scrollViewHeight;
ScrollView scrollViewNavigationDrawerContent;
private String server_path;
private String server_path_target;
SharedPreferences sharedPreferences;
private String status;
FrameLayout statusBar;
int textColorPrimary;
private Timer timer;
ToggleButton toggleButtonDrawer;
Toolbar toolbar;
TypedValue typedValueColorBackground;
TypedValue typedValueColorPrimary;
TypedValue typedValueTextColorControlHighlight;
TypedValue typedValueTextColorPrimary;
private String url_iklan;
ViewPager viewPager;
ViewTreeObserver viewTreeObserverNavigationDrawerScrollView;
/* renamed from: org.bpmikc.akm.MainActivity.1 */
class C06091 implements DialogInterface.OnClickListener {
C06091() {
}
public void onClick(DialogInterface dialog, int which) {
switch (which) {
case GridLayoutManager.DEFAULT_SPAN_COUNT /*-1*/:
MainActivity.this.finish();
default:
}
}
}
/* renamed from: org.bpmikc.akm.MainActivity.2 */
class C06102 implements OnGlobalLayoutListener {
C06102() {
}
public void onGlobalLayout() {
if (VERSION.SDK_INT > 16) {
MainActivity.this.relativeLayoutScrollViewChild.getViewTreeObserver().removeOnGlobalLayoutListener(this);
} else {
MainActivity.this.relativeLayoutScrollViewChild.getViewTreeObserver().removeGlobalOnLayoutListener(this);
}
MainActivity.this.drawerHeight = (float) MainActivity.this.relativeLayoutScrollViewChild.getHeight();
MainActivity.this.scrollViewHeight = (float) MainActivity.this.scrollViewNavigationDrawerContent.getHeight();
if (MainActivity.this.drawerHeight > MainActivity.this.scrollViewHeight) {
MainActivity.this.frameLayoutSetting1.setVisibility(0);
}
if (MainActivity.this.drawerHeight < MainActivity.this.scrollViewHeight) {
MainActivity.this.frameLayoutSetting1.setVisibility(8);
}
}
}
/* renamed from: org.bpmikc.akm.MainActivity.3 */
class C06123 implements OnScrollChangedListener {
/* renamed from: org.bpmikc.akm.MainActivity.3.1 */
class C06111 implements OnTouchListener {
C06111() {
}
public boolean onTouch(View v, MotionEvent event) {
switch (event.getAction()) {
case CompletionEvent.STATUS_FAILURE /*1*/:
if (MainActivity.this.scrollViewNavigationDrawerContent.getScrollY() != 0) {
MainActivity.this.frameLayoutSetting1.animate().translationY((float) MainActivity.this.frameLayoutSetting1.getHeight()).setInterpolator(new AccelerateInterpolator(5.0f)).setDuration(400);
break;
}
break;
case CompletionEvent.STATUS_CONFLICT /*2*/:
if (MainActivity.this.scrollViewNavigationDrawerContent.getScrollY() != 0) {
MainActivity.this.frameLayoutSetting1.animate().translationY((float) MainActivity.this.frameLayoutSetting1.getHeight()).setInterpolator(new AccelerateInterpolator(5.0f)).setDuration(400);
break;
}
break;
}
return false;
}
}
C06123() {
}
public void onScrollChanged() {
MainActivity.this.scrollViewNavigationDrawerContent.setOnTouchListener(new C06111());
if (MainActivity.this.scrollViewNavigationDrawerContent.getScrollY() == 0) {
MainActivity.this.frameLayoutSetting1.animate().translationY(0.0f).setInterpolator(new DecelerateInterpolator(5.0f)).setDuration(600);
}
}
}
/* renamed from: org.bpmikc.akm.MainActivity.4 */
class C06134 implements OnTouchListener {
C06134() {
}
public boolean onTouch(View v, MotionEvent event) {
switch (event.getAction()) {
case CompletionEvent.STATUS_FAILURE /*1*/:
MainActivity.this.scrollViewNavigationDrawerContent.getViewTreeObserver().addOnScrollChangedListener(MainActivity.this.onScrollChangedListener);
break;
case CompletionEvent.STATUS_CONFLICT /*2*/:
MainActivity.this.scrollViewNavigationDrawerContent.getViewTreeObserver().addOnScrollChangedListener(MainActivity.this.onScrollChangedListener);
break;
}
return false;
}
}
/* renamed from: org.bpmikc.akm.MainActivity.5 */
class C06145 extends SimpleOnGestureListener {
C06145() {
}
public boolean onSingleTapUp(MotionEvent e) {
return true;
}
}
/* renamed from: org.bpmikc.akm.MainActivity.14 */
class AnonymousClass14 implements Listener<JSONObject> {
final /* synthetic */ ImageView val$img_iklan;
final /* synthetic */ String val$server_path;
/* renamed from: org.bpmikc.akm.MainActivity.14.1 */
class C06071 implements Runnable {
int f4b;
final /* synthetic */ String[] val$image_resources;
C06071(String[] strArr) {
this.val$image_resources = strArr;
this.f4b = 0;
}
public void run() {
Glide.with(MainActivity.this.getApplication()).load(this.val$image_resources[this.f4b]).into(AnonymousClass14.this.val$img_iklan);
MainActivity.this.f12a = this.f4b;
this.f4b++;
if (this.f4b > this.val$image_resources.length - 1) {
this.f4b = 0;
}
MainActivity.this.handler.postDelayed(this, (long) Integer.decode(MainActivity.this.durasi).intValue());
}
}
/* renamed from: org.bpmikc.akm.MainActivity.14.2 */
class C06082 implements OnClickListener {
final /* synthetic */ String[] val$imageArray_url;
C06082(String[] strArr) {
this.val$imageArray_url = strArr;
}
public void onClick(View arg0) {
String url_proses = this.val$imageArray_url[MainActivity.this.f12a];
Bundle bundlex = new Bundle();
bundlex.putString("url_iklan", url_proses);
MainActivity.this.getSupportFragmentManager().beginTransaction().replace(C0615R.id.main_activity_content_frame, Frg_Iklan.newInstance(bundlex)).commit();
}
}
AnonymousClass14(String str, ImageView imageView) {
this.val$server_path = str;
this.val$img_iklan = imageView;
}
public void onResponse(JSONObject response) {
try {
JSONArray ja = response.getJSONArray("iklan");
String[] image_resources = new String[ja.length()];
String[] imageArray_url = new String[ja.length()];
Arrays.fill(image_resources, null);
Arrays.fill(imageArray_url, null);
for (int i = 0; i < ja.length(); i++) {
JSONObject c = ja.getJSONObject(i);
MainActivity.this.id_rec = c.getString("id_rec");
MainActivity.this.menu = c.getString("menu");
MainActivity.this.status = c.getString(Games.EXTRA_STATUS);
MainActivity.this.url_iklan = c.getString("url_iklan");
MainActivity.this.flag_01 = c.getString("flag_01");
MainActivity.this.flag_02 = c.getString("flag_02");
MainActivity.this.flag_03 = c.getString("flag_03");
MainActivity.this.image_iklan = c.getString("image_iklan");
MainActivity.this.durasi = c.getString("durasi");
image_resources[i] = this.val$server_path + "/app_files/" + MainActivity.this.image_iklan;
imageArray_url[i] = MainActivity.this.url_iklan;
}
MainActivity.this.handler.removeCallbacksAndMessages(null);
MainActivity.this.handler.postDelayed(new C06071(image_resources), 500);
this.val$img_iklan.setOnClickListener(new C06082(imageArray_url));
} catch (JSONException e) {
e.printStackTrace();
}
}
}
/* renamed from: org.bpmikc.akm.MainActivity.6 */
class C08836 implements OnItemTouchListener {
final /* synthetic */ GestureDetector val$mGestureDetector;
C08836(GestureDetector gestureDetector) {
this.val$mGestureDetector = gestureDetector;
}
public boolean onInterceptTouchEvent(RecyclerView recyclerView, MotionEvent motionEvent) {
View child = recyclerView.findChildViewUnder(motionEvent.getX(), motionEvent.getY());
if (child == null || !this.val$mGestureDetector.onTouchEvent(motionEvent)) {
return false;
}
int i;
MainActivity.this.drawerLayout.closeDrawers();
for (i = 0; i < MainActivity.this.recyclerViewDrawer2.getChildCount(); i++) {
LinearLayout linearLayoutItem = (LinearLayout) MainActivity.this.recyclerViewDrawer2.getChildAt(i).findViewById(C0615R.id.linearLayoutItem);
((TextView) MainActivity.this.recyclerViewDrawer2.getChildAt(i).findViewById(C0615R.id.textViewDrawerItemTitle)).setTextColor(MainActivity.this.textColorPrimary);
linearLayoutItem.setBackgroundColor(MainActivity.this.colorBackground);
}
for (i = 0; i < MainActivity.this.recyclerViewDrawer3.getChildCount(); i++) {
linearLayoutItem = (LinearLayout) MainActivity.this.recyclerViewDrawer3.getChildAt(i).findViewById(C0615R.id.linearLayoutItem);
((TextView) MainActivity.this.recyclerViewDrawer3.getChildAt(i).findViewById(C0615R.id.textViewDrawerItemTitle)).setTextColor(MainActivity.this.textColorPrimary);
linearLayoutItem.setBackgroundColor(MainActivity.this.colorBackground);
}
for (i = 0; i < MainActivity.this.recyclerViewDrawerSettings.getChildCount(); i++) {
linearLayoutItem = (LinearLayout) MainActivity.this.recyclerViewDrawerSettings.getChildAt(i).findViewById(C0615R.id.linearLayoutItem);
((TextView) MainActivity.this.recyclerViewDrawerSettings.getChildAt(i).findViewById(C0615R.id.textViewDrawerItemTitle)).setTextColor(MainActivity.this.textColorPrimary);
linearLayoutItem.setBackgroundColor(MainActivity.this.colorBackground);
}
TextView textViewDrawerItemTitle;
Bundle bundle;
switch (recyclerView.getChildPosition(child)) {
case SpinnerCompat.MODE_DIALOG /*0*/:
for (i = 0; i < MainActivity.this.recyclerViewDrawer1.getChildCount(); i++) {
textViewDrawerItemTitle = (TextView) MainActivity.this.recyclerViewDrawer1.getChildAt(i).findViewById(C0615R.id.textViewDrawerItemTitle);
linearLayoutItem = (LinearLayout) MainActivity.this.recyclerViewDrawer1.getChildAt(i).findViewById(C0615R.id.linearLayoutItem);
if (i == 0) {
textViewDrawerItemTitle.setTextColor(MainActivity.this.colorPrimary);
linearLayoutItem.setBackgroundColor(MainActivity.this.colorControlHighlight);
} else {
textViewDrawerItemTitle.setTextColor(MainActivity.this.textColorPrimary);
linearLayoutItem.setBackgroundColor(MainActivity.this.colorBackground);
}
}
Toast.makeText(MainActivity.this, "Menu Home ", 0).show();
if (MainActivity.this.getSupportActionBar() != null) {
MainActivity.this.getSupportActionBar().setTitle((CharSequence) "Assalamu'alaikum");
}
MainActivity.this.timer_iklan("home");
bundle = new Bundle();
bundle.putString("judul", "Home");
MainActivity.this.getSupportFragmentManager().beginTransaction().replace(C0615R.id.main_activity_content_frame, Frg_Home.newInstance(bundle)).commit();
break;
case CompletionEvent.STATUS_FAILURE /*1*/:
for (i = 0; i < MainActivity.this.recyclerViewDrawer1.getChildCount(); i++) {
textViewDrawerItemTitle = (TextView) MainActivity.this.recyclerViewDrawer1.getChildAt(i).findViewById(C0615R.id.textViewDrawerItemTitle);
linearLayoutItem = (LinearLayout) MainActivity.this.recyclerViewDrawer1.getChildAt(i).findViewById(C0615R.id.linearLayoutItem);
if (i == 1) {
textViewDrawerItemTitle.setTextColor(MainActivity.this.colorPrimary);
linearLayoutItem.setBackgroundColor(MainActivity.this.colorControlHighlight);
} else {
textViewDrawerItemTitle.setTextColor(MainActivity.this.textColorPrimary);
linearLayoutItem.setBackgroundColor(MainActivity.this.colorBackground);
}
}
Toast.makeText(MainActivity.this, "Menu Lokasi Masjid ", 0).show();
if (MainActivity.this.getSupportActionBar() != null) {
MainActivity.this.getSupportActionBar().setTitle((CharSequence) "Masjid");
}
MainActivity.this.timer_iklan("lokasi_masjid");
bundle = new Bundle();
bundle.putInt(Frg_Qiblat_Map.sARGUMENT_IMAGE_CODE, 2);
MainActivity.this.getSupportFragmentManager().beginTransaction().replace(C0615R.id.main_activity_content_frame, Frg_Lokasi_Masjid.newInstance(bundle)).commit();
break;
case CompletionEvent.STATUS_CONFLICT /*2*/:
for (i = 0; i < MainActivity.this.recyclerViewDrawer1.getChildCount(); i++) {
textViewDrawerItemTitle = (TextView) MainActivity.this.recyclerViewDrawer1.getChildAt(i).findViewById(C0615R.id.textViewDrawerItemTitle);
linearLayoutItem = (LinearLayout) MainActivity.this.recyclerViewDrawer1.getChildAt(i).findViewById(C0615R.id.linearLayoutItem);
if (i == 2) {
textViewDrawerItemTitle.setTextColor(MainActivity.this.colorPrimary);
linearLayoutItem.setBackgroundColor(MainActivity.this.colorControlHighlight);
} else {
textViewDrawerItemTitle.setTextColor(MainActivity.this.textColorPrimary);
linearLayoutItem.setBackgroundColor(MainActivity.this.colorBackground);
}
}
Toast.makeText(MainActivity.this, "Menu Tambah Masjid ", 0).show();
if (MainActivity.this.getSupportActionBar() != null) {
MainActivity.this.getSupportActionBar().setTitle((CharSequence) "Tambah Masjid");
}
MainActivity.this.timer_iklan("tambah_masjid");
bundle = new Bundle();
bundle.putInt(Frg_Qiblat_Map.sARGUMENT_IMAGE_CODE, 2);
MainActivity.this.getSupportFragmentManager().beginTransaction().replace(C0615R.id.main_activity_content_frame, Frg_Add_Masjid_Gmap.newInstance(bundle)).commit();
break;
case CompletionEvent.STATUS_CANCELED /*3*/:
for (i = 0; i < MainActivity.this.recyclerViewDrawer1.getChildCount(); i++) {
textViewDrawerItemTitle = (TextView) MainActivity.this.recyclerViewDrawer1.getChildAt(i).findViewById(C0615R.id.textViewDrawerItemTitle);
linearLayoutItem = (LinearLayout) MainActivity.this.recyclerViewDrawer1.getChildAt(i).findViewById(C0615R.id.linearLayoutItem);
if (i == 3) {
textViewDrawerItemTitle.setTextColor(MainActivity.this.colorPrimary);
linearLayoutItem.setBackgroundColor(MainActivity.this.colorControlHighlight);
} else {
textViewDrawerItemTitle.setTextColor(MainActivity.this.textColorPrimary);
linearLayoutItem.setBackgroundColor(MainActivity.this.colorBackground);
}
}
Toast.makeText(MainActivity.this, "Menu Cari Masjid ", 0).show();
if (MainActivity.this.getSupportActionBar() != null) {
MainActivity.this.getSupportActionBar().setTitle((CharSequence) "Cari Masjid");
}
MainActivity.this.timer_iklan("cari_masjid");
bundle = new Bundle();
bundle.putInt(Frg_Qiblat_Map.sARGUMENT_IMAGE_CODE, 2);
MainActivity.this.getSupportFragmentManager().beginTransaction().replace(C0615R.id.main_activity_content_frame, Frg_Cari_Masjid.newInstance(bundle)).commit();
break;
}
return true;
}
public void onTouchEvent(RecyclerView recyclerView, MotionEvent motionEvent) {
}
}
/* renamed from: org.bpmikc.akm.MainActivity.7 */
class C08847 implements OnItemTouchListener {
final /* synthetic */ GestureDetector val$mGestureDetector;
C08847(GestureDetector gestureDetector) {
this.val$mGestureDetector = gestureDetector;
}
public boolean onInterceptTouchEvent(RecyclerView recyclerView, MotionEvent motionEvent) {
View child = recyclerView.findChildViewUnder(motionEvent.getX(), motionEvent.getY());
if (child == null || !this.val$mGestureDetector.onTouchEvent(motionEvent)) {
return false;
}
int i;
MainActivity.this.drawerLayout.closeDrawers();
for (i = 0; i < MainActivity.this.recyclerViewDrawer1.getChildCount(); i++) {
LinearLayout linearLayoutItem = (LinearLayout) MainActivity.this.recyclerViewDrawer1.getChildAt(i).findViewById(C0615R.id.linearLayoutItem);
((TextView) MainActivity.this.recyclerViewDrawer1.getChildAt(i).findViewById(C0615R.id.textViewDrawerItemTitle)).setTextColor(MainActivity.this.textColorPrimary);
linearLayoutItem.setBackgroundColor(MainActivity.this.colorBackground);
}
for (i = 0; i < MainActivity.this.recyclerViewDrawer3.getChildCount(); i++) {
linearLayoutItem = (LinearLayout) MainActivity.this.recyclerViewDrawer3.getChildAt(i).findViewById(C0615R.id.linearLayoutItem);
((TextView) MainActivity.this.recyclerViewDrawer3.getChildAt(i).findViewById(C0615R.id.textViewDrawerItemTitle)).setTextColor(MainActivity.this.textColorPrimary);
linearLayoutItem.setBackgroundColor(MainActivity.this.colorBackground);
}
for (i = 0; i < MainActivity.this.recyclerViewDrawerSettings.getChildCount(); i++) {
linearLayoutItem = (LinearLayout) MainActivity.this.recyclerViewDrawerSettings.getChildAt(i).findViewById(C0615R.id.linearLayoutItem);
((TextView) MainActivity.this.recyclerViewDrawerSettings.getChildAt(i).findViewById(C0615R.id.textViewDrawerItemTitle)).setTextColor(MainActivity.this.textColorPrimary);
linearLayoutItem.setBackgroundColor(MainActivity.this.colorBackground);
}
TextView textViewDrawerItemTitle;
Bundle bundle;
switch (recyclerView.getChildPosition(child)) {
case SpinnerCompat.MODE_DIALOG /*0*/:
for (i = 0; i < MainActivity.this.recyclerViewDrawer2.getChildCount(); i++) {
textViewDrawerItemTitle = (TextView) MainActivity.this.recyclerViewDrawer2.getChildAt(i).findViewById(C0615R.id.textViewDrawerItemTitle);
linearLayoutItem = (LinearLayout) MainActivity.this.recyclerViewDrawer2.getChildAt(i).findViewById(C0615R.id.linearLayoutItem);
if (i == 0) {
textViewDrawerItemTitle.setTextColor(MainActivity.this.colorPrimary);
linearLayoutItem.setBackgroundColor(MainActivity.this.colorControlHighlight);
} else {
textViewDrawerItemTitle.setTextColor(MainActivity.this.textColorPrimary);
linearLayoutItem.setBackgroundColor(MainActivity.this.colorBackground);
}
}
Toast.makeText(MainActivity.this, "Menu Artikel ", 0).show();
MainActivity.this.timer_iklan("artikel");
if (MainActivity.this.getSupportActionBar() != null) {
MainActivity.this.getSupportActionBar().setTitle((CharSequence) "Artikel");
}
bundle = new Bundle();
MainActivity.this.timer_iklan("artikel");
MainActivity.this.getSupportFragmentManager().beginTransaction().replace(C0615R.id.main_activity_content_frame, Frg_Artikel.newInstance(bundle)).commit();
return true;
case CompletionEvent.STATUS_FAILURE /*1*/:
for (i = 0; i < MainActivity.this.recyclerViewDrawer2.getChildCount(); i++) {
textViewDrawerItemTitle = (TextView) MainActivity.this.recyclerViewDrawer2.getChildAt(i).findViewById(C0615R.id.textViewDrawerItemTitle);
linearLayoutItem = (LinearLayout) MainActivity.this.recyclerViewDrawer2.getChildAt(i).findViewById(C0615R.id.linearLayoutItem);
if (i == 1) {
textViewDrawerItemTitle.setTextColor(MainActivity.this.colorPrimary);
linearLayoutItem.setBackgroundColor(MainActivity.this.colorControlHighlight);
} else {
textViewDrawerItemTitle.setTextColor(MainActivity.this.textColorPrimary);
linearLayoutItem.setBackgroundColor(MainActivity.this.colorBackground);
}
}
Toast.makeText(MainActivity.this, "Menu Jadwal Sholat ", 0).show();
if (MainActivity.this.getSupportActionBar() != null) {
MainActivity.this.getSupportActionBar().setTitle((CharSequence) "Jadwal Sholat");
}
MainActivity.this.timer_iklan("jadwal_sholat");
MainActivity.this.getSupportFragmentManager().beginTransaction().replace(C0615R.id.main_activity_content_frame, Frg_Jadwal_Sholat.newInstance(new Bundle())).commit();
return true;
case CompletionEvent.STATUS_CONFLICT /*2*/:
for (i = 0; i < MainActivity.this.recyclerViewDrawer2.getChildCount(); i++) {
textViewDrawerItemTitle = (TextView) MainActivity.this.recyclerViewDrawer2.getChildAt(i).findViewById(C0615R.id.textViewDrawerItemTitle);
linearLayoutItem = (LinearLayout) MainActivity.this.recyclerViewDrawer2.getChildAt(i).findViewById(C0615R.id.linearLayoutItem);
if (i == 2) {
textViewDrawerItemTitle.setTextColor(MainActivity.this.colorPrimary);
linearLayoutItem.setBackgroundColor(MainActivity.this.colorControlHighlight);
} else {
textViewDrawerItemTitle.setTextColor(MainActivity.this.textColorPrimary);
linearLayoutItem.setBackgroundColor(MainActivity.this.colorBackground);
}
}
Toast.makeText(MainActivity.this, "Klik Button LOKASI untuk set kordinat lokasi saat ini ... ", 0).show();
if (MainActivity.this.getSupportActionBar() != null) {
MainActivity.this.getSupportActionBar().setTitle((CharSequence) "<NAME>");
}
bundle = new Bundle();
MainActivity.this.timer_iklan("arah_qiblat");
MainActivity.this.getSupportFragmentManager().beginTransaction().replace(C0615R.id.main_activity_content_frame, Frg_Kompas_Muazzin.newInstance(bundle)).commit();
return true;
default:
return true;
}
}
public void onTouchEvent(RecyclerView recyclerView, MotionEvent motionEvent) {
}
}
/* renamed from: org.bpmikc.akm.MainActivity.8 */
class C08858 implements OnItemTouchListener {
final /* synthetic */ GestureDetector val$mGestureDetector;
C08858(GestureDetector gestureDetector) {
this.val$mGestureDetector = gestureDetector;
}
public boolean onInterceptTouchEvent(RecyclerView recyclerView, MotionEvent motionEvent) {
View child = recyclerView.findChildViewUnder(motionEvent.getX(), motionEvent.getY());
if (child == null || !this.val$mGestureDetector.onTouchEvent(motionEvent)) {
return false;
}
int i;
MainActivity.this.drawerLayout.closeDrawers();
for (i = 0; i < MainActivity.this.recyclerViewDrawer1.getChildCount(); i++) {
LinearLayout linearLayoutItem = (LinearLayout) MainActivity.this.recyclerViewDrawer1.getChildAt(i).findViewById(C0615R.id.linearLayoutItem);
((TextView) MainActivity.this.recyclerViewDrawer1.getChildAt(i).findViewById(C0615R.id.textViewDrawerItemTitle)).setTextColor(MainActivity.this.textColorPrimary);
linearLayoutItem.setBackgroundColor(MainActivity.this.colorBackground);
}
for (i = 0; i < MainActivity.this.recyclerViewDrawer2.getChildCount(); i++) {
linearLayoutItem = (LinearLayout) MainActivity.this.recyclerViewDrawer2.getChildAt(i).findViewById(C0615R.id.linearLayoutItem);
((TextView) MainActivity.this.recyclerViewDrawer2.getChildAt(i).findViewById(C0615R.id.textViewDrawerItemTitle)).setTextColor(MainActivity.this.textColorPrimary);
linearLayoutItem.setBackgroundColor(MainActivity.this.colorBackground);
}
for (i = 0; i < MainActivity.this.recyclerViewDrawerSettings.getChildCount(); i++) {
linearLayoutItem = (LinearLayout) MainActivity.this.recyclerViewDrawerSettings.getChildAt(i).findViewById(C0615R.id.linearLayoutItem);
((TextView) MainActivity.this.recyclerViewDrawerSettings.getChildAt(i).findViewById(C0615R.id.textViewDrawerItemTitle)).setTextColor(MainActivity.this.textColorPrimary);
linearLayoutItem.setBackgroundColor(MainActivity.this.colorBackground);
}
TextView textViewDrawerItemTitle;
switch (recyclerView.getChildPosition(child)) {
case SpinnerCompat.MODE_DIALOG /*0*/:
for (i = 0; i < MainActivity.this.recyclerViewDrawer3.getChildCount(); i++) {
textViewDrawerItemTitle = (TextView) MainActivity.this.recyclerViewDrawer3.getChildAt(i).findViewById(C0615R.id.textViewDrawerItemTitle);
linearLayoutItem = (LinearLayout) MainActivity.this.recyclerViewDrawer3.getChildAt(i).findViewById(C0615R.id.linearLayoutItem);
if (i == 0) {
textViewDrawerItemTitle.setTextColor(MainActivity.this.colorPrimary);
linearLayoutItem.setBackgroundColor(MainActivity.this.colorControlHighlight);
} else {
textViewDrawerItemTitle.setTextColor(MainActivity.this.textColorPrimary);
linearLayoutItem.setBackgroundColor(MainActivity.this.colorBackground);
}
}
Toast.makeText(MainActivity.this, "Menu Kewanitaan ", 0).show();
if (MainActivity.this.getSupportActionBar() != null) {
MainActivity.this.getSupportActionBar().setTitle((CharSequence) "Kewanitaan");
}
MainActivity.this.timer_iklan("kewanitaan");
MainActivity.this.getSupportFragmentManager().beginTransaction().replace(C0615R.id.main_activity_content_frame, Frg_Kewanitaan.newInstance(new Bundle())).commit();
return true;
case CompletionEvent.STATUS_FAILURE /*1*/:
for (i = 0; i < MainActivity.this.recyclerViewDrawer3.getChildCount(); i++) {
textViewDrawerItemTitle = (TextView) MainActivity.this.recyclerViewDrawer3.getChildAt(i).findViewById(C0615R.id.textViewDrawerItemTitle);
linearLayoutItem = (LinearLayout) MainActivity.this.recyclerViewDrawer3.getChildAt(i).findViewById(C0615R.id.linearLayoutItem);
if (i == 1) {
textViewDrawerItemTitle.setTextColor(MainActivity.this.colorPrimary);
linearLayoutItem.setBackgroundColor(MainActivity.this.colorControlHighlight);
} else {
textViewDrawerItemTitle.setTextColor(MainActivity.this.textColorPrimary);
linearLayoutItem.setBackgroundColor(MainActivity.this.colorBackground);
}
}
Toast.makeText(MainActivity.this, "Menu Donasi dan Iklan ", 0).show();
if (MainActivity.this.getSupportActionBar() != null) {
MainActivity.this.getSupportActionBar().setTitle((CharSequence) "Donasi dan Iklan");
}
MainActivity.this.timer_iklan("donasi_iklan");
MainActivity.this.getSupportFragmentManager().beginTransaction().replace(C0615R.id.main_activity_content_frame, Frg_Donasi.newInstance(new Bundle())).commit();
return true;
case CompletionEvent.STATUS_CONFLICT /*2*/:
for (i = 0; i < MainActivity.this.recyclerViewDrawer3.getChildCount(); i++) {
textViewDrawerItemTitle = (TextView) MainActivity.this.recyclerViewDrawer3.getChildAt(i).findViewById(C0615R.id.textViewDrawerItemTitle);
linearLayoutItem = (LinearLayout) MainActivity.this.recyclerViewDrawer3.getChildAt(i).findViewById(C0615R.id.linearLayoutItem);
if (i == 2) {
textViewDrawerItemTitle.setTextColor(MainActivity.this.colorPrimary);
linearLayoutItem.setBackgroundColor(MainActivity.this.colorControlHighlight);
} else {
textViewDrawerItemTitle.setTextColor(MainActivity.this.textColorPrimary);
linearLayoutItem.setBackgroundColor(MainActivity.this.colorBackground);
}
}
Toast.makeText(MainActivity.this, "Menu Info Transaksi Online ", 0).show();
if (MainActivity.this.getSupportActionBar() != null) {
MainActivity.this.getSupportActionBar().setTitle((CharSequence) "Transaksi Online");
}
MainActivity.this.timer_iklan("transaksi_online");
MainActivity.this.getSupportFragmentManager().beginTransaction().replace(C0615R.id.main_activity_content_frame, Frg_Transaksi_Online.newInstance(new Bundle())).commit();
return true;
default:
return true;
}
}
public void onTouchEvent(RecyclerView recyclerView, MotionEvent motionEvent) {
}
}
/* renamed from: org.bpmikc.akm.MainActivity.9 */
class C08869 implements OnItemTouchListener {
final /* synthetic */ GestureDetector val$mGestureDetector;
C08869(GestureDetector gestureDetector) {
this.val$mGestureDetector = gestureDetector;
}
public boolean onInterceptTouchEvent(RecyclerView recyclerView, MotionEvent motionEvent) {
View child = recyclerView.findChildViewUnder(motionEvent.getX(), motionEvent.getY());
if (child == null || !this.val$mGestureDetector.onTouchEvent(motionEvent)) {
return false;
}
int i;
MainActivity.this.drawerLayout.closeDrawers();
for (i = 0; i < MainActivity.this.recyclerViewDrawer1.getChildCount(); i++) {
LinearLayout linearLayoutItem = (LinearLayout) MainActivity.this.recyclerViewDrawer1.getChildAt(i).findViewById(C0615R.id.linearLayoutItem);
((TextView) MainActivity.this.recyclerViewDrawer1.getChildAt(i).findViewById(C0615R.id.textViewDrawerItemTitle)).setTextColor(MainActivity.this.textColorPrimary);
linearLayoutItem.setBackgroundColor(MainActivity.this.colorBackground);
}
for (i = 0; i < MainActivity.this.recyclerViewDrawer2.getChildCount(); i++) {
linearLayoutItem = (LinearLayout) MainActivity.this.recyclerViewDrawer3.getChildAt(i).findViewById(C0615R.id.linearLayoutItem);
((TextView) MainActivity.this.recyclerViewDrawer2.getChildAt(i).findViewById(C0615R.id.textViewDrawerItemTitle)).setTextColor(MainActivity.this.textColorPrimary);
linearLayoutItem.setBackgroundColor(MainActivity.this.colorBackground);
}
for (i = 0; i < MainActivity.this.recyclerViewDrawer3.getChildCount(); i++) {
linearLayoutItem = (LinearLayout) MainActivity.this.recyclerViewDrawer3.getChildAt(i).findViewById(C0615R.id.linearLayoutItem);
((TextView) MainActivity.this.recyclerViewDrawer3.getChildAt(i).findViewById(C0615R.id.textViewDrawerItemTitle)).setTextColor(MainActivity.this.textColorPrimary);
linearLayoutItem.setBackgroundColor(MainActivity.this.colorBackground);
}
TextView textViewDrawerItemTitle;
Bundle bundle;
switch (recyclerView.getChildPosition(child)) {
case SpinnerCompat.MODE_DIALOG /*0*/:
for (i = 0; i < MainActivity.this.recyclerViewDrawerSettings.getChildCount(); i++) {
textViewDrawerItemTitle = (TextView) MainActivity.this.recyclerViewDrawerSettings.getChildAt(i).findViewById(C0615R.id.textViewDrawerItemTitle);
linearLayoutItem = (LinearLayout) MainActivity.this.recyclerViewDrawerSettings.getChildAt(i).findViewById(C0615R.id.linearLayoutItem);
if (i == 0) {
textViewDrawerItemTitle.setTextColor(MainActivity.this.colorPrimary);
linearLayoutItem.setBackgroundColor(MainActivity.this.colorControlHighlight);
} else {
textViewDrawerItemTitle.setTextColor(MainActivity.this.textColorPrimary);
linearLayoutItem.setBackgroundColor(MainActivity.this.colorBackground);
}
}
Toast.makeText(MainActivity.this, "Menu Tampilan ", 0).show();
if (MainActivity.this.getSupportActionBar() != null) {
MainActivity.this.getSupportActionBar().setTitle((CharSequence) "Tampilan");
}
bundle = new Bundle();
MainActivity.this.timer_iklan("option_tampilan");
MainActivity.this.getSupportFragmentManager().beginTransaction().replace(C0615R.id.main_activity_content_frame, Frg_Setting.newInstance(bundle)).commit();
return true;
case CompletionEvent.STATUS_FAILURE /*1*/:
for (i = 0; i < MainActivity.this.recyclerViewDrawerSettings.getChildCount(); i++) {
textViewDrawerItemTitle = (TextView) MainActivity.this.recyclerViewDrawerSettings.getChildAt(i).findViewById(C0615R.id.textViewDrawerItemTitle);
linearLayoutItem = (LinearLayout) MainActivity.this.recyclerViewDrawerSettings.getChildAt(i).findViewById(C0615R.id.linearLayoutItem);
if (i == 1) {
textViewDrawerItemTitle.setTextColor(MainActivity.this.colorPrimary);
linearLayoutItem.setBackgroundColor(MainActivity.this.colorControlHighlight);
} else {
textViewDrawerItemTitle.setTextColor(MainActivity.this.textColorPrimary);
linearLayoutItem.setBackgroundColor(MainActivity.this.colorBackground);
}
}
Toast.makeText(MainActivity.this, "Menu Beri Masukan ", 0).show();
if (MainActivity.this.getSupportActionBar() != null) {
MainActivity.this.getSupportActionBar().setTitle((CharSequence) "Saran & Masukan");
}
bundle = new Bundle();
MainActivity.this.timer_iklan("beri_masukan");
MainActivity.this.getSupportFragmentManager().beginTransaction().replace(C0615R.id.main_activity_content_frame, Frg_Faq_Masukan.newInstance(bundle)).commit();
return true;
default:
return true;
}
}
public void onTouchEvent(RecyclerView recyclerView, MotionEvent motionEvent) {
}
}
public MainActivity() {
this.server_path = "http://192.168.3.11/ikcv20";
this.server_path_target = "http://192.168.3.11/ikcv20";
this.count = 0;
this.f12a = 0;
this.imageArray_url = new String[0];
this.id_rec = BuildConfig.FLAVOR;
this.menu = BuildConfig.FLAVOR;
this.status = BuildConfig.FLAVOR;
this.url_iklan = BuildConfig.FLAVOR;
this.durasi = BuildConfig.FLAVOR;
this.flag_01 = BuildConfig.FLAVOR;
this.flag_02 = BuildConfig.FLAVOR;
this.flag_03 = BuildConfig.FLAVOR;
this.image_iklan = BuildConfig.FLAVOR;
this.ik = 0;
this.handler = new Handler();
}
protected void onCreate(Bundle savedInstanceState) {
setupTheme();
super.onCreate(savedInstanceState);
setContentView((int) C0615R.layout.activity_main);
this.mPreferences = Preferences.getInstance(this);
this.toolbar = (Toolbar) findViewById(C0615R.id.toolbar);
setSupportActionBar(this.toolbar);
getSupportActionBar().setTitle((CharSequence) "Masjid v2.1");
this.statusBar = (FrameLayout) findViewById(C0615R.id.statusBar);
MySQLiteHelper db = new MySQLiteHelper(getApplicationContext());
setupNavigationDrawer();
setupButtons();
SharedPreferences pref = getSharedPreferences("MyPrefs", 0);
Editor edit = pref.edit();
edit.putString("server_path", this.server_path_target);
edit.commit();
this.server_path = pref.getString("server_path", BuildConfig.FLAVOR);
getSupportFragmentManager().beginTransaction().replace(C0615R.id.main_activity_content_frame, Frg_Home.newInstance(this.bundle)).commit();
timer_iklan("home");
}
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(C0615R.menu.menu_main, menu);
return true;
}
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case C0615R.id.action_settings:
showToast("Mengubah Tampilan Warna Aplikasi ...");
if (getSupportActionBar() != null) {
getSupportActionBar().setTitle((CharSequence) "Tampilan");
}
Bundle bundle = new Bundle();
timer_iklan("option_tampilan");
getSupportFragmentManager().beginTransaction().setCustomAnimations(C0615R.anim.enter_from_right, C0615R.anim.exit_to_right, C0615R.anim.enter_from_right, C0615R.anim.exit_to_right).replace(C0615R.id.main_activity_content_frame, Frg_Setting.newInstance(bundle)).commit();
break;
case C0615R.id.action_help:
showToast("Bantuan Penggunaan Aplikasi ...");
if (getSupportActionBar() != null) {
getSupportActionBar().setTitle((CharSequence) "Bantuan");
}
timer_iklan("option_bantuan");
getSupportFragmentManager().beginTransaction().setCustomAnimations(C0615R.anim.enter_from_right, C0615R.anim.exit_to_right, C0615R.anim.enter_from_right, C0615R.anim.exit_to_right).replace(C0615R.id.main_activity_content_frame, Frg_Bantuan.newInstance(new Bundle())).commit();
break;
case C0615R.id.action_about:
showToast("Info Terkait Aplikasi ...");
if (getSupportActionBar() != null) {
getSupportActionBar().setTitle((CharSequence) "Info Aplikasi");
}
timer_iklan("option_aplikasi");
getSupportFragmentManager().beginTransaction().setCustomAnimations(C0615R.anim.enter_from_right, C0615R.anim.exit_to_right, C0615R.anim.enter_from_right, C0615R.anim.exit_to_right).replace(C0615R.id.main_activity_content_frame, Frg_Info_Aplikasi.newInstance(new Bundle())).commit();
break;
case C0615R.id.action_exit:
DialogInterface.OnClickListener dialogClickListener = new C06091();
new Builder(this).setMessage("Akan Keluar Aplikasi Masjid ?").setPositiveButton("Ya", dialogClickListener).setNegativeButton("Tidak", dialogClickListener).show();
break;
}
return super.onOptionsItemSelected(item);
}
/* JADX WARNING: inconsistent code. */
/* Code decompiled incorrectly, please refer to instructions dump. */
public void setupTheme() {
/*
r4 = this;
r0 = 0;
r1 = "VALUES";
r1 = r4.getSharedPreferences(r1, r0);
r4.sharedPreferences = r1;
r1 = r4.sharedPreferences;
r2 = "THEME";
r3 = "REDLIGHT";
r2 = r1.getString(r2, r3);
r1 = -1;
r3 = r2.hashCode();
switch(r3) {
case 8986405: goto L_0x0020;
case 14885192: goto L_0x003d;
case 469056868: goto L_0x0033;
case 1801159527: goto L_0x0029;
default: goto L_0x001b;
};
L_0x001b:
r0 = r1;
L_0x001c:
switch(r0) {
case 0: goto L_0x0047;
case 1: goto L_0x004e;
case 2: goto L_0x0055;
case 3: goto L_0x005c;
default: goto L_0x001f;
};
L_0x001f:
return;
L_0x0020:
r3 = "REDLIGHT";
r2 = r2.equals(r3);
if (r2 == 0) goto L_0x001b;
L_0x0028:
goto L_0x001c;
L_0x0029:
r0 = "REDDARK";
r0 = r2.equals(r0);
if (r0 == 0) goto L_0x001b;
L_0x0031:
r0 = 1;
goto L_0x001c;
L_0x0033:
r0 = "INDIGOLIGHT";
r0 = r2.equals(r0);
if (r0 == 0) goto L_0x001b;
L_0x003b:
r0 = 2;
goto L_0x001c;
L_0x003d:
r0 = "INDIGODARK";
r0 = r2.equals(r0);
if (r0 == 0) goto L_0x001b;
L_0x0045:
r0 = 3;
goto L_0x001c;
L_0x0047:
r0 = 2131296306; // 0x7f090032 float:1.8210525E38 double:1.053000286E-314;
r4.setTheme(r0);
goto L_0x001f;
L_0x004e:
r0 = 2131296305; // 0x7f090031 float:1.8210523E38 double:1.0530002854E-314;
r4.setTheme(r0);
goto L_0x001f;
L_0x0055:
r0 = 2131296304; // 0x7f090030 float:1.821052E38 double:1.053000285E-314;
r4.setTheme(r0);
goto L_0x001f;
L_0x005c:
r0 = 2131296303; // 0x7f09002f float:1.8210519E38 double:1.0530002844E-314;
r4.setTheme(r0);
goto L_0x001f;
*/
throw new UnsupportedOperationException("Method not decompiled: org.bpmikc.akm.MainActivity.setupTheme():void");
}
public void setupNavigationDrawer() {
this.drawerLayout = (DrawerLayout) findViewById(C0615R.id.drawerLayout);
this.drawerToggle = new ActionBarDrawerToggle(this, this.drawerLayout, this.toolbar, C0615R.string.drawer_open, C0615R.string.drawer_close);
this.drawerLayout.setDrawerListener(this.drawerToggle);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setHomeButtonEnabled(true);
this.drawerToggle.syncState();
String server_path = getSharedPreferences("MyPrefs", 0).getString("server_path", BuildConfig.FLAVOR);
String urlPictureMain = server_path + "/app_files/sujud.png";
String urlCoverMain = server_path + "/app_files/masjid.jpg";
String urlPictureSecond = server_path + "/app_files/bulanbintang.jpg";
ImageView imageViewPictureMain = (ImageView) findViewById(C0615R.id.imageViewPictureMain);
ImageView imageViewPictureSecond = (ImageView) findViewById(C0615R.id.imageViewPictureSecond);
Glide.with(getApplicationContext()).load(urlCoverMain).into((ImageView) findViewById(C0615R.id.imageViewCover));
Glide.with(getApplicationContext()).load(urlPictureMain).asBitmap().transform(new CropCircleTransform(getApplicationContext())).into(imageViewPictureMain);
Glide.with(getApplicationContext()).load(urlPictureSecond).asBitmap().transform(new CropCircleTransform(getApplicationContext())).into(imageViewPictureSecond);
TypedValue typedValue = new TypedValue();
getTheme().resolveAttribute(C0615R.attr.colorPrimaryDark, typedValue, true);
this.drawerLayout.setStatusBarBackgroundColor(typedValue.data);
this.toggleButtonDrawer = (ToggleButton) findViewById(C0615R.id.toggleButtonDrawer);
this.toggleButtonDrawer.setOnClickListener(this);
hideNavigationDrawerSettingsAndFeedbackOnScroll();
setupNavigationDrawerRecyclerViews();
}
public void setupButtons() {
}
private void hideNavigationDrawerSettingsAndFeedbackOnScroll() {
this.scrollViewNavigationDrawerContent = (ScrollView) findViewById(C0615R.id.scrollViewNavigationDrawerContent);
this.relativeLayoutScrollViewChild = (RelativeLayout) findViewById(C0615R.id.relativeLayoutScrollViewChild);
this.frameLayoutSetting1 = (FrameLayout) findViewById(C0615R.id.frameLayoutSettings1);
this.viewTreeObserverNavigationDrawerScrollView = this.relativeLayoutScrollViewChild.getViewTreeObserver();
if (this.viewTreeObserverNavigationDrawerScrollView.isAlive()) {
this.viewTreeObserverNavigationDrawerScrollView.addOnGlobalLayoutListener(new C06102());
}
this.onScrollChangedListener = new C06123();
this.scrollViewNavigationDrawerContent.setOnTouchListener(new C06134());
}
private void setupNavigationDrawerRecyclerViews() {
if (getSupportActionBar() != null) {
getSupportActionBar().setTitle((CharSequence) "Assalamu'alaikum");
}
this.recyclerViewDrawer1 = (RecyclerView) findViewById(C0615R.id.recyclerViewDrawer1);
this.linearLayoutManager = new LinearLayoutManager(this);
this.recyclerViewDrawer1.setLayoutManager(this.linearLayoutManager);
this.drawerItems1 = new ArrayList();
this.drawerItems1.add(new DrawerItem(getResources().getDrawable(C0615R.drawable.ic_action_home), "Home"));
this.drawerItems1.add(new DrawerItem(getResources().getDrawable(C0615R.drawable.ic_action_lokasi_masjid), "Lokasi Masjid"));
this.drawerItems1.add(new DrawerItem(getResources().getDrawable(C0615R.drawable.ic_action_tambah), "Tambah Masjid"));
this.drawerItems1.add(new DrawerItem(getResources().getDrawable(C0615R.drawable.ic_cari_masjid), "Cari Masjid"));
this.drawerAdapter1 = new DrawerAdapter(this.drawerItems1);
this.recyclerViewDrawer1.setAdapter(this.drawerAdapter1);
this.recyclerViewDrawer1.setMinimumHeight(convertDpToPx(200));
this.recyclerViewDrawer1.setHasFixedSize(true);
GestureDetector mGestureDetector = new GestureDetector(this, new C06145());
this.recyclerViewDrawer1.addOnItemTouchListener(new C08836(mGestureDetector));
this.recyclerViewDrawer2 = (RecyclerView) findViewById(C0615R.id.recyclerViewDrawer2);
this.linearLayoutManager2 = new LinearLayoutManager(this);
this.recyclerViewDrawer2.setLayoutManager(this.linearLayoutManager2);
this.drawerItems2 = new ArrayList();
this.drawerItems2.add(new DrawerItem(getResources().getDrawable(C0615R.drawable.ic_action_content_drafts), "Artikel"));
this.drawerItems2.add(new DrawerItem(getResources().getDrawable(C0615R.drawable.ic_action_content_send), "<NAME>"));
this.drawerItems2.add(new DrawerItem(getResources().getDrawable(C0615R.drawable.ic_action_social_notifications_on), "Qiblat"));
this.drawerAdapter2 = new DrawerAdapter(this.drawerItems2);
this.recyclerViewDrawer2.setAdapter(this.drawerAdapter2);
this.recyclerViewDrawer2.setMinimumHeight(convertDpToPx(144));
this.recyclerViewDrawer2.setHasFixedSize(true);
this.recyclerViewDrawer2.addOnItemTouchListener(new C08847(mGestureDetector));
this.recyclerViewDrawer3 = (RecyclerView) findViewById(C0615R.id.recyclerViewDrawer3);
this.linearLayoutManager3 = new LinearLayoutManager(this);
this.recyclerViewDrawer3.setLayoutManager(this.linearLayoutManager3);
this.drawerItems3 = new ArrayList();
this.drawerItems3.add(new DrawerItem(getResources().getDrawable(C0615R.drawable.ic_action_kewanitaan), "Kewanitaan"));
this.drawerItems3.add(new DrawerItem(getResources().getDrawable(C0615R.drawable.ic_action_action_label), "Donasi dan Iklan "));
this.drawerItems3.add(new DrawerItem(getResources().getDrawable(C0615R.drawable.ic_action_online), "Transaksi Online"));
this.drawerAdapter3 = new DrawerAdapter(this.drawerItems3);
this.recyclerViewDrawer3.setAdapter(this.drawerAdapter3);
this.recyclerViewDrawer3.setMinimumHeight(convertDpToPx(144));
this.recyclerViewDrawer3.setHasFixedSize(true);
this.recyclerViewDrawer3.addOnItemTouchListener(new C08858(mGestureDetector));
this.recyclerViewDrawerSettings = (RecyclerView) findViewById(C0615R.id.recyclerViewDrawerSettings);
this.linearLayoutManagerSettings = new LinearLayoutManager(this);
this.recyclerViewDrawerSettings.setLayoutManager(this.linearLayoutManagerSettings);
this.drawerItemsSettings = new ArrayList();
this.drawerItemsSettings.add(new DrawerItem(getResources().getDrawable(C0615R.drawable.ic_action_action_settings), "Tampilan"));
this.drawerItemsSettings.add(new DrawerItem(getResources().getDrawable(C0615R.drawable.ic_action_action_help), "Beri Masukan"));
this.drawerAdapterSettings = new DrawerAdapter(this.drawerItemsSettings);
this.recyclerViewDrawerSettings.setAdapter(this.drawerAdapterSettings);
this.recyclerViewDrawerSettings.setMinimumHeight(convertDpToPx(96));
this.recyclerViewDrawerSettings.setHasFixedSize(true);
this.recyclerViewDrawerSettings.addOnItemTouchListener(new C08869(mGestureDetector));
this.typedValueColorPrimary = new TypedValue();
getTheme().resolveAttribute(C0615R.attr.colorPrimary, this.typedValueColorPrimary, true);
this.colorPrimary = this.typedValueColorPrimary.data;
this.typedValueTextColorPrimary = new TypedValue();
getTheme().resolveAttribute(16842806, this.typedValueTextColorPrimary, true);
this.textColorPrimary = this.typedValueTextColorPrimary.data;
this.typedValueTextColorControlHighlight = new TypedValue();
getTheme().resolveAttribute(C0615R.attr.colorControlHighlight, this.typedValueTextColorControlHighlight, true);
this.colorControlHighlight = this.typedValueTextColorControlHighlight.data;
this.typedValueColorBackground = new TypedValue();
getTheme().resolveAttribute(16842801, this.typedValueColorBackground, true);
this.colorBackground = this.typedValueColorBackground.data;
new Handler().postDelayed(new Runnable() {
public void run() {
int i;
for (i = 0; i < MainActivity.this.recyclerViewDrawer1.getChildCount(); i++) {
ImageView imageViewDrawerItemIcon = (ImageView) MainActivity.this.recyclerViewDrawer1.getChildAt(i).findViewById(C0615R.id.imageViewDrawerItemIcon);
TextView textViewDrawerItemTitle = (TextView) MainActivity.this.recyclerViewDrawer1.getChildAt(i).findViewById(C0615R.id.textViewDrawerItemTitle);
LinearLayout linearLayoutItem = (LinearLayout) MainActivity.this.recyclerViewDrawer1.getChildAt(i).findViewById(C0615R.id.linearLayoutItem);
if (i == 0) {
imageViewDrawerItemIcon.setColorFilter(MainActivity.this.colorPrimary);
if (VERSION.SDK_INT > 15) {
imageViewDrawerItemIcon.setImageAlpha(MotionEventCompat.ACTION_MASK);
} else {
imageViewDrawerItemIcon.setAlpha(MotionEventCompat.ACTION_MASK);
}
textViewDrawerItemTitle.setTextColor(MainActivity.this.colorPrimary);
linearLayoutItem.setBackgroundColor(MainActivity.this.colorControlHighlight);
} else {
imageViewDrawerItemIcon.setColorFilter(MainActivity.this.textColorPrimary);
if (VERSION.SDK_INT > 15) {
imageViewDrawerItemIcon.setImageAlpha(138);
} else {
imageViewDrawerItemIcon.setAlpha(138);
}
textViewDrawerItemTitle.setTextColor(MainActivity.this.textColorPrimary);
linearLayoutItem.setBackgroundColor(MainActivity.this.colorBackground);
}
}
for (i = 0; i < MainActivity.this.recyclerViewDrawer2.getChildCount(); i++) {
imageViewDrawerItemIcon = (ImageView) MainActivity.this.recyclerViewDrawer2.getChildAt(i).findViewById(C0615R.id.imageViewDrawerItemIcon);
textViewDrawerItemTitle = (TextView) MainActivity.this.recyclerViewDrawer2.getChildAt(i).findViewById(C0615R.id.textViewDrawerItemTitle);
linearLayoutItem = (LinearLayout) MainActivity.this.recyclerViewDrawer2.getChildAt(i).findViewById(C0615R.id.linearLayoutItem);
imageViewDrawerItemIcon.setColorFilter(MainActivity.this.textColorPrimary);
if (VERSION.SDK_INT > 15) {
imageViewDrawerItemIcon.setImageAlpha(138);
} else {
imageViewDrawerItemIcon.setAlpha(138);
}
textViewDrawerItemTitle.setTextColor(MainActivity.this.textColorPrimary);
linearLayoutItem.setBackgroundColor(MainActivity.this.colorBackground);
}
for (i = 0; i < MainActivity.this.recyclerViewDrawer3.getChildCount(); i++) {
imageViewDrawerItemIcon = (ImageView) MainActivity.this.recyclerViewDrawer3.getChildAt(i).findViewById(C0615R.id.imageViewDrawerItemIcon);
textViewDrawerItemTitle = (TextView) MainActivity.this.recyclerViewDrawer3.getChildAt(i).findViewById(C0615R.id.textViewDrawerItemTitle);
linearLayoutItem = (LinearLayout) MainActivity.this.recyclerViewDrawer3.getChildAt(i).findViewById(C0615R.id.linearLayoutItem);
imageViewDrawerItemIcon.setColorFilter(MainActivity.this.textColorPrimary);
if (VERSION.SDK_INT > 15) {
imageViewDrawerItemIcon.setImageAlpha(67);
} else {
imageViewDrawerItemIcon.setAlpha(67);
}
textViewDrawerItemTitle.setTextColor(MainActivity.this.textColorPrimary);
linearLayoutItem.setBackgroundColor(MainActivity.this.colorBackground);
}
for (i = 0; i < MainActivity.this.recyclerViewDrawerSettings.getChildCount(); i++) {
imageViewDrawerItemIcon = (ImageView) MainActivity.this.recyclerViewDrawerSettings.getChildAt(i).findViewById(C0615R.id.imageViewDrawerItemIcon);
textViewDrawerItemTitle = (TextView) MainActivity.this.recyclerViewDrawerSettings.getChildAt(i).findViewById(C0615R.id.textViewDrawerItemTitle);
linearLayoutItem = (LinearLayout) MainActivity.this.recyclerViewDrawerSettings.getChildAt(i).findViewById(C0615R.id.linearLayoutItem);
imageViewDrawerItemIcon.setColorFilter(MainActivity.this.textColorPrimary);
if (VERSION.SDK_INT > 15) {
imageViewDrawerItemIcon.setImageAlpha(138);
} else {
imageViewDrawerItemIcon.setAlpha(138);
}
textViewDrawerItemTitle.setTextColor(MainActivity.this.textColorPrimary);
linearLayoutItem.setBackgroundColor(MainActivity.this.colorBackground);
}
ImageView imageViewSettingsIcon = (ImageView) MainActivity.this.findViewById(C0615R.id.imageViewSettingsIcon);
TextView textViewSettingsTitle = (TextView) MainActivity.this.findViewById(C0615R.id.textViewSettingsTitle);
imageViewSettingsIcon.setColorFilter(MainActivity.this.textColorPrimary);
if (VERSION.SDK_INT > 15) {
imageViewSettingsIcon.setImageAlpha(138);
} else {
imageViewSettingsIcon.setAlpha(138);
}
textViewSettingsTitle.setTextColor(MainActivity.this.textColorPrimary);
ImageView imageViewHelpIcon = (ImageView) MainActivity.this.findViewById(C0615R.id.imageViewHelpIcon);
TextView textViewHelpTitle = (TextView) MainActivity.this.findViewById(C0615R.id.textViewHelpTitle);
imageViewHelpIcon.setColorFilter(MainActivity.this.textColorPrimary);
if (VERSION.SDK_INT > 15) {
imageViewHelpIcon.setImageAlpha(138);
} else {
imageViewHelpIcon.setAlpha(138);
}
textViewHelpTitle.setTextColor(MainActivity.this.textColorPrimary);
}
}, 250);
this.itemClickSupport1 = ItemClickSupport.addTo(this.recyclerViewDrawer1);
this.itemClickSupport1.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(RecyclerView parent, View view, int position, long id) {
int i;
for (i = 0; i < MainActivity.this.recyclerViewDrawer1.getChildCount(); i++) {
ImageView imageViewDrawerItemIcon = (ImageView) MainActivity.this.recyclerViewDrawer1.getChildAt(i).findViewById(C0615R.id.imageViewDrawerItemIcon);
TextView textViewDrawerItemTitle = (TextView) MainActivity.this.recyclerViewDrawer1.getChildAt(i).findViewById(C0615R.id.textViewDrawerItemTitle);
LinearLayout linearLayoutItem = (LinearLayout) MainActivity.this.recyclerViewDrawer1.getChildAt(i).findViewById(C0615R.id.linearLayoutItem);
if (i == position) {
imageViewDrawerItemIcon.setColorFilter(MainActivity.this.colorPrimary);
if (VERSION.SDK_INT > 15) {
imageViewDrawerItemIcon.setImageAlpha(MotionEventCompat.ACTION_MASK);
} else {
imageViewDrawerItemIcon.setAlpha(MotionEventCompat.ACTION_MASK);
}
textViewDrawerItemTitle.setTextColor(MainActivity.this.colorPrimary);
linearLayoutItem.setBackgroundColor(MainActivity.this.colorControlHighlight);
} else {
imageViewDrawerItemIcon.setColorFilter(MainActivity.this.textColorPrimary);
if (VERSION.SDK_INT > 15) {
imageViewDrawerItemIcon.setImageAlpha(138);
} else {
imageViewDrawerItemIcon.setAlpha(138);
}
textViewDrawerItemTitle.setTextColor(MainActivity.this.textColorPrimary);
linearLayoutItem.setBackgroundColor(MainActivity.this.colorBackground);
}
}
for (i = 0; i < MainActivity.this.recyclerViewDrawer2.getChildCount(); i++) {
imageViewDrawerItemIcon = (ImageView) MainActivity.this.recyclerViewDrawer2.getChildAt(i).findViewById(C0615R.id.imageViewDrawerItemIcon);
textViewDrawerItemTitle = (TextView) MainActivity.this.recyclerViewDrawer2.getChildAt(i).findViewById(C0615R.id.textViewDrawerItemTitle);
linearLayoutItem = (LinearLayout) MainActivity.this.recyclerViewDrawer2.getChildAt(i).findViewById(C0615R.id.linearLayoutItem);
imageViewDrawerItemIcon.setColorFilter(MainActivity.this.textColorPrimary);
if (VERSION.SDK_INT > 15) {
imageViewDrawerItemIcon.setImageAlpha(138);
} else {
imageViewDrawerItemIcon.setAlpha(138);
}
textViewDrawerItemTitle.setTextColor(MainActivity.this.textColorPrimary);
linearLayoutItem.setBackgroundColor(MainActivity.this.colorBackground);
}
for (i = 0; i < MainActivity.this.recyclerViewDrawer3.getChildCount(); i++) {
imageViewDrawerItemIcon = (ImageView) MainActivity.this.recyclerViewDrawer3.getChildAt(i).findViewById(C0615R.id.imageViewDrawerItemIcon);
textViewDrawerItemTitle = (TextView) MainActivity.this.recyclerViewDrawer3.getChildAt(i).findViewById(C0615R.id.textViewDrawerItemTitle);
linearLayoutItem = (LinearLayout) MainActivity.this.recyclerViewDrawer3.getChildAt(i).findViewById(C0615R.id.linearLayoutItem);
imageViewDrawerItemIcon.setColorFilter(MainActivity.this.textColorPrimary);
textViewDrawerItemTitle.setTextColor(MainActivity.this.textColorPrimary);
if (VERSION.SDK_INT > 15) {
imageViewDrawerItemIcon.setImageAlpha(67);
} else {
imageViewDrawerItemIcon.setAlpha(67);
}
linearLayoutItem.setBackgroundColor(MainActivity.this.colorBackground);
}
}
});
this.itemClickSupport2 = ItemClickSupport.addTo(this.recyclerViewDrawer2);
this.itemClickSupport2.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(RecyclerView parent, View view, int position, long id) {
int i;
for (i = 0; i < MainActivity.this.recyclerViewDrawer2.getChildCount(); i++) {
ImageView imageViewDrawerItemIcon = (ImageView) MainActivity.this.recyclerViewDrawer2.getChildAt(i).findViewById(C0615R.id.imageViewDrawerItemIcon);
TextView textViewDrawerItemTitle = (TextView) MainActivity.this.recyclerViewDrawer2.getChildAt(i).findViewById(C0615R.id.textViewDrawerItemTitle);
LinearLayout linearLayoutItem = (LinearLayout) MainActivity.this.recyclerViewDrawer2.getChildAt(i).findViewById(C0615R.id.linearLayoutItem);
if (i == position) {
imageViewDrawerItemIcon.setColorFilter(MainActivity.this.colorPrimary);
if (VERSION.SDK_INT > 15) {
imageViewDrawerItemIcon.setImageAlpha(MotionEventCompat.ACTION_MASK);
} else {
imageViewDrawerItemIcon.setAlpha(MotionEventCompat.ACTION_MASK);
}
textViewDrawerItemTitle.setTextColor(MainActivity.this.colorPrimary);
linearLayoutItem.setBackgroundColor(MainActivity.this.colorControlHighlight);
} else {
imageViewDrawerItemIcon.setColorFilter(MainActivity.this.textColorPrimary);
if (VERSION.SDK_INT > 15) {
imageViewDrawerItemIcon.setImageAlpha(138);
} else {
imageViewDrawerItemIcon.setAlpha(138);
}
textViewDrawerItemTitle.setTextColor(MainActivity.this.textColorPrimary);
linearLayoutItem.setBackgroundColor(MainActivity.this.colorBackground);
}
}
for (i = 0; i < MainActivity.this.recyclerViewDrawer1.getChildCount(); i++) {
imageViewDrawerItemIcon = (ImageView) MainActivity.this.recyclerViewDrawer1.getChildAt(i).findViewById(C0615R.id.imageViewDrawerItemIcon);
textViewDrawerItemTitle = (TextView) MainActivity.this.recyclerViewDrawer1.getChildAt(i).findViewById(C0615R.id.textViewDrawerItemTitle);
linearLayoutItem = (LinearLayout) MainActivity.this.recyclerViewDrawer1.getChildAt(i).findViewById(C0615R.id.linearLayoutItem);
imageViewDrawerItemIcon.setColorFilter(MainActivity.this.textColorPrimary);
if (VERSION.SDK_INT > 15) {
imageViewDrawerItemIcon.setImageAlpha(138);
} else {
imageViewDrawerItemIcon.setAlpha(138);
}
textViewDrawerItemTitle.setTextColor(MainActivity.this.textColorPrimary);
linearLayoutItem.setBackgroundColor(MainActivity.this.colorBackground);
}
for (i = 0; i < MainActivity.this.recyclerViewDrawer3.getChildCount(); i++) {
imageViewDrawerItemIcon = (ImageView) MainActivity.this.recyclerViewDrawer3.getChildAt(i).findViewById(C0615R.id.imageViewDrawerItemIcon);
textViewDrawerItemTitle = (TextView) MainActivity.this.recyclerViewDrawer3.getChildAt(i).findViewById(C0615R.id.textViewDrawerItemTitle);
linearLayoutItem = (LinearLayout) MainActivity.this.recyclerViewDrawer3.getChildAt(i).findViewById(C0615R.id.linearLayoutItem);
imageViewDrawerItemIcon.setColorFilter(MainActivity.this.textColorPrimary);
if (VERSION.SDK_INT > 15) {
imageViewDrawerItemIcon.setImageAlpha(67);
} else {
imageViewDrawerItemIcon.setAlpha(67);
}
textViewDrawerItemTitle.setTextColor(MainActivity.this.textColorPrimary);
linearLayoutItem.setBackgroundColor(MainActivity.this.colorBackground);
}
}
});
this.itemClickSupport3 = ItemClickSupport.addTo(this.recyclerViewDrawer3);
this.itemClickSupport3.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(RecyclerView parent, View view, int position, long id) {
int i;
for (i = 0; i < MainActivity.this.recyclerViewDrawer3.getChildCount(); i++) {
ImageView imageViewDrawerItemIcon = (ImageView) MainActivity.this.recyclerViewDrawer3.getChildAt(i).findViewById(C0615R.id.imageViewDrawerItemIcon);
TextView textViewDrawerItemTitle = (TextView) MainActivity.this.recyclerViewDrawer3.getChildAt(i).findViewById(C0615R.id.textViewDrawerItemTitle);
LinearLayout linearLayoutItem = (LinearLayout) MainActivity.this.recyclerViewDrawer3.getChildAt(i).findViewById(C0615R.id.linearLayoutItem);
if (i == position) {
imageViewDrawerItemIcon.setColorFilter(MainActivity.this.colorPrimary);
if (VERSION.SDK_INT > 15) {
imageViewDrawerItemIcon.setImageAlpha(138);
} else {
imageViewDrawerItemIcon.setAlpha(138);
}
textViewDrawerItemTitle.setTextColor(MainActivity.this.colorPrimary);
linearLayoutItem.setBackgroundColor(MainActivity.this.colorControlHighlight);
} else {
imageViewDrawerItemIcon.setColorFilter(MainActivity.this.textColorPrimary);
if (VERSION.SDK_INT > 15) {
imageViewDrawerItemIcon.setImageAlpha(67);
} else {
imageViewDrawerItemIcon.setAlpha(67);
}
textViewDrawerItemTitle.setTextColor(MainActivity.this.textColorPrimary);
linearLayoutItem.setBackgroundColor(MainActivity.this.colorBackground);
}
}
for (i = 0; i < MainActivity.this.recyclerViewDrawer1.getChildCount(); i++) {
imageViewDrawerItemIcon = (ImageView) MainActivity.this.recyclerViewDrawer1.getChildAt(i).findViewById(C0615R.id.imageViewDrawerItemIcon);
textViewDrawerItemTitle = (TextView) MainActivity.this.recyclerViewDrawer1.getChildAt(i).findViewById(C0615R.id.textViewDrawerItemTitle);
linearLayoutItem = (LinearLayout) MainActivity.this.recyclerViewDrawer1.getChildAt(i).findViewById(C0615R.id.linearLayoutItem);
imageViewDrawerItemIcon.setColorFilter(MainActivity.this.textColorPrimary);
if (VERSION.SDK_INT > 15) {
imageViewDrawerItemIcon.setImageAlpha(138);
} else {
imageViewDrawerItemIcon.setAlpha(138);
}
textViewDrawerItemTitle.setTextColor(MainActivity.this.textColorPrimary);
linearLayoutItem.setBackgroundColor(MainActivity.this.colorBackground);
}
for (i = 0; i < MainActivity.this.recyclerViewDrawer2.getChildCount(); i++) {
imageViewDrawerItemIcon = (ImageView) MainActivity.this.recyclerViewDrawer2.getChildAt(i).findViewById(C0615R.id.imageViewDrawerItemIcon);
textViewDrawerItemTitle = (TextView) MainActivity.this.recyclerViewDrawer2.getChildAt(i).findViewById(C0615R.id.textViewDrawerItemTitle);
linearLayoutItem = (LinearLayout) MainActivity.this.recyclerViewDrawer2.getChildAt(i).findViewById(C0615R.id.linearLayoutItem);
imageViewDrawerItemIcon.setColorFilter(MainActivity.this.textColorPrimary);
if (VERSION.SDK_INT > 15) {
imageViewDrawerItemIcon.setImageAlpha(138);
} else {
imageViewDrawerItemIcon.setAlpha(138);
}
textViewDrawerItemTitle.setTextColor(MainActivity.this.textColorPrimary);
linearLayoutItem.setBackgroundColor(MainActivity.this.colorBackground);
}
}
});
}
public void onClick(View v) {
this.sharedPreferences = getSharedPreferences("VALUES", 0);
Intent intent = new Intent(this, MainActivity.class);
switch (v.getId()) {
case C0615R.id.buttonRedLight:
this.sharedPreferences.edit().putString("THEME", "REDLIGHT").apply();
startActivity(intent);
case C0615R.id.buttonIndigoLight:
this.sharedPreferences.edit().putString("THEME", "INDIGOLIGHT").apply();
startActivity(intent);
case C0615R.id.buttonRedDark:
this.sharedPreferences.edit().putString("THEME", "REDDARK").apply();
startActivity(intent);
case C0615R.id.buttonIndigoDark:
this.sharedPreferences.edit().putString("THEME", "INDIGODARK").apply();
startActivity(intent);
case C0615R.id.toggleButtonDrawer:
this.linearLayoutDrawerAccount = (LinearLayout) findViewById(C0615R.id.linearLayoutDrawerAccounts);
this.linearLayoutDrawerMain = (LinearLayout) findViewById(C0615R.id.linearLayoutDrawerMain);
this.imageViewDrawerArrowUpDown = (ImageView) findViewById(C0615R.id.imageViewDrawerArrowUpDown);
this.frameLayoutSetting1 = (FrameLayout) findViewById(C0615R.id.frameLayoutSettings1);
Animation animation;
if (this.linearLayoutDrawerAccount.getVisibility() == 0) {
this.linearLayoutDrawerAccount.setVisibility(8);
this.linearLayoutDrawerMain.setVisibility(0);
if (this.frameLayoutSetting1.getVisibility() == 0) {
this.frameLayoutSetting1.setVisibility(8);
} else {
hideNavigationDrawerSettingsAndFeedbackOnScroll();
}
animation = new RotateAnimation(0.0f, -180.0f, 1, 0.5f, 1, 0.5f);
animation.setFillAfter(true);
animation.setDuration(500);
this.imageViewDrawerArrowUpDown.startAnimation(animation);
this.imageViewDrawerArrowUpDown.setBackgroundResource(C0615R.drawable.ic_navigation_arrow_drop_up);
} else {
this.linearLayoutDrawerAccount.setVisibility(0);
this.linearLayoutDrawerMain.setVisibility(8);
animation = new RotateAnimation(0.0f, BitmapDescriptorFactory.HUE_CYAN, 1, 0.5f, 1, 0.5f);
animation.setFillAfter(true);
animation.setDuration(500);
this.imageViewDrawerArrowUpDown.startAnimation(animation);
this.imageViewDrawerArrowUpDown.setBackgroundResource(C0615R.drawable.ic_navigation_arrow_drop_down);
}
if (this.frameLayoutSetting1.getVisibility() == 0) {
this.frameLayoutSetting1.setVisibility(8);
} else {
hideNavigationDrawerSettingsAndFeedbackOnScroll();
}
default:
}
}
public int convertDpToPx(int dp) {
return (int) ((((float) dp) * getResources().getDisplayMetrics().density) + 0.5f);
}
private void showToast(String message) {
Toast.makeText(getApplicationContext(), message, 0).show();
}
private void timer_iklan(String smenu) {
String fsmenu = smenu;
String server_path = getApplication().getSharedPreferences("MyPrefs", 0).getString("server_path", BuildConfig.FLAVOR);
Volley.newRequestQueue(getApplication()).add(new JsonObjectRequest(0, server_path + "/app_mobiles/get_kriteria_iklan.php?kriteria=" + smenu, null, new AnonymousClass14(server_path, (ImageView) findViewById(C0615R.id.view_iklan)), new ErrorListener() {
public void onErrorResponse(VolleyError error) {
error.printStackTrace();
}
}));
}
}
| 82,278 | 0.64334 | 0.62024 | 1,339 | 60.459297 | 45.533813 | 298 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.791636 | false | false | 9 |
71d230099b1ffceb62345e2b42e01846da63f4c7 | 35,880,156,791,605 | 01d03a5a8b9f82ab8c763e6bed45a3866f34e6d1 | /src/main/java/com/xirvir/feeds/FeedsConfig.java | 8fb10d8c0f5339c02524194c4dfdb072b3099d5a | [] | no_license | mmurfin87/feeds | https://github.com/mmurfin87/feeds | 85ea1e272940d39b6a584c1347471b2e3286fb01 | 9184e06c45fa555dba7a1cd5ed7bc5e128fedfe1 | refs/heads/master | 2022-05-01T20:01:14.644000 | 2022-05-01T02:28:30 | 2022-05-01T02:28:30 | 189,618,069 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.xirvir.feeds;
import io.dropwizard.Configuration;
import io.dropwizard.db.DataSourceFactory;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
@Data
public class FeedsConfig extends Configuration
{
private String testvalue;
private DataSourceFactory database;
}
| UTF-8 | Java | 339 | java | FeedsConfig.java | Java | [] | null | [] | package com.xirvir.feeds;
import io.dropwizard.Configuration;
import io.dropwizard.db.DataSourceFactory;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
@Data
public class FeedsConfig extends Configuration
{
private String testvalue;
private DataSourceFactory database;
}
| 339 | 0.837758 | 0.837758 | 15 | 21.6 | 15.776776 | 46 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.733333 | false | false | 9 |
bfb2513a225c8374fa2f90bf851fd864268a17c4 | 8,959,301,819,519 | 7eb7b6737ccf43da2eb6dc7fe347372f9044c8ff | /text-client/src/main/java/bot/Scenario/FindCommandScenario.java | 276a4401b55a4e45c00edc46f810566df0010588 | [] | no_license | Golizart/to_seHakaton | https://github.com/Golizart/to_seHakaton | 084f8010f9df868e56bdc96540943ab6427525c1 | fecb4f16aeaf182ad90fb3414e6a5da3e6d064b1 | refs/heads/master | 2021-08-28T11:50:03.939000 | 2017-12-12T05:09:06 | 2017-12-12T05:09:06 | 104,568,888 | 1 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package bot.Scenario;
import bot.Commands.BotCommand.*;
import bot.Commands.BotCommand.Settings.PrintSettingCommand;
import bot.Commands.BotCommand.Settings.SortSettingCommand;
import bot.Commands.BotCommand.Settings.ViewSettingCommand;
import bot.botInterface.Messages;
/**
* Created by golizar on 09.12.17.
*/
public class FindCommandScenario {
public static Command findCommand(Messages messages){
if(commandFind(messages, CommandTypes.MENU))
return MenuCommand.getInstance();
if(commandFind(messages, CommandTypes.START))
return StartCommand.getInstance();
if(commandFind(messages, CommandTypes.CALL))
return CallCommand.getInstance();
if(commandFind(messages, CommandTypes.REVIEWS))
return ReviewsCoomand.getInstance();
if(commandFind(messages, CommandTypes.MORE_PROPOSALS))
return MoreProposalsCoomand.getInstance();
if(commandFind(messages, CommandTypes.MY_BOOKINGS))
return MoreProposalsCoomand.getInstance();
if(commandFind(messages, CommandTypes.CLOSE_MENU))
return CloseMenuCommand.getInstance();
if(commandFind(messages, CommandTypes.SETTINGS))
return CloseMenuCommand.getInstance();
if(commandFind(messages, CommandTypes.PRINT_SETTINGS))
return PrintSettingCommand.getInstance();
if(commandFind(messages, CommandTypes.SORT_SETTINGS))
return SortSettingCommand.getInstance();
if(commandFind(messages, CommandTypes.VIEW_SETTINGS))
return ViewSettingCommand.getInstance();
if(commandFind(messages, CommandTypes.BOOKING))
return BookingCommand.getInstance();
return SpeechCommand.getInstance();
}
private static boolean commandFind(Messages messages, CommandTypes commandTypes){
String text = messages.getText();
for(String variant : commandTypes.getCommandVariant()){
if(text.equals(variant))
return true;
}
return false;
}
}
| UTF-8 | Java | 2,080 | java | FindCommandScenario.java | Java | [
{
"context": "port bot.botInterface.Messages;\n\n/**\n * Created by golizar on 09.12.17.\n */\npublic class FindCommandScenario",
"end": 298,
"score": 0.9996244311332703,
"start": 291,
"tag": "USERNAME",
"value": "golizar"
}
] | null | [] | package bot.Scenario;
import bot.Commands.BotCommand.*;
import bot.Commands.BotCommand.Settings.PrintSettingCommand;
import bot.Commands.BotCommand.Settings.SortSettingCommand;
import bot.Commands.BotCommand.Settings.ViewSettingCommand;
import bot.botInterface.Messages;
/**
* Created by golizar on 09.12.17.
*/
public class FindCommandScenario {
public static Command findCommand(Messages messages){
if(commandFind(messages, CommandTypes.MENU))
return MenuCommand.getInstance();
if(commandFind(messages, CommandTypes.START))
return StartCommand.getInstance();
if(commandFind(messages, CommandTypes.CALL))
return CallCommand.getInstance();
if(commandFind(messages, CommandTypes.REVIEWS))
return ReviewsCoomand.getInstance();
if(commandFind(messages, CommandTypes.MORE_PROPOSALS))
return MoreProposalsCoomand.getInstance();
if(commandFind(messages, CommandTypes.MY_BOOKINGS))
return MoreProposalsCoomand.getInstance();
if(commandFind(messages, CommandTypes.CLOSE_MENU))
return CloseMenuCommand.getInstance();
if(commandFind(messages, CommandTypes.SETTINGS))
return CloseMenuCommand.getInstance();
if(commandFind(messages, CommandTypes.PRINT_SETTINGS))
return PrintSettingCommand.getInstance();
if(commandFind(messages, CommandTypes.SORT_SETTINGS))
return SortSettingCommand.getInstance();
if(commandFind(messages, CommandTypes.VIEW_SETTINGS))
return ViewSettingCommand.getInstance();
if(commandFind(messages, CommandTypes.BOOKING))
return BookingCommand.getInstance();
return SpeechCommand.getInstance();
}
private static boolean commandFind(Messages messages, CommandTypes commandTypes){
String text = messages.getText();
for(String variant : commandTypes.getCommandVariant()){
if(text.equals(variant))
return true;
}
return false;
}
}
| 2,080 | 0.691346 | 0.688462 | 64 | 31.5 | 25.566702 | 85 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.546875 | false | false | 9 |
1351b158e1ed6cdd4c5a490495b9119d12767f7b | 12,824,772,365,206 | af196907b4f69f5d3fe4cf6a6e8b1b03f7d1cdfa | /src/main/java/com/finalmobile/wemarket/repository/ProductRepository.java | cffea922fe3bb8521b18c4636b33a1e0ec9b7223 | [] | no_license | thuanle1203/wemarket-back-end | https://github.com/thuanle1203/wemarket-back-end | 599eda7f78226a719e027bb5986227c08a8c0c45 | 5498eac2a09bbddccfb9e11fe5cb9322dd6c8337 | refs/heads/WMK-1_master | 2023-06-05T01:42:17.965000 | 2021-06-25T16:47:28 | 2021-06-25T16:47:28 | 364,306,428 | 0 | 0 | null | false | 2021-06-23T15:28:02 | 2021-05-04T15:43:29 | 2021-05-08T05:42:32 | 2021-06-23T15:28:01 | 244 | 0 | 0 | 0 | Java | false | false | package com.finalmobile.wemarket.repository;
import com.finalmobile.wemarket.models.Product;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import java.util.List;
public interface ProductRepository extends JpaRepository<Product,Integer> {
Product findProductById(int id);
@Query(value="SELECT * FROM product INNER JOIN market WHERE product.market_id=market.id AND product.market_id=?1",nativeQuery = true)
List<Product> findProductByMarketId(int id);
}
| UTF-8 | Java | 537 | java | ProductRepository.java | Java | [] | null | [] | package com.finalmobile.wemarket.repository;
import com.finalmobile.wemarket.models.Product;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import java.util.List;
public interface ProductRepository extends JpaRepository<Product,Integer> {
Product findProductById(int id);
@Query(value="SELECT * FROM product INNER JOIN market WHERE product.market_id=market.id AND product.market_id=?1",nativeQuery = true)
List<Product> findProductByMarketId(int id);
}
| 537 | 0.804469 | 0.802607 | 13 | 40.307693 | 37.244274 | 137 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.692308 | false | false | 9 |
ec14a75855a2982e4817c1673d69634c22685497 | 32,126,355,401,919 | 0fbd3066ac9367714ca1d5d57cdcf8b792907e2c | /POO III/Trabalho 02/Trabalho/Trabalho/src/Controller/daoVendedor.java | 9781b1ccd5f860498fe43e83fb16419e1d44443a | [] | no_license | gustavocomin/Faculdade | https://github.com/gustavocomin/Faculdade | cb9843f77666ab3ccbb44042cc83d3a0b5d8eae4 | 852b77a49202d576af8f1ce1db462fbd3af5adbd | refs/heads/main | 2023-06-17T10:44:57.430000 | 2021-07-09T22:27:31 | 2021-07-09T22:27:31 | 302,500,184 | 0 | 1 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package Controller;
import Model.Cidade;
import Model.Vendedor;
import java.util.List;
public class daoVendedor extends dao<Vendedor>{
public List<Vendedor> getList(){
String JPQL="select c from Vendedor c order by c.nome";
return super.getList(JPQL);
}
public List<Vendedor> getList(String filtro){
String JPQL="select c from Vendedor c where c.nome like ?1 order by c.nome";
return super.getList(JPQL,filtro);
}
public List<Vendedor> getList(Cidade cidade){
String JPQL="select c from Vendedor c where c.cidade = ?1 order by c.nome";
return super.getList(JPQL,cidade);
}
}
| UTF-8 | Java | 654 | java | daoVendedor.java | Java | [] | null | [] |
package Controller;
import Model.Cidade;
import Model.Vendedor;
import java.util.List;
public class daoVendedor extends dao<Vendedor>{
public List<Vendedor> getList(){
String JPQL="select c from Vendedor c order by c.nome";
return super.getList(JPQL);
}
public List<Vendedor> getList(String filtro){
String JPQL="select c from Vendedor c where c.nome like ?1 order by c.nome";
return super.getList(JPQL,filtro);
}
public List<Vendedor> getList(Cidade cidade){
String JPQL="select c from Vendedor c where c.cidade = ?1 order by c.nome";
return super.getList(JPQL,cidade);
}
}
| 654 | 0.675841 | 0.672783 | 20 | 31.65 | 25.298765 | 84 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.6 | false | false | 9 |
6bbbf53324207b8ec42d1a67df42e952d004e636 | 8,821,862,886,217 | c02ea549c4a2f35339fc28dba59ee8355965dc82 | /src/ventanas/RegistroUsuarios.java | a29e32a0815bed7ef43e8b2f35849877fd1681a7 | [] | no_license | MarcoDosSantos/DataSystem | https://github.com/MarcoDosSantos/DataSystem | 18858bf59fe10724f099c22260fdfa8840238eff | 74d048c8e97759247f0deb28260574a904a232b6 | refs/heads/master | 2020-05-04T13:29:44.576000 | 2019-04-02T21:52:00 | 2019-04-02T21:52:00 | 179,144,808 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package ventanas;
import java.awt.Image;
import java.awt.Toolkit;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import javax.swing.Icon;
import javax.swing.ImageIcon;
import javax.swing.JComboBox;
import javax.swing.JOptionPane;
import clases.Conexion;
import java.awt.Color;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.util.Scanner;
public class RegistroUsuarios extends javax.swing.JFrame {
private String usuario1 = new Login().usuario;
public RegistroUsuarios() {
initComponents();
setSize(650, 430); // Asigna (confirma) el tamaño del formulario.
setResizable(false); // Impide que el usuario modifique las dimensiones del formulario.
setLocationRelativeTo(null); // Hace que el formulario aparezca en el centro de la pantalla cuando se inicia la aplicación.
setTitle("Registrar nuevo usuario - Sesion de " + usuario1); // Cambia el texto de la barra de arriba por el que establecemos.
//La siguiente línea de código sirve para agregar la imagen al JLabel_wallpaper.
ImageIcon wallpaper = new ImageIcon("src/images/wallpaperprincipal.png");
// Creamos la instancia de ImageIcon, vinculándola a la imagen que queremos utilizar como fondo.
// En el próximo bloque de código, vamos a crear una instancia de la clase Icon, porque nos va a servir
// para indicarle al programa, que queremos que distribuya y escale el wallpaper al tamaño entero del JLabel_wallpaper.
Icon icono = new ImageIcon(wallpaper.getImage().getScaledInstance(jLabel_wallpaper.getWidth(),
jLabel_wallpaper.getHeight(), Image.SCALE_DEFAULT));
// Ahora le indicamos a jLaber_wallpaper, que incorpore el icono.
jLabel_wallpaper.setIcon(icono);
this.repaint(); // *Opcional* Sirve para que ejecute las líneas anteriores y establezca la imagen de fondo.
}
@Override
public Image getIconImage() {
Image retValue = Toolkit.getDefaultToolkit().getImage(ClassLoader.getSystemResource("images/icon.png"));
return retValue;
}
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
jLabel_registroUsuarios = new javax.swing.JLabel();
jTextField_nombre_apellido = new javax.swing.JTextField();
jTextField_email = new javax.swing.JTextField();
jTextField_telefono = new javax.swing.JTextField();
jTextField_nombre_usuario = new javax.swing.JTextField();
jButton_registrarUsuario = new javax.swing.JButton();
jLabel1 = new javax.swing.JLabel();
jLabel2 = new javax.swing.JLabel();
jLabel3 = new javax.swing.JLabel();
jLabel4 = new javax.swing.JLabel();
jLabel5 = new javax.swing.JLabel();
jLabel6 = new javax.swing.JLabel();
jPasswordField1 = new javax.swing.JPasswordField();
jComboBox_permisoDe = new javax.swing.JComboBox<>();
jLabel_footer = new javax.swing.JLabel();
jLabel_wallpaper = new javax.swing.JLabel();
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
setIconImage(getIconImage());
getContentPane().setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());
jLabel_registroUsuarios.setFont(new java.awt.Font("Arial", 1, 20)); // NOI18N
jLabel_registroUsuarios.setForeground(new java.awt.Color(255, 255, 255));
jLabel_registroUsuarios.setText("Registro de usuarios");
getContentPane().add(jLabel_registroUsuarios, new org.netbeans.lib.awtextra.AbsoluteConstraints(210, 10, 210, -1));
jTextField_nombre_apellido.setBackground(new java.awt.Color(153, 153, 255));
jTextField_nombre_apellido.setFont(new java.awt.Font("Arial", 0, 18)); // NOI18N
jTextField_nombre_apellido.setForeground(new java.awt.Color(255, 255, 255));
jTextField_nombre_apellido.setHorizontalAlignment(javax.swing.JTextField.CENTER);
jTextField_nombre_apellido.setBorder(new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.RAISED));
getContentPane().add(jTextField_nombre_apellido, new org.netbeans.lib.awtextra.AbsoluteConstraints(20, 70, 250, -1));
jTextField_email.setBackground(new java.awt.Color(153, 153, 255));
jTextField_email.setFont(new java.awt.Font("Arial", 0, 18)); // NOI18N
jTextField_email.setForeground(new java.awt.Color(255, 255, 255));
jTextField_email.setHorizontalAlignment(javax.swing.JTextField.CENTER);
jTextField_email.setBorder(new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.RAISED));
getContentPane().add(jTextField_email, new org.netbeans.lib.awtextra.AbsoluteConstraints(20, 170, 250, -1));
jTextField_telefono.setBackground(new java.awt.Color(153, 153, 255));
jTextField_telefono.setFont(new java.awt.Font("Arial", 0, 18)); // NOI18N
jTextField_telefono.setForeground(new java.awt.Color(255, 255, 255));
jTextField_telefono.setHorizontalAlignment(javax.swing.JTextField.CENTER);
jTextField_telefono.setBorder(new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.RAISED));
getContentPane().add(jTextField_telefono, new org.netbeans.lib.awtextra.AbsoluteConstraints(20, 270, 250, -1));
jTextField_nombre_usuario.setBackground(new java.awt.Color(153, 153, 255));
jTextField_nombre_usuario.setFont(new java.awt.Font("Arial", 0, 18)); // NOI18N
jTextField_nombre_usuario.setForeground(new java.awt.Color(255, 255, 255));
jTextField_nombre_usuario.setHorizontalAlignment(javax.swing.JTextField.CENTER);
jTextField_nombre_usuario.setBorder(new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.RAISED));
getContentPane().add(jTextField_nombre_usuario, new org.netbeans.lib.awtextra.AbsoluteConstraints(345, 70, 250, -1));
jButton_registrarUsuario.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/addUser.png"))); // NOI18N
jButton_registrarUsuario.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton_registrarUsuarioActionPerformed(evt);
}
});
getContentPane().add(jButton_registrarUsuario, new org.netbeans.lib.awtextra.AbsoluteConstraints(470, 280, 120, 100));
jLabel1.setFont(new java.awt.Font("Arial", 1, 12)); // NOI18N
jLabel1.setForeground(new java.awt.Color(255, 255, 255));
jLabel1.setText("Nombre de usuario:");
getContentPane().add(jLabel1, new org.netbeans.lib.awtextra.AbsoluteConstraints(350, 50, -1, -1));
jLabel2.setFont(new java.awt.Font("Arial", 1, 12)); // NOI18N
jLabel2.setForeground(new java.awt.Color(255, 255, 255));
jLabel2.setText("em@il:");
getContentPane().add(jLabel2, new org.netbeans.lib.awtextra.AbsoluteConstraints(30, 150, -1, -1));
jLabel3.setFont(new java.awt.Font("Arial", 1, 12)); // NOI18N
jLabel3.setForeground(new java.awt.Color(255, 255, 255));
jLabel3.setText("Teléfono");
getContentPane().add(jLabel3, new org.netbeans.lib.awtextra.AbsoluteConstraints(30, 250, -1, -1));
jLabel4.setFont(new java.awt.Font("Arial", 1, 12)); // NOI18N
jLabel4.setForeground(new java.awt.Color(255, 255, 255));
jLabel4.setText("Permiso de:");
getContentPane().add(jLabel4, new org.netbeans.lib.awtextra.AbsoluteConstraints(30, 340, -1, -1));
jLabel5.setFont(new java.awt.Font("Arial", 1, 12)); // NOI18N
jLabel5.setForeground(new java.awt.Color(255, 255, 255));
jLabel5.setText("Contraseña:");
getContentPane().add(jLabel5, new org.netbeans.lib.awtextra.AbsoluteConstraints(350, 150, -1, -1));
jLabel6.setFont(new java.awt.Font("Arial", 1, 12)); // NOI18N
jLabel6.setForeground(new java.awt.Color(255, 255, 255));
jLabel6.setText("Nombre y Apellido(s)");
getContentPane().add(jLabel6, new org.netbeans.lib.awtextra.AbsoluteConstraints(25, 50, -1, -1));
jPasswordField1.setBackground(new java.awt.Color(153, 153, 255));
jPasswordField1.setFont(new java.awt.Font("Arial", 0, 18)); // NOI18N
jPasswordField1.setForeground(new java.awt.Color(255, 255, 255));
jPasswordField1.setHorizontalAlignment(javax.swing.JTextField.CENTER);
jPasswordField1.setBorder(new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.RAISED));
getContentPane().add(jPasswordField1, new org.netbeans.lib.awtextra.AbsoluteConstraints(345, 170, 250, -1));
jComboBox_permisoDe.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N
jComboBox_permisoDe.setModel(new javax.swing.DefaultComboBoxModel<>(new String[] { "Administrador", "Capturista", "Técnico" }));
getContentPane().add(jComboBox_permisoDe, new org.netbeans.lib.awtextra.AbsoluteConstraints(30, 360, -1, -1));
jLabel_footer.setForeground(new java.awt.Color(51, 51, 51));
jLabel_footer.setText("Creado por Marco Dos Santos");
getContentPane().add(jLabel_footer, new org.netbeans.lib.awtextra.AbsoluteConstraints(255, 380, -1, -1));
jLabel_wallpaper.setBackground(new java.awt.Color(153, 153, 255));
jLabel_wallpaper.setForeground(new java.awt.Color(255, 255, 255));
jLabel_wallpaper.setBorder(new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.RAISED));
getContentPane().add(jLabel_wallpaper, new org.netbeans.lib.awtextra.AbsoluteConstraints(0, 0, 650, 430));
pack();
}// </editor-fold>//GEN-END:initComponents
private void jButton_registrarUsuarioActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton_registrarUsuarioActionPerformed
String textoPermiso = jComboBox_permisoDe.getSelectedItem().toString();
String nombreApellido = jTextField_nombre_apellido.getText().trim();
String email = jTextField_email.getText().trim();
String telefono = jTextField_telefono.getText().trim();
String nombreUsuario = jTextField_nombre_usuario.getText().trim();
String contrasenia = jPasswordField1.getText().trim();
if (nombreApellido.equals("") || email.equals("") || telefono.equals("")
|| nombreUsuario.equals("") || contrasenia.equals("")) {
if (nombreApellido.equals("")) {
jTextField_nombre_apellido.setBackground(Color.red);
}
if (email.equals("")) {
jTextField_email.setBackground(Color.red);
}
if (telefono.equals("")) {
jTextField_telefono.setBackground(Color.red);
}
if (nombreUsuario.equals("")) {
jTextField_nombre_usuario.setBackground(Color.red);
}
if (contrasenia.equals("")) {
jPasswordField1.setBackground(Color.red);
}
JOptionPane.showMessageDialog(null, "Debes completar todos los campos.");
} else if (!nombreApellido.equals("") && !email.equals("") && !telefono.equals("")
&& !nombreUsuario.equals("") && !contrasenia.equals("")) {
int hayArroba = 0;
int posicionArroba = 0;
int hayPunto = 0;
for (int i = 0; i < email.length(); i++) {
if (email.charAt(i) == '@') {
hayArroba++;
}
}
if (hayArroba != 1) {
jTextField_email.setBackground(Color.red);
JOptionPane.showMessageDialog(null, "Debes introducir un mail válido.");
hayArroba = 0;
posicionArroba = 0;
hayPunto = 0;
email = "";
} else {
posicionArroba = email.indexOf('@');
String extracto = email.substring(posicionArroba);
for (int j = 0; j < extracto.length(); j++) {
if (extracto.charAt(j) == '.') {
hayPunto++;
}
}
if (hayPunto == 1 || hayPunto == 2) {
//System.out.println("El mail es válido.");
try {
Connection cn = Conexion.conectar();
PreparedStatement pst = cn.prepareStatement(
"insert into usuarios "
+ "values (id_usuario = 1,?,?,?,?,?,?,?,?)");
pst.setString(1, nombreApellido);
pst.setString(2, email);
pst.setString(3, telefono);
pst.setString(4, nombreUsuario);
pst.setString(5, contrasenia);
pst.setString(6, textoPermiso);
pst.setString(7, "Activo");
pst.setString(8, usuario1);
pst.executeUpdate();
jTextField_nombre_apellido.setText("");
jTextField_email.setText("");
jTextField_telefono.setText("");
jTextField_nombre_usuario.setText("");
jPasswordField1.setText("");
jTextField_nombre_apellido.setBackground(new Color(38, 176, 55));
jTextField_email.setBackground(new Color(38, 176, 55));
jTextField_telefono.setBackground(new Color(38, 176, 55));
jTextField_nombre_usuario.setBackground(new Color(38, 176, 55));
jPasswordField1.setBackground(new Color(38, 176, 55));
JOptionPane.showMessageDialog(null, "Registro exitoso.");
dispose();
} catch (Exception e) {
JOptionPane.showMessageDialog(null, "Error al registrar usuario: " + e);
}
} else {
jTextField_email.setBackground(Color.red);
JOptionPane.showMessageDialog(null, "Debes introducir un mail válido.");
hayArroba = 0;
posicionArroba = 0;
hayPunto = 0;
email = "";
extracto = "";
}
}
}
}//GEN-LAST:event_jButton_registrarUsuarioActionPerformed
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
* For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(RegistroUsuarios.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(RegistroUsuarios.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(RegistroUsuarios.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(RegistroUsuarios.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
}
//</editor-fold>
/* Create and display the form */
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new RegistroUsuarios().setVisible(true);
}
});
}
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton jButton_registrarUsuario;
private javax.swing.JComboBox<String> jComboBox_permisoDe;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel4;
private javax.swing.JLabel jLabel5;
private javax.swing.JLabel jLabel6;
private javax.swing.JLabel jLabel_footer;
private javax.swing.JLabel jLabel_registroUsuarios;
private javax.swing.JLabel jLabel_wallpaper;
private javax.swing.JPasswordField jPasswordField1;
private javax.swing.JTextField jTextField_email;
private javax.swing.JTextField jTextField_nombre_apellido;
private javax.swing.JTextField jTextField_nombre_usuario;
private javax.swing.JTextField jTextField_telefono;
// End of variables declaration//GEN-END:variables
}
| UTF-8 | Java | 17,334 | java | RegistroUsuarios.java | Java | [
{
"context": "1, 51));\n jLabel_footer.setText(\"Creado por Marco Dos Santos\");\n getContentPane().add(jLabel_footer, ne",
"end": 9255,
"score": 0.9998667240142822,
"start": 9239,
"tag": "NAME",
"value": "Marco Dos Santos"
}
] | null | [] | package ventanas;
import java.awt.Image;
import java.awt.Toolkit;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import javax.swing.Icon;
import javax.swing.ImageIcon;
import javax.swing.JComboBox;
import javax.swing.JOptionPane;
import clases.Conexion;
import java.awt.Color;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.util.Scanner;
public class RegistroUsuarios extends javax.swing.JFrame {
private String usuario1 = new Login().usuario;
public RegistroUsuarios() {
initComponents();
setSize(650, 430); // Asigna (confirma) el tamaño del formulario.
setResizable(false); // Impide que el usuario modifique las dimensiones del formulario.
setLocationRelativeTo(null); // Hace que el formulario aparezca en el centro de la pantalla cuando se inicia la aplicación.
setTitle("Registrar nuevo usuario - Sesion de " + usuario1); // Cambia el texto de la barra de arriba por el que establecemos.
//La siguiente línea de código sirve para agregar la imagen al JLabel_wallpaper.
ImageIcon wallpaper = new ImageIcon("src/images/wallpaperprincipal.png");
// Creamos la instancia de ImageIcon, vinculándola a la imagen que queremos utilizar como fondo.
// En el próximo bloque de código, vamos a crear una instancia de la clase Icon, porque nos va a servir
// para indicarle al programa, que queremos que distribuya y escale el wallpaper al tamaño entero del JLabel_wallpaper.
Icon icono = new ImageIcon(wallpaper.getImage().getScaledInstance(jLabel_wallpaper.getWidth(),
jLabel_wallpaper.getHeight(), Image.SCALE_DEFAULT));
// Ahora le indicamos a jLaber_wallpaper, que incorpore el icono.
jLabel_wallpaper.setIcon(icono);
this.repaint(); // *Opcional* Sirve para que ejecute las líneas anteriores y establezca la imagen de fondo.
}
@Override
public Image getIconImage() {
Image retValue = Toolkit.getDefaultToolkit().getImage(ClassLoader.getSystemResource("images/icon.png"));
return retValue;
}
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
jLabel_registroUsuarios = new javax.swing.JLabel();
jTextField_nombre_apellido = new javax.swing.JTextField();
jTextField_email = new javax.swing.JTextField();
jTextField_telefono = new javax.swing.JTextField();
jTextField_nombre_usuario = new javax.swing.JTextField();
jButton_registrarUsuario = new javax.swing.JButton();
jLabel1 = new javax.swing.JLabel();
jLabel2 = new javax.swing.JLabel();
jLabel3 = new javax.swing.JLabel();
jLabel4 = new javax.swing.JLabel();
jLabel5 = new javax.swing.JLabel();
jLabel6 = new javax.swing.JLabel();
jPasswordField1 = new javax.swing.JPasswordField();
jComboBox_permisoDe = new javax.swing.JComboBox<>();
jLabel_footer = new javax.swing.JLabel();
jLabel_wallpaper = new javax.swing.JLabel();
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
setIconImage(getIconImage());
getContentPane().setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());
jLabel_registroUsuarios.setFont(new java.awt.Font("Arial", 1, 20)); // NOI18N
jLabel_registroUsuarios.setForeground(new java.awt.Color(255, 255, 255));
jLabel_registroUsuarios.setText("Registro de usuarios");
getContentPane().add(jLabel_registroUsuarios, new org.netbeans.lib.awtextra.AbsoluteConstraints(210, 10, 210, -1));
jTextField_nombre_apellido.setBackground(new java.awt.Color(153, 153, 255));
jTextField_nombre_apellido.setFont(new java.awt.Font("Arial", 0, 18)); // NOI18N
jTextField_nombre_apellido.setForeground(new java.awt.Color(255, 255, 255));
jTextField_nombre_apellido.setHorizontalAlignment(javax.swing.JTextField.CENTER);
jTextField_nombre_apellido.setBorder(new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.RAISED));
getContentPane().add(jTextField_nombre_apellido, new org.netbeans.lib.awtextra.AbsoluteConstraints(20, 70, 250, -1));
jTextField_email.setBackground(new java.awt.Color(153, 153, 255));
jTextField_email.setFont(new java.awt.Font("Arial", 0, 18)); // NOI18N
jTextField_email.setForeground(new java.awt.Color(255, 255, 255));
jTextField_email.setHorizontalAlignment(javax.swing.JTextField.CENTER);
jTextField_email.setBorder(new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.RAISED));
getContentPane().add(jTextField_email, new org.netbeans.lib.awtextra.AbsoluteConstraints(20, 170, 250, -1));
jTextField_telefono.setBackground(new java.awt.Color(153, 153, 255));
jTextField_telefono.setFont(new java.awt.Font("Arial", 0, 18)); // NOI18N
jTextField_telefono.setForeground(new java.awt.Color(255, 255, 255));
jTextField_telefono.setHorizontalAlignment(javax.swing.JTextField.CENTER);
jTextField_telefono.setBorder(new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.RAISED));
getContentPane().add(jTextField_telefono, new org.netbeans.lib.awtextra.AbsoluteConstraints(20, 270, 250, -1));
jTextField_nombre_usuario.setBackground(new java.awt.Color(153, 153, 255));
jTextField_nombre_usuario.setFont(new java.awt.Font("Arial", 0, 18)); // NOI18N
jTextField_nombre_usuario.setForeground(new java.awt.Color(255, 255, 255));
jTextField_nombre_usuario.setHorizontalAlignment(javax.swing.JTextField.CENTER);
jTextField_nombre_usuario.setBorder(new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.RAISED));
getContentPane().add(jTextField_nombre_usuario, new org.netbeans.lib.awtextra.AbsoluteConstraints(345, 70, 250, -1));
jButton_registrarUsuario.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/addUser.png"))); // NOI18N
jButton_registrarUsuario.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton_registrarUsuarioActionPerformed(evt);
}
});
getContentPane().add(jButton_registrarUsuario, new org.netbeans.lib.awtextra.AbsoluteConstraints(470, 280, 120, 100));
jLabel1.setFont(new java.awt.Font("Arial", 1, 12)); // NOI18N
jLabel1.setForeground(new java.awt.Color(255, 255, 255));
jLabel1.setText("Nombre de usuario:");
getContentPane().add(jLabel1, new org.netbeans.lib.awtextra.AbsoluteConstraints(350, 50, -1, -1));
jLabel2.setFont(new java.awt.Font("Arial", 1, 12)); // NOI18N
jLabel2.setForeground(new java.awt.Color(255, 255, 255));
jLabel2.setText("em@il:");
getContentPane().add(jLabel2, new org.netbeans.lib.awtextra.AbsoluteConstraints(30, 150, -1, -1));
jLabel3.setFont(new java.awt.Font("Arial", 1, 12)); // NOI18N
jLabel3.setForeground(new java.awt.Color(255, 255, 255));
jLabel3.setText("Teléfono");
getContentPane().add(jLabel3, new org.netbeans.lib.awtextra.AbsoluteConstraints(30, 250, -1, -1));
jLabel4.setFont(new java.awt.Font("Arial", 1, 12)); // NOI18N
jLabel4.setForeground(new java.awt.Color(255, 255, 255));
jLabel4.setText("Permiso de:");
getContentPane().add(jLabel4, new org.netbeans.lib.awtextra.AbsoluteConstraints(30, 340, -1, -1));
jLabel5.setFont(new java.awt.Font("Arial", 1, 12)); // NOI18N
jLabel5.setForeground(new java.awt.Color(255, 255, 255));
jLabel5.setText("Contraseña:");
getContentPane().add(jLabel5, new org.netbeans.lib.awtextra.AbsoluteConstraints(350, 150, -1, -1));
jLabel6.setFont(new java.awt.Font("Arial", 1, 12)); // NOI18N
jLabel6.setForeground(new java.awt.Color(255, 255, 255));
jLabel6.setText("Nombre y Apellido(s)");
getContentPane().add(jLabel6, new org.netbeans.lib.awtextra.AbsoluteConstraints(25, 50, -1, -1));
jPasswordField1.setBackground(new java.awt.Color(153, 153, 255));
jPasswordField1.setFont(new java.awt.Font("Arial", 0, 18)); // NOI18N
jPasswordField1.setForeground(new java.awt.Color(255, 255, 255));
jPasswordField1.setHorizontalAlignment(javax.swing.JTextField.CENTER);
jPasswordField1.setBorder(new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.RAISED));
getContentPane().add(jPasswordField1, new org.netbeans.lib.awtextra.AbsoluteConstraints(345, 170, 250, -1));
jComboBox_permisoDe.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N
jComboBox_permisoDe.setModel(new javax.swing.DefaultComboBoxModel<>(new String[] { "Administrador", "Capturista", "Técnico" }));
getContentPane().add(jComboBox_permisoDe, new org.netbeans.lib.awtextra.AbsoluteConstraints(30, 360, -1, -1));
jLabel_footer.setForeground(new java.awt.Color(51, 51, 51));
jLabel_footer.setText("Creado por <NAME>");
getContentPane().add(jLabel_footer, new org.netbeans.lib.awtextra.AbsoluteConstraints(255, 380, -1, -1));
jLabel_wallpaper.setBackground(new java.awt.Color(153, 153, 255));
jLabel_wallpaper.setForeground(new java.awt.Color(255, 255, 255));
jLabel_wallpaper.setBorder(new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.RAISED));
getContentPane().add(jLabel_wallpaper, new org.netbeans.lib.awtextra.AbsoluteConstraints(0, 0, 650, 430));
pack();
}// </editor-fold>//GEN-END:initComponents
private void jButton_registrarUsuarioActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton_registrarUsuarioActionPerformed
String textoPermiso = jComboBox_permisoDe.getSelectedItem().toString();
String nombreApellido = jTextField_nombre_apellido.getText().trim();
String email = jTextField_email.getText().trim();
String telefono = jTextField_telefono.getText().trim();
String nombreUsuario = jTextField_nombre_usuario.getText().trim();
String contrasenia = jPasswordField1.getText().trim();
if (nombreApellido.equals("") || email.equals("") || telefono.equals("")
|| nombreUsuario.equals("") || contrasenia.equals("")) {
if (nombreApellido.equals("")) {
jTextField_nombre_apellido.setBackground(Color.red);
}
if (email.equals("")) {
jTextField_email.setBackground(Color.red);
}
if (telefono.equals("")) {
jTextField_telefono.setBackground(Color.red);
}
if (nombreUsuario.equals("")) {
jTextField_nombre_usuario.setBackground(Color.red);
}
if (contrasenia.equals("")) {
jPasswordField1.setBackground(Color.red);
}
JOptionPane.showMessageDialog(null, "Debes completar todos los campos.");
} else if (!nombreApellido.equals("") && !email.equals("") && !telefono.equals("")
&& !nombreUsuario.equals("") && !contrasenia.equals("")) {
int hayArroba = 0;
int posicionArroba = 0;
int hayPunto = 0;
for (int i = 0; i < email.length(); i++) {
if (email.charAt(i) == '@') {
hayArroba++;
}
}
if (hayArroba != 1) {
jTextField_email.setBackground(Color.red);
JOptionPane.showMessageDialog(null, "Debes introducir un mail válido.");
hayArroba = 0;
posicionArroba = 0;
hayPunto = 0;
email = "";
} else {
posicionArroba = email.indexOf('@');
String extracto = email.substring(posicionArroba);
for (int j = 0; j < extracto.length(); j++) {
if (extracto.charAt(j) == '.') {
hayPunto++;
}
}
if (hayPunto == 1 || hayPunto == 2) {
//System.out.println("El mail es válido.");
try {
Connection cn = Conexion.conectar();
PreparedStatement pst = cn.prepareStatement(
"insert into usuarios "
+ "values (id_usuario = 1,?,?,?,?,?,?,?,?)");
pst.setString(1, nombreApellido);
pst.setString(2, email);
pst.setString(3, telefono);
pst.setString(4, nombreUsuario);
pst.setString(5, contrasenia);
pst.setString(6, textoPermiso);
pst.setString(7, "Activo");
pst.setString(8, usuario1);
pst.executeUpdate();
jTextField_nombre_apellido.setText("");
jTextField_email.setText("");
jTextField_telefono.setText("");
jTextField_nombre_usuario.setText("");
jPasswordField1.setText("");
jTextField_nombre_apellido.setBackground(new Color(38, 176, 55));
jTextField_email.setBackground(new Color(38, 176, 55));
jTextField_telefono.setBackground(new Color(38, 176, 55));
jTextField_nombre_usuario.setBackground(new Color(38, 176, 55));
jPasswordField1.setBackground(new Color(38, 176, 55));
JOptionPane.showMessageDialog(null, "Registro exitoso.");
dispose();
} catch (Exception e) {
JOptionPane.showMessageDialog(null, "Error al registrar usuario: " + e);
}
} else {
jTextField_email.setBackground(Color.red);
JOptionPane.showMessageDialog(null, "Debes introducir un mail válido.");
hayArroba = 0;
posicionArroba = 0;
hayPunto = 0;
email = "";
extracto = "";
}
}
}
}//GEN-LAST:event_jButton_registrarUsuarioActionPerformed
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
* For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(RegistroUsuarios.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(RegistroUsuarios.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(RegistroUsuarios.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(RegistroUsuarios.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
}
//</editor-fold>
/* Create and display the form */
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new RegistroUsuarios().setVisible(true);
}
});
}
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton jButton_registrarUsuario;
private javax.swing.JComboBox<String> jComboBox_permisoDe;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel4;
private javax.swing.JLabel jLabel5;
private javax.swing.JLabel jLabel6;
private javax.swing.JLabel jLabel_footer;
private javax.swing.JLabel jLabel_registroUsuarios;
private javax.swing.JLabel jLabel_wallpaper;
private javax.swing.JPasswordField jPasswordField1;
private javax.swing.JTextField jTextField_email;
private javax.swing.JTextField jTextField_nombre_apellido;
private javax.swing.JTextField jTextField_nombre_usuario;
private javax.swing.JTextField jTextField_telefono;
// End of variables declaration//GEN-END:variables
}
| 17,324 | 0.637912 | 0.609562 | 328 | 51.80183 | 36.284702 | 147 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.20122 | false | false | 9 |
53efae85b6d73c4fb6545e6b6be38de3dbf90f22 | 25,683,904,445,527 | d6fadf99b73c7bac83409c194d0a11481912a8a4 | /src/main/java/com/afaqy/avl/webnotifier/connections/ConnectionManager.java | 9813e0caf4e01b948c0527c90f568f815368750e | [] | no_license | avljenkins/web | https://github.com/avljenkins/web | c47ffef98131376ce8b0314587be344b25c6c7d6 | 7f66eecb77290baf86929b07f881cd5b57f4f6d1 | refs/heads/master | 2022-12-02T20:40:29.058000 | 2020-06-09T23:02:41 | 2020-06-09T23:02:41 | 287,904,641 | 0 | 0 | null | true | 2020-08-16T08:32:55 | 2020-08-16T08:32:55 | 2020-06-09T23:02:44 | 2020-08-09T22:16:39 | 2,377 | 0 | 0 | 0 | null | false | false | package com.afaqy.avl.webnotifier.connections;
import com.afaqy.avl.core.helper.log.LogMsg;
import com.afaqy.avl.webnotifier.WebNotifierConstants;
import com.afaqy.avl.webnotifier.model.DeviceConnectionStatus;
import com.afaqy.avl.webnotifier.model.WebSocketBindEvent;
import com.afaqy.avl.webnotifier.model.WebSocketsEvent;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
public class ConnectionManager {
private static final Logger LOGGER = LogManager.getLogger(ConnectionManager.class);
private final ConcurrentHashMap<String, Set<UpdateListener>> normalListenersMap = new ConcurrentHashMap<>();
private final ConcurrentHashMap<String, AsyncSocket> adminsMap = new ConcurrentHashMap<>();
private volatile long listenersCount = 0;
public ConnectionManager() {
}
public ConcurrentHashMap<String, Set<UpdateListener>> getNormalListenersMap() {
return normalListenersMap;
}
public ConcurrentHashMap<String, AsyncSocket> getAdminsMap() {
return adminsMap;
}
/**
* @param users users to be notified
* @param event websocket event
*/
public synchronized void updateEvent(List<String> users, WebSocketsEvent event) {
try {
for (String userId : users) {
if (normalListenersMap.containsKey(userId)) {
for (UpdateListener listener : normalListenersMap.get(userId)) {
listener.onUpdateEvent(event);
}
}
}
adminsMap.values().forEach(x -> x.onUpdateEvent(event));
} catch (Exception ex) {
ex.printStackTrace();
LOGGER.catching(ex);
}
}
/**
* @param users users to be notified
* @param event websocket event
*/
public synchronized void updateBindEvent(List<String> users, WebSocketBindEvent event) {
try {
for (String userId : users) {
if (normalListenersMap.containsKey(userId)) {
for (UpdateListener listener : normalListenersMap.get(userId)) {
listener.onUpdateBindEvent(event);
}
}
}
adminsMap.values().forEach(x -> x.onUpdateBindEvent(event));
} catch (Exception ex) {
ex.printStackTrace();
LOGGER.catching(ex);
}
}
/**
* add new listener check if admin ad to admin map, else listeners map
*
* @param listener socket listener
*/
public synchronized void addListener(UpdateListener listener) {
try {
if (listener.isAdmin()) {
// make sure that user is admin
AsyncSocket socket = (AsyncSocket) listener;
adminsMap.put(socket.getSocketChannelId(), socket);
listenersCount++;
} else {
if (!normalListenersMap.containsKey(listener.getUserId())) {
normalListenersMap.put(listener.getUserId(), new HashSet<>());
}
normalListenersMap.get(listener.getUserId()).add(listener);
listenersCount++;
}
LOGGER.info(new LogMsg(WebNotifierConstants.WEB, listener.getUserId(), String.format("New listener connected, admin=%s,T[%d]", listener.isAdmin() + "", listenersCount)));
} catch (Exception ex) {
LOGGER.catching(ex);
}
}
/**
* Close specific socket listener
*
* @param listener socket listener
*/
public synchronized void closeListener(UpdateListener listener) {
AsyncSocket socket = (AsyncSocket) listener;
socket.close();
removeListener(listener);
LOGGER.info(new LogMsg(WebNotifierConstants.WEB, listener.getUserId(), String.format("Listener removed, admin=%s,T[%d]", listener.isAdmin() + "", listenersCount)));
}
/**
* remove specific socket listener
*
* @param listener socket listener
*/
public synchronized void removeListener(UpdateListener listener) {
if (listener.isAdmin()) {
AsyncSocket socket = (AsyncSocket) listener;
adminsMap.remove(socket.getSocketChannelId());
listenersCount--;
} else {
Set<UpdateListener> listeners = normalListenersMap.get(listener.getUserId());
if (listeners != null) {
listeners.remove(listener);
listenersCount--;
}
}
LOGGER.info(new LogMsg(WebNotifierConstants.WEB, listener.getUserId(), String.format("Listener removed, admin=%s,T[%d]", listener.isAdmin() + "", listenersCount)));
}
/**
* delete all sockets
*/
public synchronized void removeAllListener() {
for (UpdateListener listener : getListeners()) {
listener.close();
}
normalListenersMap.clear();
adminsMap.clear();
listenersCount = 0;
}
public Set<UpdateListener> getListeners() {
Set<UpdateListener> listeners = new HashSet<>();
normalListenersMap.values().forEach(listeners::addAll);
listeners.addAll(adminsMap.values());
return listeners;
}
public Map<String, Integer> getListenersCount() {
int adminMapSize = adminsMap.size();
int normalListenersSize = getNormalListenersSize();
Map<String, Integer> result = new HashMap();
result.put("admin", adminMapSize);
result.put("normal", normalListenersSize);
result.put("total", (adminMapSize + normalListenersSize));
return result;
}
public int getNormalListenersSize() {
int normalListenersSize = 0;
Collection<Set<UpdateListener>> sets = normalListenersMap.values();
for (Set<UpdateListener> itm : sets) {
normalListenersSize += itm.size();
}
return normalListenersSize;
}
public void updateDeviceStatus(DeviceConnectionStatus status, String statusJson) {
// just update associated user to an unit's update
try {
if (status.getUsers() != null) {
for (String userId : status.getUsers()) {
if (normalListenersMap.containsKey(userId)) {
for (UpdateListener listener : normalListenersMap.get(userId)) {
listener.onUpdateDeviceStatus(status, statusJson);
}
}
}
adminsMap.values().forEach(x -> x.onUpdateDeviceStatus(status, statusJson));
}
}catch (Exception ex){
LOGGER.catching(ex);
}
}
}
| UTF-8 | Java | 6,789 | java | ConnectionManager.java | Java | [] | null | [] | package com.afaqy.avl.webnotifier.connections;
import com.afaqy.avl.core.helper.log.LogMsg;
import com.afaqy.avl.webnotifier.WebNotifierConstants;
import com.afaqy.avl.webnotifier.model.DeviceConnectionStatus;
import com.afaqy.avl.webnotifier.model.WebSocketBindEvent;
import com.afaqy.avl.webnotifier.model.WebSocketsEvent;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
public class ConnectionManager {
private static final Logger LOGGER = LogManager.getLogger(ConnectionManager.class);
private final ConcurrentHashMap<String, Set<UpdateListener>> normalListenersMap = new ConcurrentHashMap<>();
private final ConcurrentHashMap<String, AsyncSocket> adminsMap = new ConcurrentHashMap<>();
private volatile long listenersCount = 0;
public ConnectionManager() {
}
public ConcurrentHashMap<String, Set<UpdateListener>> getNormalListenersMap() {
return normalListenersMap;
}
public ConcurrentHashMap<String, AsyncSocket> getAdminsMap() {
return adminsMap;
}
/**
* @param users users to be notified
* @param event websocket event
*/
public synchronized void updateEvent(List<String> users, WebSocketsEvent event) {
try {
for (String userId : users) {
if (normalListenersMap.containsKey(userId)) {
for (UpdateListener listener : normalListenersMap.get(userId)) {
listener.onUpdateEvent(event);
}
}
}
adminsMap.values().forEach(x -> x.onUpdateEvent(event));
} catch (Exception ex) {
ex.printStackTrace();
LOGGER.catching(ex);
}
}
/**
* @param users users to be notified
* @param event websocket event
*/
public synchronized void updateBindEvent(List<String> users, WebSocketBindEvent event) {
try {
for (String userId : users) {
if (normalListenersMap.containsKey(userId)) {
for (UpdateListener listener : normalListenersMap.get(userId)) {
listener.onUpdateBindEvent(event);
}
}
}
adminsMap.values().forEach(x -> x.onUpdateBindEvent(event));
} catch (Exception ex) {
ex.printStackTrace();
LOGGER.catching(ex);
}
}
/**
* add new listener check if admin ad to admin map, else listeners map
*
* @param listener socket listener
*/
public synchronized void addListener(UpdateListener listener) {
try {
if (listener.isAdmin()) {
// make sure that user is admin
AsyncSocket socket = (AsyncSocket) listener;
adminsMap.put(socket.getSocketChannelId(), socket);
listenersCount++;
} else {
if (!normalListenersMap.containsKey(listener.getUserId())) {
normalListenersMap.put(listener.getUserId(), new HashSet<>());
}
normalListenersMap.get(listener.getUserId()).add(listener);
listenersCount++;
}
LOGGER.info(new LogMsg(WebNotifierConstants.WEB, listener.getUserId(), String.format("New listener connected, admin=%s,T[%d]", listener.isAdmin() + "", listenersCount)));
} catch (Exception ex) {
LOGGER.catching(ex);
}
}
/**
* Close specific socket listener
*
* @param listener socket listener
*/
public synchronized void closeListener(UpdateListener listener) {
AsyncSocket socket = (AsyncSocket) listener;
socket.close();
removeListener(listener);
LOGGER.info(new LogMsg(WebNotifierConstants.WEB, listener.getUserId(), String.format("Listener removed, admin=%s,T[%d]", listener.isAdmin() + "", listenersCount)));
}
/**
* remove specific socket listener
*
* @param listener socket listener
*/
public synchronized void removeListener(UpdateListener listener) {
if (listener.isAdmin()) {
AsyncSocket socket = (AsyncSocket) listener;
adminsMap.remove(socket.getSocketChannelId());
listenersCount--;
} else {
Set<UpdateListener> listeners = normalListenersMap.get(listener.getUserId());
if (listeners != null) {
listeners.remove(listener);
listenersCount--;
}
}
LOGGER.info(new LogMsg(WebNotifierConstants.WEB, listener.getUserId(), String.format("Listener removed, admin=%s,T[%d]", listener.isAdmin() + "", listenersCount)));
}
/**
* delete all sockets
*/
public synchronized void removeAllListener() {
for (UpdateListener listener : getListeners()) {
listener.close();
}
normalListenersMap.clear();
adminsMap.clear();
listenersCount = 0;
}
public Set<UpdateListener> getListeners() {
Set<UpdateListener> listeners = new HashSet<>();
normalListenersMap.values().forEach(listeners::addAll);
listeners.addAll(adminsMap.values());
return listeners;
}
public Map<String, Integer> getListenersCount() {
int adminMapSize = adminsMap.size();
int normalListenersSize = getNormalListenersSize();
Map<String, Integer> result = new HashMap();
result.put("admin", adminMapSize);
result.put("normal", normalListenersSize);
result.put("total", (adminMapSize + normalListenersSize));
return result;
}
public int getNormalListenersSize() {
int normalListenersSize = 0;
Collection<Set<UpdateListener>> sets = normalListenersMap.values();
for (Set<UpdateListener> itm : sets) {
normalListenersSize += itm.size();
}
return normalListenersSize;
}
public void updateDeviceStatus(DeviceConnectionStatus status, String statusJson) {
// just update associated user to an unit's update
try {
if (status.getUsers() != null) {
for (String userId : status.getUsers()) {
if (normalListenersMap.containsKey(userId)) {
for (UpdateListener listener : normalListenersMap.get(userId)) {
listener.onUpdateDeviceStatus(status, statusJson);
}
}
}
adminsMap.values().forEach(x -> x.onUpdateDeviceStatus(status, statusJson));
}
}catch (Exception ex){
LOGGER.catching(ex);
}
}
}
| 6,789 | 0.604802 | 0.604065 | 192 | 34.359375 | 31.972172 | 182 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.520833 | false | false | 9 |
7082d66dc867de87399b1eacf5e8cb89b793a858 | 11,699,490,935,529 | d3ba5bef35a81a8174e88722897b08d985735223 | /src/main/java/com/gentian/e/voting/entities/Subject.java | d1f334c9162224499c1dbd4432322e76eb688f8a | [] | no_license | demaj/e-Voting | https://github.com/demaj/e-Voting | 6e8aeabe43ebb79cb7f9bf495653ca75cb098529 | 4e2e23428582d78f259b91248094dbb4d42ecc21 | refs/heads/master | 2021-02-16T16:27:05.754000 | 2020-07-14T08:02:28 | 2020-07-14T08:02:28 | 261,667,271 | 5 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.gentian.e.voting.entities;
import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
/**
*
* @author Gentian
*/
@Entity
@Table(name = "subjektet")
public class Subject implements Serializable {
private static final long serialVersionUID = 1L;
// <editor-fold defaultstate="collapsed" desc="Property Id">
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "subjekti_id")
private int _id;
public int getId() {
return _id;
}
public void setId(int id) {
_id = id;
}
// </editor-fold>
// <editor-fold defaultstate="collapsed" desc="Property Name">
@Column(name = "subjekti_emri")
private String _name;
public String getName() {
return _name;
}
public void setName(String name) {
_name = name;
}
// </editor-fold>
/*
// <editor-fold defaultstate="collapsed" desc="Property ESubject">
@OneToOne(fetch = FetchType.EAGER, cascade = CascadeType.ALL)
@JoinColumn(name = "zs_subjekti_id", referencedColumnName = "subjekti_id")
private ESubject _eSubject;
public ESubject getESubject() {
return _eSubject;
}
public void setESubject(ESubject eSubject) {
_eSubject = eSubject;
}
// </editor-fold>
*/
@Override
public String toString() {
return "Subjekti[ Id=" + _id + ", Emri=" + _name + " ]";
}
}
| UTF-8 | Java | 1,616 | java | Subject.java | Java | [
{
"context": "import javax.persistence.Table;\n\n/**\n *\n * @author Gentian\n */\n@Entity\n@Table(name = \"subjektet\")\npublic cla",
"end": 304,
"score": 0.9996078014373779,
"start": 297,
"tag": "NAME",
"value": "Gentian"
}
] | null | [] | package com.gentian.e.voting.entities;
import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
/**
*
* @author Gentian
*/
@Entity
@Table(name = "subjektet")
public class Subject implements Serializable {
private static final long serialVersionUID = 1L;
// <editor-fold defaultstate="collapsed" desc="Property Id">
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "subjekti_id")
private int _id;
public int getId() {
return _id;
}
public void setId(int id) {
_id = id;
}
// </editor-fold>
// <editor-fold defaultstate="collapsed" desc="Property Name">
@Column(name = "subjekti_emri")
private String _name;
public String getName() {
return _name;
}
public void setName(String name) {
_name = name;
}
// </editor-fold>
/*
// <editor-fold defaultstate="collapsed" desc="Property ESubject">
@OneToOne(fetch = FetchType.EAGER, cascade = CascadeType.ALL)
@JoinColumn(name = "zs_subjekti_id", referencedColumnName = "subjekti_id")
private ESubject _eSubject;
public ESubject getESubject() {
return _eSubject;
}
public void setESubject(ESubject eSubject) {
_eSubject = eSubject;
}
// </editor-fold>
*/
@Override
public String toString() {
return "Subjekti[ Id=" + _id + ", Emri=" + _name + " ]";
}
}
| 1,616 | 0.634282 | 0.633663 | 70 | 22.085714 | 20.407101 | 78 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.314286 | false | false | 9 |
e07c72725cf6fa6e6a25862ff7af5665593e8f1d | 4,913,442,609,655 | e1718c5c56e505231b4514a5aaac10e986baf910 | /src/application/MovieClass.java | a7593e3cfa9f3b2c51cc832e2719e6782b642d08 | [] | no_license | joy-98/movie-ticketing-system | https://github.com/joy-98/movie-ticketing-system | 716bc5be7de6b9842e6a6ba19adc5ce037794693 | f2307278c0c731b1563a12d186b3dd1aebb192da | refs/heads/master | 2022-11-24T23:42:31.178000 | 2020-08-03T15:40:06 | 2020-08-03T15:40:06 | 284,735,813 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package application;
import java.util.*;
import java.io.*;
import java.time.LocalDate;
public class MovieClass{
//arraylist to store data from chosenmovie class
public ArrayList<ChosenMovie> chosenarr = new ArrayList<>();
//Variables
private String ImagePath;
private String MovieName;
private String Genre;
private String Language;
private String Duration;
//load from chosenMovie.dat
public void load() {
File chosenf = new File("chosenMovie.dat");
try {
chosenf.createNewFile();
} catch (Exception e) {
}
// Create a file if it doesn't exist
ObjectInputStream ois;
try {
ois = new ObjectInputStream(new FileInputStream(chosenf));
chosenarr = (ArrayList<ChosenMovie>) ois.readObject();
} catch (Exception e) {
}
}
//save into chosenMovie.dat
public void save() {
File chosenf = new File("chosenMovie.dat");
try {
chosenf.createNewFile();
} catch (Exception e) {
}
// Create a file if it doesn't exist
ObjectOutputStream oos;
try {
oos = new ObjectOutputStream(new FileOutputStream(chosenf));
//writing the into .dat as an array
oos.writeObject(chosenarr);
} catch (Exception e) {
}
}
//default constructor
public MovieClass() {
}
public MovieClass(String path, String name, String genre, String language, String duration){
ImagePath = path;
MovieName = name;
Genre = genre;
Language = language;
Duration = duration;
}
public void addArr(String movieName, String cinema, LocalDate date, String showtime, ArrayList<String> chosenseats) {
load();
ChosenMovie newarr = new ChosenMovie(movieName,cinema,date,showtime,chosenseats);
chosenarr.add(newarr); // add into to arraylist
save();
}
public String getPath() {
return ImagePath;
}
public void setPath(String path) {
ImagePath = path;
}
public String getMovieName() {
return MovieName;
}
public void setMovieName(String name) {
MovieName = name;
}
public String getGenre() {
return Genre;
}
public void setGenre(String genre) {
Genre = genre;
}
public String getLanguage() {
return Language;
}
public void setLanguage(String language) {
Language = language;
}
public String getDuration() {
return Duration;
}
public void setDuration(String duration) {
Duration = duration;
}
}
| UTF-8 | Java | 2,504 | java | MovieClass.java | Java | [] | null | [] | package application;
import java.util.*;
import java.io.*;
import java.time.LocalDate;
public class MovieClass{
//arraylist to store data from chosenmovie class
public ArrayList<ChosenMovie> chosenarr = new ArrayList<>();
//Variables
private String ImagePath;
private String MovieName;
private String Genre;
private String Language;
private String Duration;
//load from chosenMovie.dat
public void load() {
File chosenf = new File("chosenMovie.dat");
try {
chosenf.createNewFile();
} catch (Exception e) {
}
// Create a file if it doesn't exist
ObjectInputStream ois;
try {
ois = new ObjectInputStream(new FileInputStream(chosenf));
chosenarr = (ArrayList<ChosenMovie>) ois.readObject();
} catch (Exception e) {
}
}
//save into chosenMovie.dat
public void save() {
File chosenf = new File("chosenMovie.dat");
try {
chosenf.createNewFile();
} catch (Exception e) {
}
// Create a file if it doesn't exist
ObjectOutputStream oos;
try {
oos = new ObjectOutputStream(new FileOutputStream(chosenf));
//writing the into .dat as an array
oos.writeObject(chosenarr);
} catch (Exception e) {
}
}
//default constructor
public MovieClass() {
}
public MovieClass(String path, String name, String genre, String language, String duration){
ImagePath = path;
MovieName = name;
Genre = genre;
Language = language;
Duration = duration;
}
public void addArr(String movieName, String cinema, LocalDate date, String showtime, ArrayList<String> chosenseats) {
load();
ChosenMovie newarr = new ChosenMovie(movieName,cinema,date,showtime,chosenseats);
chosenarr.add(newarr); // add into to arraylist
save();
}
public String getPath() {
return ImagePath;
}
public void setPath(String path) {
ImagePath = path;
}
public String getMovieName() {
return MovieName;
}
public void setMovieName(String name) {
MovieName = name;
}
public String getGenre() {
return Genre;
}
public void setGenre(String genre) {
Genre = genre;
}
public String getLanguage() {
return Language;
}
public void setLanguage(String language) {
Language = language;
}
public String getDuration() {
return Duration;
}
public void setDuration(String duration) {
Duration = duration;
}
}
| 2,504 | 0.642173 | 0.642173 | 134 | 16.686567 | 19.930634 | 118 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.858209 | false | false | 9 |
5f9653f4f77896f39d2954086829ed01bda52418 | 6,373,731,487,955 | dd79fca04afa46bfc3e0c11bd53cd101f42e19ba | /BlogAppBackend/src/main/java/com/blogapp/controller/CommentController.java | 2dc44008990cbc40357e7f7f74caf6e01fac416b | [] | no_license | varsha-mindfire/blog-backend | https://github.com/varsha-mindfire/blog-backend | efadf113232582c9d8a2723bff089767667904e7 | c42c17e0d8572b47411466294b2af71aacb34b1e | refs/heads/main | 2023-05-03T16:42:49.503000 | 2021-05-23T21:32:47 | 2021-05-23T21:32:47 | 349,315,094 | 0 | 0 | null | false | 2021-05-23T21:32:47 | 2021-03-19T05:47:33 | 2021-05-21T05:46:39 | 2021-05-23T21:32:47 | 1,308 | 0 | 0 | 0 | Java | false | false | package com.blogapp.controller;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.blogapp.constants.Emessage;
import com.blogapp.dto.request.DtoComment;
import com.blogapp.dto.response.EmessageResponse;
import com.blogapp.model.Comment;
import com.blogapp.repo.CommentRepository;
import com.blogapp.services.CommentService;
/**
* @author Varsha
* @since 15/03/2021
*/
@RestController
@RequestMapping("/api/comments")
@CrossOrigin("http://localhost:4200")
public class CommentController {
@Autowired
CommentService commentService;
@Autowired
CommentRepository commentRepository;
/**
* Method for posting comments in a particular blog
*
* @param commentdto
* @return ResponseMessage
*/
@PostMapping("/createcomment")
public ResponseEntity<EmessageResponse> createComment(@RequestBody DtoComment commentdto) {
commentService.save(commentdto);
return ResponseEntity.ok(new EmessageResponse(Emessage.COMMENT_ADDED));
}
/**
* Method for fetching all comments for a particular blog.
*
* @param id
* @return List of comments
*/
@GetMapping("/id/{id}")
public ResponseEntity<List<Comment>> getCommentsByBlogid(@PathVariable String id) {
return ResponseEntity.status(HttpStatus.OK).body(commentService.getAllCommentsForPost(id));
}
}
| UTF-8 | Java | 1,839 | java | CommentController.java | Java | [
{
"context": "m.blogapp.services.CommentService;\n\n/**\n * @author Varsha\n * @since 15/03/2021\n */\n@RestController\n@Request",
"end": 914,
"score": 0.9984428882598877,
"start": 908,
"tag": "NAME",
"value": "Varsha"
}
] | null | [] | package com.blogapp.controller;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.blogapp.constants.Emessage;
import com.blogapp.dto.request.DtoComment;
import com.blogapp.dto.response.EmessageResponse;
import com.blogapp.model.Comment;
import com.blogapp.repo.CommentRepository;
import com.blogapp.services.CommentService;
/**
* @author Varsha
* @since 15/03/2021
*/
@RestController
@RequestMapping("/api/comments")
@CrossOrigin("http://localhost:4200")
public class CommentController {
@Autowired
CommentService commentService;
@Autowired
CommentRepository commentRepository;
/**
* Method for posting comments in a particular blog
*
* @param commentdto
* @return ResponseMessage
*/
@PostMapping("/createcomment")
public ResponseEntity<EmessageResponse> createComment(@RequestBody DtoComment commentdto) {
commentService.save(commentdto);
return ResponseEntity.ok(new EmessageResponse(Emessage.COMMENT_ADDED));
}
/**
* Method for fetching all comments for a particular blog.
*
* @param id
* @return List of comments
*/
@GetMapping("/id/{id}")
public ResponseEntity<List<Comment>> getCommentsByBlogid(@PathVariable String id) {
return ResponseEntity.status(HttpStatus.OK).body(commentService.getAllCommentsForPost(id));
}
}
| 1,839 | 0.799891 | 0.793366 | 59 | 30.169491 | 25.570211 | 93 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.864407 | false | false | 9 |
498477249d01ae7ec57b78d31a534f3ef85fefc7 | 20,495,583,956,640 | 5a3b060fe5dd7c75bad9cbc5835baad1878cd86f | /game/src/Converter.java | a30d0512c37792d1a34692935e9b04db8cba8c5a | [] | no_license | AustinStephen/MazeGame | https://github.com/AustinStephen/MazeGame | 4e993cda582a7bf57a634aafdb816732ca7c0143 | 7dea4241420a3d9e5d01fb0baed9bf6473927a49 | refs/heads/main | 2023-08-27T06:11:25.747000 | 2021-10-20T16:02:06 | 2021-10-20T16:02:06 | 373,317,129 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | /**
* Converter.java
* @author Group J (Ryan Harding, Michael Pate, Adeline Reichert, Austin
* Stephen, and Ben Wilkin)
* Date: Apr 30, 2021
* Purpose: Converts between byte arrays and ints, floats, and bytes.
* The methods came from:
* http://www.java2s.com/Book/Java/Examples/
* Convert_data_to_byte_array_back_and_forth.htm
*/
import java.nio.ByteBuffer;
public class Converter
{
public static int convertToInt(byte[] array)
{
ByteBuffer buffer = ByteBuffer.wrap(array);
return buffer.getInt();
}
public static float convertToFloat(byte[] array)
{
ByteBuffer buffer = ByteBuffer.wrap(array);
return buffer.getFloat();
}
public static byte convertToByte(byte[] array)
{
return array[0];
}
public static long convertToLong(byte[] array)
{
ByteBuffer buffer = ByteBuffer.wrap(array);
return buffer.getLong();
}
public static byte[] convertToByteArray(int value)
{
byte[] bytes = new byte[4];
ByteBuffer buffer = ByteBuffer.allocate(bytes.length);
buffer.putInt(value);
return buffer.array();
}
public static byte[] convertToByteArray(float value)
{
byte[] bytes = new byte[4];
ByteBuffer buffer = ByteBuffer.allocate(bytes.length);
buffer.putFloat(value);
return buffer.array();
}
public static byte[] convertToByteArray(long value) {
byte[] bytes = new byte[8];
ByteBuffer buffer = ByteBuffer.allocate(bytes.length);
buffer.putLong(value);
return buffer.array();
}
};
| UTF-8 | Java | 1,564 | java | Converter.java | Java | [
{
"context": "/**\n * Converter.java\n * @author Group J (Ryan Harding, Michael Pate, Adeline Reichert, Austin\n * ",
"end": 54,
"score": 0.9998717904090881,
"start": 42,
"tag": "NAME",
"value": "Ryan Harding"
},
{
"context": "* Converter.java\n * @author Group J (Ryan Harding,... | null | [] | /**
* Converter.java
* @author Group J (<NAME>, <NAME>, <NAME>, Austin
* Stephen, and <NAME>)
* Date: Apr 30, 2021
* Purpose: Converts between byte arrays and ints, floats, and bytes.
* The methods came from:
* http://www.java2s.com/Book/Java/Examples/
* Convert_data_to_byte_array_back_and_forth.htm
*/
import java.nio.ByteBuffer;
public class Converter
{
public static int convertToInt(byte[] array)
{
ByteBuffer buffer = ByteBuffer.wrap(array);
return buffer.getInt();
}
public static float convertToFloat(byte[] array)
{
ByteBuffer buffer = ByteBuffer.wrap(array);
return buffer.getFloat();
}
public static byte convertToByte(byte[] array)
{
return array[0];
}
public static long convertToLong(byte[] array)
{
ByteBuffer buffer = ByteBuffer.wrap(array);
return buffer.getLong();
}
public static byte[] convertToByteArray(int value)
{
byte[] bytes = new byte[4];
ByteBuffer buffer = ByteBuffer.allocate(bytes.length);
buffer.putInt(value);
return buffer.array();
}
public static byte[] convertToByteArray(float value)
{
byte[] bytes = new byte[4];
ByteBuffer buffer = ByteBuffer.allocate(bytes.length);
buffer.putFloat(value);
return buffer.array();
}
public static byte[] convertToByteArray(long value) {
byte[] bytes = new byte[8];
ByteBuffer buffer = ByteBuffer.allocate(bytes.length);
buffer.putLong(value);
return buffer.array();
}
};
| 1,538 | 0.657928 | 0.650895 | 63 | 23.825397 | 22.087517 | 72 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.444444 | false | false | 9 |
e4116b8cca00826d63054feb5329d9602cb86e56 | 28,183,575,419,502 | 61d8fd135b8ede5c4851668470ea41ba29ee2f21 | /app/src/main/java/com/consideredhamster/yetanotherpixeldungeon/actors/mobs/DwarfMonk.java | 7eed15269811c9d7a84ee861b6ef68f001253e26 | [] | no_license | lazarish/EvenMorePixelDungeon | https://github.com/lazarish/EvenMorePixelDungeon | d3530e27ff609d08368b45716efba358f04c8410 | 66eedbe76b93f3c4f7e0d028364b5dcf991df0ba | refs/heads/master | 2021-01-22T01:48:03.749000 | 2017-09-03T10:03:18 | 2017-09-03T10:03:18 | 102,237,571 | 1 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | /*
* Pixel Dungeon
* Copyright (C) 2012-2015 Oleg Dolya
*
* Yet Another Pixel Dungeon
* Copyright (C) 2015-2016 Considered Hamster
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU 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 Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package com.consideredhamster.yetanotherpixeldungeon.actors.mobs;
import java.util.HashSet;
import com.consideredhamster.yetanotherpixeldungeon.DamageType;
import com.consideredhamster.yetanotherpixeldungeon.actors.Char;
import com.consideredhamster.yetanotherpixeldungeon.actors.buffs.Buff;
import com.consideredhamster.yetanotherpixeldungeon.actors.buffs.Combo;
import com.consideredhamster.yetanotherpixeldungeon.actors.mobs.npcs.AmbitiousImp;
import com.consideredhamster.yetanotherpixeldungeon.items.food.OverpricedRation;
import com.consideredhamster.yetanotherpixeldungeon.sprites.MonkSprite;
import com.consideredhamster.yetanotherpixeldungeon.utils.GLog;
public class DwarfMonk extends MobEvasive {
// public static final String TXT_DISARMED = "Monk's attack has knocked your %s out of your hands!";
public static boolean swarmer = true;
public DwarfMonk() {
super( 13 );
name = "dwarf monk";
spriteClass = MonkSprite.class;
loot = new OverpricedRation();
lootChance = 0.1f;
}
@Override
public float attackDelay() {
return 0.5f;
}
// @Override
// public String defenseVerb() {
// return "parried";
// }
@Override
public void die( Object cause, DamageType dmg ) {
AmbitiousImp.Quest.process( this );
super.die( cause, dmg );
}
@Override
public int attackProc( Char enemy, int damage ) {
Buff.affect(this, Combo.class).hit();
return damage;
}
@Override
public int damageRoll() {
int dmg = super.damageRoll();
Combo buff = buff( Combo.class );
if( buff != null ) {
dmg += (int) (dmg * buff.modifier());
}
return dmg;
}
@Override
public String description() {
return
"These monks are fanatics, who devoted themselves to protecting their city's secrets from all intruders. " +
"They don't use any armor or weapons, relying solely on the art of hand-to-hand combat.";
}
public static final HashSet<Class<? extends DamageType>> RESISTANCES = new HashSet<>();
static {
RESISTANCES.add(DamageType.Body.class);
RESISTANCES.add(DamageType.Mind.class);
}
@Override
public HashSet<Class<? extends DamageType>> resistances() {
return RESISTANCES;
}
}
| UTF-8 | Java | 3,073 | java | DwarfMonk.java | Java | [
{
"context": "/*\n * Pixel Dungeon\n * Copyright (C) 2012-2015 Oleg Dolya\n *\n * Yet Another Pixel Dungeon\n * Copyright (C) ",
"end": 57,
"score": 0.9997396469116211,
"start": 47,
"tag": "NAME",
"value": "Oleg Dolya"
},
{
"context": "t Another Pixel Dungeon\n * Copyright (C) 2015-2... | null | [] | /*
* Pixel Dungeon
* Copyright (C) 2012-2015 <NAME>
*
* Yet Another Pixel Dungeon
* Copyright (C) 2015-2016 <NAME>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU 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 Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package com.consideredhamster.yetanotherpixeldungeon.actors.mobs;
import java.util.HashSet;
import com.consideredhamster.yetanotherpixeldungeon.DamageType;
import com.consideredhamster.yetanotherpixeldungeon.actors.Char;
import com.consideredhamster.yetanotherpixeldungeon.actors.buffs.Buff;
import com.consideredhamster.yetanotherpixeldungeon.actors.buffs.Combo;
import com.consideredhamster.yetanotherpixeldungeon.actors.mobs.npcs.AmbitiousImp;
import com.consideredhamster.yetanotherpixeldungeon.items.food.OverpricedRation;
import com.consideredhamster.yetanotherpixeldungeon.sprites.MonkSprite;
import com.consideredhamster.yetanotherpixeldungeon.utils.GLog;
public class DwarfMonk extends MobEvasive {
// public static final String TXT_DISARMED = "Monk's attack has knocked your %s out of your hands!";
public static boolean swarmer = true;
public DwarfMonk() {
super( 13 );
name = "dwarf monk";
spriteClass = MonkSprite.class;
loot = new OverpricedRation();
lootChance = 0.1f;
}
@Override
public float attackDelay() {
return 0.5f;
}
// @Override
// public String defenseVerb() {
// return "parried";
// }
@Override
public void die( Object cause, DamageType dmg ) {
AmbitiousImp.Quest.process( this );
super.die( cause, dmg );
}
@Override
public int attackProc( Char enemy, int damage ) {
Buff.affect(this, Combo.class).hit();
return damage;
}
@Override
public int damageRoll() {
int dmg = super.damageRoll();
Combo buff = buff( Combo.class );
if( buff != null ) {
dmg += (int) (dmg * buff.modifier());
}
return dmg;
}
@Override
public String description() {
return
"These monks are fanatics, who devoted themselves to protecting their city's secrets from all intruders. " +
"They don't use any armor or weapons, relying solely on the art of hand-to-hand combat.";
}
public static final HashSet<Class<? extends DamageType>> RESISTANCES = new HashSet<>();
static {
RESISTANCES.add(DamageType.Body.class);
RESISTANCES.add(DamageType.Mind.class);
}
@Override
public HashSet<Class<? extends DamageType>> resistances() {
return RESISTANCES;
}
}
| 3,057 | 0.709079 | 0.701595 | 111 | 26.684685 | 28.486753 | 111 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.747748 | false | false | 9 |
6d47b05cd93e86ed58f00a2c3ffc62ed9c87bbec | 25,735,444,058,538 | b2f07f3e27b2162b5ee6896814f96c59c2c17405 | /javax/swing/plaf/basic/BasicTabbedPaneUI.java | 365d4c24b4b55828fc208120b32bd2af9827dcd7 | [] | no_license | weiju-xi/RT-JAR-CODE | https://github.com/weiju-xi/RT-JAR-CODE | e33d4ccd9306d9e63029ddb0c145e620921d2dbd | d5b2590518ffb83596a3aa3849249cf871ab6d4e | refs/heads/master | 2021-09-08T02:36:06.675000 | 2018-03-06T05:27:49 | 2018-03-06T05:27:49 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | /* */ package javax.swing.plaf.basic;
/* */
/* */ import java.awt.Color;
/* */ import java.awt.Component;
/* */ import java.awt.Component.BaselineResizeBehavior;
/* */ import java.awt.Container;
/* */ import java.awt.Dimension;
/* */ import java.awt.Font;
/* */ import java.awt.FontMetrics;
/* */ import java.awt.Graphics;
/* */ import java.awt.Graphics2D;
/* */ import java.awt.Insets;
/* */ import java.awt.LayoutManager;
/* */ import java.awt.Point;
/* */ import java.awt.Polygon;
/* */ import java.awt.Rectangle;
/* */ import java.awt.Shape;
/* */ import java.awt.event.ActionEvent;
/* */ import java.awt.event.ActionListener;
/* */ import java.awt.event.ContainerEvent;
/* */ import java.awt.event.ContainerListener;
/* */ import java.awt.event.FocusAdapter;
/* */ import java.awt.event.FocusEvent;
/* */ import java.awt.event.FocusListener;
/* */ import java.awt.event.MouseAdapter;
/* */ import java.awt.event.MouseEvent;
/* */ import java.awt.event.MouseListener;
/* */ import java.awt.event.MouseMotionListener;
/* */ import java.beans.PropertyChangeEvent;
/* */ import java.beans.PropertyChangeListener;
/* */ import java.util.Hashtable;
/* */ import java.util.Vector;
/* */ import javax.swing.Action;
/* */ import javax.swing.ActionMap;
/* */ import javax.swing.Icon;
/* */ import javax.swing.InputMap;
/* */ import javax.swing.JButton;
/* */ import javax.swing.JComponent;
/* */ import javax.swing.JPanel;
/* */ import javax.swing.JTabbedPane;
/* */ import javax.swing.JViewport;
/* */ import javax.swing.KeyStroke;
/* */ import javax.swing.LookAndFeel;
/* */ import javax.swing.SwingConstants;
/* */ import javax.swing.SwingUtilities;
/* */ import javax.swing.UIManager;
/* */ import javax.swing.event.ChangeEvent;
/* */ import javax.swing.event.ChangeListener;
/* */ import javax.swing.plaf.ComponentInputMapUIResource;
/* */ import javax.swing.plaf.ComponentUI;
/* */ import javax.swing.plaf.TabbedPaneUI;
/* */ import javax.swing.plaf.UIResource;
/* */ import javax.swing.text.View;
/* */ import sun.swing.DefaultLookup;
/* */ import sun.swing.SwingUtilities2;
/* */ import sun.swing.UIAction;
/* */
/* */ public class BasicTabbedPaneUI extends TabbedPaneUI
/* */ implements SwingConstants
/* */ {
/* */ protected JTabbedPane tabPane;
/* */ protected Color highlight;
/* */ protected Color lightHighlight;
/* */ protected Color shadow;
/* */ protected Color darkShadow;
/* */ protected Color focus;
/* */ private Color selectedColor;
/* */ protected int textIconGap;
/* */ protected int tabRunOverlay;
/* */ protected Insets tabInsets;
/* */ protected Insets selectedTabPadInsets;
/* */ protected Insets tabAreaInsets;
/* */ protected Insets contentBorderInsets;
/* */ private boolean tabsOverlapBorder;
/* */ private boolean tabsOpaque;
/* */ private boolean contentOpaque;
/* */
/* */ @Deprecated
/* */ protected KeyStroke upKey;
/* */
/* */ @Deprecated
/* */ protected KeyStroke downKey;
/* */
/* */ @Deprecated
/* */ protected KeyStroke leftKey;
/* */
/* */ @Deprecated
/* */ protected KeyStroke rightKey;
/* */ protected int[] tabRuns;
/* */ protected int runCount;
/* */ protected int selectedRun;
/* */ protected Rectangle[] rects;
/* */ protected int maxTabHeight;
/* */ protected int maxTabWidth;
/* */ protected ChangeListener tabChangeListener;
/* */ protected PropertyChangeListener propertyChangeListener;
/* */ protected MouseListener mouseListener;
/* */ protected FocusListener focusListener;
/* */ private Insets currentPadInsets;
/* */ private Insets currentTabAreaInsets;
/* */ private Component visibleComponent;
/* */ private Vector<View> htmlViews;
/* */ private Hashtable<Integer, Integer> mnemonicToIndexMap;
/* */ private InputMap mnemonicInputMap;
/* */ private ScrollableTabSupport tabScroller;
/* */ private TabContainer tabContainer;
/* */ protected transient Rectangle calcRect;
/* */ private int focusIndex;
/* */ private Handler handler;
/* */ private int rolloverTabIndex;
/* */ private boolean isRunsDirty;
/* */ private boolean calculatedBaseline;
/* */ private int baseline;
/* 917 */ private static int[] xCropLen = { 1, 1, 0, 0, 1, 1, 2, 2 };
/* 918 */ private static int[] yCropLen = { 0, 3, 3, 6, 6, 9, 9, 12 };
/* */ private static final int CROP_SEGMENT = 12;
/* */
/* */ public BasicTabbedPaneUI()
/* */ {
/* 77 */ this.tabsOpaque = true;
/* 78 */ this.contentOpaque = true;
/* */
/* 124 */ this.tabRuns = new int[10];
/* 125 */ this.runCount = 0;
/* 126 */ this.selectedRun = -1;
/* 127 */ this.rects = new Rectangle[0];
/* */
/* 140 */ this.currentPadInsets = new Insets(0, 0, 0, 0);
/* 141 */ this.currentTabAreaInsets = new Insets(0, 0, 0, 0);
/* */
/* 164 */ this.calcRect = new Rectangle(0, 0, 0, 0);
/* */ }
/* */
/* */ public static ComponentUI createUI(JComponent paramJComponent)
/* */ {
/* 194 */ return new BasicTabbedPaneUI();
/* */ }
/* */
/* */ static void loadActionMap(LazyActionMap paramLazyActionMap) {
/* 198 */ paramLazyActionMap.put(new Actions("navigateNext"));
/* 199 */ paramLazyActionMap.put(new Actions("navigatePrevious"));
/* 200 */ paramLazyActionMap.put(new Actions("navigateRight"));
/* 201 */ paramLazyActionMap.put(new Actions("navigateLeft"));
/* 202 */ paramLazyActionMap.put(new Actions("navigateUp"));
/* 203 */ paramLazyActionMap.put(new Actions("navigateDown"));
/* 204 */ paramLazyActionMap.put(new Actions("navigatePageUp"));
/* 205 */ paramLazyActionMap.put(new Actions("navigatePageDown"));
/* 206 */ paramLazyActionMap.put(new Actions("requestFocus"));
/* 207 */ paramLazyActionMap.put(new Actions("requestFocusForVisibleComponent"));
/* 208 */ paramLazyActionMap.put(new Actions("setSelectedIndex"));
/* 209 */ paramLazyActionMap.put(new Actions("selectTabWithFocus"));
/* 210 */ paramLazyActionMap.put(new Actions("scrollTabsForwardAction"));
/* 211 */ paramLazyActionMap.put(new Actions("scrollTabsBackwardAction"));
/* */ }
/* */
/* */ public void installUI(JComponent paramJComponent)
/* */ {
/* 217 */ this.tabPane = ((JTabbedPane)paramJComponent);
/* */
/* 219 */ this.calculatedBaseline = false;
/* 220 */ this.rolloverTabIndex = -1;
/* 221 */ this.focusIndex = -1;
/* 222 */ paramJComponent.setLayout(createLayoutManager());
/* 223 */ installComponents();
/* 224 */ installDefaults();
/* 225 */ installListeners();
/* 226 */ installKeyboardActions();
/* */ }
/* */
/* */ public void uninstallUI(JComponent paramJComponent) {
/* 230 */ uninstallKeyboardActions();
/* 231 */ uninstallListeners();
/* 232 */ uninstallDefaults();
/* 233 */ uninstallComponents();
/* 234 */ paramJComponent.setLayout(null);
/* */
/* 236 */ this.tabPane = null;
/* */ }
/* */
/* */ protected LayoutManager createLayoutManager()
/* */ {
/* 250 */ if (this.tabPane.getTabLayoutPolicy() == 1) {
/* 251 */ return new TabbedPaneScrollLayout(null);
/* */ }
/* 253 */ return new TabbedPaneLayout();
/* */ }
/* */
/* */ private boolean scrollableTabLayoutEnabled()
/* */ {
/* 263 */ return this.tabPane.getLayout() instanceof TabbedPaneScrollLayout;
/* */ }
/* */
/* */ protected void installComponents()
/* */ {
/* 273 */ if ((scrollableTabLayoutEnabled()) &&
/* 274 */ (this.tabScroller == null)) {
/* 275 */ this.tabScroller = new ScrollableTabSupport(this.tabPane.getTabPlacement());
/* 276 */ this.tabPane.add(this.tabScroller.viewport);
/* */ }
/* */
/* 279 */ installTabContainer();
/* */ }
/* */
/* */ private void installTabContainer() {
/* 283 */ for (int i = 0; i < this.tabPane.getTabCount(); i++) {
/* 284 */ Component localComponent = this.tabPane.getTabComponentAt(i);
/* 285 */ if (localComponent != null) {
/* 286 */ if (this.tabContainer == null) {
/* 287 */ this.tabContainer = new TabContainer();
/* */ }
/* 289 */ this.tabContainer.add(localComponent);
/* */ }
/* */ }
/* 292 */ if (this.tabContainer == null) {
/* 293 */ return;
/* */ }
/* 295 */ if (scrollableTabLayoutEnabled())
/* 296 */ this.tabScroller.tabPanel.add(this.tabContainer);
/* */ else
/* 298 */ this.tabPane.add(this.tabContainer);
/* */ }
/* */
/* */ protected JButton createScrollButton(int paramInt)
/* */ {
/* 317 */ if ((paramInt != 5) && (paramInt != 1) && (paramInt != 3) && (paramInt != 7))
/* */ {
/* 319 */ throw new IllegalArgumentException("Direction must be one of: SOUTH, NORTH, EAST or WEST");
/* */ }
/* */
/* 322 */ return new ScrollableTabButton(paramInt);
/* */ }
/* */
/* */ protected void uninstallComponents()
/* */ {
/* 332 */ uninstallTabContainer();
/* 333 */ if (scrollableTabLayoutEnabled()) {
/* 334 */ this.tabPane.remove(this.tabScroller.viewport);
/* 335 */ this.tabPane.remove(this.tabScroller.scrollForwardButton);
/* 336 */ this.tabPane.remove(this.tabScroller.scrollBackwardButton);
/* 337 */ this.tabScroller = null;
/* */ }
/* */ }
/* */
/* */ private void uninstallTabContainer() {
/* 342 */ if (this.tabContainer == null) {
/* 343 */ return;
/* */ }
/* */
/* 347 */ this.tabContainer.notifyTabbedPane = false;
/* 348 */ this.tabContainer.removeAll();
/* 349 */ if (scrollableTabLayoutEnabled()) {
/* 350 */ this.tabContainer.remove(this.tabScroller.croppedEdge);
/* 351 */ this.tabScroller.tabPanel.remove(this.tabContainer);
/* */ } else {
/* 353 */ this.tabPane.remove(this.tabContainer);
/* */ }
/* 355 */ this.tabContainer = null;
/* */ }
/* */
/* */ protected void installDefaults() {
/* 359 */ LookAndFeel.installColorsAndFont(this.tabPane, "TabbedPane.background", "TabbedPane.foreground", "TabbedPane.font");
/* */
/* 361 */ this.highlight = UIManager.getColor("TabbedPane.light");
/* 362 */ this.lightHighlight = UIManager.getColor("TabbedPane.highlight");
/* 363 */ this.shadow = UIManager.getColor("TabbedPane.shadow");
/* 364 */ this.darkShadow = UIManager.getColor("TabbedPane.darkShadow");
/* 365 */ this.focus = UIManager.getColor("TabbedPane.focus");
/* 366 */ this.selectedColor = UIManager.getColor("TabbedPane.selected");
/* */
/* 368 */ this.textIconGap = UIManager.getInt("TabbedPane.textIconGap");
/* 369 */ this.tabInsets = UIManager.getInsets("TabbedPane.tabInsets");
/* 370 */ this.selectedTabPadInsets = UIManager.getInsets("TabbedPane.selectedTabPadInsets");
/* 371 */ this.tabAreaInsets = UIManager.getInsets("TabbedPane.tabAreaInsets");
/* 372 */ this.tabsOverlapBorder = UIManager.getBoolean("TabbedPane.tabsOverlapBorder");
/* 373 */ this.contentBorderInsets = UIManager.getInsets("TabbedPane.contentBorderInsets");
/* 374 */ this.tabRunOverlay = UIManager.getInt("TabbedPane.tabRunOverlay");
/* 375 */ this.tabsOpaque = UIManager.getBoolean("TabbedPane.tabsOpaque");
/* 376 */ this.contentOpaque = UIManager.getBoolean("TabbedPane.contentOpaque");
/* 377 */ Object localObject = UIManager.get("TabbedPane.opaque");
/* 378 */ if (localObject == null) {
/* 379 */ localObject = Boolean.FALSE;
/* */ }
/* 381 */ LookAndFeel.installProperty(this.tabPane, "opaque", localObject);
/* */
/* 386 */ if (this.tabInsets == null) this.tabInsets = new Insets(0, 4, 1, 4);
/* 387 */ if (this.selectedTabPadInsets == null) this.selectedTabPadInsets = new Insets(2, 2, 2, 1);
/* 388 */ if (this.tabAreaInsets == null) this.tabAreaInsets = new Insets(3, 2, 0, 2);
/* 389 */ if (this.contentBorderInsets == null) this.contentBorderInsets = new Insets(2, 2, 3, 3);
/* */ }
/* */
/* */ protected void uninstallDefaults()
/* */ {
/* 393 */ this.highlight = null;
/* 394 */ this.lightHighlight = null;
/* 395 */ this.shadow = null;
/* 396 */ this.darkShadow = null;
/* 397 */ this.focus = null;
/* 398 */ this.tabInsets = null;
/* 399 */ this.selectedTabPadInsets = null;
/* 400 */ this.tabAreaInsets = null;
/* 401 */ this.contentBorderInsets = null;
/* */ }
/* */
/* */ protected void installListeners() {
/* 405 */ if ((this.propertyChangeListener = createPropertyChangeListener()) != null) {
/* 406 */ this.tabPane.addPropertyChangeListener(this.propertyChangeListener);
/* */ }
/* 408 */ if ((this.tabChangeListener = createChangeListener()) != null) {
/* 409 */ this.tabPane.addChangeListener(this.tabChangeListener);
/* */ }
/* 411 */ if ((this.mouseListener = createMouseListener()) != null) {
/* 412 */ this.tabPane.addMouseListener(this.mouseListener);
/* */ }
/* 414 */ this.tabPane.addMouseMotionListener(getHandler());
/* 415 */ if ((this.focusListener = createFocusListener()) != null) {
/* 416 */ this.tabPane.addFocusListener(this.focusListener);
/* */ }
/* 418 */ this.tabPane.addContainerListener(getHandler());
/* 419 */ if (this.tabPane.getTabCount() > 0)
/* 420 */ this.htmlViews = createHTMLVector();
/* */ }
/* */
/* */ protected void uninstallListeners()
/* */ {
/* 425 */ if (this.mouseListener != null) {
/* 426 */ this.tabPane.removeMouseListener(this.mouseListener);
/* 427 */ this.mouseListener = null;
/* */ }
/* 429 */ this.tabPane.removeMouseMotionListener(getHandler());
/* 430 */ if (this.focusListener != null) {
/* 431 */ this.tabPane.removeFocusListener(this.focusListener);
/* 432 */ this.focusListener = null;
/* */ }
/* */
/* 435 */ this.tabPane.removeContainerListener(getHandler());
/* 436 */ if (this.htmlViews != null) {
/* 437 */ this.htmlViews.removeAllElements();
/* 438 */ this.htmlViews = null;
/* */ }
/* 440 */ if (this.tabChangeListener != null) {
/* 441 */ this.tabPane.removeChangeListener(this.tabChangeListener);
/* 442 */ this.tabChangeListener = null;
/* */ }
/* 444 */ if (this.propertyChangeListener != null) {
/* 445 */ this.tabPane.removePropertyChangeListener(this.propertyChangeListener);
/* 446 */ this.propertyChangeListener = null;
/* */ }
/* 448 */ this.handler = null;
/* */ }
/* */
/* */ protected MouseListener createMouseListener() {
/* 452 */ return getHandler();
/* */ }
/* */
/* */ protected FocusListener createFocusListener() {
/* 456 */ return getHandler();
/* */ }
/* */
/* */ protected ChangeListener createChangeListener() {
/* 460 */ return getHandler();
/* */ }
/* */
/* */ protected PropertyChangeListener createPropertyChangeListener() {
/* 464 */ return getHandler();
/* */ }
/* */
/* */ private Handler getHandler() {
/* 468 */ if (this.handler == null) {
/* 469 */ this.handler = new Handler(null);
/* */ }
/* 471 */ return this.handler;
/* */ }
/* */
/* */ protected void installKeyboardActions() {
/* 475 */ InputMap localInputMap = getInputMap(1);
/* */
/* 478 */ SwingUtilities.replaceUIInputMap(this.tabPane, 1, localInputMap);
/* */
/* 481 */ localInputMap = getInputMap(0);
/* 482 */ SwingUtilities.replaceUIInputMap(this.tabPane, 0, localInputMap);
/* */
/* 484 */ LazyActionMap.installLazyActionMap(this.tabPane, BasicTabbedPaneUI.class, "TabbedPane.actionMap");
/* */
/* 486 */ updateMnemonics();
/* */ }
/* */
/* */ InputMap getInputMap(int paramInt) {
/* 490 */ if (paramInt == 1) {
/* 491 */ return (InputMap)DefaultLookup.get(this.tabPane, this, "TabbedPane.ancestorInputMap");
/* */ }
/* */
/* 494 */ if (paramInt == 0) {
/* 495 */ return (InputMap)DefaultLookup.get(this.tabPane, this, "TabbedPane.focusInputMap");
/* */ }
/* */
/* 498 */ return null;
/* */ }
/* */
/* */ protected void uninstallKeyboardActions() {
/* 502 */ SwingUtilities.replaceUIActionMap(this.tabPane, null);
/* 503 */ SwingUtilities.replaceUIInputMap(this.tabPane, 1, null);
/* */
/* 506 */ SwingUtilities.replaceUIInputMap(this.tabPane, 0, null);
/* */
/* 508 */ SwingUtilities.replaceUIInputMap(this.tabPane, 2, null);
/* */
/* 511 */ this.mnemonicToIndexMap = null;
/* 512 */ this.mnemonicInputMap = null;
/* */ }
/* */
/* */ private void updateMnemonics()
/* */ {
/* 520 */ resetMnemonics();
/* 521 */ for (int i = this.tabPane.getTabCount() - 1; i >= 0;
/* 522 */ i--) {
/* 523 */ int j = this.tabPane.getMnemonicAt(i);
/* */
/* 525 */ if (j > 0)
/* 526 */ addMnemonic(i, j);
/* */ }
/* */ }
/* */
/* */ private void resetMnemonics()
/* */ {
/* 535 */ if (this.mnemonicToIndexMap != null) {
/* 536 */ this.mnemonicToIndexMap.clear();
/* 537 */ this.mnemonicInputMap.clear();
/* */ }
/* */ }
/* */
/* */ private void addMnemonic(int paramInt1, int paramInt2)
/* */ {
/* 545 */ if (this.mnemonicToIndexMap == null) {
/* 546 */ initMnemonics();
/* */ }
/* 548 */ this.mnemonicInputMap.put(KeyStroke.getKeyStroke(paramInt2, BasicLookAndFeel.getFocusAcceleratorKeyMask()), "setSelectedIndex");
/* */
/* 550 */ this.mnemonicToIndexMap.put(Integer.valueOf(paramInt2), Integer.valueOf(paramInt1));
/* */ }
/* */
/* */ private void initMnemonics()
/* */ {
/* 557 */ this.mnemonicToIndexMap = new Hashtable();
/* 558 */ this.mnemonicInputMap = new ComponentInputMapUIResource(this.tabPane);
/* 559 */ this.mnemonicInputMap.setParent(SwingUtilities.getUIInputMap(this.tabPane, 2));
/* */
/* 561 */ SwingUtilities.replaceUIInputMap(this.tabPane, 2, this.mnemonicInputMap);
/* */ }
/* */
/* */ private void setRolloverTab(int paramInt1, int paramInt2)
/* */ {
/* 575 */ setRolloverTab(tabForCoordinate(this.tabPane, paramInt1, paramInt2, false));
/* */ }
/* */
/* */ protected void setRolloverTab(int paramInt)
/* */ {
/* 588 */ this.rolloverTabIndex = paramInt;
/* */ }
/* */
/* */ protected int getRolloverTab()
/* */ {
/* 600 */ return this.rolloverTabIndex;
/* */ }
/* */
/* */ public Dimension getMinimumSize(JComponent paramJComponent)
/* */ {
/* 605 */ return null;
/* */ }
/* */
/* */ public Dimension getMaximumSize(JComponent paramJComponent)
/* */ {
/* 610 */ return null;
/* */ }
/* */
/* */ public int getBaseline(JComponent paramJComponent, int paramInt1, int paramInt2)
/* */ {
/* 622 */ super.getBaseline(paramJComponent, paramInt1, paramInt2);
/* 623 */ int i = calculateBaselineIfNecessary();
/* 624 */ if (i != -1) {
/* 625 */ int j = this.tabPane.getTabPlacement();
/* 626 */ Insets localInsets1 = this.tabPane.getInsets();
/* 627 */ Insets localInsets2 = getTabAreaInsets(j);
/* 628 */ switch (j) {
/* */ case 1:
/* 630 */ i += localInsets1.top + localInsets2.top;
/* 631 */ return i;
/* */ case 3:
/* 633 */ i = paramInt2 - localInsets1.bottom - localInsets2.bottom - this.maxTabHeight + i;
/* */
/* 635 */ return i;
/* */ case 2:
/* */ case 4:
/* 638 */ i += localInsets1.top + localInsets2.top;
/* 639 */ return i;
/* */ }
/* */ }
/* 642 */ return -1;
/* */ }
/* */
/* */ public Component.BaselineResizeBehavior getBaselineResizeBehavior(JComponent paramJComponent)
/* */ {
/* 655 */ super.getBaselineResizeBehavior(paramJComponent);
/* 656 */ switch (this.tabPane.getTabPlacement()) {
/* */ case 1:
/* */ case 2:
/* */ case 4:
/* 660 */ return Component.BaselineResizeBehavior.CONSTANT_ASCENT;
/* */ case 3:
/* 662 */ return Component.BaselineResizeBehavior.CONSTANT_DESCENT;
/* */ }
/* 664 */ return Component.BaselineResizeBehavior.OTHER;
/* */ }
/* */
/* */ protected int getBaseline(int paramInt)
/* */ {
/* 678 */ if (this.tabPane.getTabComponentAt(paramInt) != null) {
/* 679 */ int i = getBaselineOffset();
/* 680 */ if (i != 0)
/* */ {
/* 684 */ return -1;
/* */ }
/* 686 */ Component localComponent = this.tabPane.getTabComponentAt(paramInt);
/* 687 */ Dimension localDimension = localComponent.getPreferredSize();
/* 688 */ Insets localInsets = getTabInsets(this.tabPane.getTabPlacement(), paramInt);
/* 689 */ int m = this.maxTabHeight - localInsets.top - localInsets.bottom;
/* 690 */ return localComponent.getBaseline(localDimension.width, localDimension.height) + (m - localDimension.height) / 2 + localInsets.top;
/* */ }
/* */
/* 694 */ Object localObject = getTextViewForTab(paramInt);
/* 695 */ if (localObject != null) {
/* 696 */ j = (int)((View)localObject).getPreferredSpan(1);
/* 697 */ k = BasicHTML.getHTMLBaseline((View)localObject, (int)((View)localObject).getPreferredSpan(0), j);
/* */
/* 699 */ if (k >= 0) {
/* 700 */ return this.maxTabHeight / 2 - j / 2 + k + getBaselineOffset();
/* */ }
/* */
/* 703 */ return -1;
/* */ }
/* */
/* 706 */ localObject = getFontMetrics();
/* 707 */ int j = ((FontMetrics)localObject).getHeight();
/* 708 */ int k = ((FontMetrics)localObject).getAscent();
/* 709 */ return this.maxTabHeight / 2 - j / 2 + k + getBaselineOffset();
/* */ }
/* */
/* */ protected int getBaselineOffset()
/* */ {
/* 721 */ switch (this.tabPane.getTabPlacement()) {
/* */ case 1:
/* 723 */ if (this.tabPane.getTabCount() > 1) {
/* 724 */ return 1;
/* */ }
/* */
/* 727 */ return -1;
/* */ case 3:
/* 730 */ if (this.tabPane.getTabCount() > 1) {
/* 731 */ return -1;
/* */ }
/* */
/* 734 */ return 1;
/* */ }
/* */
/* 737 */ return this.maxTabHeight % 2;
/* */ }
/* */
/* */ private int calculateBaselineIfNecessary()
/* */ {
/* 742 */ if (!this.calculatedBaseline) {
/* 743 */ this.calculatedBaseline = true;
/* 744 */ this.baseline = -1;
/* 745 */ if (this.tabPane.getTabCount() > 0) {
/* 746 */ calculateBaseline();
/* */ }
/* */ }
/* 749 */ return this.baseline;
/* */ }
/* */
/* */ private void calculateBaseline() {
/* 753 */ int i = this.tabPane.getTabCount();
/* 754 */ int j = this.tabPane.getTabPlacement();
/* 755 */ this.maxTabHeight = calculateMaxTabHeight(j);
/* 756 */ this.baseline = getBaseline(0);
/* 757 */ if (isHorizontalTabPlacement()) {
/* 758 */ for (int k = 1; k < i; k++) {
/* 759 */ if (getBaseline(k) != this.baseline) {
/* 760 */ this.baseline = -1;
/* 761 */ break;
/* */ }
/* */ }
/* */ }
/* */ else
/* */ {
/* 767 */ FontMetrics localFontMetrics = getFontMetrics();
/* 768 */ int m = localFontMetrics.getHeight();
/* 769 */ int n = calculateTabHeight(j, 0, m);
/* 770 */ for (int i1 = 1; i1 < i; i1++) {
/* 771 */ int i2 = calculateTabHeight(j, i1, m);
/* 772 */ if (n != i2)
/* */ {
/* 774 */ this.baseline = -1;
/* 775 */ break;
/* */ }
/* */ }
/* */ }
/* */ }
/* */
/* */ public void paint(Graphics paramGraphics, JComponent paramJComponent)
/* */ {
/* 784 */ int i = this.tabPane.getSelectedIndex();
/* 785 */ int j = this.tabPane.getTabPlacement();
/* */
/* 787 */ ensureCurrentLayout();
/* */
/* 790 */ if (this.tabsOverlapBorder) {
/* 791 */ paintContentBorder(paramGraphics, j, i);
/* */ }
/* */
/* 796 */ if (!scrollableTabLayoutEnabled()) {
/* 797 */ paintTabArea(paramGraphics, j, i);
/* */ }
/* 799 */ if (!this.tabsOverlapBorder)
/* 800 */ paintContentBorder(paramGraphics, j, i);
/* */ }
/* */
/* */ protected void paintTabArea(Graphics paramGraphics, int paramInt1, int paramInt2)
/* */ {
/* 822 */ int i = this.tabPane.getTabCount();
/* */
/* 824 */ Rectangle localRectangle1 = new Rectangle();
/* 825 */ Rectangle localRectangle2 = new Rectangle();
/* 826 */ Rectangle localRectangle3 = paramGraphics.getClipBounds();
/* */
/* 829 */ for (int j = this.runCount - 1; j >= 0; j--) {
/* 830 */ int k = this.tabRuns[j];
/* 831 */ int m = this.tabRuns[(j + 1)];
/* 832 */ int n = m != 0 ? m - 1 : i - 1;
/* 833 */ for (int i1 = k; i1 <= n; i1++) {
/* 834 */ if ((i1 != paramInt2) && (this.rects[i1].intersects(localRectangle3))) {
/* 835 */ paintTab(paramGraphics, paramInt1, this.rects, i1, localRectangle1, localRectangle2);
/* */ }
/* */
/* */ }
/* */
/* */ }
/* */
/* 842 */ if ((paramInt2 >= 0) && (this.rects[paramInt2].intersects(localRectangle3)))
/* 843 */ paintTab(paramGraphics, paramInt1, this.rects, paramInt2, localRectangle1, localRectangle2);
/* */ }
/* */
/* */ protected void paintTab(Graphics paramGraphics, int paramInt1, Rectangle[] paramArrayOfRectangle, int paramInt2, Rectangle paramRectangle1, Rectangle paramRectangle2)
/* */ {
/* 850 */ Rectangle localRectangle = paramArrayOfRectangle[paramInt2];
/* 851 */ int i = this.tabPane.getSelectedIndex();
/* 852 */ boolean bool = i == paramInt2;
/* */
/* 854 */ if ((this.tabsOpaque) || (this.tabPane.isOpaque())) {
/* 855 */ paintTabBackground(paramGraphics, paramInt1, paramInt2, localRectangle.x, localRectangle.y, localRectangle.width, localRectangle.height, bool);
/* */ }
/* */
/* 859 */ paintTabBorder(paramGraphics, paramInt1, paramInt2, localRectangle.x, localRectangle.y, localRectangle.width, localRectangle.height, bool);
/* */
/* 862 */ String str1 = this.tabPane.getTitleAt(paramInt2);
/* 863 */ Font localFont = this.tabPane.getFont();
/* 864 */ FontMetrics localFontMetrics = SwingUtilities2.getFontMetrics(this.tabPane, paramGraphics, localFont);
/* 865 */ Icon localIcon = getIconForTab(paramInt2);
/* */
/* 867 */ layoutLabel(paramInt1, localFontMetrics, paramInt2, str1, localIcon, localRectangle, paramRectangle1, paramRectangle2, bool);
/* */
/* 870 */ if (this.tabPane.getTabComponentAt(paramInt2) == null) {
/* 871 */ String str2 = str1;
/* */
/* 873 */ if ((scrollableTabLayoutEnabled()) && (this.tabScroller.croppedEdge.isParamsSet()) && (this.tabScroller.croppedEdge.getTabIndex() == paramInt2) && (isHorizontalTabPlacement()))
/* */ {
/* 875 */ int j = this.tabScroller.croppedEdge.getCropline() - (paramRectangle2.x - localRectangle.x) - this.tabScroller.croppedEdge.getCroppedSideWidth();
/* */
/* 877 */ str2 = SwingUtilities2.clipStringIfNecessary(null, localFontMetrics, str1, j);
/* 878 */ } else if ((!scrollableTabLayoutEnabled()) && (isHorizontalTabPlacement())) {
/* 879 */ str2 = SwingUtilities2.clipStringIfNecessary(null, localFontMetrics, str1, paramRectangle2.width);
/* */ }
/* */
/* 882 */ paintText(paramGraphics, paramInt1, localFont, localFontMetrics, paramInt2, str2, paramRectangle2, bool);
/* */
/* 885 */ paintIcon(paramGraphics, paramInt1, paramInt2, localIcon, paramRectangle1, bool);
/* */ }
/* 887 */ paintFocusIndicator(paramGraphics, paramInt1, paramArrayOfRectangle, paramInt2, paramRectangle1, paramRectangle2, bool);
/* */ }
/* */
/* */ private boolean isHorizontalTabPlacement()
/* */ {
/* 892 */ return (this.tabPane.getTabPlacement() == 1) || (this.tabPane.getTabPlacement() == 3);
/* */ }
/* */
/* */ private static Polygon createCroppedTabShape(int paramInt1, Rectangle paramRectangle, int paramInt2)
/* */ {
/* */ int i;
/* */ int j;
/* */ int k;
/* */ int m;
/* 927 */ switch (paramInt1) {
/* */ case 2:
/* */ case 4:
/* 930 */ i = paramRectangle.width;
/* 931 */ j = paramRectangle.x;
/* 932 */ k = paramRectangle.x + paramRectangle.width;
/* 933 */ m = paramRectangle.y + paramRectangle.height;
/* 934 */ break;
/* */ case 1:
/* */ case 3:
/* */ default:
/* 938 */ i = paramRectangle.height;
/* 939 */ j = paramRectangle.y;
/* 940 */ k = paramRectangle.y + paramRectangle.height;
/* 941 */ m = paramRectangle.x + paramRectangle.width;
/* */ }
/* 943 */ int n = i / 12;
/* 944 */ if (i % 12 > 0) {
/* 945 */ n++;
/* */ }
/* 947 */ int i1 = 2 + n * 8;
/* 948 */ int[] arrayOfInt1 = new int[i1];
/* 949 */ int[] arrayOfInt2 = new int[i1];
/* 950 */ int i2 = 0;
/* */
/* 952 */ arrayOfInt1[i2] = m;
/* 953 */ arrayOfInt2[(i2++)] = k;
/* 954 */ arrayOfInt1[i2] = m;
/* 955 */ arrayOfInt2[(i2++)] = j;
/* 956 */ for (int i3 = 0; i3 < n; i3++) {
/* 957 */ for (int i4 = 0; i4 < xCropLen.length; i4++) {
/* 958 */ arrayOfInt1[i2] = (paramInt2 - xCropLen[i4]);
/* 959 */ arrayOfInt2[i2] = (j + i3 * 12 + yCropLen[i4]);
/* 960 */ if (arrayOfInt2[i2] >= k) {
/* 961 */ arrayOfInt2[i2] = k;
/* 962 */ i2++;
/* 963 */ break;
/* */ }
/* 965 */ i2++;
/* */ }
/* */ }
/* 968 */ if ((paramInt1 == 1) || (paramInt1 == 3)) {
/* 969 */ return new Polygon(arrayOfInt1, arrayOfInt2, i2);
/* */ }
/* */
/* 972 */ return new Polygon(arrayOfInt2, arrayOfInt1, i2);
/* */ }
/* */
/* */ private void paintCroppedTabEdge(Graphics paramGraphics)
/* */ {
/* 980 */ int i = this.tabScroller.croppedEdge.getTabIndex();
/* 981 */ int j = this.tabScroller.croppedEdge.getCropline();
/* */ int k;
/* */ int m;
/* */ int n;
/* 983 */ switch (this.tabPane.getTabPlacement()) {
/* */ case 2:
/* */ case 4:
/* 986 */ k = this.rects[i].x;
/* 987 */ m = j;
/* 988 */ n = k;
/* 989 */ paramGraphics.setColor(this.shadow);
/* */ case 1:
/* 990 */ case 3: } while (n <= k + this.rects[i].width) {
/* 991 */ for (int i1 = 0; i1 < xCropLen.length; i1 += 2) {
/* 992 */ paramGraphics.drawLine(n + yCropLen[i1], m - xCropLen[i1], n + yCropLen[(i1 + 1)] - 1, m - xCropLen[(i1 + 1)]);
/* */ }
/* */
/* 995 */ n += 12; continue;
/* */
/* 1001 */ k = j;
/* 1002 */ m = this.rects[i].y;
/* 1003 */ i1 = m;
/* 1004 */ paramGraphics.setColor(this.shadow);
/* 1005 */ while (i1 <= m + this.rects[i].height) {
/* 1006 */ for (int i2 = 0; i2 < xCropLen.length; i2 += 2) {
/* 1007 */ paramGraphics.drawLine(k - xCropLen[i2], i1 + yCropLen[i2], k - xCropLen[(i2 + 1)], i1 + yCropLen[(i2 + 1)] - 1);
/* */ }
/* */
/* 1010 */ i1 += 12;
/* */ }
/* */ }
/* */ }
/* */
/* */ protected void layoutLabel(int paramInt1, FontMetrics paramFontMetrics, int paramInt2, String paramString, Icon paramIcon, Rectangle paramRectangle1, Rectangle paramRectangle2, Rectangle paramRectangle3, boolean paramBoolean)
/* */ {
/* 1020 */ paramRectangle3.x = (paramRectangle3.y = paramRectangle2.x = paramRectangle2.y = 0);
/* */
/* 1022 */ View localView = getTextViewForTab(paramInt2);
/* 1023 */ if (localView != null) {
/* 1024 */ this.tabPane.putClientProperty("html", localView);
/* */ }
/* */
/* 1027 */ SwingUtilities.layoutCompoundLabel(this.tabPane, paramFontMetrics, paramString, paramIcon, 0, 0, 0, 11, paramRectangle1, paramRectangle2, paramRectangle3, this.textIconGap);
/* */
/* 1038 */ this.tabPane.putClientProperty("html", null);
/* */
/* 1040 */ int i = getTabLabelShiftX(paramInt1, paramInt2, paramBoolean);
/* 1041 */ int j = getTabLabelShiftY(paramInt1, paramInt2, paramBoolean);
/* 1042 */ paramRectangle2.x += i;
/* 1043 */ paramRectangle2.y += j;
/* 1044 */ paramRectangle3.x += i;
/* 1045 */ paramRectangle3.y += j;
/* */ }
/* */
/* */ protected void paintIcon(Graphics paramGraphics, int paramInt1, int paramInt2, Icon paramIcon, Rectangle paramRectangle, boolean paramBoolean)
/* */ {
/* 1051 */ if (paramIcon != null)
/* 1052 */ paramIcon.paintIcon(this.tabPane, paramGraphics, paramRectangle.x, paramRectangle.y);
/* */ }
/* */
/* */ protected void paintText(Graphics paramGraphics, int paramInt1, Font paramFont, FontMetrics paramFontMetrics, int paramInt2, String paramString, Rectangle paramRectangle, boolean paramBoolean)
/* */ {
/* 1061 */ paramGraphics.setFont(paramFont);
/* */
/* 1063 */ View localView = getTextViewForTab(paramInt2);
/* 1064 */ if (localView != null)
/* */ {
/* 1066 */ localView.paint(paramGraphics, paramRectangle);
/* */ }
/* */ else {
/* 1069 */ int i = this.tabPane.getDisplayedMnemonicIndexAt(paramInt2);
/* */
/* 1071 */ if ((this.tabPane.isEnabled()) && (this.tabPane.isEnabledAt(paramInt2))) {
/* 1072 */ Object localObject = this.tabPane.getForegroundAt(paramInt2);
/* 1073 */ if ((paramBoolean) && ((localObject instanceof UIResource))) {
/* 1074 */ Color localColor = UIManager.getColor("TabbedPane.selectedForeground");
/* */
/* 1076 */ if (localColor != null) {
/* 1077 */ localObject = localColor;
/* */ }
/* */ }
/* 1080 */ paramGraphics.setColor((Color)localObject);
/* 1081 */ SwingUtilities2.drawStringUnderlineCharAt(this.tabPane, paramGraphics, paramString, i, paramRectangle.x, paramRectangle.y + paramFontMetrics.getAscent());
/* */ }
/* */ else
/* */ {
/* 1086 */ paramGraphics.setColor(this.tabPane.getBackgroundAt(paramInt2).brighter());
/* 1087 */ SwingUtilities2.drawStringUnderlineCharAt(this.tabPane, paramGraphics, paramString, i, paramRectangle.x, paramRectangle.y + paramFontMetrics.getAscent());
/* */
/* 1090 */ paramGraphics.setColor(this.tabPane.getBackgroundAt(paramInt2).darker());
/* 1091 */ SwingUtilities2.drawStringUnderlineCharAt(this.tabPane, paramGraphics, paramString, i, paramRectangle.x - 1, paramRectangle.y + paramFontMetrics.getAscent() - 1);
/* */ }
/* */ }
/* */ }
/* */
/* */ protected int getTabLabelShiftX(int paramInt1, int paramInt2, boolean paramBoolean)
/* */ {
/* 1101 */ Rectangle localRectangle = this.rects[paramInt2];
/* 1102 */ String str = paramBoolean ? "selectedLabelShift" : "labelShift";
/* 1103 */ int i = DefaultLookup.getInt(this.tabPane, this, "TabbedPane." + str, 1);
/* */
/* 1106 */ switch (paramInt1) {
/* */ case 2:
/* 1108 */ return i;
/* */ case 4:
/* 1110 */ return -i;
/* */ case 1:
/* */ case 3:
/* */ }
/* 1114 */ return localRectangle.width % 2;
/* */ }
/* */
/* */ protected int getTabLabelShiftY(int paramInt1, int paramInt2, boolean paramBoolean)
/* */ {
/* 1119 */ Rectangle localRectangle = this.rects[paramInt2];
/* 1120 */ int i = paramBoolean ? DefaultLookup.getInt(this.tabPane, this, "TabbedPane.selectedLabelShift", -1) : DefaultLookup.getInt(this.tabPane, this, "TabbedPane.labelShift", 1);
/* */
/* 1123 */ switch (paramInt1) {
/* */ case 3:
/* 1125 */ return -i;
/* */ case 2:
/* */ case 4:
/* 1128 */ return localRectangle.height % 2;
/* */ case 1:
/* */ }
/* 1131 */ return i;
/* */ }
/* */
/* */ protected void paintFocusIndicator(Graphics paramGraphics, int paramInt1, Rectangle[] paramArrayOfRectangle, int paramInt2, Rectangle paramRectangle1, Rectangle paramRectangle2, boolean paramBoolean)
/* */ {
/* 1139 */ Rectangle localRectangle = paramArrayOfRectangle[paramInt2];
/* 1140 */ if ((this.tabPane.hasFocus()) && (paramBoolean))
/* */ {
/* 1142 */ paramGraphics.setColor(this.focus);
/* */ int i;
/* */ int j;
/* */ int k;
/* */ int m;
/* 1143 */ switch (paramInt1) {
/* */ case 2:
/* 1145 */ i = localRectangle.x + 3;
/* 1146 */ j = localRectangle.y + 3;
/* 1147 */ k = localRectangle.width - 5;
/* 1148 */ m = localRectangle.height - 6;
/* 1149 */ break;
/* */ case 4:
/* 1151 */ i = localRectangle.x + 2;
/* 1152 */ j = localRectangle.y + 3;
/* 1153 */ k = localRectangle.width - 5;
/* 1154 */ m = localRectangle.height - 6;
/* 1155 */ break;
/* */ case 3:
/* 1157 */ i = localRectangle.x + 3;
/* 1158 */ j = localRectangle.y + 2;
/* 1159 */ k = localRectangle.width - 6;
/* 1160 */ m = localRectangle.height - 5;
/* 1161 */ break;
/* */ case 1:
/* */ default:
/* 1164 */ i = localRectangle.x + 3;
/* 1165 */ j = localRectangle.y + 3;
/* 1166 */ k = localRectangle.width - 6;
/* 1167 */ m = localRectangle.height - 5;
/* */ }
/* 1169 */ BasicGraphicsUtils.drawDashedRect(paramGraphics, i, j, k, m);
/* */ }
/* */ }
/* */
/* */ protected void paintTabBorder(Graphics paramGraphics, int paramInt1, int paramInt2, int paramInt3, int paramInt4, int paramInt5, int paramInt6, boolean paramBoolean)
/* */ {
/* 1182 */ paramGraphics.setColor(this.lightHighlight);
/* */
/* 1184 */ switch (paramInt1) {
/* */ case 2:
/* 1186 */ paramGraphics.drawLine(paramInt3 + 1, paramInt4 + paramInt6 - 2, paramInt3 + 1, paramInt4 + paramInt6 - 2);
/* 1187 */ paramGraphics.drawLine(paramInt3, paramInt4 + 2, paramInt3, paramInt4 + paramInt6 - 3);
/* 1188 */ paramGraphics.drawLine(paramInt3 + 1, paramInt4 + 1, paramInt3 + 1, paramInt4 + 1);
/* 1189 */ paramGraphics.drawLine(paramInt3 + 2, paramInt4, paramInt3 + paramInt5 - 1, paramInt4);
/* */
/* 1191 */ paramGraphics.setColor(this.shadow);
/* 1192 */ paramGraphics.drawLine(paramInt3 + 2, paramInt4 + paramInt6 - 2, paramInt3 + paramInt5 - 1, paramInt4 + paramInt6 - 2);
/* */
/* 1194 */ paramGraphics.setColor(this.darkShadow);
/* 1195 */ paramGraphics.drawLine(paramInt3 + 2, paramInt4 + paramInt6 - 1, paramInt3 + paramInt5 - 1, paramInt4 + paramInt6 - 1);
/* 1196 */ break;
/* */ case 4:
/* 1198 */ paramGraphics.drawLine(paramInt3, paramInt4, paramInt3 + paramInt5 - 3, paramInt4);
/* */
/* 1200 */ paramGraphics.setColor(this.shadow);
/* 1201 */ paramGraphics.drawLine(paramInt3, paramInt4 + paramInt6 - 2, paramInt3 + paramInt5 - 3, paramInt4 + paramInt6 - 2);
/* 1202 */ paramGraphics.drawLine(paramInt3 + paramInt5 - 2, paramInt4 + 2, paramInt3 + paramInt5 - 2, paramInt4 + paramInt6 - 3);
/* */
/* 1204 */ paramGraphics.setColor(this.darkShadow);
/* 1205 */ paramGraphics.drawLine(paramInt3 + paramInt5 - 2, paramInt4 + 1, paramInt3 + paramInt5 - 2, paramInt4 + 1);
/* 1206 */ paramGraphics.drawLine(paramInt3 + paramInt5 - 2, paramInt4 + paramInt6 - 2, paramInt3 + paramInt5 - 2, paramInt4 + paramInt6 - 2);
/* 1207 */ paramGraphics.drawLine(paramInt3 + paramInt5 - 1, paramInt4 + 2, paramInt3 + paramInt5 - 1, paramInt4 + paramInt6 - 3);
/* 1208 */ paramGraphics.drawLine(paramInt3, paramInt4 + paramInt6 - 1, paramInt3 + paramInt5 - 3, paramInt4 + paramInt6 - 1);
/* 1209 */ break;
/* */ case 3:
/* 1211 */ paramGraphics.drawLine(paramInt3, paramInt4, paramInt3, paramInt4 + paramInt6 - 3);
/* 1212 */ paramGraphics.drawLine(paramInt3 + 1, paramInt4 + paramInt6 - 2, paramInt3 + 1, paramInt4 + paramInt6 - 2);
/* */
/* 1214 */ paramGraphics.setColor(this.shadow);
/* 1215 */ paramGraphics.drawLine(paramInt3 + 2, paramInt4 + paramInt6 - 2, paramInt3 + paramInt5 - 3, paramInt4 + paramInt6 - 2);
/* 1216 */ paramGraphics.drawLine(paramInt3 + paramInt5 - 2, paramInt4, paramInt3 + paramInt5 - 2, paramInt4 + paramInt6 - 3);
/* */
/* 1218 */ paramGraphics.setColor(this.darkShadow);
/* 1219 */ paramGraphics.drawLine(paramInt3 + 2, paramInt4 + paramInt6 - 1, paramInt3 + paramInt5 - 3, paramInt4 + paramInt6 - 1);
/* 1220 */ paramGraphics.drawLine(paramInt3 + paramInt5 - 2, paramInt4 + paramInt6 - 2, paramInt3 + paramInt5 - 2, paramInt4 + paramInt6 - 2);
/* 1221 */ paramGraphics.drawLine(paramInt3 + paramInt5 - 1, paramInt4, paramInt3 + paramInt5 - 1, paramInt4 + paramInt6 - 3);
/* 1222 */ break;
/* */ case 1:
/* */ default:
/* 1225 */ paramGraphics.drawLine(paramInt3, paramInt4 + 2, paramInt3, paramInt4 + paramInt6 - 1);
/* 1226 */ paramGraphics.drawLine(paramInt3 + 1, paramInt4 + 1, paramInt3 + 1, paramInt4 + 1);
/* 1227 */ paramGraphics.drawLine(paramInt3 + 2, paramInt4, paramInt3 + paramInt5 - 3, paramInt4);
/* */
/* 1229 */ paramGraphics.setColor(this.shadow);
/* 1230 */ paramGraphics.drawLine(paramInt3 + paramInt5 - 2, paramInt4 + 2, paramInt3 + paramInt5 - 2, paramInt4 + paramInt6 - 1);
/* */
/* 1232 */ paramGraphics.setColor(this.darkShadow);
/* 1233 */ paramGraphics.drawLine(paramInt3 + paramInt5 - 1, paramInt4 + 2, paramInt3 + paramInt5 - 1, paramInt4 + paramInt6 - 1);
/* 1234 */ paramGraphics.drawLine(paramInt3 + paramInt5 - 2, paramInt4 + 1, paramInt3 + paramInt5 - 2, paramInt4 + 1);
/* */ }
/* */ }
/* */
/* */ protected void paintTabBackground(Graphics paramGraphics, int paramInt1, int paramInt2, int paramInt3, int paramInt4, int paramInt5, int paramInt6, boolean paramBoolean)
/* */ {
/* 1242 */ paramGraphics.setColor((!paramBoolean) || (this.selectedColor == null) ? this.tabPane.getBackgroundAt(paramInt2) : this.selectedColor);
/* */
/* 1244 */ switch (paramInt1) {
/* */ case 2:
/* 1246 */ paramGraphics.fillRect(paramInt3 + 1, paramInt4 + 1, paramInt5 - 1, paramInt6 - 3);
/* 1247 */ break;
/* */ case 4:
/* 1249 */ paramGraphics.fillRect(paramInt3, paramInt4 + 1, paramInt5 - 2, paramInt6 - 3);
/* 1250 */ break;
/* */ case 3:
/* 1252 */ paramGraphics.fillRect(paramInt3 + 1, paramInt4, paramInt5 - 3, paramInt6 - 1);
/* 1253 */ break;
/* */ case 1:
/* */ default:
/* 1256 */ paramGraphics.fillRect(paramInt3 + 1, paramInt4 + 1, paramInt5 - 3, paramInt6 - 1);
/* */ }
/* */ }
/* */
/* */ protected void paintContentBorder(Graphics paramGraphics, int paramInt1, int paramInt2) {
/* 1261 */ int i = this.tabPane.getWidth();
/* 1262 */ int j = this.tabPane.getHeight();
/* 1263 */ Insets localInsets1 = this.tabPane.getInsets();
/* 1264 */ Insets localInsets2 = getTabAreaInsets(paramInt1);
/* */
/* 1266 */ int k = localInsets1.left;
/* 1267 */ int m = localInsets1.top;
/* 1268 */ int n = i - localInsets1.right - localInsets1.left;
/* 1269 */ int i1 = j - localInsets1.top - localInsets1.bottom;
/* */
/* 1271 */ switch (paramInt1) {
/* */ case 2:
/* 1273 */ k += calculateTabAreaWidth(paramInt1, this.runCount, this.maxTabWidth);
/* 1274 */ if (this.tabsOverlapBorder) {
/* 1275 */ k -= localInsets2.right;
/* */ }
/* 1277 */ n -= k - localInsets1.left;
/* 1278 */ break;
/* */ case 4:
/* 1280 */ n -= calculateTabAreaWidth(paramInt1, this.runCount, this.maxTabWidth);
/* 1281 */ if (this.tabsOverlapBorder)
/* 1282 */ n += localInsets2.left; break;
/* */ case 3:
/* 1286 */ i1 -= calculateTabAreaHeight(paramInt1, this.runCount, this.maxTabHeight);
/* 1287 */ if (this.tabsOverlapBorder)
/* 1288 */ i1 += localInsets2.top; break;
/* */ case 1:
/* */ default:
/* 1293 */ m += calculateTabAreaHeight(paramInt1, this.runCount, this.maxTabHeight);
/* 1294 */ if (this.tabsOverlapBorder) {
/* 1295 */ m -= localInsets2.bottom;
/* */ }
/* 1297 */ i1 -= m - localInsets1.top;
/* */ }
/* */
/* 1300 */ if ((this.tabPane.getTabCount() > 0) && ((this.contentOpaque) || (this.tabPane.isOpaque())))
/* */ {
/* 1302 */ Color localColor = UIManager.getColor("TabbedPane.contentAreaColor");
/* 1303 */ if (localColor != null) {
/* 1304 */ paramGraphics.setColor(localColor);
/* */ }
/* 1306 */ else if ((this.selectedColor == null) || (paramInt2 == -1)) {
/* 1307 */ paramGraphics.setColor(this.tabPane.getBackground());
/* */ }
/* */ else {
/* 1310 */ paramGraphics.setColor(this.selectedColor);
/* */ }
/* 1312 */ paramGraphics.fillRect(k, m, n, i1);
/* */ }
/* */
/* 1315 */ paintContentBorderTopEdge(paramGraphics, paramInt1, paramInt2, k, m, n, i1);
/* 1316 */ paintContentBorderLeftEdge(paramGraphics, paramInt1, paramInt2, k, m, n, i1);
/* 1317 */ paintContentBorderBottomEdge(paramGraphics, paramInt1, paramInt2, k, m, n, i1);
/* 1318 */ paintContentBorderRightEdge(paramGraphics, paramInt1, paramInt2, k, m, n, i1);
/* */ }
/* */
/* */ protected void paintContentBorderTopEdge(Graphics paramGraphics, int paramInt1, int paramInt2, int paramInt3, int paramInt4, int paramInt5, int paramInt6)
/* */ {
/* 1325 */ Rectangle localRectangle = paramInt2 < 0 ? null : getTabBounds(paramInt2, this.calcRect);
/* */
/* 1328 */ paramGraphics.setColor(this.lightHighlight);
/* */
/* 1334 */ if ((paramInt1 != 1) || (paramInt2 < 0) || (localRectangle.y + localRectangle.height + 1 < paramInt4) || (localRectangle.x < paramInt3) || (localRectangle.x > paramInt3 + paramInt5))
/* */ {
/* 1337 */ paramGraphics.drawLine(paramInt3, paramInt4, paramInt3 + paramInt5 - 2, paramInt4);
/* */ }
/* */ else {
/* 1340 */ paramGraphics.drawLine(paramInt3, paramInt4, localRectangle.x - 1, paramInt4);
/* 1341 */ if (localRectangle.x + localRectangle.width < paramInt3 + paramInt5 - 2) {
/* 1342 */ paramGraphics.drawLine(localRectangle.x + localRectangle.width, paramInt4, paramInt3 + paramInt5 - 2, paramInt4);
/* */ }
/* */ else {
/* 1345 */ paramGraphics.setColor(this.shadow);
/* 1346 */ paramGraphics.drawLine(paramInt3 + paramInt5 - 2, paramInt4, paramInt3 + paramInt5 - 2, paramInt4);
/* */ }
/* */ }
/* */ }
/* */
/* */ protected void paintContentBorderLeftEdge(Graphics paramGraphics, int paramInt1, int paramInt2, int paramInt3, int paramInt4, int paramInt5, int paramInt6)
/* */ {
/* 1354 */ Rectangle localRectangle = paramInt2 < 0 ? null : getTabBounds(paramInt2, this.calcRect);
/* */
/* 1357 */ paramGraphics.setColor(this.lightHighlight);
/* */
/* 1363 */ if ((paramInt1 != 2) || (paramInt2 < 0) || (localRectangle.x + localRectangle.width + 1 < paramInt3) || (localRectangle.y < paramInt4) || (localRectangle.y > paramInt4 + paramInt6))
/* */ {
/* 1366 */ paramGraphics.drawLine(paramInt3, paramInt4, paramInt3, paramInt4 + paramInt6 - 2);
/* */ }
/* */ else {
/* 1369 */ paramGraphics.drawLine(paramInt3, paramInt4, paramInt3, localRectangle.y - 1);
/* 1370 */ if (localRectangle.y + localRectangle.height < paramInt4 + paramInt6 - 2)
/* 1371 */ paramGraphics.drawLine(paramInt3, localRectangle.y + localRectangle.height, paramInt3, paramInt4 + paramInt6 - 2);
/* */ }
/* */ }
/* */
/* */ protected void paintContentBorderBottomEdge(Graphics paramGraphics, int paramInt1, int paramInt2, int paramInt3, int paramInt4, int paramInt5, int paramInt6)
/* */ {
/* 1380 */ Rectangle localRectangle = paramInt2 < 0 ? null : getTabBounds(paramInt2, this.calcRect);
/* */
/* 1383 */ paramGraphics.setColor(this.shadow);
/* */
/* 1389 */ if ((paramInt1 != 3) || (paramInt2 < 0) || (localRectangle.y - 1 > paramInt6) || (localRectangle.x < paramInt3) || (localRectangle.x > paramInt3 + paramInt5))
/* */ {
/* 1392 */ paramGraphics.drawLine(paramInt3 + 1, paramInt4 + paramInt6 - 2, paramInt3 + paramInt5 - 2, paramInt4 + paramInt6 - 2);
/* 1393 */ paramGraphics.setColor(this.darkShadow);
/* 1394 */ paramGraphics.drawLine(paramInt3, paramInt4 + paramInt6 - 1, paramInt3 + paramInt5 - 1, paramInt4 + paramInt6 - 1);
/* */ }
/* */ else {
/* 1397 */ paramGraphics.drawLine(paramInt3 + 1, paramInt4 + paramInt6 - 2, localRectangle.x - 1, paramInt4 + paramInt6 - 2);
/* 1398 */ paramGraphics.setColor(this.darkShadow);
/* 1399 */ paramGraphics.drawLine(paramInt3, paramInt4 + paramInt6 - 1, localRectangle.x - 1, paramInt4 + paramInt6 - 1);
/* 1400 */ if (localRectangle.x + localRectangle.width < paramInt3 + paramInt5 - 2) {
/* 1401 */ paramGraphics.setColor(this.shadow);
/* 1402 */ paramGraphics.drawLine(localRectangle.x + localRectangle.width, paramInt4 + paramInt6 - 2, paramInt3 + paramInt5 - 2, paramInt4 + paramInt6 - 2);
/* 1403 */ paramGraphics.setColor(this.darkShadow);
/* 1404 */ paramGraphics.drawLine(localRectangle.x + localRectangle.width, paramInt4 + paramInt6 - 1, paramInt3 + paramInt5 - 1, paramInt4 + paramInt6 - 1);
/* */ }
/* */ }
/* */ }
/* */
/* */ protected void paintContentBorderRightEdge(Graphics paramGraphics, int paramInt1, int paramInt2, int paramInt3, int paramInt4, int paramInt5, int paramInt6)
/* */ {
/* 1413 */ Rectangle localRectangle = paramInt2 < 0 ? null : getTabBounds(paramInt2, this.calcRect);
/* */
/* 1416 */ paramGraphics.setColor(this.shadow);
/* */
/* 1422 */ if ((paramInt1 != 4) || (paramInt2 < 0) || (localRectangle.x - 1 > paramInt5) || (localRectangle.y < paramInt4) || (localRectangle.y > paramInt4 + paramInt6))
/* */ {
/* 1425 */ paramGraphics.drawLine(paramInt3 + paramInt5 - 2, paramInt4 + 1, paramInt3 + paramInt5 - 2, paramInt4 + paramInt6 - 3);
/* 1426 */ paramGraphics.setColor(this.darkShadow);
/* 1427 */ paramGraphics.drawLine(paramInt3 + paramInt5 - 1, paramInt4, paramInt3 + paramInt5 - 1, paramInt4 + paramInt6 - 1);
/* */ }
/* */ else {
/* 1430 */ paramGraphics.drawLine(paramInt3 + paramInt5 - 2, paramInt4 + 1, paramInt3 + paramInt5 - 2, localRectangle.y - 1);
/* 1431 */ paramGraphics.setColor(this.darkShadow);
/* 1432 */ paramGraphics.drawLine(paramInt3 + paramInt5 - 1, paramInt4, paramInt3 + paramInt5 - 1, localRectangle.y - 1);
/* */
/* 1434 */ if (localRectangle.y + localRectangle.height < paramInt4 + paramInt6 - 2) {
/* 1435 */ paramGraphics.setColor(this.shadow);
/* 1436 */ paramGraphics.drawLine(paramInt3 + paramInt5 - 2, localRectangle.y + localRectangle.height, paramInt3 + paramInt5 - 2, paramInt4 + paramInt6 - 2);
/* */
/* 1438 */ paramGraphics.setColor(this.darkShadow);
/* 1439 */ paramGraphics.drawLine(paramInt3 + paramInt5 - 1, localRectangle.y + localRectangle.height, paramInt3 + paramInt5 - 1, paramInt4 + paramInt6 - 2);
/* */ }
/* */ }
/* */ }
/* */
/* */ private void ensureCurrentLayout()
/* */ {
/* 1446 */ if (!this.tabPane.isValid()) {
/* 1447 */ this.tabPane.validate();
/* */ }
/* */
/* 1453 */ if (!this.tabPane.isValid()) {
/* 1454 */ TabbedPaneLayout localTabbedPaneLayout = (TabbedPaneLayout)this.tabPane.getLayout();
/* 1455 */ localTabbedPaneLayout.calculateLayoutInfo();
/* */ }
/* */ }
/* */
/* */ public Rectangle getTabBounds(JTabbedPane paramJTabbedPane, int paramInt)
/* */ {
/* 1467 */ ensureCurrentLayout();
/* 1468 */ Rectangle localRectangle = new Rectangle();
/* 1469 */ return getTabBounds(paramInt, localRectangle);
/* */ }
/* */
/* */ public int getTabRunCount(JTabbedPane paramJTabbedPane) {
/* 1473 */ ensureCurrentLayout();
/* 1474 */ return this.runCount;
/* */ }
/* */
/* */ public int tabForCoordinate(JTabbedPane paramJTabbedPane, int paramInt1, int paramInt2)
/* */ {
/* 1482 */ return tabForCoordinate(paramJTabbedPane, paramInt1, paramInt2, true);
/* */ }
/* */
/* */ private int tabForCoordinate(JTabbedPane paramJTabbedPane, int paramInt1, int paramInt2, boolean paramBoolean)
/* */ {
/* 1487 */ if (paramBoolean) {
/* 1488 */ ensureCurrentLayout();
/* */ }
/* 1490 */ if (this.isRunsDirty)
/* */ {
/* 1493 */ return -1;
/* */ }
/* 1495 */ Point localPoint = new Point(paramInt1, paramInt2);
/* */
/* 1497 */ if (scrollableTabLayoutEnabled()) {
/* 1498 */ translatePointToTabPanel(paramInt1, paramInt2, localPoint);
/* 1499 */ Rectangle localRectangle = this.tabScroller.viewport.getViewRect();
/* 1500 */ if (!localRectangle.contains(localPoint)) {
/* 1501 */ return -1;
/* */ }
/* */ }
/* 1504 */ int i = this.tabPane.getTabCount();
/* 1505 */ for (int j = 0; j < i; j++) {
/* 1506 */ if (this.rects[j].contains(localPoint.x, localPoint.y)) {
/* 1507 */ return j;
/* */ }
/* */ }
/* 1510 */ return -1;
/* */ }
/* */
/* */ protected Rectangle getTabBounds(int paramInt, Rectangle paramRectangle)
/* */ {
/* 1534 */ paramRectangle.width = this.rects[paramInt].width;
/* 1535 */ paramRectangle.height = this.rects[paramInt].height;
/* */
/* 1537 */ if (scrollableTabLayoutEnabled())
/* */ {
/* 1540 */ Point localPoint1 = this.tabScroller.viewport.getLocation();
/* 1541 */ Point localPoint2 = this.tabScroller.viewport.getViewPosition();
/* 1542 */ paramRectangle.x = (this.rects[paramInt].x + localPoint1.x - localPoint2.x);
/* 1543 */ paramRectangle.y = (this.rects[paramInt].y + localPoint1.y - localPoint2.y);
/* */ }
/* */ else {
/* 1546 */ paramRectangle.x = this.rects[paramInt].x;
/* 1547 */ paramRectangle.y = this.rects[paramInt].y;
/* */ }
/* 1549 */ return paramRectangle;
/* */ }
/* */
/* */ private int getClosestTab(int paramInt1, int paramInt2)
/* */ {
/* 1557 */ int i = 0;
/* 1558 */ int j = Math.min(this.rects.length, this.tabPane.getTabCount());
/* 1559 */ int k = j;
/* 1560 */ int m = this.tabPane.getTabPlacement();
/* 1561 */ int n = (m == 1) || (m == 3) ? 1 : 0;
/* 1562 */ int i1 = n != 0 ? paramInt1 : paramInt2;
/* */
/* 1564 */ while (i != k) {
/* 1565 */ int i2 = (k + i) / 2;
/* */ int i3;
/* */ int i4;
/* 1569 */ if (n != 0) {
/* 1570 */ i3 = this.rects[i2].x;
/* 1571 */ i4 = i3 + this.rects[i2].width;
/* */ }
/* */ else {
/* 1574 */ i3 = this.rects[i2].y;
/* 1575 */ i4 = i3 + this.rects[i2].height;
/* */ }
/* 1577 */ if (i1 < i3) {
/* 1578 */ k = i2;
/* 1579 */ if (i == k) {
/* 1580 */ return Math.max(0, i2 - 1);
/* */ }
/* */ }
/* 1583 */ else if (i1 >= i4) {
/* 1584 */ i = i2;
/* 1585 */ if (k - i <= 1)
/* 1586 */ return Math.max(i2 + 1, j - 1);
/* */ }
/* */ else
/* */ {
/* 1590 */ return i2;
/* */ }
/* */ }
/* 1593 */ return i;
/* */ }
/* */
/* */ private Point translatePointToTabPanel(int paramInt1, int paramInt2, Point paramPoint)
/* */ {
/* 1602 */ Point localPoint1 = this.tabScroller.viewport.getLocation();
/* 1603 */ Point localPoint2 = this.tabScroller.viewport.getViewPosition();
/* 1604 */ paramPoint.x = (paramInt1 - localPoint1.x + localPoint2.x);
/* 1605 */ paramPoint.y = (paramInt2 - localPoint1.y + localPoint2.y);
/* 1606 */ return paramPoint;
/* */ }
/* */
/* */ protected Component getVisibleComponent()
/* */ {
/* 1612 */ return this.visibleComponent;
/* */ }
/* */
/* */ protected void setVisibleComponent(Component paramComponent) {
/* 1616 */ if ((this.visibleComponent != null) && (this.visibleComponent != paramComponent) && (this.visibleComponent.getParent() == this.tabPane) && (this.visibleComponent.isVisible()))
/* */ {
/* 1621 */ this.visibleComponent.setVisible(false);
/* */ }
/* 1623 */ if ((paramComponent != null) && (!paramComponent.isVisible())) {
/* 1624 */ paramComponent.setVisible(true);
/* */ }
/* 1626 */ this.visibleComponent = paramComponent;
/* */ }
/* */
/* */ protected void assureRectsCreated(int paramInt) {
/* 1630 */ int i = this.rects.length;
/* 1631 */ if (paramInt != i) {
/* 1632 */ Rectangle[] arrayOfRectangle = new Rectangle[paramInt];
/* 1633 */ System.arraycopy(this.rects, 0, arrayOfRectangle, 0, Math.min(i, paramInt));
/* */
/* 1635 */ this.rects = arrayOfRectangle;
/* 1636 */ for (int j = i; j < paramInt; j++)
/* 1637 */ this.rects[j] = new Rectangle();
/* */ }
/* */ }
/* */
/* */ protected void expandTabRunsArray()
/* */ {
/* 1644 */ int i = this.tabRuns.length;
/* 1645 */ int[] arrayOfInt = new int[i + 10];
/* 1646 */ System.arraycopy(this.tabRuns, 0, arrayOfInt, 0, this.runCount);
/* 1647 */ this.tabRuns = arrayOfInt;
/* */ }
/* */
/* */ protected int getRunForTab(int paramInt1, int paramInt2) {
/* 1651 */ for (int i = 0; i < this.runCount; i++) {
/* 1652 */ int j = this.tabRuns[i];
/* 1653 */ int k = lastTabInRun(paramInt1, i);
/* 1654 */ if ((paramInt2 >= j) && (paramInt2 <= k)) {
/* 1655 */ return i;
/* */ }
/* */ }
/* 1658 */ return 0;
/* */ }
/* */
/* */ protected int lastTabInRun(int paramInt1, int paramInt2) {
/* 1662 */ if (this.runCount == 1) {
/* 1663 */ return paramInt1 - 1;
/* */ }
/* 1665 */ int i = paramInt2 == this.runCount - 1 ? 0 : paramInt2 + 1;
/* 1666 */ if (this.tabRuns[i] == 0) {
/* 1667 */ return paramInt1 - 1;
/* */ }
/* 1669 */ return this.tabRuns[i] - 1;
/* */ }
/* */
/* */ protected int getTabRunOverlay(int paramInt) {
/* 1673 */ return this.tabRunOverlay;
/* */ }
/* */
/* */ protected int getTabRunIndent(int paramInt1, int paramInt2) {
/* 1677 */ return 0;
/* */ }
/* */
/* */ protected boolean shouldPadTabRun(int paramInt1, int paramInt2) {
/* 1681 */ return this.runCount > 1;
/* */ }
/* */
/* */ protected boolean shouldRotateTabRuns(int paramInt) {
/* 1685 */ return true;
/* */ }
/* */
/* */ protected Icon getIconForTab(int paramInt) {
/* 1689 */ return (!this.tabPane.isEnabled()) || (!this.tabPane.isEnabledAt(paramInt)) ? this.tabPane.getDisabledIconAt(paramInt) : this.tabPane.getIconAt(paramInt);
/* */ }
/* */
/* */ protected View getTextViewForTab(int paramInt)
/* */ {
/* 1705 */ if (this.htmlViews != null) {
/* 1706 */ return (View)this.htmlViews.elementAt(paramInt);
/* */ }
/* 1708 */ return null;
/* */ }
/* */
/* */ protected int calculateTabHeight(int paramInt1, int paramInt2, int paramInt3) {
/* 1712 */ int i = 0;
/* 1713 */ Component localComponent = this.tabPane.getTabComponentAt(paramInt2);
/* 1714 */ if (localComponent != null) {
/* 1715 */ i = localComponent.getPreferredSize().height;
/* */ } else {
/* 1717 */ localObject = getTextViewForTab(paramInt2);
/* 1718 */ if (localObject != null)
/* */ {
/* 1720 */ i += (int)((View)localObject).getPreferredSpan(1);
/* */ }
/* */ else {
/* 1723 */ i += paramInt3;
/* */ }
/* 1725 */ Icon localIcon = getIconForTab(paramInt2);
/* */
/* 1727 */ if (localIcon != null) {
/* 1728 */ i = Math.max(i, localIcon.getIconHeight());
/* */ }
/* */ }
/* 1731 */ Object localObject = getTabInsets(paramInt1, paramInt2);
/* 1732 */ i += ((Insets)localObject).top + ((Insets)localObject).bottom + 2;
/* 1733 */ return i;
/* */ }
/* */
/* */ protected int calculateMaxTabHeight(int paramInt) {
/* 1737 */ FontMetrics localFontMetrics = getFontMetrics();
/* 1738 */ int i = this.tabPane.getTabCount();
/* 1739 */ int j = 0;
/* 1740 */ int k = localFontMetrics.getHeight();
/* 1741 */ for (int m = 0; m < i; m++) {
/* 1742 */ j = Math.max(calculateTabHeight(paramInt, m, k), j);
/* */ }
/* 1744 */ return j;
/* */ }
/* */
/* */ protected int calculateTabWidth(int paramInt1, int paramInt2, FontMetrics paramFontMetrics) {
/* 1748 */ Insets localInsets = getTabInsets(paramInt1, paramInt2);
/* 1749 */ int i = localInsets.left + localInsets.right + 3;
/* 1750 */ Component localComponent = this.tabPane.getTabComponentAt(paramInt2);
/* 1751 */ if (localComponent != null) {
/* 1752 */ i += localComponent.getPreferredSize().width;
/* */ } else {
/* 1754 */ Icon localIcon = getIconForTab(paramInt2);
/* 1755 */ if (localIcon != null) {
/* 1756 */ i += localIcon.getIconWidth() + this.textIconGap;
/* */ }
/* 1758 */ View localView = getTextViewForTab(paramInt2);
/* 1759 */ if (localView != null)
/* */ {
/* 1761 */ i += (int)localView.getPreferredSpan(0);
/* */ }
/* */ else {
/* 1764 */ String str = this.tabPane.getTitleAt(paramInt2);
/* 1765 */ i += SwingUtilities2.stringWidth(this.tabPane, paramFontMetrics, str);
/* */ }
/* */ }
/* 1768 */ return i;
/* */ }
/* */
/* */ protected int calculateMaxTabWidth(int paramInt) {
/* 1772 */ FontMetrics localFontMetrics = getFontMetrics();
/* 1773 */ int i = this.tabPane.getTabCount();
/* 1774 */ int j = 0;
/* 1775 */ for (int k = 0; k < i; k++) {
/* 1776 */ j = Math.max(calculateTabWidth(paramInt, k, localFontMetrics), j);
/* */ }
/* 1778 */ return j;
/* */ }
/* */
/* */ protected int calculateTabAreaHeight(int paramInt1, int paramInt2, int paramInt3) {
/* 1782 */ Insets localInsets = getTabAreaInsets(paramInt1);
/* 1783 */ int i = getTabRunOverlay(paramInt1);
/* 1784 */ return paramInt2 > 0 ? paramInt2 * (paramInt3 - i) + i + localInsets.top + localInsets.bottom : 0;
/* */ }
/* */
/* */ protected int calculateTabAreaWidth(int paramInt1, int paramInt2, int paramInt3)
/* */ {
/* 1791 */ Insets localInsets = getTabAreaInsets(paramInt1);
/* 1792 */ int i = getTabRunOverlay(paramInt1);
/* 1793 */ return paramInt2 > 0 ? paramInt2 * (paramInt3 - i) + i + localInsets.left + localInsets.right : 0;
/* */ }
/* */
/* */ protected Insets getTabInsets(int paramInt1, int paramInt2)
/* */ {
/* 1800 */ return this.tabInsets;
/* */ }
/* */
/* */ protected Insets getSelectedTabPadInsets(int paramInt) {
/* 1804 */ rotateInsets(this.selectedTabPadInsets, this.currentPadInsets, paramInt);
/* 1805 */ return this.currentPadInsets;
/* */ }
/* */
/* */ protected Insets getTabAreaInsets(int paramInt) {
/* 1809 */ rotateInsets(this.tabAreaInsets, this.currentTabAreaInsets, paramInt);
/* 1810 */ return this.currentTabAreaInsets;
/* */ }
/* */
/* */ protected Insets getContentBorderInsets(int paramInt) {
/* 1814 */ return this.contentBorderInsets;
/* */ }
/* */
/* */ protected FontMetrics getFontMetrics() {
/* 1818 */ Font localFont = this.tabPane.getFont();
/* 1819 */ return this.tabPane.getFontMetrics(localFont);
/* */ }
/* */
/* */ protected void navigateSelectedTab(int paramInt)
/* */ {
/* 1826 */ int i = this.tabPane.getTabPlacement();
/* 1827 */ int j = DefaultLookup.getBoolean(this.tabPane, this, "TabbedPane.selectionFollowsFocus", true) ? this.tabPane.getSelectedIndex() : getFocusIndex();
/* */
/* 1830 */ int k = this.tabPane.getTabCount();
/* 1831 */ boolean bool = BasicGraphicsUtils.isLeftToRight(this.tabPane);
/* */
/* 1834 */ if (k <= 0)
/* */ return;
/* */ int m;
/* 1839 */ switch (i) {
/* */ case 2:
/* */ case 4:
/* 1842 */ switch (paramInt) {
/* */ case 12:
/* 1844 */ selectNextTab(j);
/* 1845 */ break;
/* */ case 13:
/* 1847 */ selectPreviousTab(j);
/* 1848 */ break;
/* */ case 1:
/* 1850 */ selectPreviousTabInRun(j);
/* 1851 */ break;
/* */ case 5:
/* 1853 */ selectNextTabInRun(j);
/* 1854 */ break;
/* */ case 7:
/* 1856 */ m = getTabRunOffset(i, k, j, false);
/* 1857 */ selectAdjacentRunTab(i, j, m);
/* 1858 */ break;
/* */ case 3:
/* 1860 */ m = getTabRunOffset(i, k, j, true);
/* 1861 */ selectAdjacentRunTab(i, j, m);
/* */ case 2:
/* */ case 4:
/* */ case 6:
/* */ case 8:
/* */ case 9:
/* */ case 10:
/* 1865 */ case 11: } break;
/* */ case 1:
/* */ case 3:
/* */ default:
/* 1869 */ switch (paramInt) {
/* */ case 12:
/* 1871 */ selectNextTab(j);
/* 1872 */ break;
/* */ case 13:
/* 1874 */ selectPreviousTab(j);
/* 1875 */ break;
/* */ case 1:
/* 1877 */ m = getTabRunOffset(i, k, j, false);
/* 1878 */ selectAdjacentRunTab(i, j, m);
/* 1879 */ break;
/* */ case 5:
/* 1881 */ m = getTabRunOffset(i, k, j, true);
/* 1882 */ selectAdjacentRunTab(i, j, m);
/* 1883 */ break;
/* */ case 3:
/* 1885 */ if (bool)
/* 1886 */ selectNextTabInRun(j);
/* */ else {
/* 1888 */ selectPreviousTabInRun(j);
/* */ }
/* 1890 */ break;
/* */ case 7:
/* 1892 */ if (bool)
/* 1893 */ selectPreviousTabInRun(j);
/* */ else
/* 1895 */ selectNextTabInRun(j); break;
/* */ case 2:
/* */ case 4:
/* */ case 6:
/* */ case 8:
/* */ case 9:
/* */ case 10:
/* 1897 */ case 11: } break;
/* */ }
/* */ }
/* */
/* */ protected void selectNextTabInRun(int paramInt)
/* */ {
/* 1904 */ int i = this.tabPane.getTabCount();
/* 1905 */ int j = getNextTabIndexInRun(i, paramInt);
/* */
/* 1907 */ while ((j != paramInt) && (!this.tabPane.isEnabledAt(j))) {
/* 1908 */ j = getNextTabIndexInRun(i, j);
/* */ }
/* 1910 */ navigateTo(j);
/* */ }
/* */
/* */ protected void selectPreviousTabInRun(int paramInt) {
/* 1914 */ int i = this.tabPane.getTabCount();
/* 1915 */ int j = getPreviousTabIndexInRun(i, paramInt);
/* */
/* 1917 */ while ((j != paramInt) && (!this.tabPane.isEnabledAt(j))) {
/* 1918 */ j = getPreviousTabIndexInRun(i, j);
/* */ }
/* 1920 */ navigateTo(j);
/* */ }
/* */
/* */ protected void selectNextTab(int paramInt) {
/* 1924 */ int i = getNextTabIndex(paramInt);
/* */
/* 1926 */ while ((i != paramInt) && (!this.tabPane.isEnabledAt(i))) {
/* 1927 */ i = getNextTabIndex(i);
/* */ }
/* 1929 */ navigateTo(i);
/* */ }
/* */
/* */ protected void selectPreviousTab(int paramInt) {
/* 1933 */ int i = getPreviousTabIndex(paramInt);
/* */
/* 1935 */ while ((i != paramInt) && (!this.tabPane.isEnabledAt(i))) {
/* 1936 */ i = getPreviousTabIndex(i);
/* */ }
/* 1938 */ navigateTo(i);
/* */ }
/* */
/* */ protected void selectAdjacentRunTab(int paramInt1, int paramInt2, int paramInt3)
/* */ {
/* 1943 */ if (this.runCount < 2) {
/* 1944 */ return;
/* */ }
/* */
/* 1947 */ Rectangle localRectangle = this.rects[paramInt2];
/* */ int i;
/* 1948 */ switch (paramInt1) {
/* */ case 2:
/* */ case 4:
/* 1951 */ i = tabForCoordinate(this.tabPane, localRectangle.x + localRectangle.width / 2 + paramInt3, localRectangle.y + localRectangle.height / 2);
/* */
/* 1953 */ break;
/* */ case 1:
/* */ case 3:
/* */ default:
/* 1957 */ i = tabForCoordinate(this.tabPane, localRectangle.x + localRectangle.width / 2, localRectangle.y + localRectangle.height / 2 + paramInt3);
/* */ }
/* */
/* 1960 */ if (i != -1) {
/* 1961 */ while ((!this.tabPane.isEnabledAt(i)) && (i != paramInt2)) {
/* 1962 */ i = getNextTabIndex(i);
/* */ }
/* 1964 */ navigateTo(i);
/* */ }
/* */ }
/* */
/* */ private void navigateTo(int paramInt) {
/* 1969 */ if (DefaultLookup.getBoolean(this.tabPane, this, "TabbedPane.selectionFollowsFocus", true))
/* */ {
/* 1971 */ this.tabPane.setSelectedIndex(paramInt);
/* */ }
/* */ else
/* 1974 */ setFocusIndex(paramInt, true);
/* */ }
/* */
/* */ void setFocusIndex(int paramInt, boolean paramBoolean)
/* */ {
/* 1979 */ if ((paramBoolean) && (!this.isRunsDirty)) {
/* 1980 */ repaintTab(this.focusIndex);
/* 1981 */ this.focusIndex = paramInt;
/* 1982 */ repaintTab(this.focusIndex);
/* */ }
/* */ else {
/* 1985 */ this.focusIndex = paramInt;
/* */ }
/* */ }
/* */
/* */ private void repaintTab(int paramInt)
/* */ {
/* 1995 */ if ((!this.isRunsDirty) && (paramInt >= 0) && (paramInt < this.tabPane.getTabCount()))
/* 1996 */ this.tabPane.repaint(getTabBounds(this.tabPane, paramInt));
/* */ }
/* */
/* */ private void validateFocusIndex()
/* */ {
/* 2004 */ if (this.focusIndex >= this.tabPane.getTabCount())
/* 2005 */ setFocusIndex(this.tabPane.getSelectedIndex(), false);
/* */ }
/* */
/* */ protected int getFocusIndex()
/* */ {
/* 2016 */ return this.focusIndex;
/* */ }
/* */
/* */ protected int getTabRunOffset(int paramInt1, int paramInt2, int paramInt3, boolean paramBoolean)
/* */ {
/* 2021 */ int i = getRunForTab(paramInt2, paramInt3);
/* */ int j;
/* 2023 */ switch (paramInt1) {
/* */ case 2:
/* 2025 */ if (i == 0) {
/* 2026 */ j = paramBoolean ? -(calculateTabAreaWidth(paramInt1, this.runCount, this.maxTabWidth) - this.maxTabWidth) : -this.maxTabWidth;
/* */ }
/* 2030 */ else if (i == this.runCount - 1) {
/* 2031 */ j = paramBoolean ? this.maxTabWidth : calculateTabAreaWidth(paramInt1, this.runCount, this.maxTabWidth) - this.maxTabWidth;
/* */ }
/* */ else
/* */ {
/* 2035 */ j = paramBoolean ? this.maxTabWidth : -this.maxTabWidth;
/* */ }
/* 2037 */ break;
/* */ case 4:
/* 2040 */ if (i == 0) {
/* 2041 */ j = paramBoolean ? this.maxTabWidth : calculateTabAreaWidth(paramInt1, this.runCount, this.maxTabWidth) - this.maxTabWidth;
/* */ }
/* 2044 */ else if (i == this.runCount - 1) {
/* 2045 */ j = paramBoolean ? -(calculateTabAreaWidth(paramInt1, this.runCount, this.maxTabWidth) - this.maxTabWidth) : -this.maxTabWidth;
/* */ }
/* */ else
/* */ {
/* 2049 */ j = paramBoolean ? this.maxTabWidth : -this.maxTabWidth;
/* */ }
/* 2051 */ break;
/* */ case 3:
/* 2054 */ if (i == 0) {
/* 2055 */ j = paramBoolean ? this.maxTabHeight : calculateTabAreaHeight(paramInt1, this.runCount, this.maxTabHeight) - this.maxTabHeight;
/* */ }
/* 2058 */ else if (i == this.runCount - 1) {
/* 2059 */ j = paramBoolean ? -(calculateTabAreaHeight(paramInt1, this.runCount, this.maxTabHeight) - this.maxTabHeight) : -this.maxTabHeight;
/* */ }
/* */ else
/* */ {
/* 2063 */ j = paramBoolean ? this.maxTabHeight : -this.maxTabHeight;
/* */ }
/* 2065 */ break;
/* */ case 1:
/* */ default:
/* 2069 */ if (i == 0) {
/* 2070 */ j = paramBoolean ? -(calculateTabAreaHeight(paramInt1, this.runCount, this.maxTabHeight) - this.maxTabHeight) : -this.maxTabHeight;
/* */ }
/* 2073 */ else if (i == this.runCount - 1) {
/* 2074 */ j = paramBoolean ? this.maxTabHeight : calculateTabAreaHeight(paramInt1, this.runCount, this.maxTabHeight) - this.maxTabHeight;
/* */ }
/* */ else
/* */ {
/* 2078 */ j = paramBoolean ? this.maxTabHeight : -this.maxTabHeight;
/* */ }
/* */ break;
/* */ }
/* 2082 */ return j;
/* */ }
/* */
/* */ protected int getPreviousTabIndex(int paramInt) {
/* 2086 */ int i = paramInt - 1 >= 0 ? paramInt - 1 : this.tabPane.getTabCount() - 1;
/* 2087 */ return i >= 0 ? i : 0;
/* */ }
/* */
/* */ protected int getNextTabIndex(int paramInt) {
/* 2091 */ return (paramInt + 1) % this.tabPane.getTabCount();
/* */ }
/* */
/* */ protected int getNextTabIndexInRun(int paramInt1, int paramInt2) {
/* 2095 */ if (this.runCount < 2) {
/* 2096 */ return getNextTabIndex(paramInt2);
/* */ }
/* 2098 */ int i = getRunForTab(paramInt1, paramInt2);
/* 2099 */ int j = getNextTabIndex(paramInt2);
/* 2100 */ if (j == this.tabRuns[getNextTabRun(i)]) {
/* 2101 */ return this.tabRuns[i];
/* */ }
/* 2103 */ return j;
/* */ }
/* */
/* */ protected int getPreviousTabIndexInRun(int paramInt1, int paramInt2) {
/* 2107 */ if (this.runCount < 2) {
/* 2108 */ return getPreviousTabIndex(paramInt2);
/* */ }
/* 2110 */ int i = getRunForTab(paramInt1, paramInt2);
/* 2111 */ if (paramInt2 == this.tabRuns[i]) {
/* 2112 */ int j = this.tabRuns[getNextTabRun(i)] - 1;
/* 2113 */ return j != -1 ? j : paramInt1 - 1;
/* */ }
/* 2115 */ return getPreviousTabIndex(paramInt2);
/* */ }
/* */
/* */ protected int getPreviousTabRun(int paramInt) {
/* 2119 */ int i = paramInt - 1 >= 0 ? paramInt - 1 : this.runCount - 1;
/* 2120 */ return i >= 0 ? i : 0;
/* */ }
/* */
/* */ protected int getNextTabRun(int paramInt) {
/* 2124 */ return (paramInt + 1) % this.runCount;
/* */ }
/* */
/* */ protected static void rotateInsets(Insets paramInsets1, Insets paramInsets2, int paramInt)
/* */ {
/* 2129 */ switch (paramInt) {
/* */ case 2:
/* 2131 */ paramInsets2.top = paramInsets1.left;
/* 2132 */ paramInsets2.left = paramInsets1.top;
/* 2133 */ paramInsets2.bottom = paramInsets1.right;
/* 2134 */ paramInsets2.right = paramInsets1.bottom;
/* 2135 */ break;
/* */ case 3:
/* 2137 */ paramInsets2.top = paramInsets1.bottom;
/* 2138 */ paramInsets2.left = paramInsets1.left;
/* 2139 */ paramInsets2.bottom = paramInsets1.top;
/* 2140 */ paramInsets2.right = paramInsets1.right;
/* 2141 */ break;
/* */ case 4:
/* 2143 */ paramInsets2.top = paramInsets1.left;
/* 2144 */ paramInsets2.left = paramInsets1.bottom;
/* 2145 */ paramInsets2.bottom = paramInsets1.right;
/* 2146 */ paramInsets2.right = paramInsets1.top;
/* 2147 */ break;
/* */ case 1:
/* */ default:
/* 2150 */ paramInsets2.top = paramInsets1.top;
/* 2151 */ paramInsets2.left = paramInsets1.left;
/* 2152 */ paramInsets2.bottom = paramInsets1.bottom;
/* 2153 */ paramInsets2.right = paramInsets1.right;
/* */ }
/* */ }
/* */
/* */ boolean requestFocusForVisibleComponent()
/* */ {
/* 2161 */ return SwingUtilities2.tabbedPaneChangeFocusTo(getVisibleComponent());
/* */ }
/* */
/* */ private Vector<View> createHTMLVector()
/* */ {
/* 3805 */ Vector localVector = new Vector();
/* 3806 */ int i = this.tabPane.getTabCount();
/* 3807 */ if (i > 0) {
/* 3808 */ for (int j = 0; j < i; j++) {
/* 3809 */ String str = this.tabPane.getTitleAt(j);
/* 3810 */ if (BasicHTML.isHTMLString(str))
/* 3811 */ localVector.addElement(BasicHTML.createHTMLView(this.tabPane, str));
/* */ else {
/* 3813 */ localVector.addElement(null);
/* */ }
/* */ }
/* */ }
/* 3817 */ return localVector;
/* */ }
/* */
/* */ private static class Actions extends UIAction
/* */ {
/* */ static final String NEXT = "navigateNext";
/* */ static final String PREVIOUS = "navigatePrevious";
/* */ static final String RIGHT = "navigateRight";
/* */ static final String LEFT = "navigateLeft";
/* */ static final String UP = "navigateUp";
/* */ static final String DOWN = "navigateDown";
/* */ static final String PAGE_UP = "navigatePageUp";
/* */ static final String PAGE_DOWN = "navigatePageDown";
/* */ static final String REQUEST_FOCUS = "requestFocus";
/* */ static final String REQUEST_FOCUS_FOR_VISIBLE = "requestFocusForVisibleComponent";
/* */ static final String SET_SELECTED = "setSelectedIndex";
/* */ static final String SELECT_FOCUSED = "selectTabWithFocus";
/* */ static final String SCROLL_FORWARD = "scrollTabsForwardAction";
/* */ static final String SCROLL_BACKWARD = "scrollTabsBackwardAction";
/* */
/* */ Actions(String paramString)
/* */ {
/* 2182 */ super();
/* */ }
/* */
/* */ public void actionPerformed(ActionEvent paramActionEvent) {
/* 2186 */ String str1 = getName();
/* 2187 */ JTabbedPane localJTabbedPane = (JTabbedPane)paramActionEvent.getSource();
/* 2188 */ BasicTabbedPaneUI localBasicTabbedPaneUI = (BasicTabbedPaneUI)BasicLookAndFeel.getUIOfType(localJTabbedPane.getUI(), BasicTabbedPaneUI.class);
/* */
/* 2191 */ if (localBasicTabbedPaneUI == null) {
/* 2192 */ return;
/* */ }
/* 2194 */ if (str1 == "navigateNext") {
/* 2195 */ localBasicTabbedPaneUI.navigateSelectedTab(12);
/* */ }
/* 2197 */ else if (str1 == "navigatePrevious") {
/* 2198 */ localBasicTabbedPaneUI.navigateSelectedTab(13);
/* */ }
/* 2200 */ else if (str1 == "navigateRight") {
/* 2201 */ localBasicTabbedPaneUI.navigateSelectedTab(3);
/* */ }
/* 2203 */ else if (str1 == "navigateLeft") {
/* 2204 */ localBasicTabbedPaneUI.navigateSelectedTab(7);
/* */ }
/* 2206 */ else if (str1 == "navigateUp") {
/* 2207 */ localBasicTabbedPaneUI.navigateSelectedTab(1);
/* */ }
/* 2209 */ else if (str1 == "navigateDown") {
/* 2210 */ localBasicTabbedPaneUI.navigateSelectedTab(5);
/* */ }
/* */ else
/* */ {
/* */ int i;
/* 2212 */ if (str1 == "navigatePageUp") {
/* 2213 */ i = localJTabbedPane.getTabPlacement();
/* 2214 */ if ((i == 1) || (i == 3))
/* 2215 */ localBasicTabbedPaneUI.navigateSelectedTab(7);
/* */ else {
/* 2217 */ localBasicTabbedPaneUI.navigateSelectedTab(1);
/* */ }
/* */ }
/* 2220 */ else if (str1 == "navigatePageDown") {
/* 2221 */ i = localJTabbedPane.getTabPlacement();
/* 2222 */ if ((i == 1) || (i == 3))
/* 2223 */ localBasicTabbedPaneUI.navigateSelectedTab(3);
/* */ else {
/* 2225 */ localBasicTabbedPaneUI.navigateSelectedTab(5);
/* */ }
/* */ }
/* 2228 */ else if (str1 == "requestFocus") {
/* 2229 */ localJTabbedPane.requestFocus();
/* */ }
/* 2231 */ else if (str1 == "requestFocusForVisibleComponent") {
/* 2232 */ localBasicTabbedPaneUI.requestFocusForVisibleComponent();
/* */ }
/* 2234 */ else if (str1 == "setSelectedIndex") {
/* 2235 */ String str2 = paramActionEvent.getActionCommand();
/* */
/* 2237 */ if ((str2 != null) && (str2.length() > 0)) {
/* 2238 */ int k = paramActionEvent.getActionCommand().charAt(0);
/* 2239 */ if ((k >= 97) && (k <= 122)) {
/* 2240 */ k -= 32;
/* */ }
/* 2242 */ Integer localInteger = (Integer)localBasicTabbedPaneUI.mnemonicToIndexMap.get(Integer.valueOf(k));
/* 2243 */ if ((localInteger != null) && (localJTabbedPane.isEnabledAt(localInteger.intValue()))) {
/* 2244 */ localJTabbedPane.setSelectedIndex(localInteger.intValue());
/* */ }
/* */ }
/* */ }
/* 2248 */ else if (str1 == "selectTabWithFocus") {
/* 2249 */ int j = localBasicTabbedPaneUI.getFocusIndex();
/* 2250 */ if (j != -1) {
/* 2251 */ localJTabbedPane.setSelectedIndex(j);
/* */ }
/* */ }
/* 2254 */ else if (str1 == "scrollTabsForwardAction") {
/* 2255 */ if (localBasicTabbedPaneUI.scrollableTabLayoutEnabled()) {
/* 2256 */ localBasicTabbedPaneUI.tabScroller.scrollForward(localJTabbedPane.getTabPlacement());
/* */ }
/* */ }
/* 2259 */ else if ((str1 == "scrollTabsBackwardAction") &&
/* 2260 */ (localBasicTabbedPaneUI.scrollableTabLayoutEnabled())) {
/* 2261 */ localBasicTabbedPaneUI.tabScroller.scrollBackward(localJTabbedPane.getTabPlacement());
/* */ }
/* */ }
/* */ }
/* */ }
/* */
/* */ private class CroppedEdge extends JPanel
/* */ implements UIResource
/* */ {
/* */ private Shape shape;
/* */ private int tabIndex;
/* */ private int cropline;
/* */ private int cropx;
/* */ private int cropy;
/* */
/* */ public CroppedEdge()
/* */ {
/* 3871 */ setOpaque(false);
/* */ }
/* */
/* */ public void setParams(int paramInt1, int paramInt2, int paramInt3, int paramInt4) {
/* 3875 */ this.tabIndex = paramInt1;
/* 3876 */ this.cropline = paramInt2;
/* 3877 */ this.cropx = paramInt3;
/* 3878 */ this.cropy = paramInt4;
/* 3879 */ Rectangle localRectangle = BasicTabbedPaneUI.this.rects[paramInt1];
/* 3880 */ setBounds(localRectangle);
/* 3881 */ this.shape = BasicTabbedPaneUI.createCroppedTabShape(BasicTabbedPaneUI.this.tabPane.getTabPlacement(), localRectangle, paramInt2);
/* 3882 */ if ((getParent() == null) && (BasicTabbedPaneUI.this.tabContainer != null))
/* 3883 */ BasicTabbedPaneUI.this.tabContainer.add(this, 0);
/* */ }
/* */
/* */ public void resetParams()
/* */ {
/* 3888 */ this.shape = null;
/* 3889 */ if ((getParent() == BasicTabbedPaneUI.this.tabContainer) && (BasicTabbedPaneUI.this.tabContainer != null))
/* 3890 */ BasicTabbedPaneUI.this.tabContainer.remove(this);
/* */ }
/* */
/* */ public boolean isParamsSet()
/* */ {
/* 3895 */ return this.shape != null;
/* */ }
/* */
/* */ public int getTabIndex() {
/* 3899 */ return this.tabIndex;
/* */ }
/* */
/* */ public int getCropline() {
/* 3903 */ return this.cropline;
/* */ }
/* */
/* */ public int getCroppedSideWidth() {
/* 3907 */ return 3;
/* */ }
/* */
/* */ private Color getBgColor() {
/* 3911 */ Container localContainer = BasicTabbedPaneUI.this.tabPane.getParent();
/* 3912 */ if (localContainer != null) {
/* 3913 */ Color localColor = localContainer.getBackground();
/* 3914 */ if (localColor != null) {
/* 3915 */ return localColor;
/* */ }
/* */ }
/* 3918 */ return UIManager.getColor("control");
/* */ }
/* */
/* */ protected void paintComponent(Graphics paramGraphics) {
/* 3922 */ super.paintComponent(paramGraphics);
/* 3923 */ if ((isParamsSet()) && ((paramGraphics instanceof Graphics2D))) {
/* 3924 */ Graphics2D localGraphics2D = (Graphics2D)paramGraphics;
/* 3925 */ localGraphics2D.clipRect(0, 0, getWidth(), getHeight());
/* 3926 */ localGraphics2D.setColor(getBgColor());
/* 3927 */ localGraphics2D.translate(this.cropx, this.cropy);
/* 3928 */ localGraphics2D.fill(this.shape);
/* 3929 */ BasicTabbedPaneUI.this.paintCroppedTabEdge(paramGraphics);
/* 3930 */ localGraphics2D.translate(-this.cropx, -this.cropy);
/* */ }
/* */ }
/* */ }
/* */
/* */ public class FocusHandler extends FocusAdapter
/* */ {
/* */ public FocusHandler()
/* */ {
/* */ }
/* */
/* */ public void focusGained(FocusEvent paramFocusEvent)
/* */ {
/* 3797 */ BasicTabbedPaneUI.this.getHandler().focusGained(paramFocusEvent);
/* */ }
/* */ public void focusLost(FocusEvent paramFocusEvent) {
/* 3800 */ BasicTabbedPaneUI.this.getHandler().focusLost(paramFocusEvent);
/* */ }
/* */ }
/* */
/* */ private class Handler
/* */ implements ChangeListener, ContainerListener, FocusListener, MouseListener, MouseMotionListener, PropertyChangeListener
/* */ {
/* */ private Handler()
/* */ {
/* */ }
/* */
/* */ public void propertyChange(PropertyChangeEvent paramPropertyChangeEvent)
/* */ {
/* 3516 */ JTabbedPane localJTabbedPane = (JTabbedPane)paramPropertyChangeEvent.getSource();
/* 3517 */ String str = paramPropertyChangeEvent.getPropertyName();
/* 3518 */ boolean bool1 = BasicTabbedPaneUI.this.scrollableTabLayoutEnabled();
/* 3519 */ if (str == "mnemonicAt") {
/* 3520 */ BasicTabbedPaneUI.this.updateMnemonics();
/* 3521 */ localJTabbedPane.repaint();
/* */ }
/* 3523 */ else if (str == "displayedMnemonicIndexAt") {
/* 3524 */ localJTabbedPane.repaint();
/* */ }
/* 3526 */ else if (str == "indexForTitle") {
/* 3527 */ BasicTabbedPaneUI.this.calculatedBaseline = false;
/* 3528 */ Integer localInteger = (Integer)paramPropertyChangeEvent.getNewValue();
/* */
/* 3531 */ if (BasicTabbedPaneUI.this.htmlViews != null) {
/* 3532 */ BasicTabbedPaneUI.this.htmlViews.removeElementAt(localInteger.intValue());
/* */ }
/* 3534 */ updateHtmlViews(localInteger.intValue());
/* 3535 */ } else if (str == "tabLayoutPolicy") {
/* 3536 */ BasicTabbedPaneUI.this.uninstallUI(localJTabbedPane);
/* 3537 */ BasicTabbedPaneUI.this.installUI(localJTabbedPane);
/* 3538 */ BasicTabbedPaneUI.this.calculatedBaseline = false;
/* 3539 */ } else if (str == "tabPlacement") {
/* 3540 */ if (BasicTabbedPaneUI.this.scrollableTabLayoutEnabled()) {
/* 3541 */ BasicTabbedPaneUI.this.tabScroller.createButtons();
/* */ }
/* 3543 */ BasicTabbedPaneUI.this.calculatedBaseline = false;
/* 3544 */ } else if ((str == "opaque") && (bool1)) {
/* 3545 */ boolean bool2 = ((Boolean)paramPropertyChangeEvent.getNewValue()).booleanValue();
/* 3546 */ BasicTabbedPaneUI.this.tabScroller.tabPanel.setOpaque(bool2);
/* 3547 */ BasicTabbedPaneUI.this.tabScroller.viewport.setOpaque(bool2);
/* */ }
/* */ else
/* */ {
/* */ Object localObject;
/* 3548 */ if ((str == "background") && (bool1)) {
/* 3549 */ localObject = (Color)paramPropertyChangeEvent.getNewValue();
/* 3550 */ BasicTabbedPaneUI.this.tabScroller.tabPanel.setBackground((Color)localObject);
/* 3551 */ BasicTabbedPaneUI.this.tabScroller.viewport.setBackground((Color)localObject);
/* 3552 */ Color localColor = BasicTabbedPaneUI.this.selectedColor == null ? localObject : BasicTabbedPaneUI.this.selectedColor;
/* 3553 */ BasicTabbedPaneUI.this.tabScroller.scrollForwardButton.setBackground(localColor);
/* 3554 */ BasicTabbedPaneUI.this.tabScroller.scrollBackwardButton.setBackground(localColor);
/* 3555 */ } else if (str == "indexForTabComponent") {
/* 3556 */ if (BasicTabbedPaneUI.this.tabContainer != null) {
/* 3557 */ BasicTabbedPaneUI.TabContainer.access$1700(BasicTabbedPaneUI.this.tabContainer);
/* */ }
/* 3559 */ localObject = BasicTabbedPaneUI.this.tabPane.getTabComponentAt(((Integer)paramPropertyChangeEvent.getNewValue()).intValue());
/* */
/* 3561 */ if (localObject != null) {
/* 3562 */ if (BasicTabbedPaneUI.this.tabContainer == null)
/* 3563 */ BasicTabbedPaneUI.this.installTabContainer();
/* */ else {
/* 3565 */ BasicTabbedPaneUI.this.tabContainer.add((Component)localObject);
/* */ }
/* */ }
/* 3568 */ BasicTabbedPaneUI.this.tabPane.revalidate();
/* 3569 */ BasicTabbedPaneUI.this.tabPane.repaint();
/* 3570 */ BasicTabbedPaneUI.this.calculatedBaseline = false;
/* 3571 */ } else if (str == "indexForNullComponent") {
/* 3572 */ BasicTabbedPaneUI.this.isRunsDirty = true;
/* 3573 */ updateHtmlViews(((Integer)paramPropertyChangeEvent.getNewValue()).intValue());
/* 3574 */ } else if (str == "font") {
/* 3575 */ BasicTabbedPaneUI.this.calculatedBaseline = false;
/* */ }
/* */ }
/* */ }
/* */
/* 3580 */ private void updateHtmlViews(int paramInt) { String str = BasicTabbedPaneUI.this.tabPane.getTitleAt(paramInt);
/* 3581 */ boolean bool = BasicHTML.isHTMLString(str);
/* 3582 */ if (bool) {
/* 3583 */ if (BasicTabbedPaneUI.this.htmlViews == null) {
/* 3584 */ BasicTabbedPaneUI.this.htmlViews = BasicTabbedPaneUI.this.createHTMLVector();
/* */ } else {
/* 3586 */ View localView = BasicHTML.createHTMLView(BasicTabbedPaneUI.this.tabPane, str);
/* 3587 */ BasicTabbedPaneUI.this.htmlViews.insertElementAt(localView, paramInt);
/* */ }
/* */ }
/* 3590 */ else if (BasicTabbedPaneUI.this.htmlViews != null) {
/* 3591 */ BasicTabbedPaneUI.this.htmlViews.insertElementAt(null, paramInt);
/* */ }
/* */
/* 3594 */ BasicTabbedPaneUI.this.updateMnemonics();
/* */ }
/* */
/* */ public void stateChanged(ChangeEvent paramChangeEvent)
/* */ {
/* 3601 */ JTabbedPane localJTabbedPane = (JTabbedPane)paramChangeEvent.getSource();
/* 3602 */ localJTabbedPane.revalidate();
/* 3603 */ localJTabbedPane.repaint();
/* */
/* 3605 */ BasicTabbedPaneUI.this.setFocusIndex(localJTabbedPane.getSelectedIndex(), false);
/* */
/* 3607 */ if (BasicTabbedPaneUI.this.scrollableTabLayoutEnabled()) {
/* 3608 */ int i = localJTabbedPane.getSelectedIndex();
/* 3609 */ if ((i < BasicTabbedPaneUI.this.rects.length) && (i != -1))
/* 3610 */ BasicTabbedPaneUI.this.tabScroller.tabPanel.scrollRectToVisible((Rectangle)BasicTabbedPaneUI.this.rects[i].clone());
/* */ }
/* */ }
/* */
/* */ public void mouseClicked(MouseEvent paramMouseEvent)
/* */ {
/* */ }
/* */
/* */ public void mouseReleased(MouseEvent paramMouseEvent)
/* */ {
/* */ }
/* */
/* */ public void mouseEntered(MouseEvent paramMouseEvent)
/* */ {
/* 3626 */ BasicTabbedPaneUI.this.setRolloverTab(paramMouseEvent.getX(), paramMouseEvent.getY());
/* */ }
/* */
/* */ public void mouseExited(MouseEvent paramMouseEvent) {
/* 3630 */ BasicTabbedPaneUI.this.setRolloverTab(-1);
/* */ }
/* */
/* */ public void mousePressed(MouseEvent paramMouseEvent) {
/* 3634 */ if (!BasicTabbedPaneUI.this.tabPane.isEnabled()) {
/* 3635 */ return;
/* */ }
/* 3637 */ int i = BasicTabbedPaneUI.this.tabForCoordinate(BasicTabbedPaneUI.this.tabPane, paramMouseEvent.getX(), paramMouseEvent.getY());
/* 3638 */ if ((i >= 0) && (BasicTabbedPaneUI.this.tabPane.isEnabledAt(i)))
/* 3639 */ if (i != BasicTabbedPaneUI.this.tabPane.getSelectedIndex())
/* */ {
/* 3644 */ BasicTabbedPaneUI.this.tabPane.setSelectedIndex(i);
/* */ }
/* 3646 */ else if (BasicTabbedPaneUI.this.tabPane.isRequestFocusEnabled())
/* */ {
/* 3649 */ BasicTabbedPaneUI.this.tabPane.requestFocus();
/* */ }
/* */ }
/* */
/* */ public void mouseDragged(MouseEvent paramMouseEvent)
/* */ {
/* */ }
/* */
/* */ public void mouseMoved(MouseEvent paramMouseEvent)
/* */ {
/* 3661 */ BasicTabbedPaneUI.this.setRolloverTab(paramMouseEvent.getX(), paramMouseEvent.getY());
/* */ }
/* */
/* */ public void focusGained(FocusEvent paramFocusEvent)
/* */ {
/* 3668 */ BasicTabbedPaneUI.this.setFocusIndex(BasicTabbedPaneUI.this.tabPane.getSelectedIndex(), true);
/* */ }
/* */ public void focusLost(FocusEvent paramFocusEvent) {
/* 3671 */ BasicTabbedPaneUI.this.repaintTab(BasicTabbedPaneUI.this.focusIndex);
/* */ }
/* */
/* */ public void componentAdded(ContainerEvent paramContainerEvent)
/* */ {
/* 3709 */ JTabbedPane localJTabbedPane = (JTabbedPane)paramContainerEvent.getContainer();
/* 3710 */ Component localComponent = paramContainerEvent.getChild();
/* 3711 */ if ((localComponent instanceof UIResource)) {
/* 3712 */ return;
/* */ }
/* 3714 */ BasicTabbedPaneUI.this.isRunsDirty = true;
/* 3715 */ updateHtmlViews(localJTabbedPane.indexOfComponent(localComponent));
/* */ }
/* */ public void componentRemoved(ContainerEvent paramContainerEvent) {
/* 3718 */ JTabbedPane localJTabbedPane = (JTabbedPane)paramContainerEvent.getContainer();
/* 3719 */ Component localComponent = paramContainerEvent.getChild();
/* 3720 */ if ((localComponent instanceof UIResource)) {
/* 3721 */ return;
/* */ }
/* */
/* 3729 */ Integer localInteger = (Integer)localJTabbedPane.getClientProperty("__index_to_remove__");
/* */
/* 3731 */ if (localInteger != null) {
/* 3732 */ int i = localInteger.intValue();
/* 3733 */ if ((BasicTabbedPaneUI.this.htmlViews != null) && (BasicTabbedPaneUI.this.htmlViews.size() > i)) {
/* 3734 */ BasicTabbedPaneUI.this.htmlViews.removeElementAt(i);
/* */ }
/* 3736 */ localJTabbedPane.putClientProperty("__index_to_remove__", null);
/* */ }
/* 3738 */ BasicTabbedPaneUI.this.isRunsDirty = true;
/* 3739 */ BasicTabbedPaneUI.this.updateMnemonics();
/* */
/* 3741 */ BasicTabbedPaneUI.this.validateFocusIndex();
/* */ }
/* */ }
/* */
/* */ public class MouseHandler extends MouseAdapter
/* */ {
/* */ public MouseHandler()
/* */ {
/* */ }
/* */
/* */ public void mousePressed(MouseEvent paramMouseEvent)
/* */ {
/* 3783 */ BasicTabbedPaneUI.this.getHandler().mousePressed(paramMouseEvent);
/* */ }
/* */ }
/* */
/* */ public class PropertyChangeHandler
/* */ implements PropertyChangeListener
/* */ {
/* */ public PropertyChangeHandler()
/* */ {
/* */ }
/* */
/* */ public void propertyChange(PropertyChangeEvent paramPropertyChangeEvent)
/* */ {
/* 3755 */ BasicTabbedPaneUI.this.getHandler().propertyChange(paramPropertyChangeEvent);
/* */ }
/* */ }
/* */
/* */ private class ScrollableTabButton extends BasicArrowButton
/* */ implements UIResource, SwingConstants
/* */ {
/* */ public ScrollableTabButton(int arg2)
/* */ {
/* 3498 */ super(UIManager.getColor("TabbedPane.selected"), UIManager.getColor("TabbedPane.shadow"), UIManager.getColor("TabbedPane.darkShadow"), UIManager.getColor("TabbedPane.highlight"));
/* */ }
/* */ }
/* */
/* */ private class ScrollableTabPanel extends JPanel
/* */ implements UIResource
/* */ {
/* */ public ScrollableTabPanel()
/* */ {
/* 3467 */ super();
/* 3468 */ setOpaque(BasicTabbedPaneUI.this.tabPane.isOpaque());
/* 3469 */ Color localColor = UIManager.getColor("TabbedPane.tabAreaBackground");
/* 3470 */ if (localColor == null) {
/* 3471 */ localColor = BasicTabbedPaneUI.this.tabPane.getBackground();
/* */ }
/* 3473 */ setBackground(localColor);
/* */ }
/* */ public void paintComponent(Graphics paramGraphics) {
/* 3476 */ super.paintComponent(paramGraphics);
/* 3477 */ BasicTabbedPaneUI.this.paintTabArea(paramGraphics, BasicTabbedPaneUI.this.tabPane.getTabPlacement(), BasicTabbedPaneUI.this.tabPane.getSelectedIndex());
/* */
/* 3479 */ if ((BasicTabbedPaneUI.this.tabScroller.croppedEdge.isParamsSet()) && (BasicTabbedPaneUI.this.tabContainer == null)) {
/* 3480 */ Rectangle localRectangle = BasicTabbedPaneUI.this.rects[BasicTabbedPaneUI.this.tabScroller.croppedEdge.getTabIndex()];
/* 3481 */ paramGraphics.translate(localRectangle.x, localRectangle.y);
/* 3482 */ BasicTabbedPaneUI.this.tabScroller.croppedEdge.paintComponent(paramGraphics);
/* 3483 */ paramGraphics.translate(-localRectangle.x, -localRectangle.y);
/* */ }
/* */ }
/* */
/* */ public void doLayout() {
/* 3488 */ if (getComponentCount() > 0) {
/* 3489 */ Component localComponent = getComponent(0);
/* 3490 */ localComponent.setBounds(0, 0, getWidth(), getHeight());
/* */ }
/* */ }
/* */ }
/* */
/* */ private class ScrollableTabSupport
/* */ implements ActionListener, ChangeListener
/* */ {
/* */ public BasicTabbedPaneUI.ScrollableTabViewport viewport;
/* */ public BasicTabbedPaneUI.ScrollableTabPanel tabPanel;
/* */ public JButton scrollForwardButton;
/* */ public JButton scrollBackwardButton;
/* */ public BasicTabbedPaneUI.CroppedEdge croppedEdge;
/* */ public int leadingTabIndex;
/* 3254 */ private Point tabViewPosition = new Point(0, 0);
/* */
/* */ ScrollableTabSupport(int arg2) {
/* 3257 */ this.viewport = new BasicTabbedPaneUI.ScrollableTabViewport(BasicTabbedPaneUI.this);
/* 3258 */ this.tabPanel = new BasicTabbedPaneUI.ScrollableTabPanel(BasicTabbedPaneUI.this);
/* 3259 */ this.viewport.setView(this.tabPanel);
/* 3260 */ this.viewport.addChangeListener(this);
/* 3261 */ this.croppedEdge = new BasicTabbedPaneUI.CroppedEdge(BasicTabbedPaneUI.this);
/* 3262 */ createButtons();
/* */ }
/* */
/* */ void createButtons()
/* */ {
/* 3269 */ if (this.scrollForwardButton != null) {
/* 3270 */ BasicTabbedPaneUI.this.tabPane.remove(this.scrollForwardButton);
/* 3271 */ this.scrollForwardButton.removeActionListener(this);
/* 3272 */ BasicTabbedPaneUI.this.tabPane.remove(this.scrollBackwardButton);
/* 3273 */ this.scrollBackwardButton.removeActionListener(this);
/* */ }
/* 3275 */ int i = BasicTabbedPaneUI.this.tabPane.getTabPlacement();
/* 3276 */ if ((i == 1) || (i == 3)) {
/* 3277 */ this.scrollForwardButton = BasicTabbedPaneUI.this.createScrollButton(3);
/* 3278 */ this.scrollBackwardButton = BasicTabbedPaneUI.this.createScrollButton(7);
/* */ }
/* */ else {
/* 3281 */ this.scrollForwardButton = BasicTabbedPaneUI.this.createScrollButton(5);
/* 3282 */ this.scrollBackwardButton = BasicTabbedPaneUI.this.createScrollButton(1);
/* */ }
/* 3284 */ this.scrollForwardButton.addActionListener(this);
/* 3285 */ this.scrollBackwardButton.addActionListener(this);
/* 3286 */ BasicTabbedPaneUI.this.tabPane.add(this.scrollForwardButton);
/* 3287 */ BasicTabbedPaneUI.this.tabPane.add(this.scrollBackwardButton);
/* */ }
/* */
/* */ public void scrollForward(int paramInt) {
/* 3291 */ Dimension localDimension = this.viewport.getViewSize();
/* 3292 */ Rectangle localRectangle = this.viewport.getViewRect();
/* */
/* 3294 */ if ((paramInt == 1) || (paramInt == 3))
/* */ {
/* 3295 */ if (localRectangle.width < localDimension.width - localRectangle.x);
/* */ }
/* 3299 */ else if (localRectangle.height >= localDimension.height - localRectangle.y) {
/* 3300 */ return;
/* */ }
/* */
/* 3303 */ setLeadingTabIndex(paramInt, this.leadingTabIndex + 1);
/* */ }
/* */
/* */ public void scrollBackward(int paramInt) {
/* 3307 */ if (this.leadingTabIndex == 0) {
/* 3308 */ return;
/* */ }
/* 3310 */ setLeadingTabIndex(paramInt, this.leadingTabIndex - 1);
/* */ }
/* */
/* */ public void setLeadingTabIndex(int paramInt1, int paramInt2) {
/* 3314 */ this.leadingTabIndex = paramInt2;
/* 3315 */ Dimension localDimension1 = this.viewport.getViewSize();
/* 3316 */ Rectangle localRectangle = this.viewport.getViewRect();
/* */ Dimension localDimension2;
/* 3318 */ switch (paramInt1) {
/* */ case 1:
/* */ case 3:
/* 3321 */ this.tabViewPosition.x = (this.leadingTabIndex == 0 ? 0 : BasicTabbedPaneUI.this.rects[this.leadingTabIndex].x);
/* */
/* 3323 */ if (localDimension1.width - this.tabViewPosition.x < localRectangle.width)
/* */ {
/* 3326 */ localDimension2 = new Dimension(localDimension1.width - this.tabViewPosition.x, localRectangle.height);
/* */
/* 3328 */ this.viewport.setExtentSize(localDimension2);
/* 3329 */ }break;
/* */ case 2:
/* */ case 4:
/* 3333 */ this.tabViewPosition.y = (this.leadingTabIndex == 0 ? 0 : BasicTabbedPaneUI.this.rects[this.leadingTabIndex].y);
/* */
/* 3335 */ if (localDimension1.height - this.tabViewPosition.y < localRectangle.height)
/* */ {
/* 3338 */ localDimension2 = new Dimension(localRectangle.width, localDimension1.height - this.tabViewPosition.y);
/* */
/* 3340 */ this.viewport.setExtentSize(localDimension2);
/* */ }break;
/* */ }
/* 3343 */ this.viewport.setViewPosition(this.tabViewPosition);
/* */ }
/* */
/* */ public void stateChanged(ChangeEvent paramChangeEvent) {
/* 3347 */ updateView();
/* */ }
/* */
/* */ private void updateView() {
/* 3351 */ int i = BasicTabbedPaneUI.this.tabPane.getTabPlacement();
/* 3352 */ int j = BasicTabbedPaneUI.this.tabPane.getTabCount();
/* 3353 */ Rectangle localRectangle1 = this.viewport.getBounds();
/* 3354 */ Dimension localDimension = this.viewport.getViewSize();
/* 3355 */ Rectangle localRectangle2 = this.viewport.getViewRect();
/* */
/* 3357 */ this.leadingTabIndex = BasicTabbedPaneUI.this.getClosestTab(localRectangle2.x, localRectangle2.y);
/* */
/* 3360 */ if (this.leadingTabIndex + 1 < j) {
/* 3361 */ switch (i) {
/* */ case 1:
/* */ case 3:
/* 3364 */ if (BasicTabbedPaneUI.this.rects[this.leadingTabIndex].x < localRectangle2.x)
/* 3365 */ this.leadingTabIndex += 1; break;
/* */ case 2:
/* */ case 4:
/* 3370 */ if (BasicTabbedPaneUI.this.rects[this.leadingTabIndex].y < localRectangle2.y) {
/* 3371 */ this.leadingTabIndex += 1;
/* */ }
/* */ break;
/* */ }
/* */ }
/* 3376 */ Insets localInsets = BasicTabbedPaneUI.this.getContentBorderInsets(i);
/* 3377 */ switch (i) {
/* */ case 2:
/* 3379 */ BasicTabbedPaneUI.this.tabPane.repaint(localRectangle1.x + localRectangle1.width, localRectangle1.y, localInsets.left, localRectangle1.height);
/* */
/* 3381 */ this.scrollBackwardButton.setEnabled((localRectangle2.y > 0) && (this.leadingTabIndex > 0));
/* */
/* 3383 */ this.scrollForwardButton.setEnabled((this.leadingTabIndex < j - 1) && (localDimension.height - localRectangle2.y > localRectangle2.height));
/* */
/* 3386 */ break;
/* */ case 4:
/* 3388 */ BasicTabbedPaneUI.this.tabPane.repaint(localRectangle1.x - localInsets.right, localRectangle1.y, localInsets.right, localRectangle1.height);
/* */
/* 3390 */ this.scrollBackwardButton.setEnabled((localRectangle2.y > 0) && (this.leadingTabIndex > 0));
/* */
/* 3392 */ this.scrollForwardButton.setEnabled((this.leadingTabIndex < j - 1) && (localDimension.height - localRectangle2.y > localRectangle2.height));
/* */
/* 3395 */ break;
/* */ case 3:
/* 3397 */ BasicTabbedPaneUI.this.tabPane.repaint(localRectangle1.x, localRectangle1.y - localInsets.bottom, localRectangle1.width, localInsets.bottom);
/* */
/* 3399 */ this.scrollBackwardButton.setEnabled((localRectangle2.x > 0) && (this.leadingTabIndex > 0));
/* */
/* 3401 */ this.scrollForwardButton.setEnabled((this.leadingTabIndex < j - 1) && (localDimension.width - localRectangle2.x > localRectangle2.width));
/* */
/* 3404 */ break;
/* */ case 1:
/* */ default:
/* 3407 */ BasicTabbedPaneUI.this.tabPane.repaint(localRectangle1.x, localRectangle1.y + localRectangle1.height, localRectangle1.width, localInsets.top);
/* */
/* 3409 */ this.scrollBackwardButton.setEnabled((localRectangle2.x > 0) && (this.leadingTabIndex > 0));
/* */
/* 3411 */ this.scrollForwardButton.setEnabled((this.leadingTabIndex < j - 1) && (localDimension.width - localRectangle2.x > localRectangle2.width));
/* */ }
/* */ }
/* */
/* */ public void actionPerformed(ActionEvent paramActionEvent)
/* */ {
/* 3421 */ ActionMap localActionMap = BasicTabbedPaneUI.this.tabPane.getActionMap();
/* */
/* 3423 */ if (localActionMap != null)
/* */ {
/* */ String str;
/* 3426 */ if (paramActionEvent.getSource() == this.scrollForwardButton) {
/* 3427 */ str = "scrollTabsForwardAction";
/* */ }
/* */ else {
/* 3430 */ str = "scrollTabsBackwardAction";
/* */ }
/* 3432 */ Action localAction = localActionMap.get(str);
/* */
/* 3434 */ if ((localAction != null) && (localAction.isEnabled()))
/* 3435 */ localAction.actionPerformed(new ActionEvent(BasicTabbedPaneUI.this.tabPane, 1001, null, paramActionEvent.getWhen(), paramActionEvent.getModifiers()));
/* */ }
/* */ }
/* */
/* */ public String toString()
/* */ {
/* 3443 */ return "viewport.viewSize=" + this.viewport.getViewSize() + "\n" + "viewport.viewRectangle=" + this.viewport.getViewRect() + "\n" + "leadingTabIndex=" + this.leadingTabIndex + "\n" + "tabViewPosition=" + this.tabViewPosition;
/* */ }
/* */ }
/* */
/* */ private class ScrollableTabViewport extends JViewport
/* */ implements UIResource
/* */ {
/* */ public ScrollableTabViewport()
/* */ {
/* 3454 */ setName("TabbedPane.scrollableViewport");
/* 3455 */ setScrollMode(0);
/* 3456 */ setOpaque(BasicTabbedPaneUI.this.tabPane.isOpaque());
/* 3457 */ Color localColor = UIManager.getColor("TabbedPane.tabAreaBackground");
/* 3458 */ if (localColor == null) {
/* 3459 */ localColor = BasicTabbedPaneUI.this.tabPane.getBackground();
/* */ }
/* 3461 */ setBackground(localColor);
/* */ }
/* */ }
/* */
/* */ private class TabContainer extends JPanel
/* */ implements UIResource
/* */ {
/* 3821 */ private boolean notifyTabbedPane = true;
/* */
/* */ public TabContainer() {
/* 3824 */ super();
/* 3825 */ setOpaque(false);
/* */ }
/* */
/* */ public void remove(Component paramComponent) {
/* 3829 */ int i = BasicTabbedPaneUI.this.tabPane.indexOfTabComponent(paramComponent);
/* 3830 */ super.remove(paramComponent);
/* 3831 */ if ((this.notifyTabbedPane) && (i != -1))
/* 3832 */ BasicTabbedPaneUI.this.tabPane.setTabComponentAt(i, null);
/* */ }
/* */
/* */ private void removeUnusedTabComponents()
/* */ {
/* 3837 */ for (Component localComponent : getComponents())
/* 3838 */ if (!(localComponent instanceof UIResource)) {
/* 3839 */ int k = BasicTabbedPaneUI.this.tabPane.indexOfTabComponent(localComponent);
/* 3840 */ if (k == -1)
/* 3841 */ super.remove(localComponent);
/* */ }
/* */ }
/* */
/* */ public boolean isOptimizedDrawingEnabled()
/* */ {
/* 3848 */ return (BasicTabbedPaneUI.this.tabScroller != null) && (!BasicTabbedPaneUI.this.tabScroller.croppedEdge.isParamsSet());
/* */ }
/* */
/* */ public void doLayout()
/* */ {
/* 3855 */ if (BasicTabbedPaneUI.this.scrollableTabLayoutEnabled()) {
/* 3856 */ BasicTabbedPaneUI.this.tabScroller.tabPanel.repaint();
/* 3857 */ BasicTabbedPaneUI.this.tabScroller.updateView();
/* */ } else {
/* 3859 */ BasicTabbedPaneUI.this.tabPane.repaint(getBounds());
/* */ }
/* */ }
/* */ }
/* */
/* */ public class TabSelectionHandler
/* */ implements ChangeListener
/* */ {
/* */ public TabSelectionHandler()
/* */ {
/* */ }
/* */
/* */ public void stateChanged(ChangeEvent paramChangeEvent)
/* */ {
/* 3769 */ BasicTabbedPaneUI.this.getHandler().stateChanged(paramChangeEvent);
/* */ }
/* */ }
/* */
/* */ public class TabbedPaneLayout
/* */ implements LayoutManager
/* */ {
/* */ public TabbedPaneLayout()
/* */ {
/* */ }
/* */
/* */ public void addLayoutComponent(String paramString, Component paramComponent)
/* */ {
/* */ }
/* */
/* */ public void removeLayoutComponent(Component paramComponent)
/* */ {
/* */ }
/* */
/* */ public Dimension preferredLayoutSize(Container paramContainer)
/* */ {
/* 2278 */ return calculateSize(false);
/* */ }
/* */
/* */ public Dimension minimumLayoutSize(Container paramContainer) {
/* 2282 */ return calculateSize(true);
/* */ }
/* */
/* */ protected Dimension calculateSize(boolean paramBoolean) {
/* 2286 */ int i = BasicTabbedPaneUI.this.tabPane.getTabPlacement();
/* 2287 */ Insets localInsets1 = BasicTabbedPaneUI.this.tabPane.getInsets();
/* 2288 */ Insets localInsets2 = BasicTabbedPaneUI.this.getContentBorderInsets(i);
/* 2289 */ Insets localInsets3 = BasicTabbedPaneUI.this.getTabAreaInsets(i);
/* */
/* 2291 */ Dimension localDimension1 = new Dimension(0, 0);
/* 2292 */ int j = 0;
/* 2293 */ int k = 0;
/* 2294 */ int m = 0;
/* 2295 */ int n = 0;
/* */
/* 2300 */ for (int i1 = 0; i1 < BasicTabbedPaneUI.this.tabPane.getTabCount(); i1++) {
/* 2301 */ Component localComponent = BasicTabbedPaneUI.this.tabPane.getComponentAt(i1);
/* 2302 */ if (localComponent != null) {
/* 2303 */ Dimension localDimension2 = paramBoolean ? localComponent.getMinimumSize() : localComponent.getPreferredSize();
/* */
/* 2306 */ if (localDimension2 != null) {
/* 2307 */ n = Math.max(localDimension2.height, n);
/* 2308 */ m = Math.max(localDimension2.width, m);
/* */ }
/* */ }
/* */ }
/* */
/* 2313 */ k += m;
/* 2314 */ j += n;
/* */
/* 2320 */ switch (i) {
/* */ case 2:
/* */ case 4:
/* 2323 */ j = Math.max(j, BasicTabbedPaneUI.this.calculateMaxTabHeight(i));
/* 2324 */ i1 = preferredTabAreaWidth(i, j - localInsets3.top - localInsets3.bottom);
/* 2325 */ k += i1;
/* 2326 */ break;
/* */ case 1:
/* */ case 3:
/* */ default:
/* 2330 */ k = Math.max(k, BasicTabbedPaneUI.this.calculateMaxTabWidth(i));
/* 2331 */ i1 = preferredTabAreaHeight(i, k - localInsets3.left - localInsets3.right);
/* 2332 */ j += i1;
/* */ }
/* 2334 */ return new Dimension(k + localInsets1.left + localInsets1.right + localInsets2.left + localInsets2.right, j + localInsets1.bottom + localInsets1.top + localInsets2.top + localInsets2.bottom);
/* */ }
/* */
/* */ protected int preferredTabAreaHeight(int paramInt1, int paramInt2)
/* */ {
/* 2340 */ FontMetrics localFontMetrics = BasicTabbedPaneUI.this.getFontMetrics();
/* 2341 */ int i = BasicTabbedPaneUI.this.tabPane.getTabCount();
/* 2342 */ int j = 0;
/* 2343 */ if (i > 0) {
/* 2344 */ int k = 1;
/* 2345 */ int m = 0;
/* */
/* 2347 */ int n = BasicTabbedPaneUI.this.calculateMaxTabHeight(paramInt1);
/* */
/* 2349 */ for (int i1 = 0; i1 < i; i1++) {
/* 2350 */ int i2 = BasicTabbedPaneUI.this.calculateTabWidth(paramInt1, i1, localFontMetrics);
/* */
/* 2352 */ if ((m != 0) && (m + i2 > paramInt2)) {
/* 2353 */ k++;
/* 2354 */ m = 0;
/* */ }
/* 2356 */ m += i2;
/* */ }
/* 2358 */ j = BasicTabbedPaneUI.this.calculateTabAreaHeight(paramInt1, k, n);
/* */ }
/* 2360 */ return j;
/* */ }
/* */
/* */ protected int preferredTabAreaWidth(int paramInt1, int paramInt2) {
/* 2364 */ FontMetrics localFontMetrics = BasicTabbedPaneUI.this.getFontMetrics();
/* 2365 */ int i = BasicTabbedPaneUI.this.tabPane.getTabCount();
/* 2366 */ int j = 0;
/* 2367 */ if (i > 0) {
/* 2368 */ int k = 1;
/* 2369 */ int m = 0;
/* 2370 */ int n = localFontMetrics.getHeight();
/* */
/* 2372 */ BasicTabbedPaneUI.this.maxTabWidth = BasicTabbedPaneUI.this.calculateMaxTabWidth(paramInt1);
/* */
/* 2374 */ for (int i1 = 0; i1 < i; i1++) {
/* 2375 */ int i2 = BasicTabbedPaneUI.this.calculateTabHeight(paramInt1, i1, n);
/* */
/* 2377 */ if ((m != 0) && (m + i2 > paramInt2)) {
/* 2378 */ k++;
/* 2379 */ m = 0;
/* */ }
/* 2381 */ m += i2;
/* */ }
/* 2383 */ j = BasicTabbedPaneUI.this.calculateTabAreaWidth(paramInt1, k, BasicTabbedPaneUI.this.maxTabWidth);
/* */ }
/* 2385 */ return j;
/* */ }
/* */
/* */ public void layoutContainer(Container paramContainer)
/* */ {
/* 2400 */ BasicTabbedPaneUI.this.setRolloverTab(-1);
/* */
/* 2402 */ int i = BasicTabbedPaneUI.this.tabPane.getTabPlacement();
/* 2403 */ Insets localInsets1 = BasicTabbedPaneUI.this.tabPane.getInsets();
/* 2404 */ int j = BasicTabbedPaneUI.this.tabPane.getSelectedIndex();
/* 2405 */ Component localComponent1 = BasicTabbedPaneUI.this.getVisibleComponent();
/* */
/* 2407 */ calculateLayoutInfo();
/* */
/* 2409 */ Component localComponent2 = null;
/* 2410 */ if (j < 0) {
/* 2411 */ if (localComponent1 != null)
/* */ {
/* 2413 */ BasicTabbedPaneUI.this.setVisibleComponent(null);
/* */ }
/* */ }
/* 2416 */ else localComponent2 = BasicTabbedPaneUI.this.tabPane.getComponentAt(j);
/* */
/* 2419 */ int i2 = 0;
/* 2420 */ int i3 = 0;
/* 2421 */ Insets localInsets2 = BasicTabbedPaneUI.this.getContentBorderInsets(i);
/* */
/* 2423 */ int i4 = 0;
/* */
/* 2432 */ if (localComponent2 != null) {
/* 2433 */ if ((localComponent2 != localComponent1) && (localComponent1 != null))
/* */ {
/* 2435 */ if (SwingUtilities.findFocusOwner(localComponent1) != null) {
/* 2436 */ i4 = 1;
/* */ }
/* */ }
/* 2439 */ BasicTabbedPaneUI.this.setVisibleComponent(localComponent2);
/* */ }
/* */
/* 2442 */ Rectangle localRectangle = BasicTabbedPaneUI.this.tabPane.getBounds();
/* 2443 */ int i5 = BasicTabbedPaneUI.this.tabPane.getComponentCount();
/* */
/* 2445 */ if (i5 > 0)
/* */ {
/* */ int k;
/* */ int m;
/* 2447 */ switch (i) {
/* */ case 2:
/* 2449 */ i2 = BasicTabbedPaneUI.this.calculateTabAreaWidth(i, BasicTabbedPaneUI.this.runCount, BasicTabbedPaneUI.this.maxTabWidth);
/* 2450 */ k = localInsets1.left + i2 + localInsets2.left;
/* 2451 */ m = localInsets1.top + localInsets2.top;
/* 2452 */ break;
/* */ case 4:
/* 2454 */ i2 = BasicTabbedPaneUI.this.calculateTabAreaWidth(i, BasicTabbedPaneUI.this.runCount, BasicTabbedPaneUI.this.maxTabWidth);
/* 2455 */ k = localInsets1.left + localInsets2.left;
/* 2456 */ m = localInsets1.top + localInsets2.top;
/* 2457 */ break;
/* */ case 3:
/* 2459 */ i3 = BasicTabbedPaneUI.this.calculateTabAreaHeight(i, BasicTabbedPaneUI.this.runCount, BasicTabbedPaneUI.this.maxTabHeight);
/* 2460 */ k = localInsets1.left + localInsets2.left;
/* 2461 */ m = localInsets1.top + localInsets2.top;
/* 2462 */ break;
/* */ case 1:
/* */ default:
/* 2465 */ i3 = BasicTabbedPaneUI.this.calculateTabAreaHeight(i, BasicTabbedPaneUI.this.runCount, BasicTabbedPaneUI.this.maxTabHeight);
/* 2466 */ k = localInsets1.left + localInsets2.left;
/* 2467 */ m = localInsets1.top + i3 + localInsets2.top;
/* */ }
/* */
/* 2470 */ int n = localRectangle.width - i2 - localInsets1.left - localInsets1.right - localInsets2.left - localInsets2.right;
/* */
/* 2473 */ int i1 = localRectangle.height - i3 - localInsets1.top - localInsets1.bottom - localInsets2.top - localInsets2.bottom;
/* */
/* 2477 */ for (int i6 = 0; i6 < i5; i6++) {
/* 2478 */ Component localComponent3 = BasicTabbedPaneUI.this.tabPane.getComponent(i6);
/* 2479 */ if (localComponent3 == BasicTabbedPaneUI.this.tabContainer)
/* */ {
/* 2481 */ int i7 = i2 == 0 ? localRectangle.width : i2 + localInsets1.left + localInsets1.right + localInsets2.left + localInsets2.right;
/* */
/* 2484 */ int i8 = i3 == 0 ? localRectangle.height : i3 + localInsets1.top + localInsets1.bottom + localInsets2.top + localInsets2.bottom;
/* */
/* 2488 */ int i9 = 0;
/* 2489 */ int i10 = 0;
/* 2490 */ if (i == 3)
/* 2491 */ i10 = localRectangle.height - i8;
/* 2492 */ else if (i == 4) {
/* 2493 */ i9 = localRectangle.width - i7;
/* */ }
/* 2495 */ localComponent3.setBounds(i9, i10, i7, i8);
/* */ } else {
/* 2497 */ localComponent3.setBounds(k, m, n, i1);
/* */ }
/* */ }
/* */ }
/* 2501 */ layoutTabComponents();
/* 2502 */ if ((i4 != 0) &&
/* 2503 */ (!BasicTabbedPaneUI.this.requestFocusForVisibleComponent()))
/* 2504 */ BasicTabbedPaneUI.this.tabPane.requestFocus();
/* */ }
/* */
/* */ public void calculateLayoutInfo()
/* */ {
/* 2510 */ int i = BasicTabbedPaneUI.this.tabPane.getTabCount();
/* 2511 */ BasicTabbedPaneUI.this.assureRectsCreated(i);
/* 2512 */ calculateTabRects(BasicTabbedPaneUI.this.tabPane.getTabPlacement(), i);
/* 2513 */ BasicTabbedPaneUI.this.isRunsDirty = false;
/* */ }
/* */
/* */ private void layoutTabComponents() {
/* 2517 */ if (BasicTabbedPaneUI.this.tabContainer == null) {
/* 2518 */ return;
/* */ }
/* 2520 */ Rectangle localRectangle = new Rectangle();
/* 2521 */ Point localPoint = new Point(-BasicTabbedPaneUI.this.tabContainer.getX(), -BasicTabbedPaneUI.this.tabContainer.getY());
/* 2522 */ if (BasicTabbedPaneUI.this.scrollableTabLayoutEnabled()) {
/* 2523 */ BasicTabbedPaneUI.this.translatePointToTabPanel(0, 0, localPoint);
/* */ }
/* 2525 */ for (int i = 0; i < BasicTabbedPaneUI.this.tabPane.getTabCount(); i++) {
/* 2526 */ Component localComponent = BasicTabbedPaneUI.this.tabPane.getTabComponentAt(i);
/* 2527 */ if (localComponent != null)
/* */ {
/* 2530 */ BasicTabbedPaneUI.this.getTabBounds(i, localRectangle);
/* 2531 */ Dimension localDimension = localComponent.getPreferredSize();
/* 2532 */ Insets localInsets = BasicTabbedPaneUI.this.getTabInsets(BasicTabbedPaneUI.this.tabPane.getTabPlacement(), i);
/* 2533 */ int j = localRectangle.x + localInsets.left + localPoint.x;
/* 2534 */ int k = localRectangle.y + localInsets.top + localPoint.y;
/* 2535 */ int m = localRectangle.width - localInsets.left - localInsets.right;
/* 2536 */ int n = localRectangle.height - localInsets.top - localInsets.bottom;
/* */
/* 2538 */ int i1 = j + (m - localDimension.width) / 2;
/* 2539 */ int i2 = k + (n - localDimension.height) / 2;
/* 2540 */ int i3 = BasicTabbedPaneUI.this.tabPane.getTabPlacement();
/* 2541 */ boolean bool = i == BasicTabbedPaneUI.this.tabPane.getSelectedIndex();
/* 2542 */ localComponent.setBounds(i1 + BasicTabbedPaneUI.this.getTabLabelShiftX(i3, i, bool), i2 + BasicTabbedPaneUI.this.getTabLabelShiftY(i3, i, bool), localDimension.width, localDimension.height);
/* */ }
/* */ }
/* */ }
/* */
/* */ protected void calculateTabRects(int paramInt1, int paramInt2)
/* */ {
/* 2549 */ FontMetrics localFontMetrics = BasicTabbedPaneUI.this.getFontMetrics();
/* 2550 */ Dimension localDimension = BasicTabbedPaneUI.this.tabPane.getSize();
/* 2551 */ Insets localInsets1 = BasicTabbedPaneUI.this.tabPane.getInsets();
/* 2552 */ Insets localInsets2 = BasicTabbedPaneUI.this.getTabAreaInsets(paramInt1);
/* 2553 */ int i = localFontMetrics.getHeight();
/* 2554 */ int j = BasicTabbedPaneUI.this.tabPane.getSelectedIndex();
/* */
/* 2559 */ int i4 = (paramInt1 == 2) || (paramInt1 == 4) ? 1 : 0;
/* 2560 */ boolean bool = BasicGraphicsUtils.isLeftToRight(BasicTabbedPaneUI.this.tabPane);
/* */ int i1;
/* */ int i2;
/* */ int i3;
/* 2565 */ switch (paramInt1) {
/* */ case 2:
/* 2567 */ BasicTabbedPaneUI.this.maxTabWidth = BasicTabbedPaneUI.this.calculateMaxTabWidth(paramInt1);
/* 2568 */ i1 = localInsets1.left + localInsets2.left;
/* 2569 */ i2 = localInsets1.top + localInsets2.top;
/* 2570 */ i3 = localDimension.height - (localInsets1.bottom + localInsets2.bottom);
/* 2571 */ break;
/* */ case 4:
/* 2573 */ BasicTabbedPaneUI.this.maxTabWidth = BasicTabbedPaneUI.this.calculateMaxTabWidth(paramInt1);
/* 2574 */ i1 = localDimension.width - localInsets1.right - localInsets2.right - BasicTabbedPaneUI.this.maxTabWidth;
/* 2575 */ i2 = localInsets1.top + localInsets2.top;
/* 2576 */ i3 = localDimension.height - (localInsets1.bottom + localInsets2.bottom);
/* 2577 */ break;
/* */ case 3:
/* 2579 */ BasicTabbedPaneUI.this.maxTabHeight = BasicTabbedPaneUI.this.calculateMaxTabHeight(paramInt1);
/* 2580 */ i1 = localInsets1.left + localInsets2.left;
/* 2581 */ i2 = localDimension.height - localInsets1.bottom - localInsets2.bottom - BasicTabbedPaneUI.this.maxTabHeight;
/* 2582 */ i3 = localDimension.width - (localInsets1.right + localInsets2.right);
/* 2583 */ break;
/* */ case 1:
/* */ default:
/* 2586 */ BasicTabbedPaneUI.this.maxTabHeight = BasicTabbedPaneUI.this.calculateMaxTabHeight(paramInt1);
/* 2587 */ i1 = localInsets1.left + localInsets2.left;
/* 2588 */ i2 = localInsets1.top + localInsets2.top;
/* 2589 */ i3 = localDimension.width - (localInsets1.right + localInsets2.right);
/* */ }
/* */
/* 2593 */ int k = BasicTabbedPaneUI.this.getTabRunOverlay(paramInt1);
/* */
/* 2595 */ BasicTabbedPaneUI.this.runCount = 0;
/* 2596 */ BasicTabbedPaneUI.this.selectedRun = -1;
/* */
/* 2598 */ if (paramInt2 == 0)
/* */ return;
/* */ Rectangle localRectangle;
/* 2604 */ for (int m = 0; m < paramInt2; m++) {
/* 2605 */ localRectangle = BasicTabbedPaneUI.this.rects[m];
/* */
/* 2607 */ if (i4 == 0)
/* */ {
/* 2609 */ if (m > 0) {
/* 2610 */ localRectangle.x = (BasicTabbedPaneUI.this.rects[(m - 1)].x + BasicTabbedPaneUI.this.rects[(m - 1)].width);
/* */ } else {
/* 2612 */ BasicTabbedPaneUI.this.tabRuns[0] = 0;
/* 2613 */ BasicTabbedPaneUI.this.runCount = 1;
/* 2614 */ BasicTabbedPaneUI.this.maxTabWidth = 0;
/* 2615 */ localRectangle.x = i1;
/* */ }
/* 2617 */ localRectangle.width = BasicTabbedPaneUI.this.calculateTabWidth(paramInt1, m, localFontMetrics);
/* 2618 */ BasicTabbedPaneUI.this.maxTabWidth = Math.max(BasicTabbedPaneUI.this.maxTabWidth, localRectangle.width);
/* */
/* 2623 */ if ((localRectangle.x != 2 + localInsets1.left) && (localRectangle.x + localRectangle.width > i3)) {
/* 2624 */ if (BasicTabbedPaneUI.this.runCount > BasicTabbedPaneUI.this.tabRuns.length - 1) {
/* 2625 */ BasicTabbedPaneUI.this.expandTabRunsArray();
/* */ }
/* 2627 */ BasicTabbedPaneUI.this.tabRuns[BasicTabbedPaneUI.this.runCount] = m;
/* 2628 */ BasicTabbedPaneUI.this.runCount += 1;
/* 2629 */ localRectangle.x = i1;
/* */ }
/* */
/* 2632 */ localRectangle.y = i2;
/* 2633 */ localRectangle.height = BasicTabbedPaneUI.this.maxTabHeight;
/* */ }
/* */ else
/* */ {
/* 2637 */ if (m > 0) {
/* 2638 */ localRectangle.y = (BasicTabbedPaneUI.this.rects[(m - 1)].y + BasicTabbedPaneUI.this.rects[(m - 1)].height);
/* */ } else {
/* 2640 */ BasicTabbedPaneUI.this.tabRuns[0] = 0;
/* 2641 */ BasicTabbedPaneUI.this.runCount = 1;
/* 2642 */ BasicTabbedPaneUI.this.maxTabHeight = 0;
/* 2643 */ localRectangle.y = i2;
/* */ }
/* 2645 */ localRectangle.height = BasicTabbedPaneUI.this.calculateTabHeight(paramInt1, m, i);
/* 2646 */ BasicTabbedPaneUI.this.maxTabHeight = Math.max(BasicTabbedPaneUI.this.maxTabHeight, localRectangle.height);
/* */
/* 2651 */ if ((localRectangle.y != 2 + localInsets1.top) && (localRectangle.y + localRectangle.height > i3)) {
/* 2652 */ if (BasicTabbedPaneUI.this.runCount > BasicTabbedPaneUI.this.tabRuns.length - 1) {
/* 2653 */ BasicTabbedPaneUI.this.expandTabRunsArray();
/* */ }
/* 2655 */ BasicTabbedPaneUI.this.tabRuns[BasicTabbedPaneUI.this.runCount] = m;
/* 2656 */ BasicTabbedPaneUI.this.runCount += 1;
/* 2657 */ localRectangle.y = i2;
/* */ }
/* */
/* 2660 */ localRectangle.x = i1;
/* 2661 */ localRectangle.width = BasicTabbedPaneUI.this.maxTabWidth;
/* */ }
/* */
/* 2664 */ if (m == j) {
/* 2665 */ BasicTabbedPaneUI.this.selectedRun = (BasicTabbedPaneUI.this.runCount - 1);
/* */ }
/* */ }
/* */
/* 2669 */ if (BasicTabbedPaneUI.this.runCount > 1)
/* */ {
/* 2671 */ normalizeTabRuns(paramInt1, paramInt2, i4 != 0 ? i2 : i1, i3);
/* */
/* 2673 */ BasicTabbedPaneUI.this.selectedRun = BasicTabbedPaneUI.this.getRunForTab(paramInt2, j);
/* */
/* 2676 */ if (BasicTabbedPaneUI.this.shouldRotateTabRuns(paramInt1))
/* 2677 */ rotateTabRuns(paramInt1, BasicTabbedPaneUI.this.selectedRun);
/* */ }
/* */ int i5;
/* 2683 */ for (m = BasicTabbedPaneUI.this.runCount - 1; m >= 0; m--) {
/* 2684 */ i5 = BasicTabbedPaneUI.this.tabRuns[m];
/* 2685 */ int i6 = BasicTabbedPaneUI.this.tabRuns[(m + 1)];
/* 2686 */ int i7 = i6 != 0 ? i6 - 1 : paramInt2 - 1;
/* */ int n;
/* 2687 */ if (i4 == 0) {
/* 2688 */ for (n = i5; n <= i7; n++) {
/* 2689 */ localRectangle = BasicTabbedPaneUI.this.rects[n];
/* 2690 */ localRectangle.y = i2;
/* 2691 */ localRectangle.x += BasicTabbedPaneUI.this.getTabRunIndent(paramInt1, m);
/* */ }
/* 2693 */ if (BasicTabbedPaneUI.this.shouldPadTabRun(paramInt1, m)) {
/* 2694 */ padTabRun(paramInt1, i5, i7, i3);
/* */ }
/* 2696 */ if (paramInt1 == 3)
/* 2697 */ i2 -= BasicTabbedPaneUI.this.maxTabHeight - k;
/* */ else
/* 2699 */ i2 += BasicTabbedPaneUI.this.maxTabHeight - k;
/* */ }
/* */ else {
/* 2702 */ for (n = i5; n <= i7; n++) {
/* 2703 */ localRectangle = BasicTabbedPaneUI.this.rects[n];
/* 2704 */ localRectangle.x = i1;
/* 2705 */ localRectangle.y += BasicTabbedPaneUI.this.getTabRunIndent(paramInt1, m);
/* */ }
/* 2707 */ if (BasicTabbedPaneUI.this.shouldPadTabRun(paramInt1, m)) {
/* 2708 */ padTabRun(paramInt1, i5, i7, i3);
/* */ }
/* 2710 */ if (paramInt1 == 4)
/* 2711 */ i1 -= BasicTabbedPaneUI.this.maxTabWidth - k;
/* */ else {
/* 2713 */ i1 += BasicTabbedPaneUI.this.maxTabWidth - k;
/* */ }
/* */ }
/* */
/* */ }
/* */
/* 2719 */ padSelectedTab(paramInt1, j);
/* */
/* 2723 */ if ((!bool) && (i4 == 0)) {
/* 2724 */ i5 = localDimension.width - (localInsets1.right + localInsets2.right);
/* */
/* 2726 */ for (m = 0; m < paramInt2; m++)
/* 2727 */ BasicTabbedPaneUI.this.rects[m].x = (i5 - BasicTabbedPaneUI.this.rects[m].x - BasicTabbedPaneUI.this.rects[m].width);
/* */ }
/* */ }
/* */
/* */ protected void rotateTabRuns(int paramInt1, int paramInt2)
/* */ {
/* 2737 */ for (int i = 0; i < paramInt2; i++) {
/* 2738 */ int j = BasicTabbedPaneUI.this.tabRuns[0];
/* 2739 */ for (int k = 1; k < BasicTabbedPaneUI.this.runCount; k++) {
/* 2740 */ BasicTabbedPaneUI.this.tabRuns[(k - 1)] = BasicTabbedPaneUI.this.tabRuns[k];
/* */ }
/* 2742 */ BasicTabbedPaneUI.this.tabRuns[(BasicTabbedPaneUI.this.runCount - 1)] = j;
/* */ }
/* */ }
/* */
/* */ protected void normalizeTabRuns(int paramInt1, int paramInt2, int paramInt3, int paramInt4)
/* */ {
/* 2748 */ int i = (paramInt1 == 2) || (paramInt1 == 4) ? 1 : 0;
/* 2749 */ int j = BasicTabbedPaneUI.this.runCount - 1;
/* 2750 */ int k = 1;
/* 2751 */ double d = 1.25D;
/* */
/* 2764 */ while (k != 0) {
/* 2765 */ int m = BasicTabbedPaneUI.this.lastTabInRun(paramInt2, j);
/* 2766 */ int n = BasicTabbedPaneUI.this.lastTabInRun(paramInt2, j - 1);
/* */ int i1;
/* */ int i2;
/* 2770 */ if (i == 0) {
/* 2771 */ i1 = BasicTabbedPaneUI.this.rects[m].x + BasicTabbedPaneUI.this.rects[m].width;
/* 2772 */ i2 = (int)(BasicTabbedPaneUI.this.maxTabWidth * d);
/* */ } else {
/* 2774 */ i1 = BasicTabbedPaneUI.this.rects[m].y + BasicTabbedPaneUI.this.rects[m].height;
/* 2775 */ i2 = (int)(BasicTabbedPaneUI.this.maxTabHeight * d * 2.0D);
/* */ }
/* */
/* 2780 */ if (paramInt4 - i1 > i2)
/* */ {
/* 2783 */ BasicTabbedPaneUI.this.tabRuns[j] = n;
/* 2784 */ if (i == 0)
/* 2785 */ BasicTabbedPaneUI.this.rects[n].x = paramInt3;
/* */ else {
/* 2787 */ BasicTabbedPaneUI.this.rects[n].y = paramInt3;
/* */ }
/* 2789 */ for (int i3 = n + 1; i3 <= m; i3++) {
/* 2790 */ if (i == 0)
/* 2791 */ BasicTabbedPaneUI.this.rects[i3].x = (BasicTabbedPaneUI.this.rects[(i3 - 1)].x + BasicTabbedPaneUI.this.rects[(i3 - 1)].width);
/* */ else {
/* 2793 */ BasicTabbedPaneUI.this.rects[i3].y = (BasicTabbedPaneUI.this.rects[(i3 - 1)].y + BasicTabbedPaneUI.this.rects[(i3 - 1)].height);
/* */ }
/* */ }
/* */ }
/* 2797 */ else if (j == BasicTabbedPaneUI.this.runCount - 1)
/* */ {
/* 2799 */ k = 0;
/* */ }
/* 2801 */ if (j - 1 > 0)
/* */ {
/* 2803 */ j--;
/* */ }
/* */ else
/* */ {
/* 2808 */ j = BasicTabbedPaneUI.this.runCount - 1;
/* 2809 */ d += 0.25D;
/* */ }
/* */ }
/* */ }
/* */
/* */ protected void padTabRun(int paramInt1, int paramInt2, int paramInt3, int paramInt4) {
/* 2815 */ Rectangle localRectangle1 = BasicTabbedPaneUI.this.rects[paramInt3];
/* */ int i;
/* */ int j;
/* */ float f;
/* */ int k;
/* */ Rectangle localRectangle2;
/* 2816 */ if ((paramInt1 == 1) || (paramInt1 == 3)) {
/* 2817 */ i = localRectangle1.x + localRectangle1.width - BasicTabbedPaneUI.this.rects[paramInt2].x;
/* 2818 */ j = paramInt4 - (localRectangle1.x + localRectangle1.width);
/* 2819 */ f = j / i;
/* */
/* 2821 */ for (k = paramInt2; k <= paramInt3; k++) {
/* 2822 */ localRectangle2 = BasicTabbedPaneUI.this.rects[k];
/* 2823 */ if (k > paramInt2) {
/* 2824 */ localRectangle2.x = (BasicTabbedPaneUI.this.rects[(k - 1)].x + BasicTabbedPaneUI.this.rects[(k - 1)].width);
/* */ }
/* 2826 */ localRectangle2.width += Math.round(localRectangle2.width * f);
/* */ }
/* 2828 */ localRectangle1.width = (paramInt4 - localRectangle1.x);
/* */ } else {
/* 2830 */ i = localRectangle1.y + localRectangle1.height - BasicTabbedPaneUI.this.rects[paramInt2].y;
/* 2831 */ j = paramInt4 - (localRectangle1.y + localRectangle1.height);
/* 2832 */ f = j / i;
/* */
/* 2834 */ for (k = paramInt2; k <= paramInt3; k++) {
/* 2835 */ localRectangle2 = BasicTabbedPaneUI.this.rects[k];
/* 2836 */ if (k > paramInt2) {
/* 2837 */ localRectangle2.y = (BasicTabbedPaneUI.this.rects[(k - 1)].y + BasicTabbedPaneUI.this.rects[(k - 1)].height);
/* */ }
/* 2839 */ localRectangle2.height += Math.round(localRectangle2.height * f);
/* */ }
/* 2841 */ localRectangle1.height = (paramInt4 - localRectangle1.y);
/* */ }
/* */ }
/* */
/* */ protected void padSelectedTab(int paramInt1, int paramInt2)
/* */ {
/* 2847 */ if (paramInt2 >= 0) {
/* 2848 */ Rectangle localRectangle = BasicTabbedPaneUI.this.rects[paramInt2];
/* 2849 */ Insets localInsets1 = BasicTabbedPaneUI.this.getSelectedTabPadInsets(paramInt1);
/* 2850 */ localRectangle.x -= localInsets1.left;
/* 2851 */ localRectangle.width += localInsets1.left + localInsets1.right;
/* 2852 */ localRectangle.y -= localInsets1.top;
/* 2853 */ localRectangle.height += localInsets1.top + localInsets1.bottom;
/* */
/* 2855 */ if (!BasicTabbedPaneUI.this.scrollableTabLayoutEnabled())
/* */ {
/* 2857 */ Dimension localDimension = BasicTabbedPaneUI.this.tabPane.getSize();
/* 2858 */ Insets localInsets2 = BasicTabbedPaneUI.this.tabPane.getInsets();
/* */ int i;
/* */ int j;
/* 2860 */ if ((paramInt1 == 2) || (paramInt1 == 4)) {
/* 2861 */ i = localInsets2.top - localRectangle.y;
/* 2862 */ if (i > 0) {
/* 2863 */ localRectangle.y += i;
/* 2864 */ localRectangle.height -= i;
/* */ }
/* 2866 */ j = localRectangle.y + localRectangle.height + localInsets2.bottom - localDimension.height;
/* 2867 */ if (j > 0)
/* 2868 */ localRectangle.height -= j;
/* */ }
/* */ else {
/* 2871 */ i = localInsets2.left - localRectangle.x;
/* 2872 */ if (i > 0) {
/* 2873 */ localRectangle.x += i;
/* 2874 */ localRectangle.width -= i;
/* */ }
/* 2876 */ j = localRectangle.x + localRectangle.width + localInsets2.right - localDimension.width;
/* 2877 */ if (j > 0)
/* 2878 */ localRectangle.width -= j;
/* */ }
/* */ }
/* */ }
/* */ }
/* */ }
/* */
/* */ private class TabbedPaneScrollLayout extends BasicTabbedPaneUI.TabbedPaneLayout {
/* 2886 */ private TabbedPaneScrollLayout() { super(); }
/* */
/* */ protected int preferredTabAreaHeight(int paramInt1, int paramInt2) {
/* 2889 */ return BasicTabbedPaneUI.this.calculateMaxTabHeight(paramInt1);
/* */ }
/* */
/* */ protected int preferredTabAreaWidth(int paramInt1, int paramInt2) {
/* 2893 */ return BasicTabbedPaneUI.this.calculateMaxTabWidth(paramInt1);
/* */ }
/* */
/* */ public void layoutContainer(Container paramContainer)
/* */ {
/* 2908 */ BasicTabbedPaneUI.this.setRolloverTab(-1);
/* */
/* 2910 */ int i = BasicTabbedPaneUI.this.tabPane.getTabPlacement();
/* 2911 */ int j = BasicTabbedPaneUI.this.tabPane.getTabCount();
/* 2912 */ Insets localInsets1 = BasicTabbedPaneUI.this.tabPane.getInsets();
/* 2913 */ int k = BasicTabbedPaneUI.this.tabPane.getSelectedIndex();
/* 2914 */ Component localComponent1 = BasicTabbedPaneUI.this.getVisibleComponent();
/* */
/* 2916 */ calculateLayoutInfo();
/* */
/* 2918 */ Component localComponent2 = null;
/* 2919 */ if (k < 0) {
/* 2920 */ if (localComponent1 != null)
/* */ {
/* 2922 */ BasicTabbedPaneUI.this.setVisibleComponent(null);
/* */ }
/* */ }
/* 2925 */ else localComponent2 = BasicTabbedPaneUI.this.tabPane.getComponentAt(k);
/* */
/* 2928 */ if (BasicTabbedPaneUI.this.tabPane.getTabCount() == 0) {
/* 2929 */ BasicTabbedPaneUI.this.tabScroller.croppedEdge.resetParams();
/* 2930 */ BasicTabbedPaneUI.this.tabScroller.scrollForwardButton.setVisible(false);
/* 2931 */ BasicTabbedPaneUI.this.tabScroller.scrollBackwardButton.setVisible(false);
/* 2932 */ return;
/* */ }
/* */
/* 2935 */ int m = 0;
/* */
/* 2944 */ if (localComponent2 != null) {
/* 2945 */ if ((localComponent2 != localComponent1) && (localComponent1 != null))
/* */ {
/* 2947 */ if (SwingUtilities.findFocusOwner(localComponent1) != null) {
/* 2948 */ m = 1;
/* */ }
/* */ }
/* 2951 */ BasicTabbedPaneUI.this.setVisibleComponent(localComponent2);
/* */ }
/* */
/* 2955 */ Insets localInsets2 = BasicTabbedPaneUI.this.getContentBorderInsets(i);
/* 2956 */ Rectangle localRectangle = BasicTabbedPaneUI.this.tabPane.getBounds();
/* 2957 */ int i8 = BasicTabbedPaneUI.this.tabPane.getComponentCount();
/* */
/* 2959 */ if (i8 > 0)
/* */ {
/* */ int i2;
/* */ int i3;
/* */ int n;
/* */ int i1;
/* */ int i4;
/* */ int i5;
/* */ int i6;
/* */ int i7;
/* 2960 */ switch (i)
/* */ {
/* */ case 2:
/* 2963 */ i2 = BasicTabbedPaneUI.this.calculateTabAreaWidth(i, BasicTabbedPaneUI.this.runCount, BasicTabbedPaneUI.this.maxTabWidth);
/* 2964 */ i3 = localRectangle.height - localInsets1.top - localInsets1.bottom;
/* 2965 */ n = localInsets1.left;
/* 2966 */ i1 = localInsets1.top;
/* */
/* 2969 */ i4 = n + i2 + localInsets2.left;
/* 2970 */ i5 = i1 + localInsets2.top;
/* 2971 */ i6 = localRectangle.width - localInsets1.left - localInsets1.right - i2 - localInsets2.left - localInsets2.right;
/* */
/* 2973 */ i7 = localRectangle.height - localInsets1.top - localInsets1.bottom - localInsets2.top - localInsets2.bottom;
/* */
/* 2975 */ break;
/* */ case 4:
/* 2978 */ i2 = BasicTabbedPaneUI.this.calculateTabAreaWidth(i, BasicTabbedPaneUI.this.runCount, BasicTabbedPaneUI.this.maxTabWidth);
/* 2979 */ i3 = localRectangle.height - localInsets1.top - localInsets1.bottom;
/* 2980 */ n = localRectangle.width - localInsets1.right - i2;
/* 2981 */ i1 = localInsets1.top;
/* */
/* 2984 */ i4 = localInsets1.left + localInsets2.left;
/* 2985 */ i5 = localInsets1.top + localInsets2.top;
/* 2986 */ i6 = localRectangle.width - localInsets1.left - localInsets1.right - i2 - localInsets2.left - localInsets2.right;
/* */
/* 2988 */ i7 = localRectangle.height - localInsets1.top - localInsets1.bottom - localInsets2.top - localInsets2.bottom;
/* */
/* 2990 */ break;
/* */ case 3:
/* 2993 */ i2 = localRectangle.width - localInsets1.left - localInsets1.right;
/* 2994 */ i3 = BasicTabbedPaneUI.this.calculateTabAreaHeight(i, BasicTabbedPaneUI.this.runCount, BasicTabbedPaneUI.this.maxTabHeight);
/* 2995 */ n = localInsets1.left;
/* 2996 */ i1 = localRectangle.height - localInsets1.bottom - i3;
/* */
/* 2999 */ i4 = localInsets1.left + localInsets2.left;
/* 3000 */ i5 = localInsets1.top + localInsets2.top;
/* 3001 */ i6 = localRectangle.width - localInsets1.left - localInsets1.right - localInsets2.left - localInsets2.right;
/* */
/* 3003 */ i7 = localRectangle.height - localInsets1.top - localInsets1.bottom - i3 - localInsets2.top - localInsets2.bottom;
/* */
/* 3005 */ break;
/* */ case 1:
/* */ default:
/* 3009 */ i2 = localRectangle.width - localInsets1.left - localInsets1.right;
/* 3010 */ i3 = BasicTabbedPaneUI.this.calculateTabAreaHeight(i, BasicTabbedPaneUI.this.runCount, BasicTabbedPaneUI.this.maxTabHeight);
/* 3011 */ n = localInsets1.left;
/* 3012 */ i1 = localInsets1.top;
/* */
/* 3015 */ i4 = n + localInsets2.left;
/* 3016 */ i5 = i1 + i3 + localInsets2.top;
/* 3017 */ i6 = localRectangle.width - localInsets1.left - localInsets1.right - localInsets2.left - localInsets2.right;
/* */
/* 3019 */ i7 = localRectangle.height - localInsets1.top - localInsets1.bottom - i3 - localInsets2.top - localInsets2.bottom;
/* */ }
/* */
/* 3023 */ for (int i9 = 0; i9 < i8; i9++) {
/* 3024 */ Component localComponent3 = BasicTabbedPaneUI.this.tabPane.getComponent(i9);
/* */ Object localObject1;
/* */ Object localObject2;
/* */ int i10;
/* */ int i11;
/* */ int i13;
/* */ int i14;
/* 3026 */ if ((BasicTabbedPaneUI.this.tabScroller != null) && (localComponent3 == BasicTabbedPaneUI.this.tabScroller.viewport)) {
/* 3027 */ localObject1 = (JViewport)localComponent3;
/* 3028 */ localObject2 = ((JViewport)localObject1).getViewRect();
/* 3029 */ i10 = i2;
/* 3030 */ i11 = i3;
/* 3031 */ Dimension localDimension = BasicTabbedPaneUI.this.tabScroller.scrollForwardButton.getPreferredSize();
/* 3032 */ switch (i) {
/* */ case 2:
/* */ case 4:
/* 3035 */ i13 = BasicTabbedPaneUI.this.rects[(j - 1)].y + BasicTabbedPaneUI.this.rects[(j - 1)].height;
/* 3036 */ if (i13 > i3)
/* */ {
/* 3038 */ i11 = i3 > 2 * localDimension.height ? i3 - 2 * localDimension.height : 0;
/* 3039 */ if (i13 - ((Rectangle)localObject2).y <= i11)
/* */ {
/* 3042 */ i11 = i13 - ((Rectangle)localObject2).y; } } break;
/* */ case 1:
/* */ case 3:
/* */ default:
/* 3049 */ i14 = BasicTabbedPaneUI.this.rects[(j - 1)].x + BasicTabbedPaneUI.this.rects[(j - 1)].width;
/* 3050 */ if (i14 > i2)
/* */ {
/* 3052 */ i10 = i2 > 2 * localDimension.width ? i2 - 2 * localDimension.width : 0;
/* 3053 */ if (i14 - ((Rectangle)localObject2).x <= i10)
/* */ {
/* 3056 */ i10 = i14 - ((Rectangle)localObject2).x;
/* */ }
/* */ }
/* */ break;
/* */ }
/* 3060 */ localComponent3.setBounds(n, i1, i10, i11);
/* */ }
/* 3062 */ else if ((BasicTabbedPaneUI.this.tabScroller != null) && ((localComponent3 == BasicTabbedPaneUI.this.tabScroller.scrollForwardButton) || (localComponent3 == BasicTabbedPaneUI.this.tabScroller.scrollBackwardButton)))
/* */ {
/* 3065 */ localObject1 = localComponent3;
/* 3066 */ localObject2 = ((Component)localObject1).getPreferredSize();
/* 3067 */ i10 = 0;
/* 3068 */ i11 = 0;
/* 3069 */ int i12 = ((Dimension)localObject2).width;
/* 3070 */ i13 = ((Dimension)localObject2).height;
/* 3071 */ i14 = 0;
/* */
/* 3073 */ switch (i) {
/* */ case 2:
/* */ case 4:
/* 3076 */ int i15 = BasicTabbedPaneUI.this.rects[(j - 1)].y + BasicTabbedPaneUI.this.rects[(j - 1)].height;
/* 3077 */ if (i15 > i3) {
/* 3078 */ i14 = 1;
/* 3079 */ i10 = i == 2 ? n + i2 - ((Dimension)localObject2).width : n;
/* 3080 */ i11 = localComponent3 == BasicTabbedPaneUI.this.tabScroller.scrollForwardButton ? localRectangle.height - localInsets1.bottom - ((Dimension)localObject2).height : localRectangle.height - localInsets1.bottom - 2 * ((Dimension)localObject2).height; } break;
/* */ case 1:
/* */ case 3:
/* */ default:
/* 3089 */ int i16 = BasicTabbedPaneUI.this.rects[(j - 1)].x + BasicTabbedPaneUI.this.rects[(j - 1)].width;
/* */
/* 3091 */ if (i16 > i2) {
/* 3092 */ i14 = 1;
/* 3093 */ i10 = localComponent3 == BasicTabbedPaneUI.this.tabScroller.scrollForwardButton ? localRectangle.width - localInsets1.left - ((Dimension)localObject2).width : localRectangle.width - localInsets1.left - 2 * ((Dimension)localObject2).width;
/* */
/* 3096 */ i11 = i == 1 ? i1 + i3 - ((Dimension)localObject2).height : i1;
/* */ }break;
/* */ }
/* 3099 */ localComponent3.setVisible(i14);
/* 3100 */ if (i14 != 0) {
/* 3101 */ localComponent3.setBounds(i10, i11, i12, i13);
/* */ }
/* */ }
/* */ else
/* */ {
/* 3106 */ localComponent3.setBounds(i4, i5, i6, i7);
/* */ }
/* */ }
/* 3109 */ super.layoutTabComponents();
/* 3110 */ layoutCroppedEdge();
/* 3111 */ if ((m != 0) &&
/* 3112 */ (!BasicTabbedPaneUI.this.requestFocusForVisibleComponent()))
/* 3113 */ BasicTabbedPaneUI.this.tabPane.requestFocus();
/* */ }
/* */ }
/* */
/* */ private void layoutCroppedEdge()
/* */ {
/* 3120 */ BasicTabbedPaneUI.this.tabScroller.croppedEdge.resetParams();
/* 3121 */ Rectangle localRectangle1 = BasicTabbedPaneUI.this.tabScroller.viewport.getViewRect();
/* */
/* 3123 */ for (int j = 0; j < BasicTabbedPaneUI.this.rects.length; j++) {
/* 3124 */ Rectangle localRectangle2 = BasicTabbedPaneUI.this.rects[j];
/* */ int i;
/* 3125 */ switch (BasicTabbedPaneUI.this.tabPane.getTabPlacement()) {
/* */ case 2:
/* */ case 4:
/* 3128 */ i = localRectangle1.y + localRectangle1.height;
/* 3129 */ if ((localRectangle2.y < i) && (localRectangle2.y + localRectangle2.height > i))
/* 3130 */ BasicTabbedPaneUI.this.tabScroller.croppedEdge.setParams(j, i - localRectangle2.y - 1, -BasicTabbedPaneUI.this.currentTabAreaInsets.left, 0); break;
/* */ case 1:
/* */ case 3:
/* */ default:
/* 3137 */ i = localRectangle1.x + localRectangle1.width;
/* 3138 */ if ((localRectangle2.x < i - 1) && (localRectangle2.x + localRectangle2.width > i))
/* 3139 */ BasicTabbedPaneUI.this.tabScroller.croppedEdge.setParams(j, i - localRectangle2.x - 1, 0, -BasicTabbedPaneUI.this.currentTabAreaInsets.top);
/* */ break;
/* */ }
/* */ }
/* */ }
/* */
/* */ protected void calculateTabRects(int paramInt1, int paramInt2)
/* */ {
/* 3147 */ FontMetrics localFontMetrics = BasicTabbedPaneUI.this.getFontMetrics();
/* 3148 */ Dimension localDimension = BasicTabbedPaneUI.this.tabPane.getSize();
/* 3149 */ Insets localInsets1 = BasicTabbedPaneUI.this.tabPane.getInsets();
/* 3150 */ Insets localInsets2 = BasicTabbedPaneUI.this.getTabAreaInsets(paramInt1);
/* 3151 */ int i = localFontMetrics.getHeight();
/* 3152 */ int j = BasicTabbedPaneUI.this.tabPane.getSelectedIndex();
/* */
/* 3154 */ int m = (paramInt1 == 2) || (paramInt1 == 4) ? 1 : 0;
/* 3155 */ boolean bool = BasicGraphicsUtils.isLeftToRight(BasicTabbedPaneUI.this.tabPane);
/* 3156 */ int n = localInsets2.left;
/* 3157 */ int i1 = localInsets2.top;
/* 3158 */ int i2 = 0;
/* 3159 */ int i3 = 0;
/* */
/* 3164 */ switch (paramInt1) {
/* */ case 2:
/* */ case 4:
/* 3167 */ BasicTabbedPaneUI.this.maxTabWidth = BasicTabbedPaneUI.this.calculateMaxTabWidth(paramInt1);
/* 3168 */ break;
/* */ case 1:
/* */ case 3:
/* */ default:
/* 3172 */ BasicTabbedPaneUI.this.maxTabHeight = BasicTabbedPaneUI.this.calculateMaxTabHeight(paramInt1);
/* */ }
/* */
/* 3175 */ BasicTabbedPaneUI.this.runCount = 0;
/* 3176 */ BasicTabbedPaneUI.this.selectedRun = -1;
/* */
/* 3178 */ if (paramInt2 == 0) {
/* 3179 */ return;
/* */ }
/* */
/* 3182 */ BasicTabbedPaneUI.this.selectedRun = 0;
/* 3183 */ BasicTabbedPaneUI.this.runCount = 1;
/* */
/* 3187 */ for (int k = 0; k < paramInt2; k++) {
/* 3188 */ Rectangle localRectangle = BasicTabbedPaneUI.this.rects[k];
/* */
/* 3190 */ if (m == 0)
/* */ {
/* 3192 */ if (k > 0) {
/* 3193 */ localRectangle.x = (BasicTabbedPaneUI.this.rects[(k - 1)].x + BasicTabbedPaneUI.this.rects[(k - 1)].width);
/* */ } else {
/* 3195 */ BasicTabbedPaneUI.this.tabRuns[0] = 0;
/* 3196 */ BasicTabbedPaneUI.this.maxTabWidth = 0;
/* 3197 */ i3 += BasicTabbedPaneUI.this.maxTabHeight;
/* 3198 */ localRectangle.x = n;
/* */ }
/* 3200 */ localRectangle.width = BasicTabbedPaneUI.this.calculateTabWidth(paramInt1, k, localFontMetrics);
/* 3201 */ i2 = localRectangle.x + localRectangle.width;
/* 3202 */ BasicTabbedPaneUI.this.maxTabWidth = Math.max(BasicTabbedPaneUI.this.maxTabWidth, localRectangle.width);
/* */
/* 3204 */ localRectangle.y = i1;
/* 3205 */ localRectangle.height = BasicTabbedPaneUI.this.maxTabHeight;
/* */ }
/* */ else
/* */ {
/* 3209 */ if (k > 0) {
/* 3210 */ localRectangle.y = (BasicTabbedPaneUI.this.rects[(k - 1)].y + BasicTabbedPaneUI.this.rects[(k - 1)].height);
/* */ } else {
/* 3212 */ BasicTabbedPaneUI.this.tabRuns[0] = 0;
/* 3213 */ BasicTabbedPaneUI.this.maxTabHeight = 0;
/* 3214 */ i2 = BasicTabbedPaneUI.this.maxTabWidth;
/* 3215 */ localRectangle.y = i1;
/* */ }
/* 3217 */ localRectangle.height = BasicTabbedPaneUI.this.calculateTabHeight(paramInt1, k, i);
/* 3218 */ i3 = localRectangle.y + localRectangle.height;
/* 3219 */ BasicTabbedPaneUI.this.maxTabHeight = Math.max(BasicTabbedPaneUI.this.maxTabHeight, localRectangle.height);
/* */
/* 3221 */ localRectangle.x = n;
/* 3222 */ localRectangle.width = BasicTabbedPaneUI.this.maxTabWidth;
/* */ }
/* */
/* */ }
/* */
/* 3227 */ if (BasicTabbedPaneUI.this.tabsOverlapBorder)
/* */ {
/* 3229 */ padSelectedTab(paramInt1, j);
/* */ }
/* */
/* 3234 */ if ((!bool) && (m == 0)) {
/* 3235 */ int i4 = localDimension.width - (localInsets1.right + localInsets2.right);
/* */
/* 3237 */ for (k = 0; k < paramInt2; k++) {
/* 3238 */ BasicTabbedPaneUI.this.rects[k].x = (i4 - BasicTabbedPaneUI.this.rects[k].x - BasicTabbedPaneUI.this.rects[k].width);
/* */ }
/* */ }
/* 3241 */ BasicTabbedPaneUI.this.tabScroller.tabPanel.setPreferredSize(new Dimension(i2, i3));
/* */ }
/* */ }
/* */ }
/* Location: C:\Program Files\Java\jdk1.7.0_79\jre\lib\rt.jar
* Qualified Name: javax.swing.plaf.basic.BasicTabbedPaneUI
* JD-Core Version: 0.6.2
*/ | UTF-8 | Java | 159,578 | java | BasicTabbedPaneUI.java | Java | [] | null | [] | /* */ package javax.swing.plaf.basic;
/* */
/* */ import java.awt.Color;
/* */ import java.awt.Component;
/* */ import java.awt.Component.BaselineResizeBehavior;
/* */ import java.awt.Container;
/* */ import java.awt.Dimension;
/* */ import java.awt.Font;
/* */ import java.awt.FontMetrics;
/* */ import java.awt.Graphics;
/* */ import java.awt.Graphics2D;
/* */ import java.awt.Insets;
/* */ import java.awt.LayoutManager;
/* */ import java.awt.Point;
/* */ import java.awt.Polygon;
/* */ import java.awt.Rectangle;
/* */ import java.awt.Shape;
/* */ import java.awt.event.ActionEvent;
/* */ import java.awt.event.ActionListener;
/* */ import java.awt.event.ContainerEvent;
/* */ import java.awt.event.ContainerListener;
/* */ import java.awt.event.FocusAdapter;
/* */ import java.awt.event.FocusEvent;
/* */ import java.awt.event.FocusListener;
/* */ import java.awt.event.MouseAdapter;
/* */ import java.awt.event.MouseEvent;
/* */ import java.awt.event.MouseListener;
/* */ import java.awt.event.MouseMotionListener;
/* */ import java.beans.PropertyChangeEvent;
/* */ import java.beans.PropertyChangeListener;
/* */ import java.util.Hashtable;
/* */ import java.util.Vector;
/* */ import javax.swing.Action;
/* */ import javax.swing.ActionMap;
/* */ import javax.swing.Icon;
/* */ import javax.swing.InputMap;
/* */ import javax.swing.JButton;
/* */ import javax.swing.JComponent;
/* */ import javax.swing.JPanel;
/* */ import javax.swing.JTabbedPane;
/* */ import javax.swing.JViewport;
/* */ import javax.swing.KeyStroke;
/* */ import javax.swing.LookAndFeel;
/* */ import javax.swing.SwingConstants;
/* */ import javax.swing.SwingUtilities;
/* */ import javax.swing.UIManager;
/* */ import javax.swing.event.ChangeEvent;
/* */ import javax.swing.event.ChangeListener;
/* */ import javax.swing.plaf.ComponentInputMapUIResource;
/* */ import javax.swing.plaf.ComponentUI;
/* */ import javax.swing.plaf.TabbedPaneUI;
/* */ import javax.swing.plaf.UIResource;
/* */ import javax.swing.text.View;
/* */ import sun.swing.DefaultLookup;
/* */ import sun.swing.SwingUtilities2;
/* */ import sun.swing.UIAction;
/* */
/* */ public class BasicTabbedPaneUI extends TabbedPaneUI
/* */ implements SwingConstants
/* */ {
/* */ protected JTabbedPane tabPane;
/* */ protected Color highlight;
/* */ protected Color lightHighlight;
/* */ protected Color shadow;
/* */ protected Color darkShadow;
/* */ protected Color focus;
/* */ private Color selectedColor;
/* */ protected int textIconGap;
/* */ protected int tabRunOverlay;
/* */ protected Insets tabInsets;
/* */ protected Insets selectedTabPadInsets;
/* */ protected Insets tabAreaInsets;
/* */ protected Insets contentBorderInsets;
/* */ private boolean tabsOverlapBorder;
/* */ private boolean tabsOpaque;
/* */ private boolean contentOpaque;
/* */
/* */ @Deprecated
/* */ protected KeyStroke upKey;
/* */
/* */ @Deprecated
/* */ protected KeyStroke downKey;
/* */
/* */ @Deprecated
/* */ protected KeyStroke leftKey;
/* */
/* */ @Deprecated
/* */ protected KeyStroke rightKey;
/* */ protected int[] tabRuns;
/* */ protected int runCount;
/* */ protected int selectedRun;
/* */ protected Rectangle[] rects;
/* */ protected int maxTabHeight;
/* */ protected int maxTabWidth;
/* */ protected ChangeListener tabChangeListener;
/* */ protected PropertyChangeListener propertyChangeListener;
/* */ protected MouseListener mouseListener;
/* */ protected FocusListener focusListener;
/* */ private Insets currentPadInsets;
/* */ private Insets currentTabAreaInsets;
/* */ private Component visibleComponent;
/* */ private Vector<View> htmlViews;
/* */ private Hashtable<Integer, Integer> mnemonicToIndexMap;
/* */ private InputMap mnemonicInputMap;
/* */ private ScrollableTabSupport tabScroller;
/* */ private TabContainer tabContainer;
/* */ protected transient Rectangle calcRect;
/* */ private int focusIndex;
/* */ private Handler handler;
/* */ private int rolloverTabIndex;
/* */ private boolean isRunsDirty;
/* */ private boolean calculatedBaseline;
/* */ private int baseline;
/* 917 */ private static int[] xCropLen = { 1, 1, 0, 0, 1, 1, 2, 2 };
/* 918 */ private static int[] yCropLen = { 0, 3, 3, 6, 6, 9, 9, 12 };
/* */ private static final int CROP_SEGMENT = 12;
/* */
/* */ public BasicTabbedPaneUI()
/* */ {
/* 77 */ this.tabsOpaque = true;
/* 78 */ this.contentOpaque = true;
/* */
/* 124 */ this.tabRuns = new int[10];
/* 125 */ this.runCount = 0;
/* 126 */ this.selectedRun = -1;
/* 127 */ this.rects = new Rectangle[0];
/* */
/* 140 */ this.currentPadInsets = new Insets(0, 0, 0, 0);
/* 141 */ this.currentTabAreaInsets = new Insets(0, 0, 0, 0);
/* */
/* 164 */ this.calcRect = new Rectangle(0, 0, 0, 0);
/* */ }
/* */
/* */ public static ComponentUI createUI(JComponent paramJComponent)
/* */ {
/* 194 */ return new BasicTabbedPaneUI();
/* */ }
/* */
/* */ static void loadActionMap(LazyActionMap paramLazyActionMap) {
/* 198 */ paramLazyActionMap.put(new Actions("navigateNext"));
/* 199 */ paramLazyActionMap.put(new Actions("navigatePrevious"));
/* 200 */ paramLazyActionMap.put(new Actions("navigateRight"));
/* 201 */ paramLazyActionMap.put(new Actions("navigateLeft"));
/* 202 */ paramLazyActionMap.put(new Actions("navigateUp"));
/* 203 */ paramLazyActionMap.put(new Actions("navigateDown"));
/* 204 */ paramLazyActionMap.put(new Actions("navigatePageUp"));
/* 205 */ paramLazyActionMap.put(new Actions("navigatePageDown"));
/* 206 */ paramLazyActionMap.put(new Actions("requestFocus"));
/* 207 */ paramLazyActionMap.put(new Actions("requestFocusForVisibleComponent"));
/* 208 */ paramLazyActionMap.put(new Actions("setSelectedIndex"));
/* 209 */ paramLazyActionMap.put(new Actions("selectTabWithFocus"));
/* 210 */ paramLazyActionMap.put(new Actions("scrollTabsForwardAction"));
/* 211 */ paramLazyActionMap.put(new Actions("scrollTabsBackwardAction"));
/* */ }
/* */
/* */ public void installUI(JComponent paramJComponent)
/* */ {
/* 217 */ this.tabPane = ((JTabbedPane)paramJComponent);
/* */
/* 219 */ this.calculatedBaseline = false;
/* 220 */ this.rolloverTabIndex = -1;
/* 221 */ this.focusIndex = -1;
/* 222 */ paramJComponent.setLayout(createLayoutManager());
/* 223 */ installComponents();
/* 224 */ installDefaults();
/* 225 */ installListeners();
/* 226 */ installKeyboardActions();
/* */ }
/* */
/* */ public void uninstallUI(JComponent paramJComponent) {
/* 230 */ uninstallKeyboardActions();
/* 231 */ uninstallListeners();
/* 232 */ uninstallDefaults();
/* 233 */ uninstallComponents();
/* 234 */ paramJComponent.setLayout(null);
/* */
/* 236 */ this.tabPane = null;
/* */ }
/* */
/* */ protected LayoutManager createLayoutManager()
/* */ {
/* 250 */ if (this.tabPane.getTabLayoutPolicy() == 1) {
/* 251 */ return new TabbedPaneScrollLayout(null);
/* */ }
/* 253 */ return new TabbedPaneLayout();
/* */ }
/* */
/* */ private boolean scrollableTabLayoutEnabled()
/* */ {
/* 263 */ return this.tabPane.getLayout() instanceof TabbedPaneScrollLayout;
/* */ }
/* */
/* */ protected void installComponents()
/* */ {
/* 273 */ if ((scrollableTabLayoutEnabled()) &&
/* 274 */ (this.tabScroller == null)) {
/* 275 */ this.tabScroller = new ScrollableTabSupport(this.tabPane.getTabPlacement());
/* 276 */ this.tabPane.add(this.tabScroller.viewport);
/* */ }
/* */
/* 279 */ installTabContainer();
/* */ }
/* */
/* */ private void installTabContainer() {
/* 283 */ for (int i = 0; i < this.tabPane.getTabCount(); i++) {
/* 284 */ Component localComponent = this.tabPane.getTabComponentAt(i);
/* 285 */ if (localComponent != null) {
/* 286 */ if (this.tabContainer == null) {
/* 287 */ this.tabContainer = new TabContainer();
/* */ }
/* 289 */ this.tabContainer.add(localComponent);
/* */ }
/* */ }
/* 292 */ if (this.tabContainer == null) {
/* 293 */ return;
/* */ }
/* 295 */ if (scrollableTabLayoutEnabled())
/* 296 */ this.tabScroller.tabPanel.add(this.tabContainer);
/* */ else
/* 298 */ this.tabPane.add(this.tabContainer);
/* */ }
/* */
/* */ protected JButton createScrollButton(int paramInt)
/* */ {
/* 317 */ if ((paramInt != 5) && (paramInt != 1) && (paramInt != 3) && (paramInt != 7))
/* */ {
/* 319 */ throw new IllegalArgumentException("Direction must be one of: SOUTH, NORTH, EAST or WEST");
/* */ }
/* */
/* 322 */ return new ScrollableTabButton(paramInt);
/* */ }
/* */
/* */ protected void uninstallComponents()
/* */ {
/* 332 */ uninstallTabContainer();
/* 333 */ if (scrollableTabLayoutEnabled()) {
/* 334 */ this.tabPane.remove(this.tabScroller.viewport);
/* 335 */ this.tabPane.remove(this.tabScroller.scrollForwardButton);
/* 336 */ this.tabPane.remove(this.tabScroller.scrollBackwardButton);
/* 337 */ this.tabScroller = null;
/* */ }
/* */ }
/* */
/* */ private void uninstallTabContainer() {
/* 342 */ if (this.tabContainer == null) {
/* 343 */ return;
/* */ }
/* */
/* 347 */ this.tabContainer.notifyTabbedPane = false;
/* 348 */ this.tabContainer.removeAll();
/* 349 */ if (scrollableTabLayoutEnabled()) {
/* 350 */ this.tabContainer.remove(this.tabScroller.croppedEdge);
/* 351 */ this.tabScroller.tabPanel.remove(this.tabContainer);
/* */ } else {
/* 353 */ this.tabPane.remove(this.tabContainer);
/* */ }
/* 355 */ this.tabContainer = null;
/* */ }
/* */
/* */ protected void installDefaults() {
/* 359 */ LookAndFeel.installColorsAndFont(this.tabPane, "TabbedPane.background", "TabbedPane.foreground", "TabbedPane.font");
/* */
/* 361 */ this.highlight = UIManager.getColor("TabbedPane.light");
/* 362 */ this.lightHighlight = UIManager.getColor("TabbedPane.highlight");
/* 363 */ this.shadow = UIManager.getColor("TabbedPane.shadow");
/* 364 */ this.darkShadow = UIManager.getColor("TabbedPane.darkShadow");
/* 365 */ this.focus = UIManager.getColor("TabbedPane.focus");
/* 366 */ this.selectedColor = UIManager.getColor("TabbedPane.selected");
/* */
/* 368 */ this.textIconGap = UIManager.getInt("TabbedPane.textIconGap");
/* 369 */ this.tabInsets = UIManager.getInsets("TabbedPane.tabInsets");
/* 370 */ this.selectedTabPadInsets = UIManager.getInsets("TabbedPane.selectedTabPadInsets");
/* 371 */ this.tabAreaInsets = UIManager.getInsets("TabbedPane.tabAreaInsets");
/* 372 */ this.tabsOverlapBorder = UIManager.getBoolean("TabbedPane.tabsOverlapBorder");
/* 373 */ this.contentBorderInsets = UIManager.getInsets("TabbedPane.contentBorderInsets");
/* 374 */ this.tabRunOverlay = UIManager.getInt("TabbedPane.tabRunOverlay");
/* 375 */ this.tabsOpaque = UIManager.getBoolean("TabbedPane.tabsOpaque");
/* 376 */ this.contentOpaque = UIManager.getBoolean("TabbedPane.contentOpaque");
/* 377 */ Object localObject = UIManager.get("TabbedPane.opaque");
/* 378 */ if (localObject == null) {
/* 379 */ localObject = Boolean.FALSE;
/* */ }
/* 381 */ LookAndFeel.installProperty(this.tabPane, "opaque", localObject);
/* */
/* 386 */ if (this.tabInsets == null) this.tabInsets = new Insets(0, 4, 1, 4);
/* 387 */ if (this.selectedTabPadInsets == null) this.selectedTabPadInsets = new Insets(2, 2, 2, 1);
/* 388 */ if (this.tabAreaInsets == null) this.tabAreaInsets = new Insets(3, 2, 0, 2);
/* 389 */ if (this.contentBorderInsets == null) this.contentBorderInsets = new Insets(2, 2, 3, 3);
/* */ }
/* */
/* */ protected void uninstallDefaults()
/* */ {
/* 393 */ this.highlight = null;
/* 394 */ this.lightHighlight = null;
/* 395 */ this.shadow = null;
/* 396 */ this.darkShadow = null;
/* 397 */ this.focus = null;
/* 398 */ this.tabInsets = null;
/* 399 */ this.selectedTabPadInsets = null;
/* 400 */ this.tabAreaInsets = null;
/* 401 */ this.contentBorderInsets = null;
/* */ }
/* */
/* */ protected void installListeners() {
/* 405 */ if ((this.propertyChangeListener = createPropertyChangeListener()) != null) {
/* 406 */ this.tabPane.addPropertyChangeListener(this.propertyChangeListener);
/* */ }
/* 408 */ if ((this.tabChangeListener = createChangeListener()) != null) {
/* 409 */ this.tabPane.addChangeListener(this.tabChangeListener);
/* */ }
/* 411 */ if ((this.mouseListener = createMouseListener()) != null) {
/* 412 */ this.tabPane.addMouseListener(this.mouseListener);
/* */ }
/* 414 */ this.tabPane.addMouseMotionListener(getHandler());
/* 415 */ if ((this.focusListener = createFocusListener()) != null) {
/* 416 */ this.tabPane.addFocusListener(this.focusListener);
/* */ }
/* 418 */ this.tabPane.addContainerListener(getHandler());
/* 419 */ if (this.tabPane.getTabCount() > 0)
/* 420 */ this.htmlViews = createHTMLVector();
/* */ }
/* */
/* */ protected void uninstallListeners()
/* */ {
/* 425 */ if (this.mouseListener != null) {
/* 426 */ this.tabPane.removeMouseListener(this.mouseListener);
/* 427 */ this.mouseListener = null;
/* */ }
/* 429 */ this.tabPane.removeMouseMotionListener(getHandler());
/* 430 */ if (this.focusListener != null) {
/* 431 */ this.tabPane.removeFocusListener(this.focusListener);
/* 432 */ this.focusListener = null;
/* */ }
/* */
/* 435 */ this.tabPane.removeContainerListener(getHandler());
/* 436 */ if (this.htmlViews != null) {
/* 437 */ this.htmlViews.removeAllElements();
/* 438 */ this.htmlViews = null;
/* */ }
/* 440 */ if (this.tabChangeListener != null) {
/* 441 */ this.tabPane.removeChangeListener(this.tabChangeListener);
/* 442 */ this.tabChangeListener = null;
/* */ }
/* 444 */ if (this.propertyChangeListener != null) {
/* 445 */ this.tabPane.removePropertyChangeListener(this.propertyChangeListener);
/* 446 */ this.propertyChangeListener = null;
/* */ }
/* 448 */ this.handler = null;
/* */ }
/* */
/* */ protected MouseListener createMouseListener() {
/* 452 */ return getHandler();
/* */ }
/* */
/* */ protected FocusListener createFocusListener() {
/* 456 */ return getHandler();
/* */ }
/* */
/* */ protected ChangeListener createChangeListener() {
/* 460 */ return getHandler();
/* */ }
/* */
/* */ protected PropertyChangeListener createPropertyChangeListener() {
/* 464 */ return getHandler();
/* */ }
/* */
/* */ private Handler getHandler() {
/* 468 */ if (this.handler == null) {
/* 469 */ this.handler = new Handler(null);
/* */ }
/* 471 */ return this.handler;
/* */ }
/* */
/* */ protected void installKeyboardActions() {
/* 475 */ InputMap localInputMap = getInputMap(1);
/* */
/* 478 */ SwingUtilities.replaceUIInputMap(this.tabPane, 1, localInputMap);
/* */
/* 481 */ localInputMap = getInputMap(0);
/* 482 */ SwingUtilities.replaceUIInputMap(this.tabPane, 0, localInputMap);
/* */
/* 484 */ LazyActionMap.installLazyActionMap(this.tabPane, BasicTabbedPaneUI.class, "TabbedPane.actionMap");
/* */
/* 486 */ updateMnemonics();
/* */ }
/* */
/* */ InputMap getInputMap(int paramInt) {
/* 490 */ if (paramInt == 1) {
/* 491 */ return (InputMap)DefaultLookup.get(this.tabPane, this, "TabbedPane.ancestorInputMap");
/* */ }
/* */
/* 494 */ if (paramInt == 0) {
/* 495 */ return (InputMap)DefaultLookup.get(this.tabPane, this, "TabbedPane.focusInputMap");
/* */ }
/* */
/* 498 */ return null;
/* */ }
/* */
/* */ protected void uninstallKeyboardActions() {
/* 502 */ SwingUtilities.replaceUIActionMap(this.tabPane, null);
/* 503 */ SwingUtilities.replaceUIInputMap(this.tabPane, 1, null);
/* */
/* 506 */ SwingUtilities.replaceUIInputMap(this.tabPane, 0, null);
/* */
/* 508 */ SwingUtilities.replaceUIInputMap(this.tabPane, 2, null);
/* */
/* 511 */ this.mnemonicToIndexMap = null;
/* 512 */ this.mnemonicInputMap = null;
/* */ }
/* */
/* */ private void updateMnemonics()
/* */ {
/* 520 */ resetMnemonics();
/* 521 */ for (int i = this.tabPane.getTabCount() - 1; i >= 0;
/* 522 */ i--) {
/* 523 */ int j = this.tabPane.getMnemonicAt(i);
/* */
/* 525 */ if (j > 0)
/* 526 */ addMnemonic(i, j);
/* */ }
/* */ }
/* */
/* */ private void resetMnemonics()
/* */ {
/* 535 */ if (this.mnemonicToIndexMap != null) {
/* 536 */ this.mnemonicToIndexMap.clear();
/* 537 */ this.mnemonicInputMap.clear();
/* */ }
/* */ }
/* */
/* */ private void addMnemonic(int paramInt1, int paramInt2)
/* */ {
/* 545 */ if (this.mnemonicToIndexMap == null) {
/* 546 */ initMnemonics();
/* */ }
/* 548 */ this.mnemonicInputMap.put(KeyStroke.getKeyStroke(paramInt2, BasicLookAndFeel.getFocusAcceleratorKeyMask()), "setSelectedIndex");
/* */
/* 550 */ this.mnemonicToIndexMap.put(Integer.valueOf(paramInt2), Integer.valueOf(paramInt1));
/* */ }
/* */
/* */ private void initMnemonics()
/* */ {
/* 557 */ this.mnemonicToIndexMap = new Hashtable();
/* 558 */ this.mnemonicInputMap = new ComponentInputMapUIResource(this.tabPane);
/* 559 */ this.mnemonicInputMap.setParent(SwingUtilities.getUIInputMap(this.tabPane, 2));
/* */
/* 561 */ SwingUtilities.replaceUIInputMap(this.tabPane, 2, this.mnemonicInputMap);
/* */ }
/* */
/* */ private void setRolloverTab(int paramInt1, int paramInt2)
/* */ {
/* 575 */ setRolloverTab(tabForCoordinate(this.tabPane, paramInt1, paramInt2, false));
/* */ }
/* */
/* */ protected void setRolloverTab(int paramInt)
/* */ {
/* 588 */ this.rolloverTabIndex = paramInt;
/* */ }
/* */
/* */ protected int getRolloverTab()
/* */ {
/* 600 */ return this.rolloverTabIndex;
/* */ }
/* */
/* */ public Dimension getMinimumSize(JComponent paramJComponent)
/* */ {
/* 605 */ return null;
/* */ }
/* */
/* */ public Dimension getMaximumSize(JComponent paramJComponent)
/* */ {
/* 610 */ return null;
/* */ }
/* */
/* */ public int getBaseline(JComponent paramJComponent, int paramInt1, int paramInt2)
/* */ {
/* 622 */ super.getBaseline(paramJComponent, paramInt1, paramInt2);
/* 623 */ int i = calculateBaselineIfNecessary();
/* 624 */ if (i != -1) {
/* 625 */ int j = this.tabPane.getTabPlacement();
/* 626 */ Insets localInsets1 = this.tabPane.getInsets();
/* 627 */ Insets localInsets2 = getTabAreaInsets(j);
/* 628 */ switch (j) {
/* */ case 1:
/* 630 */ i += localInsets1.top + localInsets2.top;
/* 631 */ return i;
/* */ case 3:
/* 633 */ i = paramInt2 - localInsets1.bottom - localInsets2.bottom - this.maxTabHeight + i;
/* */
/* 635 */ return i;
/* */ case 2:
/* */ case 4:
/* 638 */ i += localInsets1.top + localInsets2.top;
/* 639 */ return i;
/* */ }
/* */ }
/* 642 */ return -1;
/* */ }
/* */
/* */ public Component.BaselineResizeBehavior getBaselineResizeBehavior(JComponent paramJComponent)
/* */ {
/* 655 */ super.getBaselineResizeBehavior(paramJComponent);
/* 656 */ switch (this.tabPane.getTabPlacement()) {
/* */ case 1:
/* */ case 2:
/* */ case 4:
/* 660 */ return Component.BaselineResizeBehavior.CONSTANT_ASCENT;
/* */ case 3:
/* 662 */ return Component.BaselineResizeBehavior.CONSTANT_DESCENT;
/* */ }
/* 664 */ return Component.BaselineResizeBehavior.OTHER;
/* */ }
/* */
/* */ protected int getBaseline(int paramInt)
/* */ {
/* 678 */ if (this.tabPane.getTabComponentAt(paramInt) != null) {
/* 679 */ int i = getBaselineOffset();
/* 680 */ if (i != 0)
/* */ {
/* 684 */ return -1;
/* */ }
/* 686 */ Component localComponent = this.tabPane.getTabComponentAt(paramInt);
/* 687 */ Dimension localDimension = localComponent.getPreferredSize();
/* 688 */ Insets localInsets = getTabInsets(this.tabPane.getTabPlacement(), paramInt);
/* 689 */ int m = this.maxTabHeight - localInsets.top - localInsets.bottom;
/* 690 */ return localComponent.getBaseline(localDimension.width, localDimension.height) + (m - localDimension.height) / 2 + localInsets.top;
/* */ }
/* */
/* 694 */ Object localObject = getTextViewForTab(paramInt);
/* 695 */ if (localObject != null) {
/* 696 */ j = (int)((View)localObject).getPreferredSpan(1);
/* 697 */ k = BasicHTML.getHTMLBaseline((View)localObject, (int)((View)localObject).getPreferredSpan(0), j);
/* */
/* 699 */ if (k >= 0) {
/* 700 */ return this.maxTabHeight / 2 - j / 2 + k + getBaselineOffset();
/* */ }
/* */
/* 703 */ return -1;
/* */ }
/* */
/* 706 */ localObject = getFontMetrics();
/* 707 */ int j = ((FontMetrics)localObject).getHeight();
/* 708 */ int k = ((FontMetrics)localObject).getAscent();
/* 709 */ return this.maxTabHeight / 2 - j / 2 + k + getBaselineOffset();
/* */ }
/* */
/* */ protected int getBaselineOffset()
/* */ {
/* 721 */ switch (this.tabPane.getTabPlacement()) {
/* */ case 1:
/* 723 */ if (this.tabPane.getTabCount() > 1) {
/* 724 */ return 1;
/* */ }
/* */
/* 727 */ return -1;
/* */ case 3:
/* 730 */ if (this.tabPane.getTabCount() > 1) {
/* 731 */ return -1;
/* */ }
/* */
/* 734 */ return 1;
/* */ }
/* */
/* 737 */ return this.maxTabHeight % 2;
/* */ }
/* */
/* */ private int calculateBaselineIfNecessary()
/* */ {
/* 742 */ if (!this.calculatedBaseline) {
/* 743 */ this.calculatedBaseline = true;
/* 744 */ this.baseline = -1;
/* 745 */ if (this.tabPane.getTabCount() > 0) {
/* 746 */ calculateBaseline();
/* */ }
/* */ }
/* 749 */ return this.baseline;
/* */ }
/* */
/* */ private void calculateBaseline() {
/* 753 */ int i = this.tabPane.getTabCount();
/* 754 */ int j = this.tabPane.getTabPlacement();
/* 755 */ this.maxTabHeight = calculateMaxTabHeight(j);
/* 756 */ this.baseline = getBaseline(0);
/* 757 */ if (isHorizontalTabPlacement()) {
/* 758 */ for (int k = 1; k < i; k++) {
/* 759 */ if (getBaseline(k) != this.baseline) {
/* 760 */ this.baseline = -1;
/* 761 */ break;
/* */ }
/* */ }
/* */ }
/* */ else
/* */ {
/* 767 */ FontMetrics localFontMetrics = getFontMetrics();
/* 768 */ int m = localFontMetrics.getHeight();
/* 769 */ int n = calculateTabHeight(j, 0, m);
/* 770 */ for (int i1 = 1; i1 < i; i1++) {
/* 771 */ int i2 = calculateTabHeight(j, i1, m);
/* 772 */ if (n != i2)
/* */ {
/* 774 */ this.baseline = -1;
/* 775 */ break;
/* */ }
/* */ }
/* */ }
/* */ }
/* */
/* */ public void paint(Graphics paramGraphics, JComponent paramJComponent)
/* */ {
/* 784 */ int i = this.tabPane.getSelectedIndex();
/* 785 */ int j = this.tabPane.getTabPlacement();
/* */
/* 787 */ ensureCurrentLayout();
/* */
/* 790 */ if (this.tabsOverlapBorder) {
/* 791 */ paintContentBorder(paramGraphics, j, i);
/* */ }
/* */
/* 796 */ if (!scrollableTabLayoutEnabled()) {
/* 797 */ paintTabArea(paramGraphics, j, i);
/* */ }
/* 799 */ if (!this.tabsOverlapBorder)
/* 800 */ paintContentBorder(paramGraphics, j, i);
/* */ }
/* */
/* */ protected void paintTabArea(Graphics paramGraphics, int paramInt1, int paramInt2)
/* */ {
/* 822 */ int i = this.tabPane.getTabCount();
/* */
/* 824 */ Rectangle localRectangle1 = new Rectangle();
/* 825 */ Rectangle localRectangle2 = new Rectangle();
/* 826 */ Rectangle localRectangle3 = paramGraphics.getClipBounds();
/* */
/* 829 */ for (int j = this.runCount - 1; j >= 0; j--) {
/* 830 */ int k = this.tabRuns[j];
/* 831 */ int m = this.tabRuns[(j + 1)];
/* 832 */ int n = m != 0 ? m - 1 : i - 1;
/* 833 */ for (int i1 = k; i1 <= n; i1++) {
/* 834 */ if ((i1 != paramInt2) && (this.rects[i1].intersects(localRectangle3))) {
/* 835 */ paintTab(paramGraphics, paramInt1, this.rects, i1, localRectangle1, localRectangle2);
/* */ }
/* */
/* */ }
/* */
/* */ }
/* */
/* 842 */ if ((paramInt2 >= 0) && (this.rects[paramInt2].intersects(localRectangle3)))
/* 843 */ paintTab(paramGraphics, paramInt1, this.rects, paramInt2, localRectangle1, localRectangle2);
/* */ }
/* */
/* */ protected void paintTab(Graphics paramGraphics, int paramInt1, Rectangle[] paramArrayOfRectangle, int paramInt2, Rectangle paramRectangle1, Rectangle paramRectangle2)
/* */ {
/* 850 */ Rectangle localRectangle = paramArrayOfRectangle[paramInt2];
/* 851 */ int i = this.tabPane.getSelectedIndex();
/* 852 */ boolean bool = i == paramInt2;
/* */
/* 854 */ if ((this.tabsOpaque) || (this.tabPane.isOpaque())) {
/* 855 */ paintTabBackground(paramGraphics, paramInt1, paramInt2, localRectangle.x, localRectangle.y, localRectangle.width, localRectangle.height, bool);
/* */ }
/* */
/* 859 */ paintTabBorder(paramGraphics, paramInt1, paramInt2, localRectangle.x, localRectangle.y, localRectangle.width, localRectangle.height, bool);
/* */
/* 862 */ String str1 = this.tabPane.getTitleAt(paramInt2);
/* 863 */ Font localFont = this.tabPane.getFont();
/* 864 */ FontMetrics localFontMetrics = SwingUtilities2.getFontMetrics(this.tabPane, paramGraphics, localFont);
/* 865 */ Icon localIcon = getIconForTab(paramInt2);
/* */
/* 867 */ layoutLabel(paramInt1, localFontMetrics, paramInt2, str1, localIcon, localRectangle, paramRectangle1, paramRectangle2, bool);
/* */
/* 870 */ if (this.tabPane.getTabComponentAt(paramInt2) == null) {
/* 871 */ String str2 = str1;
/* */
/* 873 */ if ((scrollableTabLayoutEnabled()) && (this.tabScroller.croppedEdge.isParamsSet()) && (this.tabScroller.croppedEdge.getTabIndex() == paramInt2) && (isHorizontalTabPlacement()))
/* */ {
/* 875 */ int j = this.tabScroller.croppedEdge.getCropline() - (paramRectangle2.x - localRectangle.x) - this.tabScroller.croppedEdge.getCroppedSideWidth();
/* */
/* 877 */ str2 = SwingUtilities2.clipStringIfNecessary(null, localFontMetrics, str1, j);
/* 878 */ } else if ((!scrollableTabLayoutEnabled()) && (isHorizontalTabPlacement())) {
/* 879 */ str2 = SwingUtilities2.clipStringIfNecessary(null, localFontMetrics, str1, paramRectangle2.width);
/* */ }
/* */
/* 882 */ paintText(paramGraphics, paramInt1, localFont, localFontMetrics, paramInt2, str2, paramRectangle2, bool);
/* */
/* 885 */ paintIcon(paramGraphics, paramInt1, paramInt2, localIcon, paramRectangle1, bool);
/* */ }
/* 887 */ paintFocusIndicator(paramGraphics, paramInt1, paramArrayOfRectangle, paramInt2, paramRectangle1, paramRectangle2, bool);
/* */ }
/* */
/* */ private boolean isHorizontalTabPlacement()
/* */ {
/* 892 */ return (this.tabPane.getTabPlacement() == 1) || (this.tabPane.getTabPlacement() == 3);
/* */ }
/* */
/* */ private static Polygon createCroppedTabShape(int paramInt1, Rectangle paramRectangle, int paramInt2)
/* */ {
/* */ int i;
/* */ int j;
/* */ int k;
/* */ int m;
/* 927 */ switch (paramInt1) {
/* */ case 2:
/* */ case 4:
/* 930 */ i = paramRectangle.width;
/* 931 */ j = paramRectangle.x;
/* 932 */ k = paramRectangle.x + paramRectangle.width;
/* 933 */ m = paramRectangle.y + paramRectangle.height;
/* 934 */ break;
/* */ case 1:
/* */ case 3:
/* */ default:
/* 938 */ i = paramRectangle.height;
/* 939 */ j = paramRectangle.y;
/* 940 */ k = paramRectangle.y + paramRectangle.height;
/* 941 */ m = paramRectangle.x + paramRectangle.width;
/* */ }
/* 943 */ int n = i / 12;
/* 944 */ if (i % 12 > 0) {
/* 945 */ n++;
/* */ }
/* 947 */ int i1 = 2 + n * 8;
/* 948 */ int[] arrayOfInt1 = new int[i1];
/* 949 */ int[] arrayOfInt2 = new int[i1];
/* 950 */ int i2 = 0;
/* */
/* 952 */ arrayOfInt1[i2] = m;
/* 953 */ arrayOfInt2[(i2++)] = k;
/* 954 */ arrayOfInt1[i2] = m;
/* 955 */ arrayOfInt2[(i2++)] = j;
/* 956 */ for (int i3 = 0; i3 < n; i3++) {
/* 957 */ for (int i4 = 0; i4 < xCropLen.length; i4++) {
/* 958 */ arrayOfInt1[i2] = (paramInt2 - xCropLen[i4]);
/* 959 */ arrayOfInt2[i2] = (j + i3 * 12 + yCropLen[i4]);
/* 960 */ if (arrayOfInt2[i2] >= k) {
/* 961 */ arrayOfInt2[i2] = k;
/* 962 */ i2++;
/* 963 */ break;
/* */ }
/* 965 */ i2++;
/* */ }
/* */ }
/* 968 */ if ((paramInt1 == 1) || (paramInt1 == 3)) {
/* 969 */ return new Polygon(arrayOfInt1, arrayOfInt2, i2);
/* */ }
/* */
/* 972 */ return new Polygon(arrayOfInt2, arrayOfInt1, i2);
/* */ }
/* */
/* */ private void paintCroppedTabEdge(Graphics paramGraphics)
/* */ {
/* 980 */ int i = this.tabScroller.croppedEdge.getTabIndex();
/* 981 */ int j = this.tabScroller.croppedEdge.getCropline();
/* */ int k;
/* */ int m;
/* */ int n;
/* 983 */ switch (this.tabPane.getTabPlacement()) {
/* */ case 2:
/* */ case 4:
/* 986 */ k = this.rects[i].x;
/* 987 */ m = j;
/* 988 */ n = k;
/* 989 */ paramGraphics.setColor(this.shadow);
/* */ case 1:
/* 990 */ case 3: } while (n <= k + this.rects[i].width) {
/* 991 */ for (int i1 = 0; i1 < xCropLen.length; i1 += 2) {
/* 992 */ paramGraphics.drawLine(n + yCropLen[i1], m - xCropLen[i1], n + yCropLen[(i1 + 1)] - 1, m - xCropLen[(i1 + 1)]);
/* */ }
/* */
/* 995 */ n += 12; continue;
/* */
/* 1001 */ k = j;
/* 1002 */ m = this.rects[i].y;
/* 1003 */ i1 = m;
/* 1004 */ paramGraphics.setColor(this.shadow);
/* 1005 */ while (i1 <= m + this.rects[i].height) {
/* 1006 */ for (int i2 = 0; i2 < xCropLen.length; i2 += 2) {
/* 1007 */ paramGraphics.drawLine(k - xCropLen[i2], i1 + yCropLen[i2], k - xCropLen[(i2 + 1)], i1 + yCropLen[(i2 + 1)] - 1);
/* */ }
/* */
/* 1010 */ i1 += 12;
/* */ }
/* */ }
/* */ }
/* */
/* */ protected void layoutLabel(int paramInt1, FontMetrics paramFontMetrics, int paramInt2, String paramString, Icon paramIcon, Rectangle paramRectangle1, Rectangle paramRectangle2, Rectangle paramRectangle3, boolean paramBoolean)
/* */ {
/* 1020 */ paramRectangle3.x = (paramRectangle3.y = paramRectangle2.x = paramRectangle2.y = 0);
/* */
/* 1022 */ View localView = getTextViewForTab(paramInt2);
/* 1023 */ if (localView != null) {
/* 1024 */ this.tabPane.putClientProperty("html", localView);
/* */ }
/* */
/* 1027 */ SwingUtilities.layoutCompoundLabel(this.tabPane, paramFontMetrics, paramString, paramIcon, 0, 0, 0, 11, paramRectangle1, paramRectangle2, paramRectangle3, this.textIconGap);
/* */
/* 1038 */ this.tabPane.putClientProperty("html", null);
/* */
/* 1040 */ int i = getTabLabelShiftX(paramInt1, paramInt2, paramBoolean);
/* 1041 */ int j = getTabLabelShiftY(paramInt1, paramInt2, paramBoolean);
/* 1042 */ paramRectangle2.x += i;
/* 1043 */ paramRectangle2.y += j;
/* 1044 */ paramRectangle3.x += i;
/* 1045 */ paramRectangle3.y += j;
/* */ }
/* */
/* */ protected void paintIcon(Graphics paramGraphics, int paramInt1, int paramInt2, Icon paramIcon, Rectangle paramRectangle, boolean paramBoolean)
/* */ {
/* 1051 */ if (paramIcon != null)
/* 1052 */ paramIcon.paintIcon(this.tabPane, paramGraphics, paramRectangle.x, paramRectangle.y);
/* */ }
/* */
/* */ protected void paintText(Graphics paramGraphics, int paramInt1, Font paramFont, FontMetrics paramFontMetrics, int paramInt2, String paramString, Rectangle paramRectangle, boolean paramBoolean)
/* */ {
/* 1061 */ paramGraphics.setFont(paramFont);
/* */
/* 1063 */ View localView = getTextViewForTab(paramInt2);
/* 1064 */ if (localView != null)
/* */ {
/* 1066 */ localView.paint(paramGraphics, paramRectangle);
/* */ }
/* */ else {
/* 1069 */ int i = this.tabPane.getDisplayedMnemonicIndexAt(paramInt2);
/* */
/* 1071 */ if ((this.tabPane.isEnabled()) && (this.tabPane.isEnabledAt(paramInt2))) {
/* 1072 */ Object localObject = this.tabPane.getForegroundAt(paramInt2);
/* 1073 */ if ((paramBoolean) && ((localObject instanceof UIResource))) {
/* 1074 */ Color localColor = UIManager.getColor("TabbedPane.selectedForeground");
/* */
/* 1076 */ if (localColor != null) {
/* 1077 */ localObject = localColor;
/* */ }
/* */ }
/* 1080 */ paramGraphics.setColor((Color)localObject);
/* 1081 */ SwingUtilities2.drawStringUnderlineCharAt(this.tabPane, paramGraphics, paramString, i, paramRectangle.x, paramRectangle.y + paramFontMetrics.getAscent());
/* */ }
/* */ else
/* */ {
/* 1086 */ paramGraphics.setColor(this.tabPane.getBackgroundAt(paramInt2).brighter());
/* 1087 */ SwingUtilities2.drawStringUnderlineCharAt(this.tabPane, paramGraphics, paramString, i, paramRectangle.x, paramRectangle.y + paramFontMetrics.getAscent());
/* */
/* 1090 */ paramGraphics.setColor(this.tabPane.getBackgroundAt(paramInt2).darker());
/* 1091 */ SwingUtilities2.drawStringUnderlineCharAt(this.tabPane, paramGraphics, paramString, i, paramRectangle.x - 1, paramRectangle.y + paramFontMetrics.getAscent() - 1);
/* */ }
/* */ }
/* */ }
/* */
/* */ protected int getTabLabelShiftX(int paramInt1, int paramInt2, boolean paramBoolean)
/* */ {
/* 1101 */ Rectangle localRectangle = this.rects[paramInt2];
/* 1102 */ String str = paramBoolean ? "selectedLabelShift" : "labelShift";
/* 1103 */ int i = DefaultLookup.getInt(this.tabPane, this, "TabbedPane." + str, 1);
/* */
/* 1106 */ switch (paramInt1) {
/* */ case 2:
/* 1108 */ return i;
/* */ case 4:
/* 1110 */ return -i;
/* */ case 1:
/* */ case 3:
/* */ }
/* 1114 */ return localRectangle.width % 2;
/* */ }
/* */
/* */ protected int getTabLabelShiftY(int paramInt1, int paramInt2, boolean paramBoolean)
/* */ {
/* 1119 */ Rectangle localRectangle = this.rects[paramInt2];
/* 1120 */ int i = paramBoolean ? DefaultLookup.getInt(this.tabPane, this, "TabbedPane.selectedLabelShift", -1) : DefaultLookup.getInt(this.tabPane, this, "TabbedPane.labelShift", 1);
/* */
/* 1123 */ switch (paramInt1) {
/* */ case 3:
/* 1125 */ return -i;
/* */ case 2:
/* */ case 4:
/* 1128 */ return localRectangle.height % 2;
/* */ case 1:
/* */ }
/* 1131 */ return i;
/* */ }
/* */
/* */ protected void paintFocusIndicator(Graphics paramGraphics, int paramInt1, Rectangle[] paramArrayOfRectangle, int paramInt2, Rectangle paramRectangle1, Rectangle paramRectangle2, boolean paramBoolean)
/* */ {
/* 1139 */ Rectangle localRectangle = paramArrayOfRectangle[paramInt2];
/* 1140 */ if ((this.tabPane.hasFocus()) && (paramBoolean))
/* */ {
/* 1142 */ paramGraphics.setColor(this.focus);
/* */ int i;
/* */ int j;
/* */ int k;
/* */ int m;
/* 1143 */ switch (paramInt1) {
/* */ case 2:
/* 1145 */ i = localRectangle.x + 3;
/* 1146 */ j = localRectangle.y + 3;
/* 1147 */ k = localRectangle.width - 5;
/* 1148 */ m = localRectangle.height - 6;
/* 1149 */ break;
/* */ case 4:
/* 1151 */ i = localRectangle.x + 2;
/* 1152 */ j = localRectangle.y + 3;
/* 1153 */ k = localRectangle.width - 5;
/* 1154 */ m = localRectangle.height - 6;
/* 1155 */ break;
/* */ case 3:
/* 1157 */ i = localRectangle.x + 3;
/* 1158 */ j = localRectangle.y + 2;
/* 1159 */ k = localRectangle.width - 6;
/* 1160 */ m = localRectangle.height - 5;
/* 1161 */ break;
/* */ case 1:
/* */ default:
/* 1164 */ i = localRectangle.x + 3;
/* 1165 */ j = localRectangle.y + 3;
/* 1166 */ k = localRectangle.width - 6;
/* 1167 */ m = localRectangle.height - 5;
/* */ }
/* 1169 */ BasicGraphicsUtils.drawDashedRect(paramGraphics, i, j, k, m);
/* */ }
/* */ }
/* */
/* */ protected void paintTabBorder(Graphics paramGraphics, int paramInt1, int paramInt2, int paramInt3, int paramInt4, int paramInt5, int paramInt6, boolean paramBoolean)
/* */ {
/* 1182 */ paramGraphics.setColor(this.lightHighlight);
/* */
/* 1184 */ switch (paramInt1) {
/* */ case 2:
/* 1186 */ paramGraphics.drawLine(paramInt3 + 1, paramInt4 + paramInt6 - 2, paramInt3 + 1, paramInt4 + paramInt6 - 2);
/* 1187 */ paramGraphics.drawLine(paramInt3, paramInt4 + 2, paramInt3, paramInt4 + paramInt6 - 3);
/* 1188 */ paramGraphics.drawLine(paramInt3 + 1, paramInt4 + 1, paramInt3 + 1, paramInt4 + 1);
/* 1189 */ paramGraphics.drawLine(paramInt3 + 2, paramInt4, paramInt3 + paramInt5 - 1, paramInt4);
/* */
/* 1191 */ paramGraphics.setColor(this.shadow);
/* 1192 */ paramGraphics.drawLine(paramInt3 + 2, paramInt4 + paramInt6 - 2, paramInt3 + paramInt5 - 1, paramInt4 + paramInt6 - 2);
/* */
/* 1194 */ paramGraphics.setColor(this.darkShadow);
/* 1195 */ paramGraphics.drawLine(paramInt3 + 2, paramInt4 + paramInt6 - 1, paramInt3 + paramInt5 - 1, paramInt4 + paramInt6 - 1);
/* 1196 */ break;
/* */ case 4:
/* 1198 */ paramGraphics.drawLine(paramInt3, paramInt4, paramInt3 + paramInt5 - 3, paramInt4);
/* */
/* 1200 */ paramGraphics.setColor(this.shadow);
/* 1201 */ paramGraphics.drawLine(paramInt3, paramInt4 + paramInt6 - 2, paramInt3 + paramInt5 - 3, paramInt4 + paramInt6 - 2);
/* 1202 */ paramGraphics.drawLine(paramInt3 + paramInt5 - 2, paramInt4 + 2, paramInt3 + paramInt5 - 2, paramInt4 + paramInt6 - 3);
/* */
/* 1204 */ paramGraphics.setColor(this.darkShadow);
/* 1205 */ paramGraphics.drawLine(paramInt3 + paramInt5 - 2, paramInt4 + 1, paramInt3 + paramInt5 - 2, paramInt4 + 1);
/* 1206 */ paramGraphics.drawLine(paramInt3 + paramInt5 - 2, paramInt4 + paramInt6 - 2, paramInt3 + paramInt5 - 2, paramInt4 + paramInt6 - 2);
/* 1207 */ paramGraphics.drawLine(paramInt3 + paramInt5 - 1, paramInt4 + 2, paramInt3 + paramInt5 - 1, paramInt4 + paramInt6 - 3);
/* 1208 */ paramGraphics.drawLine(paramInt3, paramInt4 + paramInt6 - 1, paramInt3 + paramInt5 - 3, paramInt4 + paramInt6 - 1);
/* 1209 */ break;
/* */ case 3:
/* 1211 */ paramGraphics.drawLine(paramInt3, paramInt4, paramInt3, paramInt4 + paramInt6 - 3);
/* 1212 */ paramGraphics.drawLine(paramInt3 + 1, paramInt4 + paramInt6 - 2, paramInt3 + 1, paramInt4 + paramInt6 - 2);
/* */
/* 1214 */ paramGraphics.setColor(this.shadow);
/* 1215 */ paramGraphics.drawLine(paramInt3 + 2, paramInt4 + paramInt6 - 2, paramInt3 + paramInt5 - 3, paramInt4 + paramInt6 - 2);
/* 1216 */ paramGraphics.drawLine(paramInt3 + paramInt5 - 2, paramInt4, paramInt3 + paramInt5 - 2, paramInt4 + paramInt6 - 3);
/* */
/* 1218 */ paramGraphics.setColor(this.darkShadow);
/* 1219 */ paramGraphics.drawLine(paramInt3 + 2, paramInt4 + paramInt6 - 1, paramInt3 + paramInt5 - 3, paramInt4 + paramInt6 - 1);
/* 1220 */ paramGraphics.drawLine(paramInt3 + paramInt5 - 2, paramInt4 + paramInt6 - 2, paramInt3 + paramInt5 - 2, paramInt4 + paramInt6 - 2);
/* 1221 */ paramGraphics.drawLine(paramInt3 + paramInt5 - 1, paramInt4, paramInt3 + paramInt5 - 1, paramInt4 + paramInt6 - 3);
/* 1222 */ break;
/* */ case 1:
/* */ default:
/* 1225 */ paramGraphics.drawLine(paramInt3, paramInt4 + 2, paramInt3, paramInt4 + paramInt6 - 1);
/* 1226 */ paramGraphics.drawLine(paramInt3 + 1, paramInt4 + 1, paramInt3 + 1, paramInt4 + 1);
/* 1227 */ paramGraphics.drawLine(paramInt3 + 2, paramInt4, paramInt3 + paramInt5 - 3, paramInt4);
/* */
/* 1229 */ paramGraphics.setColor(this.shadow);
/* 1230 */ paramGraphics.drawLine(paramInt3 + paramInt5 - 2, paramInt4 + 2, paramInt3 + paramInt5 - 2, paramInt4 + paramInt6 - 1);
/* */
/* 1232 */ paramGraphics.setColor(this.darkShadow);
/* 1233 */ paramGraphics.drawLine(paramInt3 + paramInt5 - 1, paramInt4 + 2, paramInt3 + paramInt5 - 1, paramInt4 + paramInt6 - 1);
/* 1234 */ paramGraphics.drawLine(paramInt3 + paramInt5 - 2, paramInt4 + 1, paramInt3 + paramInt5 - 2, paramInt4 + 1);
/* */ }
/* */ }
/* */
/* */ protected void paintTabBackground(Graphics paramGraphics, int paramInt1, int paramInt2, int paramInt3, int paramInt4, int paramInt5, int paramInt6, boolean paramBoolean)
/* */ {
/* 1242 */ paramGraphics.setColor((!paramBoolean) || (this.selectedColor == null) ? this.tabPane.getBackgroundAt(paramInt2) : this.selectedColor);
/* */
/* 1244 */ switch (paramInt1) {
/* */ case 2:
/* 1246 */ paramGraphics.fillRect(paramInt3 + 1, paramInt4 + 1, paramInt5 - 1, paramInt6 - 3);
/* 1247 */ break;
/* */ case 4:
/* 1249 */ paramGraphics.fillRect(paramInt3, paramInt4 + 1, paramInt5 - 2, paramInt6 - 3);
/* 1250 */ break;
/* */ case 3:
/* 1252 */ paramGraphics.fillRect(paramInt3 + 1, paramInt4, paramInt5 - 3, paramInt6 - 1);
/* 1253 */ break;
/* */ case 1:
/* */ default:
/* 1256 */ paramGraphics.fillRect(paramInt3 + 1, paramInt4 + 1, paramInt5 - 3, paramInt6 - 1);
/* */ }
/* */ }
/* */
/* */ protected void paintContentBorder(Graphics paramGraphics, int paramInt1, int paramInt2) {
/* 1261 */ int i = this.tabPane.getWidth();
/* 1262 */ int j = this.tabPane.getHeight();
/* 1263 */ Insets localInsets1 = this.tabPane.getInsets();
/* 1264 */ Insets localInsets2 = getTabAreaInsets(paramInt1);
/* */
/* 1266 */ int k = localInsets1.left;
/* 1267 */ int m = localInsets1.top;
/* 1268 */ int n = i - localInsets1.right - localInsets1.left;
/* 1269 */ int i1 = j - localInsets1.top - localInsets1.bottom;
/* */
/* 1271 */ switch (paramInt1) {
/* */ case 2:
/* 1273 */ k += calculateTabAreaWidth(paramInt1, this.runCount, this.maxTabWidth);
/* 1274 */ if (this.tabsOverlapBorder) {
/* 1275 */ k -= localInsets2.right;
/* */ }
/* 1277 */ n -= k - localInsets1.left;
/* 1278 */ break;
/* */ case 4:
/* 1280 */ n -= calculateTabAreaWidth(paramInt1, this.runCount, this.maxTabWidth);
/* 1281 */ if (this.tabsOverlapBorder)
/* 1282 */ n += localInsets2.left; break;
/* */ case 3:
/* 1286 */ i1 -= calculateTabAreaHeight(paramInt1, this.runCount, this.maxTabHeight);
/* 1287 */ if (this.tabsOverlapBorder)
/* 1288 */ i1 += localInsets2.top; break;
/* */ case 1:
/* */ default:
/* 1293 */ m += calculateTabAreaHeight(paramInt1, this.runCount, this.maxTabHeight);
/* 1294 */ if (this.tabsOverlapBorder) {
/* 1295 */ m -= localInsets2.bottom;
/* */ }
/* 1297 */ i1 -= m - localInsets1.top;
/* */ }
/* */
/* 1300 */ if ((this.tabPane.getTabCount() > 0) && ((this.contentOpaque) || (this.tabPane.isOpaque())))
/* */ {
/* 1302 */ Color localColor = UIManager.getColor("TabbedPane.contentAreaColor");
/* 1303 */ if (localColor != null) {
/* 1304 */ paramGraphics.setColor(localColor);
/* */ }
/* 1306 */ else if ((this.selectedColor == null) || (paramInt2 == -1)) {
/* 1307 */ paramGraphics.setColor(this.tabPane.getBackground());
/* */ }
/* */ else {
/* 1310 */ paramGraphics.setColor(this.selectedColor);
/* */ }
/* 1312 */ paramGraphics.fillRect(k, m, n, i1);
/* */ }
/* */
/* 1315 */ paintContentBorderTopEdge(paramGraphics, paramInt1, paramInt2, k, m, n, i1);
/* 1316 */ paintContentBorderLeftEdge(paramGraphics, paramInt1, paramInt2, k, m, n, i1);
/* 1317 */ paintContentBorderBottomEdge(paramGraphics, paramInt1, paramInt2, k, m, n, i1);
/* 1318 */ paintContentBorderRightEdge(paramGraphics, paramInt1, paramInt2, k, m, n, i1);
/* */ }
/* */
/* */ protected void paintContentBorderTopEdge(Graphics paramGraphics, int paramInt1, int paramInt2, int paramInt3, int paramInt4, int paramInt5, int paramInt6)
/* */ {
/* 1325 */ Rectangle localRectangle = paramInt2 < 0 ? null : getTabBounds(paramInt2, this.calcRect);
/* */
/* 1328 */ paramGraphics.setColor(this.lightHighlight);
/* */
/* 1334 */ if ((paramInt1 != 1) || (paramInt2 < 0) || (localRectangle.y + localRectangle.height + 1 < paramInt4) || (localRectangle.x < paramInt3) || (localRectangle.x > paramInt3 + paramInt5))
/* */ {
/* 1337 */ paramGraphics.drawLine(paramInt3, paramInt4, paramInt3 + paramInt5 - 2, paramInt4);
/* */ }
/* */ else {
/* 1340 */ paramGraphics.drawLine(paramInt3, paramInt4, localRectangle.x - 1, paramInt4);
/* 1341 */ if (localRectangle.x + localRectangle.width < paramInt3 + paramInt5 - 2) {
/* 1342 */ paramGraphics.drawLine(localRectangle.x + localRectangle.width, paramInt4, paramInt3 + paramInt5 - 2, paramInt4);
/* */ }
/* */ else {
/* 1345 */ paramGraphics.setColor(this.shadow);
/* 1346 */ paramGraphics.drawLine(paramInt3 + paramInt5 - 2, paramInt4, paramInt3 + paramInt5 - 2, paramInt4);
/* */ }
/* */ }
/* */ }
/* */
/* */ protected void paintContentBorderLeftEdge(Graphics paramGraphics, int paramInt1, int paramInt2, int paramInt3, int paramInt4, int paramInt5, int paramInt6)
/* */ {
/* 1354 */ Rectangle localRectangle = paramInt2 < 0 ? null : getTabBounds(paramInt2, this.calcRect);
/* */
/* 1357 */ paramGraphics.setColor(this.lightHighlight);
/* */
/* 1363 */ if ((paramInt1 != 2) || (paramInt2 < 0) || (localRectangle.x + localRectangle.width + 1 < paramInt3) || (localRectangle.y < paramInt4) || (localRectangle.y > paramInt4 + paramInt6))
/* */ {
/* 1366 */ paramGraphics.drawLine(paramInt3, paramInt4, paramInt3, paramInt4 + paramInt6 - 2);
/* */ }
/* */ else {
/* 1369 */ paramGraphics.drawLine(paramInt3, paramInt4, paramInt3, localRectangle.y - 1);
/* 1370 */ if (localRectangle.y + localRectangle.height < paramInt4 + paramInt6 - 2)
/* 1371 */ paramGraphics.drawLine(paramInt3, localRectangle.y + localRectangle.height, paramInt3, paramInt4 + paramInt6 - 2);
/* */ }
/* */ }
/* */
/* */ protected void paintContentBorderBottomEdge(Graphics paramGraphics, int paramInt1, int paramInt2, int paramInt3, int paramInt4, int paramInt5, int paramInt6)
/* */ {
/* 1380 */ Rectangle localRectangle = paramInt2 < 0 ? null : getTabBounds(paramInt2, this.calcRect);
/* */
/* 1383 */ paramGraphics.setColor(this.shadow);
/* */
/* 1389 */ if ((paramInt1 != 3) || (paramInt2 < 0) || (localRectangle.y - 1 > paramInt6) || (localRectangle.x < paramInt3) || (localRectangle.x > paramInt3 + paramInt5))
/* */ {
/* 1392 */ paramGraphics.drawLine(paramInt3 + 1, paramInt4 + paramInt6 - 2, paramInt3 + paramInt5 - 2, paramInt4 + paramInt6 - 2);
/* 1393 */ paramGraphics.setColor(this.darkShadow);
/* 1394 */ paramGraphics.drawLine(paramInt3, paramInt4 + paramInt6 - 1, paramInt3 + paramInt5 - 1, paramInt4 + paramInt6 - 1);
/* */ }
/* */ else {
/* 1397 */ paramGraphics.drawLine(paramInt3 + 1, paramInt4 + paramInt6 - 2, localRectangle.x - 1, paramInt4 + paramInt6 - 2);
/* 1398 */ paramGraphics.setColor(this.darkShadow);
/* 1399 */ paramGraphics.drawLine(paramInt3, paramInt4 + paramInt6 - 1, localRectangle.x - 1, paramInt4 + paramInt6 - 1);
/* 1400 */ if (localRectangle.x + localRectangle.width < paramInt3 + paramInt5 - 2) {
/* 1401 */ paramGraphics.setColor(this.shadow);
/* 1402 */ paramGraphics.drawLine(localRectangle.x + localRectangle.width, paramInt4 + paramInt6 - 2, paramInt3 + paramInt5 - 2, paramInt4 + paramInt6 - 2);
/* 1403 */ paramGraphics.setColor(this.darkShadow);
/* 1404 */ paramGraphics.drawLine(localRectangle.x + localRectangle.width, paramInt4 + paramInt6 - 1, paramInt3 + paramInt5 - 1, paramInt4 + paramInt6 - 1);
/* */ }
/* */ }
/* */ }
/* */
/* */ protected void paintContentBorderRightEdge(Graphics paramGraphics, int paramInt1, int paramInt2, int paramInt3, int paramInt4, int paramInt5, int paramInt6)
/* */ {
/* 1413 */ Rectangle localRectangle = paramInt2 < 0 ? null : getTabBounds(paramInt2, this.calcRect);
/* */
/* 1416 */ paramGraphics.setColor(this.shadow);
/* */
/* 1422 */ if ((paramInt1 != 4) || (paramInt2 < 0) || (localRectangle.x - 1 > paramInt5) || (localRectangle.y < paramInt4) || (localRectangle.y > paramInt4 + paramInt6))
/* */ {
/* 1425 */ paramGraphics.drawLine(paramInt3 + paramInt5 - 2, paramInt4 + 1, paramInt3 + paramInt5 - 2, paramInt4 + paramInt6 - 3);
/* 1426 */ paramGraphics.setColor(this.darkShadow);
/* 1427 */ paramGraphics.drawLine(paramInt3 + paramInt5 - 1, paramInt4, paramInt3 + paramInt5 - 1, paramInt4 + paramInt6 - 1);
/* */ }
/* */ else {
/* 1430 */ paramGraphics.drawLine(paramInt3 + paramInt5 - 2, paramInt4 + 1, paramInt3 + paramInt5 - 2, localRectangle.y - 1);
/* 1431 */ paramGraphics.setColor(this.darkShadow);
/* 1432 */ paramGraphics.drawLine(paramInt3 + paramInt5 - 1, paramInt4, paramInt3 + paramInt5 - 1, localRectangle.y - 1);
/* */
/* 1434 */ if (localRectangle.y + localRectangle.height < paramInt4 + paramInt6 - 2) {
/* 1435 */ paramGraphics.setColor(this.shadow);
/* 1436 */ paramGraphics.drawLine(paramInt3 + paramInt5 - 2, localRectangle.y + localRectangle.height, paramInt3 + paramInt5 - 2, paramInt4 + paramInt6 - 2);
/* */
/* 1438 */ paramGraphics.setColor(this.darkShadow);
/* 1439 */ paramGraphics.drawLine(paramInt3 + paramInt5 - 1, localRectangle.y + localRectangle.height, paramInt3 + paramInt5 - 1, paramInt4 + paramInt6 - 2);
/* */ }
/* */ }
/* */ }
/* */
/* */ private void ensureCurrentLayout()
/* */ {
/* 1446 */ if (!this.tabPane.isValid()) {
/* 1447 */ this.tabPane.validate();
/* */ }
/* */
/* 1453 */ if (!this.tabPane.isValid()) {
/* 1454 */ TabbedPaneLayout localTabbedPaneLayout = (TabbedPaneLayout)this.tabPane.getLayout();
/* 1455 */ localTabbedPaneLayout.calculateLayoutInfo();
/* */ }
/* */ }
/* */
/* */ public Rectangle getTabBounds(JTabbedPane paramJTabbedPane, int paramInt)
/* */ {
/* 1467 */ ensureCurrentLayout();
/* 1468 */ Rectangle localRectangle = new Rectangle();
/* 1469 */ return getTabBounds(paramInt, localRectangle);
/* */ }
/* */
/* */ public int getTabRunCount(JTabbedPane paramJTabbedPane) {
/* 1473 */ ensureCurrentLayout();
/* 1474 */ return this.runCount;
/* */ }
/* */
/* */ public int tabForCoordinate(JTabbedPane paramJTabbedPane, int paramInt1, int paramInt2)
/* */ {
/* 1482 */ return tabForCoordinate(paramJTabbedPane, paramInt1, paramInt2, true);
/* */ }
/* */
/* */ private int tabForCoordinate(JTabbedPane paramJTabbedPane, int paramInt1, int paramInt2, boolean paramBoolean)
/* */ {
/* 1487 */ if (paramBoolean) {
/* 1488 */ ensureCurrentLayout();
/* */ }
/* 1490 */ if (this.isRunsDirty)
/* */ {
/* 1493 */ return -1;
/* */ }
/* 1495 */ Point localPoint = new Point(paramInt1, paramInt2);
/* */
/* 1497 */ if (scrollableTabLayoutEnabled()) {
/* 1498 */ translatePointToTabPanel(paramInt1, paramInt2, localPoint);
/* 1499 */ Rectangle localRectangle = this.tabScroller.viewport.getViewRect();
/* 1500 */ if (!localRectangle.contains(localPoint)) {
/* 1501 */ return -1;
/* */ }
/* */ }
/* 1504 */ int i = this.tabPane.getTabCount();
/* 1505 */ for (int j = 0; j < i; j++) {
/* 1506 */ if (this.rects[j].contains(localPoint.x, localPoint.y)) {
/* 1507 */ return j;
/* */ }
/* */ }
/* 1510 */ return -1;
/* */ }
/* */
/* */ protected Rectangle getTabBounds(int paramInt, Rectangle paramRectangle)
/* */ {
/* 1534 */ paramRectangle.width = this.rects[paramInt].width;
/* 1535 */ paramRectangle.height = this.rects[paramInt].height;
/* */
/* 1537 */ if (scrollableTabLayoutEnabled())
/* */ {
/* 1540 */ Point localPoint1 = this.tabScroller.viewport.getLocation();
/* 1541 */ Point localPoint2 = this.tabScroller.viewport.getViewPosition();
/* 1542 */ paramRectangle.x = (this.rects[paramInt].x + localPoint1.x - localPoint2.x);
/* 1543 */ paramRectangle.y = (this.rects[paramInt].y + localPoint1.y - localPoint2.y);
/* */ }
/* */ else {
/* 1546 */ paramRectangle.x = this.rects[paramInt].x;
/* 1547 */ paramRectangle.y = this.rects[paramInt].y;
/* */ }
/* 1549 */ return paramRectangle;
/* */ }
/* */
/* */ private int getClosestTab(int paramInt1, int paramInt2)
/* */ {
/* 1557 */ int i = 0;
/* 1558 */ int j = Math.min(this.rects.length, this.tabPane.getTabCount());
/* 1559 */ int k = j;
/* 1560 */ int m = this.tabPane.getTabPlacement();
/* 1561 */ int n = (m == 1) || (m == 3) ? 1 : 0;
/* 1562 */ int i1 = n != 0 ? paramInt1 : paramInt2;
/* */
/* 1564 */ while (i != k) {
/* 1565 */ int i2 = (k + i) / 2;
/* */ int i3;
/* */ int i4;
/* 1569 */ if (n != 0) {
/* 1570 */ i3 = this.rects[i2].x;
/* 1571 */ i4 = i3 + this.rects[i2].width;
/* */ }
/* */ else {
/* 1574 */ i3 = this.rects[i2].y;
/* 1575 */ i4 = i3 + this.rects[i2].height;
/* */ }
/* 1577 */ if (i1 < i3) {
/* 1578 */ k = i2;
/* 1579 */ if (i == k) {
/* 1580 */ return Math.max(0, i2 - 1);
/* */ }
/* */ }
/* 1583 */ else if (i1 >= i4) {
/* 1584 */ i = i2;
/* 1585 */ if (k - i <= 1)
/* 1586 */ return Math.max(i2 + 1, j - 1);
/* */ }
/* */ else
/* */ {
/* 1590 */ return i2;
/* */ }
/* */ }
/* 1593 */ return i;
/* */ }
/* */
/* */ private Point translatePointToTabPanel(int paramInt1, int paramInt2, Point paramPoint)
/* */ {
/* 1602 */ Point localPoint1 = this.tabScroller.viewport.getLocation();
/* 1603 */ Point localPoint2 = this.tabScroller.viewport.getViewPosition();
/* 1604 */ paramPoint.x = (paramInt1 - localPoint1.x + localPoint2.x);
/* 1605 */ paramPoint.y = (paramInt2 - localPoint1.y + localPoint2.y);
/* 1606 */ return paramPoint;
/* */ }
/* */
/* */ protected Component getVisibleComponent()
/* */ {
/* 1612 */ return this.visibleComponent;
/* */ }
/* */
/* */ protected void setVisibleComponent(Component paramComponent) {
/* 1616 */ if ((this.visibleComponent != null) && (this.visibleComponent != paramComponent) && (this.visibleComponent.getParent() == this.tabPane) && (this.visibleComponent.isVisible()))
/* */ {
/* 1621 */ this.visibleComponent.setVisible(false);
/* */ }
/* 1623 */ if ((paramComponent != null) && (!paramComponent.isVisible())) {
/* 1624 */ paramComponent.setVisible(true);
/* */ }
/* 1626 */ this.visibleComponent = paramComponent;
/* */ }
/* */
/* */ protected void assureRectsCreated(int paramInt) {
/* 1630 */ int i = this.rects.length;
/* 1631 */ if (paramInt != i) {
/* 1632 */ Rectangle[] arrayOfRectangle = new Rectangle[paramInt];
/* 1633 */ System.arraycopy(this.rects, 0, arrayOfRectangle, 0, Math.min(i, paramInt));
/* */
/* 1635 */ this.rects = arrayOfRectangle;
/* 1636 */ for (int j = i; j < paramInt; j++)
/* 1637 */ this.rects[j] = new Rectangle();
/* */ }
/* */ }
/* */
/* */ protected void expandTabRunsArray()
/* */ {
/* 1644 */ int i = this.tabRuns.length;
/* 1645 */ int[] arrayOfInt = new int[i + 10];
/* 1646 */ System.arraycopy(this.tabRuns, 0, arrayOfInt, 0, this.runCount);
/* 1647 */ this.tabRuns = arrayOfInt;
/* */ }
/* */
/* */ protected int getRunForTab(int paramInt1, int paramInt2) {
/* 1651 */ for (int i = 0; i < this.runCount; i++) {
/* 1652 */ int j = this.tabRuns[i];
/* 1653 */ int k = lastTabInRun(paramInt1, i);
/* 1654 */ if ((paramInt2 >= j) && (paramInt2 <= k)) {
/* 1655 */ return i;
/* */ }
/* */ }
/* 1658 */ return 0;
/* */ }
/* */
/* */ protected int lastTabInRun(int paramInt1, int paramInt2) {
/* 1662 */ if (this.runCount == 1) {
/* 1663 */ return paramInt1 - 1;
/* */ }
/* 1665 */ int i = paramInt2 == this.runCount - 1 ? 0 : paramInt2 + 1;
/* 1666 */ if (this.tabRuns[i] == 0) {
/* 1667 */ return paramInt1 - 1;
/* */ }
/* 1669 */ return this.tabRuns[i] - 1;
/* */ }
/* */
/* */ protected int getTabRunOverlay(int paramInt) {
/* 1673 */ return this.tabRunOverlay;
/* */ }
/* */
/* */ protected int getTabRunIndent(int paramInt1, int paramInt2) {
/* 1677 */ return 0;
/* */ }
/* */
/* */ protected boolean shouldPadTabRun(int paramInt1, int paramInt2) {
/* 1681 */ return this.runCount > 1;
/* */ }
/* */
/* */ protected boolean shouldRotateTabRuns(int paramInt) {
/* 1685 */ return true;
/* */ }
/* */
/* */ protected Icon getIconForTab(int paramInt) {
/* 1689 */ return (!this.tabPane.isEnabled()) || (!this.tabPane.isEnabledAt(paramInt)) ? this.tabPane.getDisabledIconAt(paramInt) : this.tabPane.getIconAt(paramInt);
/* */ }
/* */
/* */ protected View getTextViewForTab(int paramInt)
/* */ {
/* 1705 */ if (this.htmlViews != null) {
/* 1706 */ return (View)this.htmlViews.elementAt(paramInt);
/* */ }
/* 1708 */ return null;
/* */ }
/* */
/* */ protected int calculateTabHeight(int paramInt1, int paramInt2, int paramInt3) {
/* 1712 */ int i = 0;
/* 1713 */ Component localComponent = this.tabPane.getTabComponentAt(paramInt2);
/* 1714 */ if (localComponent != null) {
/* 1715 */ i = localComponent.getPreferredSize().height;
/* */ } else {
/* 1717 */ localObject = getTextViewForTab(paramInt2);
/* 1718 */ if (localObject != null)
/* */ {
/* 1720 */ i += (int)((View)localObject).getPreferredSpan(1);
/* */ }
/* */ else {
/* 1723 */ i += paramInt3;
/* */ }
/* 1725 */ Icon localIcon = getIconForTab(paramInt2);
/* */
/* 1727 */ if (localIcon != null) {
/* 1728 */ i = Math.max(i, localIcon.getIconHeight());
/* */ }
/* */ }
/* 1731 */ Object localObject = getTabInsets(paramInt1, paramInt2);
/* 1732 */ i += ((Insets)localObject).top + ((Insets)localObject).bottom + 2;
/* 1733 */ return i;
/* */ }
/* */
/* */ protected int calculateMaxTabHeight(int paramInt) {
/* 1737 */ FontMetrics localFontMetrics = getFontMetrics();
/* 1738 */ int i = this.tabPane.getTabCount();
/* 1739 */ int j = 0;
/* 1740 */ int k = localFontMetrics.getHeight();
/* 1741 */ for (int m = 0; m < i; m++) {
/* 1742 */ j = Math.max(calculateTabHeight(paramInt, m, k), j);
/* */ }
/* 1744 */ return j;
/* */ }
/* */
/* */ protected int calculateTabWidth(int paramInt1, int paramInt2, FontMetrics paramFontMetrics) {
/* 1748 */ Insets localInsets = getTabInsets(paramInt1, paramInt2);
/* 1749 */ int i = localInsets.left + localInsets.right + 3;
/* 1750 */ Component localComponent = this.tabPane.getTabComponentAt(paramInt2);
/* 1751 */ if (localComponent != null) {
/* 1752 */ i += localComponent.getPreferredSize().width;
/* */ } else {
/* 1754 */ Icon localIcon = getIconForTab(paramInt2);
/* 1755 */ if (localIcon != null) {
/* 1756 */ i += localIcon.getIconWidth() + this.textIconGap;
/* */ }
/* 1758 */ View localView = getTextViewForTab(paramInt2);
/* 1759 */ if (localView != null)
/* */ {
/* 1761 */ i += (int)localView.getPreferredSpan(0);
/* */ }
/* */ else {
/* 1764 */ String str = this.tabPane.getTitleAt(paramInt2);
/* 1765 */ i += SwingUtilities2.stringWidth(this.tabPane, paramFontMetrics, str);
/* */ }
/* */ }
/* 1768 */ return i;
/* */ }
/* */
/* */ protected int calculateMaxTabWidth(int paramInt) {
/* 1772 */ FontMetrics localFontMetrics = getFontMetrics();
/* 1773 */ int i = this.tabPane.getTabCount();
/* 1774 */ int j = 0;
/* 1775 */ for (int k = 0; k < i; k++) {
/* 1776 */ j = Math.max(calculateTabWidth(paramInt, k, localFontMetrics), j);
/* */ }
/* 1778 */ return j;
/* */ }
/* */
/* */ protected int calculateTabAreaHeight(int paramInt1, int paramInt2, int paramInt3) {
/* 1782 */ Insets localInsets = getTabAreaInsets(paramInt1);
/* 1783 */ int i = getTabRunOverlay(paramInt1);
/* 1784 */ return paramInt2 > 0 ? paramInt2 * (paramInt3 - i) + i + localInsets.top + localInsets.bottom : 0;
/* */ }
/* */
/* */ protected int calculateTabAreaWidth(int paramInt1, int paramInt2, int paramInt3)
/* */ {
/* 1791 */ Insets localInsets = getTabAreaInsets(paramInt1);
/* 1792 */ int i = getTabRunOverlay(paramInt1);
/* 1793 */ return paramInt2 > 0 ? paramInt2 * (paramInt3 - i) + i + localInsets.left + localInsets.right : 0;
/* */ }
/* */
/* */ protected Insets getTabInsets(int paramInt1, int paramInt2)
/* */ {
/* 1800 */ return this.tabInsets;
/* */ }
/* */
/* */ protected Insets getSelectedTabPadInsets(int paramInt) {
/* 1804 */ rotateInsets(this.selectedTabPadInsets, this.currentPadInsets, paramInt);
/* 1805 */ return this.currentPadInsets;
/* */ }
/* */
/* */ protected Insets getTabAreaInsets(int paramInt) {
/* 1809 */ rotateInsets(this.tabAreaInsets, this.currentTabAreaInsets, paramInt);
/* 1810 */ return this.currentTabAreaInsets;
/* */ }
/* */
/* */ protected Insets getContentBorderInsets(int paramInt) {
/* 1814 */ return this.contentBorderInsets;
/* */ }
/* */
/* */ protected FontMetrics getFontMetrics() {
/* 1818 */ Font localFont = this.tabPane.getFont();
/* 1819 */ return this.tabPane.getFontMetrics(localFont);
/* */ }
/* */
/* */ protected void navigateSelectedTab(int paramInt)
/* */ {
/* 1826 */ int i = this.tabPane.getTabPlacement();
/* 1827 */ int j = DefaultLookup.getBoolean(this.tabPane, this, "TabbedPane.selectionFollowsFocus", true) ? this.tabPane.getSelectedIndex() : getFocusIndex();
/* */
/* 1830 */ int k = this.tabPane.getTabCount();
/* 1831 */ boolean bool = BasicGraphicsUtils.isLeftToRight(this.tabPane);
/* */
/* 1834 */ if (k <= 0)
/* */ return;
/* */ int m;
/* 1839 */ switch (i) {
/* */ case 2:
/* */ case 4:
/* 1842 */ switch (paramInt) {
/* */ case 12:
/* 1844 */ selectNextTab(j);
/* 1845 */ break;
/* */ case 13:
/* 1847 */ selectPreviousTab(j);
/* 1848 */ break;
/* */ case 1:
/* 1850 */ selectPreviousTabInRun(j);
/* 1851 */ break;
/* */ case 5:
/* 1853 */ selectNextTabInRun(j);
/* 1854 */ break;
/* */ case 7:
/* 1856 */ m = getTabRunOffset(i, k, j, false);
/* 1857 */ selectAdjacentRunTab(i, j, m);
/* 1858 */ break;
/* */ case 3:
/* 1860 */ m = getTabRunOffset(i, k, j, true);
/* 1861 */ selectAdjacentRunTab(i, j, m);
/* */ case 2:
/* */ case 4:
/* */ case 6:
/* */ case 8:
/* */ case 9:
/* */ case 10:
/* 1865 */ case 11: } break;
/* */ case 1:
/* */ case 3:
/* */ default:
/* 1869 */ switch (paramInt) {
/* */ case 12:
/* 1871 */ selectNextTab(j);
/* 1872 */ break;
/* */ case 13:
/* 1874 */ selectPreviousTab(j);
/* 1875 */ break;
/* */ case 1:
/* 1877 */ m = getTabRunOffset(i, k, j, false);
/* 1878 */ selectAdjacentRunTab(i, j, m);
/* 1879 */ break;
/* */ case 5:
/* 1881 */ m = getTabRunOffset(i, k, j, true);
/* 1882 */ selectAdjacentRunTab(i, j, m);
/* 1883 */ break;
/* */ case 3:
/* 1885 */ if (bool)
/* 1886 */ selectNextTabInRun(j);
/* */ else {
/* 1888 */ selectPreviousTabInRun(j);
/* */ }
/* 1890 */ break;
/* */ case 7:
/* 1892 */ if (bool)
/* 1893 */ selectPreviousTabInRun(j);
/* */ else
/* 1895 */ selectNextTabInRun(j); break;
/* */ case 2:
/* */ case 4:
/* */ case 6:
/* */ case 8:
/* */ case 9:
/* */ case 10:
/* 1897 */ case 11: } break;
/* */ }
/* */ }
/* */
/* */ protected void selectNextTabInRun(int paramInt)
/* */ {
/* 1904 */ int i = this.tabPane.getTabCount();
/* 1905 */ int j = getNextTabIndexInRun(i, paramInt);
/* */
/* 1907 */ while ((j != paramInt) && (!this.tabPane.isEnabledAt(j))) {
/* 1908 */ j = getNextTabIndexInRun(i, j);
/* */ }
/* 1910 */ navigateTo(j);
/* */ }
/* */
/* */ protected void selectPreviousTabInRun(int paramInt) {
/* 1914 */ int i = this.tabPane.getTabCount();
/* 1915 */ int j = getPreviousTabIndexInRun(i, paramInt);
/* */
/* 1917 */ while ((j != paramInt) && (!this.tabPane.isEnabledAt(j))) {
/* 1918 */ j = getPreviousTabIndexInRun(i, j);
/* */ }
/* 1920 */ navigateTo(j);
/* */ }
/* */
/* */ protected void selectNextTab(int paramInt) {
/* 1924 */ int i = getNextTabIndex(paramInt);
/* */
/* 1926 */ while ((i != paramInt) && (!this.tabPane.isEnabledAt(i))) {
/* 1927 */ i = getNextTabIndex(i);
/* */ }
/* 1929 */ navigateTo(i);
/* */ }
/* */
/* */ protected void selectPreviousTab(int paramInt) {
/* 1933 */ int i = getPreviousTabIndex(paramInt);
/* */
/* 1935 */ while ((i != paramInt) && (!this.tabPane.isEnabledAt(i))) {
/* 1936 */ i = getPreviousTabIndex(i);
/* */ }
/* 1938 */ navigateTo(i);
/* */ }
/* */
/* */ protected void selectAdjacentRunTab(int paramInt1, int paramInt2, int paramInt3)
/* */ {
/* 1943 */ if (this.runCount < 2) {
/* 1944 */ return;
/* */ }
/* */
/* 1947 */ Rectangle localRectangle = this.rects[paramInt2];
/* */ int i;
/* 1948 */ switch (paramInt1) {
/* */ case 2:
/* */ case 4:
/* 1951 */ i = tabForCoordinate(this.tabPane, localRectangle.x + localRectangle.width / 2 + paramInt3, localRectangle.y + localRectangle.height / 2);
/* */
/* 1953 */ break;
/* */ case 1:
/* */ case 3:
/* */ default:
/* 1957 */ i = tabForCoordinate(this.tabPane, localRectangle.x + localRectangle.width / 2, localRectangle.y + localRectangle.height / 2 + paramInt3);
/* */ }
/* */
/* 1960 */ if (i != -1) {
/* 1961 */ while ((!this.tabPane.isEnabledAt(i)) && (i != paramInt2)) {
/* 1962 */ i = getNextTabIndex(i);
/* */ }
/* 1964 */ navigateTo(i);
/* */ }
/* */ }
/* */
/* */ private void navigateTo(int paramInt) {
/* 1969 */ if (DefaultLookup.getBoolean(this.tabPane, this, "TabbedPane.selectionFollowsFocus", true))
/* */ {
/* 1971 */ this.tabPane.setSelectedIndex(paramInt);
/* */ }
/* */ else
/* 1974 */ setFocusIndex(paramInt, true);
/* */ }
/* */
/* */ void setFocusIndex(int paramInt, boolean paramBoolean)
/* */ {
/* 1979 */ if ((paramBoolean) && (!this.isRunsDirty)) {
/* 1980 */ repaintTab(this.focusIndex);
/* 1981 */ this.focusIndex = paramInt;
/* 1982 */ repaintTab(this.focusIndex);
/* */ }
/* */ else {
/* 1985 */ this.focusIndex = paramInt;
/* */ }
/* */ }
/* */
/* */ private void repaintTab(int paramInt)
/* */ {
/* 1995 */ if ((!this.isRunsDirty) && (paramInt >= 0) && (paramInt < this.tabPane.getTabCount()))
/* 1996 */ this.tabPane.repaint(getTabBounds(this.tabPane, paramInt));
/* */ }
/* */
/* */ private void validateFocusIndex()
/* */ {
/* 2004 */ if (this.focusIndex >= this.tabPane.getTabCount())
/* 2005 */ setFocusIndex(this.tabPane.getSelectedIndex(), false);
/* */ }
/* */
/* */ protected int getFocusIndex()
/* */ {
/* 2016 */ return this.focusIndex;
/* */ }
/* */
/* */ protected int getTabRunOffset(int paramInt1, int paramInt2, int paramInt3, boolean paramBoolean)
/* */ {
/* 2021 */ int i = getRunForTab(paramInt2, paramInt3);
/* */ int j;
/* 2023 */ switch (paramInt1) {
/* */ case 2:
/* 2025 */ if (i == 0) {
/* 2026 */ j = paramBoolean ? -(calculateTabAreaWidth(paramInt1, this.runCount, this.maxTabWidth) - this.maxTabWidth) : -this.maxTabWidth;
/* */ }
/* 2030 */ else if (i == this.runCount - 1) {
/* 2031 */ j = paramBoolean ? this.maxTabWidth : calculateTabAreaWidth(paramInt1, this.runCount, this.maxTabWidth) - this.maxTabWidth;
/* */ }
/* */ else
/* */ {
/* 2035 */ j = paramBoolean ? this.maxTabWidth : -this.maxTabWidth;
/* */ }
/* 2037 */ break;
/* */ case 4:
/* 2040 */ if (i == 0) {
/* 2041 */ j = paramBoolean ? this.maxTabWidth : calculateTabAreaWidth(paramInt1, this.runCount, this.maxTabWidth) - this.maxTabWidth;
/* */ }
/* 2044 */ else if (i == this.runCount - 1) {
/* 2045 */ j = paramBoolean ? -(calculateTabAreaWidth(paramInt1, this.runCount, this.maxTabWidth) - this.maxTabWidth) : -this.maxTabWidth;
/* */ }
/* */ else
/* */ {
/* 2049 */ j = paramBoolean ? this.maxTabWidth : -this.maxTabWidth;
/* */ }
/* 2051 */ break;
/* */ case 3:
/* 2054 */ if (i == 0) {
/* 2055 */ j = paramBoolean ? this.maxTabHeight : calculateTabAreaHeight(paramInt1, this.runCount, this.maxTabHeight) - this.maxTabHeight;
/* */ }
/* 2058 */ else if (i == this.runCount - 1) {
/* 2059 */ j = paramBoolean ? -(calculateTabAreaHeight(paramInt1, this.runCount, this.maxTabHeight) - this.maxTabHeight) : -this.maxTabHeight;
/* */ }
/* */ else
/* */ {
/* 2063 */ j = paramBoolean ? this.maxTabHeight : -this.maxTabHeight;
/* */ }
/* 2065 */ break;
/* */ case 1:
/* */ default:
/* 2069 */ if (i == 0) {
/* 2070 */ j = paramBoolean ? -(calculateTabAreaHeight(paramInt1, this.runCount, this.maxTabHeight) - this.maxTabHeight) : -this.maxTabHeight;
/* */ }
/* 2073 */ else if (i == this.runCount - 1) {
/* 2074 */ j = paramBoolean ? this.maxTabHeight : calculateTabAreaHeight(paramInt1, this.runCount, this.maxTabHeight) - this.maxTabHeight;
/* */ }
/* */ else
/* */ {
/* 2078 */ j = paramBoolean ? this.maxTabHeight : -this.maxTabHeight;
/* */ }
/* */ break;
/* */ }
/* 2082 */ return j;
/* */ }
/* */
/* */ protected int getPreviousTabIndex(int paramInt) {
/* 2086 */ int i = paramInt - 1 >= 0 ? paramInt - 1 : this.tabPane.getTabCount() - 1;
/* 2087 */ return i >= 0 ? i : 0;
/* */ }
/* */
/* */ protected int getNextTabIndex(int paramInt) {
/* 2091 */ return (paramInt + 1) % this.tabPane.getTabCount();
/* */ }
/* */
/* */ protected int getNextTabIndexInRun(int paramInt1, int paramInt2) {
/* 2095 */ if (this.runCount < 2) {
/* 2096 */ return getNextTabIndex(paramInt2);
/* */ }
/* 2098 */ int i = getRunForTab(paramInt1, paramInt2);
/* 2099 */ int j = getNextTabIndex(paramInt2);
/* 2100 */ if (j == this.tabRuns[getNextTabRun(i)]) {
/* 2101 */ return this.tabRuns[i];
/* */ }
/* 2103 */ return j;
/* */ }
/* */
/* */ protected int getPreviousTabIndexInRun(int paramInt1, int paramInt2) {
/* 2107 */ if (this.runCount < 2) {
/* 2108 */ return getPreviousTabIndex(paramInt2);
/* */ }
/* 2110 */ int i = getRunForTab(paramInt1, paramInt2);
/* 2111 */ if (paramInt2 == this.tabRuns[i]) {
/* 2112 */ int j = this.tabRuns[getNextTabRun(i)] - 1;
/* 2113 */ return j != -1 ? j : paramInt1 - 1;
/* */ }
/* 2115 */ return getPreviousTabIndex(paramInt2);
/* */ }
/* */
/* */ protected int getPreviousTabRun(int paramInt) {
/* 2119 */ int i = paramInt - 1 >= 0 ? paramInt - 1 : this.runCount - 1;
/* 2120 */ return i >= 0 ? i : 0;
/* */ }
/* */
/* */ protected int getNextTabRun(int paramInt) {
/* 2124 */ return (paramInt + 1) % this.runCount;
/* */ }
/* */
/* */ protected static void rotateInsets(Insets paramInsets1, Insets paramInsets2, int paramInt)
/* */ {
/* 2129 */ switch (paramInt) {
/* */ case 2:
/* 2131 */ paramInsets2.top = paramInsets1.left;
/* 2132 */ paramInsets2.left = paramInsets1.top;
/* 2133 */ paramInsets2.bottom = paramInsets1.right;
/* 2134 */ paramInsets2.right = paramInsets1.bottom;
/* 2135 */ break;
/* */ case 3:
/* 2137 */ paramInsets2.top = paramInsets1.bottom;
/* 2138 */ paramInsets2.left = paramInsets1.left;
/* 2139 */ paramInsets2.bottom = paramInsets1.top;
/* 2140 */ paramInsets2.right = paramInsets1.right;
/* 2141 */ break;
/* */ case 4:
/* 2143 */ paramInsets2.top = paramInsets1.left;
/* 2144 */ paramInsets2.left = paramInsets1.bottom;
/* 2145 */ paramInsets2.bottom = paramInsets1.right;
/* 2146 */ paramInsets2.right = paramInsets1.top;
/* 2147 */ break;
/* */ case 1:
/* */ default:
/* 2150 */ paramInsets2.top = paramInsets1.top;
/* 2151 */ paramInsets2.left = paramInsets1.left;
/* 2152 */ paramInsets2.bottom = paramInsets1.bottom;
/* 2153 */ paramInsets2.right = paramInsets1.right;
/* */ }
/* */ }
/* */
/* */ boolean requestFocusForVisibleComponent()
/* */ {
/* 2161 */ return SwingUtilities2.tabbedPaneChangeFocusTo(getVisibleComponent());
/* */ }
/* */
/* */ private Vector<View> createHTMLVector()
/* */ {
/* 3805 */ Vector localVector = new Vector();
/* 3806 */ int i = this.tabPane.getTabCount();
/* 3807 */ if (i > 0) {
/* 3808 */ for (int j = 0; j < i; j++) {
/* 3809 */ String str = this.tabPane.getTitleAt(j);
/* 3810 */ if (BasicHTML.isHTMLString(str))
/* 3811 */ localVector.addElement(BasicHTML.createHTMLView(this.tabPane, str));
/* */ else {
/* 3813 */ localVector.addElement(null);
/* */ }
/* */ }
/* */ }
/* 3817 */ return localVector;
/* */ }
/* */
/* */ private static class Actions extends UIAction
/* */ {
/* */ static final String NEXT = "navigateNext";
/* */ static final String PREVIOUS = "navigatePrevious";
/* */ static final String RIGHT = "navigateRight";
/* */ static final String LEFT = "navigateLeft";
/* */ static final String UP = "navigateUp";
/* */ static final String DOWN = "navigateDown";
/* */ static final String PAGE_UP = "navigatePageUp";
/* */ static final String PAGE_DOWN = "navigatePageDown";
/* */ static final String REQUEST_FOCUS = "requestFocus";
/* */ static final String REQUEST_FOCUS_FOR_VISIBLE = "requestFocusForVisibleComponent";
/* */ static final String SET_SELECTED = "setSelectedIndex";
/* */ static final String SELECT_FOCUSED = "selectTabWithFocus";
/* */ static final String SCROLL_FORWARD = "scrollTabsForwardAction";
/* */ static final String SCROLL_BACKWARD = "scrollTabsBackwardAction";
/* */
/* */ Actions(String paramString)
/* */ {
/* 2182 */ super();
/* */ }
/* */
/* */ public void actionPerformed(ActionEvent paramActionEvent) {
/* 2186 */ String str1 = getName();
/* 2187 */ JTabbedPane localJTabbedPane = (JTabbedPane)paramActionEvent.getSource();
/* 2188 */ BasicTabbedPaneUI localBasicTabbedPaneUI = (BasicTabbedPaneUI)BasicLookAndFeel.getUIOfType(localJTabbedPane.getUI(), BasicTabbedPaneUI.class);
/* */
/* 2191 */ if (localBasicTabbedPaneUI == null) {
/* 2192 */ return;
/* */ }
/* 2194 */ if (str1 == "navigateNext") {
/* 2195 */ localBasicTabbedPaneUI.navigateSelectedTab(12);
/* */ }
/* 2197 */ else if (str1 == "navigatePrevious") {
/* 2198 */ localBasicTabbedPaneUI.navigateSelectedTab(13);
/* */ }
/* 2200 */ else if (str1 == "navigateRight") {
/* 2201 */ localBasicTabbedPaneUI.navigateSelectedTab(3);
/* */ }
/* 2203 */ else if (str1 == "navigateLeft") {
/* 2204 */ localBasicTabbedPaneUI.navigateSelectedTab(7);
/* */ }
/* 2206 */ else if (str1 == "navigateUp") {
/* 2207 */ localBasicTabbedPaneUI.navigateSelectedTab(1);
/* */ }
/* 2209 */ else if (str1 == "navigateDown") {
/* 2210 */ localBasicTabbedPaneUI.navigateSelectedTab(5);
/* */ }
/* */ else
/* */ {
/* */ int i;
/* 2212 */ if (str1 == "navigatePageUp") {
/* 2213 */ i = localJTabbedPane.getTabPlacement();
/* 2214 */ if ((i == 1) || (i == 3))
/* 2215 */ localBasicTabbedPaneUI.navigateSelectedTab(7);
/* */ else {
/* 2217 */ localBasicTabbedPaneUI.navigateSelectedTab(1);
/* */ }
/* */ }
/* 2220 */ else if (str1 == "navigatePageDown") {
/* 2221 */ i = localJTabbedPane.getTabPlacement();
/* 2222 */ if ((i == 1) || (i == 3))
/* 2223 */ localBasicTabbedPaneUI.navigateSelectedTab(3);
/* */ else {
/* 2225 */ localBasicTabbedPaneUI.navigateSelectedTab(5);
/* */ }
/* */ }
/* 2228 */ else if (str1 == "requestFocus") {
/* 2229 */ localJTabbedPane.requestFocus();
/* */ }
/* 2231 */ else if (str1 == "requestFocusForVisibleComponent") {
/* 2232 */ localBasicTabbedPaneUI.requestFocusForVisibleComponent();
/* */ }
/* 2234 */ else if (str1 == "setSelectedIndex") {
/* 2235 */ String str2 = paramActionEvent.getActionCommand();
/* */
/* 2237 */ if ((str2 != null) && (str2.length() > 0)) {
/* 2238 */ int k = paramActionEvent.getActionCommand().charAt(0);
/* 2239 */ if ((k >= 97) && (k <= 122)) {
/* 2240 */ k -= 32;
/* */ }
/* 2242 */ Integer localInteger = (Integer)localBasicTabbedPaneUI.mnemonicToIndexMap.get(Integer.valueOf(k));
/* 2243 */ if ((localInteger != null) && (localJTabbedPane.isEnabledAt(localInteger.intValue()))) {
/* 2244 */ localJTabbedPane.setSelectedIndex(localInteger.intValue());
/* */ }
/* */ }
/* */ }
/* 2248 */ else if (str1 == "selectTabWithFocus") {
/* 2249 */ int j = localBasicTabbedPaneUI.getFocusIndex();
/* 2250 */ if (j != -1) {
/* 2251 */ localJTabbedPane.setSelectedIndex(j);
/* */ }
/* */ }
/* 2254 */ else if (str1 == "scrollTabsForwardAction") {
/* 2255 */ if (localBasicTabbedPaneUI.scrollableTabLayoutEnabled()) {
/* 2256 */ localBasicTabbedPaneUI.tabScroller.scrollForward(localJTabbedPane.getTabPlacement());
/* */ }
/* */ }
/* 2259 */ else if ((str1 == "scrollTabsBackwardAction") &&
/* 2260 */ (localBasicTabbedPaneUI.scrollableTabLayoutEnabled())) {
/* 2261 */ localBasicTabbedPaneUI.tabScroller.scrollBackward(localJTabbedPane.getTabPlacement());
/* */ }
/* */ }
/* */ }
/* */ }
/* */
/* */ private class CroppedEdge extends JPanel
/* */ implements UIResource
/* */ {
/* */ private Shape shape;
/* */ private int tabIndex;
/* */ private int cropline;
/* */ private int cropx;
/* */ private int cropy;
/* */
/* */ public CroppedEdge()
/* */ {
/* 3871 */ setOpaque(false);
/* */ }
/* */
/* */ public void setParams(int paramInt1, int paramInt2, int paramInt3, int paramInt4) {
/* 3875 */ this.tabIndex = paramInt1;
/* 3876 */ this.cropline = paramInt2;
/* 3877 */ this.cropx = paramInt3;
/* 3878 */ this.cropy = paramInt4;
/* 3879 */ Rectangle localRectangle = BasicTabbedPaneUI.this.rects[paramInt1];
/* 3880 */ setBounds(localRectangle);
/* 3881 */ this.shape = BasicTabbedPaneUI.createCroppedTabShape(BasicTabbedPaneUI.this.tabPane.getTabPlacement(), localRectangle, paramInt2);
/* 3882 */ if ((getParent() == null) && (BasicTabbedPaneUI.this.tabContainer != null))
/* 3883 */ BasicTabbedPaneUI.this.tabContainer.add(this, 0);
/* */ }
/* */
/* */ public void resetParams()
/* */ {
/* 3888 */ this.shape = null;
/* 3889 */ if ((getParent() == BasicTabbedPaneUI.this.tabContainer) && (BasicTabbedPaneUI.this.tabContainer != null))
/* 3890 */ BasicTabbedPaneUI.this.tabContainer.remove(this);
/* */ }
/* */
/* */ public boolean isParamsSet()
/* */ {
/* 3895 */ return this.shape != null;
/* */ }
/* */
/* */ public int getTabIndex() {
/* 3899 */ return this.tabIndex;
/* */ }
/* */
/* */ public int getCropline() {
/* 3903 */ return this.cropline;
/* */ }
/* */
/* */ public int getCroppedSideWidth() {
/* 3907 */ return 3;
/* */ }
/* */
/* */ private Color getBgColor() {
/* 3911 */ Container localContainer = BasicTabbedPaneUI.this.tabPane.getParent();
/* 3912 */ if (localContainer != null) {
/* 3913 */ Color localColor = localContainer.getBackground();
/* 3914 */ if (localColor != null) {
/* 3915 */ return localColor;
/* */ }
/* */ }
/* 3918 */ return UIManager.getColor("control");
/* */ }
/* */
/* */ protected void paintComponent(Graphics paramGraphics) {
/* 3922 */ super.paintComponent(paramGraphics);
/* 3923 */ if ((isParamsSet()) && ((paramGraphics instanceof Graphics2D))) {
/* 3924 */ Graphics2D localGraphics2D = (Graphics2D)paramGraphics;
/* 3925 */ localGraphics2D.clipRect(0, 0, getWidth(), getHeight());
/* 3926 */ localGraphics2D.setColor(getBgColor());
/* 3927 */ localGraphics2D.translate(this.cropx, this.cropy);
/* 3928 */ localGraphics2D.fill(this.shape);
/* 3929 */ BasicTabbedPaneUI.this.paintCroppedTabEdge(paramGraphics);
/* 3930 */ localGraphics2D.translate(-this.cropx, -this.cropy);
/* */ }
/* */ }
/* */ }
/* */
/* */ public class FocusHandler extends FocusAdapter
/* */ {
/* */ public FocusHandler()
/* */ {
/* */ }
/* */
/* */ public void focusGained(FocusEvent paramFocusEvent)
/* */ {
/* 3797 */ BasicTabbedPaneUI.this.getHandler().focusGained(paramFocusEvent);
/* */ }
/* */ public void focusLost(FocusEvent paramFocusEvent) {
/* 3800 */ BasicTabbedPaneUI.this.getHandler().focusLost(paramFocusEvent);
/* */ }
/* */ }
/* */
/* */ private class Handler
/* */ implements ChangeListener, ContainerListener, FocusListener, MouseListener, MouseMotionListener, PropertyChangeListener
/* */ {
/* */ private Handler()
/* */ {
/* */ }
/* */
/* */ public void propertyChange(PropertyChangeEvent paramPropertyChangeEvent)
/* */ {
/* 3516 */ JTabbedPane localJTabbedPane = (JTabbedPane)paramPropertyChangeEvent.getSource();
/* 3517 */ String str = paramPropertyChangeEvent.getPropertyName();
/* 3518 */ boolean bool1 = BasicTabbedPaneUI.this.scrollableTabLayoutEnabled();
/* 3519 */ if (str == "mnemonicAt") {
/* 3520 */ BasicTabbedPaneUI.this.updateMnemonics();
/* 3521 */ localJTabbedPane.repaint();
/* */ }
/* 3523 */ else if (str == "displayedMnemonicIndexAt") {
/* 3524 */ localJTabbedPane.repaint();
/* */ }
/* 3526 */ else if (str == "indexForTitle") {
/* 3527 */ BasicTabbedPaneUI.this.calculatedBaseline = false;
/* 3528 */ Integer localInteger = (Integer)paramPropertyChangeEvent.getNewValue();
/* */
/* 3531 */ if (BasicTabbedPaneUI.this.htmlViews != null) {
/* 3532 */ BasicTabbedPaneUI.this.htmlViews.removeElementAt(localInteger.intValue());
/* */ }
/* 3534 */ updateHtmlViews(localInteger.intValue());
/* 3535 */ } else if (str == "tabLayoutPolicy") {
/* 3536 */ BasicTabbedPaneUI.this.uninstallUI(localJTabbedPane);
/* 3537 */ BasicTabbedPaneUI.this.installUI(localJTabbedPane);
/* 3538 */ BasicTabbedPaneUI.this.calculatedBaseline = false;
/* 3539 */ } else if (str == "tabPlacement") {
/* 3540 */ if (BasicTabbedPaneUI.this.scrollableTabLayoutEnabled()) {
/* 3541 */ BasicTabbedPaneUI.this.tabScroller.createButtons();
/* */ }
/* 3543 */ BasicTabbedPaneUI.this.calculatedBaseline = false;
/* 3544 */ } else if ((str == "opaque") && (bool1)) {
/* 3545 */ boolean bool2 = ((Boolean)paramPropertyChangeEvent.getNewValue()).booleanValue();
/* 3546 */ BasicTabbedPaneUI.this.tabScroller.tabPanel.setOpaque(bool2);
/* 3547 */ BasicTabbedPaneUI.this.tabScroller.viewport.setOpaque(bool2);
/* */ }
/* */ else
/* */ {
/* */ Object localObject;
/* 3548 */ if ((str == "background") && (bool1)) {
/* 3549 */ localObject = (Color)paramPropertyChangeEvent.getNewValue();
/* 3550 */ BasicTabbedPaneUI.this.tabScroller.tabPanel.setBackground((Color)localObject);
/* 3551 */ BasicTabbedPaneUI.this.tabScroller.viewport.setBackground((Color)localObject);
/* 3552 */ Color localColor = BasicTabbedPaneUI.this.selectedColor == null ? localObject : BasicTabbedPaneUI.this.selectedColor;
/* 3553 */ BasicTabbedPaneUI.this.tabScroller.scrollForwardButton.setBackground(localColor);
/* 3554 */ BasicTabbedPaneUI.this.tabScroller.scrollBackwardButton.setBackground(localColor);
/* 3555 */ } else if (str == "indexForTabComponent") {
/* 3556 */ if (BasicTabbedPaneUI.this.tabContainer != null) {
/* 3557 */ BasicTabbedPaneUI.TabContainer.access$1700(BasicTabbedPaneUI.this.tabContainer);
/* */ }
/* 3559 */ localObject = BasicTabbedPaneUI.this.tabPane.getTabComponentAt(((Integer)paramPropertyChangeEvent.getNewValue()).intValue());
/* */
/* 3561 */ if (localObject != null) {
/* 3562 */ if (BasicTabbedPaneUI.this.tabContainer == null)
/* 3563 */ BasicTabbedPaneUI.this.installTabContainer();
/* */ else {
/* 3565 */ BasicTabbedPaneUI.this.tabContainer.add((Component)localObject);
/* */ }
/* */ }
/* 3568 */ BasicTabbedPaneUI.this.tabPane.revalidate();
/* 3569 */ BasicTabbedPaneUI.this.tabPane.repaint();
/* 3570 */ BasicTabbedPaneUI.this.calculatedBaseline = false;
/* 3571 */ } else if (str == "indexForNullComponent") {
/* 3572 */ BasicTabbedPaneUI.this.isRunsDirty = true;
/* 3573 */ updateHtmlViews(((Integer)paramPropertyChangeEvent.getNewValue()).intValue());
/* 3574 */ } else if (str == "font") {
/* 3575 */ BasicTabbedPaneUI.this.calculatedBaseline = false;
/* */ }
/* */ }
/* */ }
/* */
/* 3580 */ private void updateHtmlViews(int paramInt) { String str = BasicTabbedPaneUI.this.tabPane.getTitleAt(paramInt);
/* 3581 */ boolean bool = BasicHTML.isHTMLString(str);
/* 3582 */ if (bool) {
/* 3583 */ if (BasicTabbedPaneUI.this.htmlViews == null) {
/* 3584 */ BasicTabbedPaneUI.this.htmlViews = BasicTabbedPaneUI.this.createHTMLVector();
/* */ } else {
/* 3586 */ View localView = BasicHTML.createHTMLView(BasicTabbedPaneUI.this.tabPane, str);
/* 3587 */ BasicTabbedPaneUI.this.htmlViews.insertElementAt(localView, paramInt);
/* */ }
/* */ }
/* 3590 */ else if (BasicTabbedPaneUI.this.htmlViews != null) {
/* 3591 */ BasicTabbedPaneUI.this.htmlViews.insertElementAt(null, paramInt);
/* */ }
/* */
/* 3594 */ BasicTabbedPaneUI.this.updateMnemonics();
/* */ }
/* */
/* */ public void stateChanged(ChangeEvent paramChangeEvent)
/* */ {
/* 3601 */ JTabbedPane localJTabbedPane = (JTabbedPane)paramChangeEvent.getSource();
/* 3602 */ localJTabbedPane.revalidate();
/* 3603 */ localJTabbedPane.repaint();
/* */
/* 3605 */ BasicTabbedPaneUI.this.setFocusIndex(localJTabbedPane.getSelectedIndex(), false);
/* */
/* 3607 */ if (BasicTabbedPaneUI.this.scrollableTabLayoutEnabled()) {
/* 3608 */ int i = localJTabbedPane.getSelectedIndex();
/* 3609 */ if ((i < BasicTabbedPaneUI.this.rects.length) && (i != -1))
/* 3610 */ BasicTabbedPaneUI.this.tabScroller.tabPanel.scrollRectToVisible((Rectangle)BasicTabbedPaneUI.this.rects[i].clone());
/* */ }
/* */ }
/* */
/* */ public void mouseClicked(MouseEvent paramMouseEvent)
/* */ {
/* */ }
/* */
/* */ public void mouseReleased(MouseEvent paramMouseEvent)
/* */ {
/* */ }
/* */
/* */ public void mouseEntered(MouseEvent paramMouseEvent)
/* */ {
/* 3626 */ BasicTabbedPaneUI.this.setRolloverTab(paramMouseEvent.getX(), paramMouseEvent.getY());
/* */ }
/* */
/* */ public void mouseExited(MouseEvent paramMouseEvent) {
/* 3630 */ BasicTabbedPaneUI.this.setRolloverTab(-1);
/* */ }
/* */
/* */ public void mousePressed(MouseEvent paramMouseEvent) {
/* 3634 */ if (!BasicTabbedPaneUI.this.tabPane.isEnabled()) {
/* 3635 */ return;
/* */ }
/* 3637 */ int i = BasicTabbedPaneUI.this.tabForCoordinate(BasicTabbedPaneUI.this.tabPane, paramMouseEvent.getX(), paramMouseEvent.getY());
/* 3638 */ if ((i >= 0) && (BasicTabbedPaneUI.this.tabPane.isEnabledAt(i)))
/* 3639 */ if (i != BasicTabbedPaneUI.this.tabPane.getSelectedIndex())
/* */ {
/* 3644 */ BasicTabbedPaneUI.this.tabPane.setSelectedIndex(i);
/* */ }
/* 3646 */ else if (BasicTabbedPaneUI.this.tabPane.isRequestFocusEnabled())
/* */ {
/* 3649 */ BasicTabbedPaneUI.this.tabPane.requestFocus();
/* */ }
/* */ }
/* */
/* */ public void mouseDragged(MouseEvent paramMouseEvent)
/* */ {
/* */ }
/* */
/* */ public void mouseMoved(MouseEvent paramMouseEvent)
/* */ {
/* 3661 */ BasicTabbedPaneUI.this.setRolloverTab(paramMouseEvent.getX(), paramMouseEvent.getY());
/* */ }
/* */
/* */ public void focusGained(FocusEvent paramFocusEvent)
/* */ {
/* 3668 */ BasicTabbedPaneUI.this.setFocusIndex(BasicTabbedPaneUI.this.tabPane.getSelectedIndex(), true);
/* */ }
/* */ public void focusLost(FocusEvent paramFocusEvent) {
/* 3671 */ BasicTabbedPaneUI.this.repaintTab(BasicTabbedPaneUI.this.focusIndex);
/* */ }
/* */
/* */ public void componentAdded(ContainerEvent paramContainerEvent)
/* */ {
/* 3709 */ JTabbedPane localJTabbedPane = (JTabbedPane)paramContainerEvent.getContainer();
/* 3710 */ Component localComponent = paramContainerEvent.getChild();
/* 3711 */ if ((localComponent instanceof UIResource)) {
/* 3712 */ return;
/* */ }
/* 3714 */ BasicTabbedPaneUI.this.isRunsDirty = true;
/* 3715 */ updateHtmlViews(localJTabbedPane.indexOfComponent(localComponent));
/* */ }
/* */ public void componentRemoved(ContainerEvent paramContainerEvent) {
/* 3718 */ JTabbedPane localJTabbedPane = (JTabbedPane)paramContainerEvent.getContainer();
/* 3719 */ Component localComponent = paramContainerEvent.getChild();
/* 3720 */ if ((localComponent instanceof UIResource)) {
/* 3721 */ return;
/* */ }
/* */
/* 3729 */ Integer localInteger = (Integer)localJTabbedPane.getClientProperty("__index_to_remove__");
/* */
/* 3731 */ if (localInteger != null) {
/* 3732 */ int i = localInteger.intValue();
/* 3733 */ if ((BasicTabbedPaneUI.this.htmlViews != null) && (BasicTabbedPaneUI.this.htmlViews.size() > i)) {
/* 3734 */ BasicTabbedPaneUI.this.htmlViews.removeElementAt(i);
/* */ }
/* 3736 */ localJTabbedPane.putClientProperty("__index_to_remove__", null);
/* */ }
/* 3738 */ BasicTabbedPaneUI.this.isRunsDirty = true;
/* 3739 */ BasicTabbedPaneUI.this.updateMnemonics();
/* */
/* 3741 */ BasicTabbedPaneUI.this.validateFocusIndex();
/* */ }
/* */ }
/* */
/* */ public class MouseHandler extends MouseAdapter
/* */ {
/* */ public MouseHandler()
/* */ {
/* */ }
/* */
/* */ public void mousePressed(MouseEvent paramMouseEvent)
/* */ {
/* 3783 */ BasicTabbedPaneUI.this.getHandler().mousePressed(paramMouseEvent);
/* */ }
/* */ }
/* */
/* */ public class PropertyChangeHandler
/* */ implements PropertyChangeListener
/* */ {
/* */ public PropertyChangeHandler()
/* */ {
/* */ }
/* */
/* */ public void propertyChange(PropertyChangeEvent paramPropertyChangeEvent)
/* */ {
/* 3755 */ BasicTabbedPaneUI.this.getHandler().propertyChange(paramPropertyChangeEvent);
/* */ }
/* */ }
/* */
/* */ private class ScrollableTabButton extends BasicArrowButton
/* */ implements UIResource, SwingConstants
/* */ {
/* */ public ScrollableTabButton(int arg2)
/* */ {
/* 3498 */ super(UIManager.getColor("TabbedPane.selected"), UIManager.getColor("TabbedPane.shadow"), UIManager.getColor("TabbedPane.darkShadow"), UIManager.getColor("TabbedPane.highlight"));
/* */ }
/* */ }
/* */
/* */ private class ScrollableTabPanel extends JPanel
/* */ implements UIResource
/* */ {
/* */ public ScrollableTabPanel()
/* */ {
/* 3467 */ super();
/* 3468 */ setOpaque(BasicTabbedPaneUI.this.tabPane.isOpaque());
/* 3469 */ Color localColor = UIManager.getColor("TabbedPane.tabAreaBackground");
/* 3470 */ if (localColor == null) {
/* 3471 */ localColor = BasicTabbedPaneUI.this.tabPane.getBackground();
/* */ }
/* 3473 */ setBackground(localColor);
/* */ }
/* */ public void paintComponent(Graphics paramGraphics) {
/* 3476 */ super.paintComponent(paramGraphics);
/* 3477 */ BasicTabbedPaneUI.this.paintTabArea(paramGraphics, BasicTabbedPaneUI.this.tabPane.getTabPlacement(), BasicTabbedPaneUI.this.tabPane.getSelectedIndex());
/* */
/* 3479 */ if ((BasicTabbedPaneUI.this.tabScroller.croppedEdge.isParamsSet()) && (BasicTabbedPaneUI.this.tabContainer == null)) {
/* 3480 */ Rectangle localRectangle = BasicTabbedPaneUI.this.rects[BasicTabbedPaneUI.this.tabScroller.croppedEdge.getTabIndex()];
/* 3481 */ paramGraphics.translate(localRectangle.x, localRectangle.y);
/* 3482 */ BasicTabbedPaneUI.this.tabScroller.croppedEdge.paintComponent(paramGraphics);
/* 3483 */ paramGraphics.translate(-localRectangle.x, -localRectangle.y);
/* */ }
/* */ }
/* */
/* */ public void doLayout() {
/* 3488 */ if (getComponentCount() > 0) {
/* 3489 */ Component localComponent = getComponent(0);
/* 3490 */ localComponent.setBounds(0, 0, getWidth(), getHeight());
/* */ }
/* */ }
/* */ }
/* */
/* */ private class ScrollableTabSupport
/* */ implements ActionListener, ChangeListener
/* */ {
/* */ public BasicTabbedPaneUI.ScrollableTabViewport viewport;
/* */ public BasicTabbedPaneUI.ScrollableTabPanel tabPanel;
/* */ public JButton scrollForwardButton;
/* */ public JButton scrollBackwardButton;
/* */ public BasicTabbedPaneUI.CroppedEdge croppedEdge;
/* */ public int leadingTabIndex;
/* 3254 */ private Point tabViewPosition = new Point(0, 0);
/* */
/* */ ScrollableTabSupport(int arg2) {
/* 3257 */ this.viewport = new BasicTabbedPaneUI.ScrollableTabViewport(BasicTabbedPaneUI.this);
/* 3258 */ this.tabPanel = new BasicTabbedPaneUI.ScrollableTabPanel(BasicTabbedPaneUI.this);
/* 3259 */ this.viewport.setView(this.tabPanel);
/* 3260 */ this.viewport.addChangeListener(this);
/* 3261 */ this.croppedEdge = new BasicTabbedPaneUI.CroppedEdge(BasicTabbedPaneUI.this);
/* 3262 */ createButtons();
/* */ }
/* */
/* */ void createButtons()
/* */ {
/* 3269 */ if (this.scrollForwardButton != null) {
/* 3270 */ BasicTabbedPaneUI.this.tabPane.remove(this.scrollForwardButton);
/* 3271 */ this.scrollForwardButton.removeActionListener(this);
/* 3272 */ BasicTabbedPaneUI.this.tabPane.remove(this.scrollBackwardButton);
/* 3273 */ this.scrollBackwardButton.removeActionListener(this);
/* */ }
/* 3275 */ int i = BasicTabbedPaneUI.this.tabPane.getTabPlacement();
/* 3276 */ if ((i == 1) || (i == 3)) {
/* 3277 */ this.scrollForwardButton = BasicTabbedPaneUI.this.createScrollButton(3);
/* 3278 */ this.scrollBackwardButton = BasicTabbedPaneUI.this.createScrollButton(7);
/* */ }
/* */ else {
/* 3281 */ this.scrollForwardButton = BasicTabbedPaneUI.this.createScrollButton(5);
/* 3282 */ this.scrollBackwardButton = BasicTabbedPaneUI.this.createScrollButton(1);
/* */ }
/* 3284 */ this.scrollForwardButton.addActionListener(this);
/* 3285 */ this.scrollBackwardButton.addActionListener(this);
/* 3286 */ BasicTabbedPaneUI.this.tabPane.add(this.scrollForwardButton);
/* 3287 */ BasicTabbedPaneUI.this.tabPane.add(this.scrollBackwardButton);
/* */ }
/* */
/* */ public void scrollForward(int paramInt) {
/* 3291 */ Dimension localDimension = this.viewport.getViewSize();
/* 3292 */ Rectangle localRectangle = this.viewport.getViewRect();
/* */
/* 3294 */ if ((paramInt == 1) || (paramInt == 3))
/* */ {
/* 3295 */ if (localRectangle.width < localDimension.width - localRectangle.x);
/* */ }
/* 3299 */ else if (localRectangle.height >= localDimension.height - localRectangle.y) {
/* 3300 */ return;
/* */ }
/* */
/* 3303 */ setLeadingTabIndex(paramInt, this.leadingTabIndex + 1);
/* */ }
/* */
/* */ public void scrollBackward(int paramInt) {
/* 3307 */ if (this.leadingTabIndex == 0) {
/* 3308 */ return;
/* */ }
/* 3310 */ setLeadingTabIndex(paramInt, this.leadingTabIndex - 1);
/* */ }
/* */
/* */ public void setLeadingTabIndex(int paramInt1, int paramInt2) {
/* 3314 */ this.leadingTabIndex = paramInt2;
/* 3315 */ Dimension localDimension1 = this.viewport.getViewSize();
/* 3316 */ Rectangle localRectangle = this.viewport.getViewRect();
/* */ Dimension localDimension2;
/* 3318 */ switch (paramInt1) {
/* */ case 1:
/* */ case 3:
/* 3321 */ this.tabViewPosition.x = (this.leadingTabIndex == 0 ? 0 : BasicTabbedPaneUI.this.rects[this.leadingTabIndex].x);
/* */
/* 3323 */ if (localDimension1.width - this.tabViewPosition.x < localRectangle.width)
/* */ {
/* 3326 */ localDimension2 = new Dimension(localDimension1.width - this.tabViewPosition.x, localRectangle.height);
/* */
/* 3328 */ this.viewport.setExtentSize(localDimension2);
/* 3329 */ }break;
/* */ case 2:
/* */ case 4:
/* 3333 */ this.tabViewPosition.y = (this.leadingTabIndex == 0 ? 0 : BasicTabbedPaneUI.this.rects[this.leadingTabIndex].y);
/* */
/* 3335 */ if (localDimension1.height - this.tabViewPosition.y < localRectangle.height)
/* */ {
/* 3338 */ localDimension2 = new Dimension(localRectangle.width, localDimension1.height - this.tabViewPosition.y);
/* */
/* 3340 */ this.viewport.setExtentSize(localDimension2);
/* */ }break;
/* */ }
/* 3343 */ this.viewport.setViewPosition(this.tabViewPosition);
/* */ }
/* */
/* */ public void stateChanged(ChangeEvent paramChangeEvent) {
/* 3347 */ updateView();
/* */ }
/* */
/* */ private void updateView() {
/* 3351 */ int i = BasicTabbedPaneUI.this.tabPane.getTabPlacement();
/* 3352 */ int j = BasicTabbedPaneUI.this.tabPane.getTabCount();
/* 3353 */ Rectangle localRectangle1 = this.viewport.getBounds();
/* 3354 */ Dimension localDimension = this.viewport.getViewSize();
/* 3355 */ Rectangle localRectangle2 = this.viewport.getViewRect();
/* */
/* 3357 */ this.leadingTabIndex = BasicTabbedPaneUI.this.getClosestTab(localRectangle2.x, localRectangle2.y);
/* */
/* 3360 */ if (this.leadingTabIndex + 1 < j) {
/* 3361 */ switch (i) {
/* */ case 1:
/* */ case 3:
/* 3364 */ if (BasicTabbedPaneUI.this.rects[this.leadingTabIndex].x < localRectangle2.x)
/* 3365 */ this.leadingTabIndex += 1; break;
/* */ case 2:
/* */ case 4:
/* 3370 */ if (BasicTabbedPaneUI.this.rects[this.leadingTabIndex].y < localRectangle2.y) {
/* 3371 */ this.leadingTabIndex += 1;
/* */ }
/* */ break;
/* */ }
/* */ }
/* 3376 */ Insets localInsets = BasicTabbedPaneUI.this.getContentBorderInsets(i);
/* 3377 */ switch (i) {
/* */ case 2:
/* 3379 */ BasicTabbedPaneUI.this.tabPane.repaint(localRectangle1.x + localRectangle1.width, localRectangle1.y, localInsets.left, localRectangle1.height);
/* */
/* 3381 */ this.scrollBackwardButton.setEnabled((localRectangle2.y > 0) && (this.leadingTabIndex > 0));
/* */
/* 3383 */ this.scrollForwardButton.setEnabled((this.leadingTabIndex < j - 1) && (localDimension.height - localRectangle2.y > localRectangle2.height));
/* */
/* 3386 */ break;
/* */ case 4:
/* 3388 */ BasicTabbedPaneUI.this.tabPane.repaint(localRectangle1.x - localInsets.right, localRectangle1.y, localInsets.right, localRectangle1.height);
/* */
/* 3390 */ this.scrollBackwardButton.setEnabled((localRectangle2.y > 0) && (this.leadingTabIndex > 0));
/* */
/* 3392 */ this.scrollForwardButton.setEnabled((this.leadingTabIndex < j - 1) && (localDimension.height - localRectangle2.y > localRectangle2.height));
/* */
/* 3395 */ break;
/* */ case 3:
/* 3397 */ BasicTabbedPaneUI.this.tabPane.repaint(localRectangle1.x, localRectangle1.y - localInsets.bottom, localRectangle1.width, localInsets.bottom);
/* */
/* 3399 */ this.scrollBackwardButton.setEnabled((localRectangle2.x > 0) && (this.leadingTabIndex > 0));
/* */
/* 3401 */ this.scrollForwardButton.setEnabled((this.leadingTabIndex < j - 1) && (localDimension.width - localRectangle2.x > localRectangle2.width));
/* */
/* 3404 */ break;
/* */ case 1:
/* */ default:
/* 3407 */ BasicTabbedPaneUI.this.tabPane.repaint(localRectangle1.x, localRectangle1.y + localRectangle1.height, localRectangle1.width, localInsets.top);
/* */
/* 3409 */ this.scrollBackwardButton.setEnabled((localRectangle2.x > 0) && (this.leadingTabIndex > 0));
/* */
/* 3411 */ this.scrollForwardButton.setEnabled((this.leadingTabIndex < j - 1) && (localDimension.width - localRectangle2.x > localRectangle2.width));
/* */ }
/* */ }
/* */
/* */ public void actionPerformed(ActionEvent paramActionEvent)
/* */ {
/* 3421 */ ActionMap localActionMap = BasicTabbedPaneUI.this.tabPane.getActionMap();
/* */
/* 3423 */ if (localActionMap != null)
/* */ {
/* */ String str;
/* 3426 */ if (paramActionEvent.getSource() == this.scrollForwardButton) {
/* 3427 */ str = "scrollTabsForwardAction";
/* */ }
/* */ else {
/* 3430 */ str = "scrollTabsBackwardAction";
/* */ }
/* 3432 */ Action localAction = localActionMap.get(str);
/* */
/* 3434 */ if ((localAction != null) && (localAction.isEnabled()))
/* 3435 */ localAction.actionPerformed(new ActionEvent(BasicTabbedPaneUI.this.tabPane, 1001, null, paramActionEvent.getWhen(), paramActionEvent.getModifiers()));
/* */ }
/* */ }
/* */
/* */ public String toString()
/* */ {
/* 3443 */ return "viewport.viewSize=" + this.viewport.getViewSize() + "\n" + "viewport.viewRectangle=" + this.viewport.getViewRect() + "\n" + "leadingTabIndex=" + this.leadingTabIndex + "\n" + "tabViewPosition=" + this.tabViewPosition;
/* */ }
/* */ }
/* */
/* */ private class ScrollableTabViewport extends JViewport
/* */ implements UIResource
/* */ {
/* */ public ScrollableTabViewport()
/* */ {
/* 3454 */ setName("TabbedPane.scrollableViewport");
/* 3455 */ setScrollMode(0);
/* 3456 */ setOpaque(BasicTabbedPaneUI.this.tabPane.isOpaque());
/* 3457 */ Color localColor = UIManager.getColor("TabbedPane.tabAreaBackground");
/* 3458 */ if (localColor == null) {
/* 3459 */ localColor = BasicTabbedPaneUI.this.tabPane.getBackground();
/* */ }
/* 3461 */ setBackground(localColor);
/* */ }
/* */ }
/* */
/* */ private class TabContainer extends JPanel
/* */ implements UIResource
/* */ {
/* 3821 */ private boolean notifyTabbedPane = true;
/* */
/* */ public TabContainer() {
/* 3824 */ super();
/* 3825 */ setOpaque(false);
/* */ }
/* */
/* */ public void remove(Component paramComponent) {
/* 3829 */ int i = BasicTabbedPaneUI.this.tabPane.indexOfTabComponent(paramComponent);
/* 3830 */ super.remove(paramComponent);
/* 3831 */ if ((this.notifyTabbedPane) && (i != -1))
/* 3832 */ BasicTabbedPaneUI.this.tabPane.setTabComponentAt(i, null);
/* */ }
/* */
/* */ private void removeUnusedTabComponents()
/* */ {
/* 3837 */ for (Component localComponent : getComponents())
/* 3838 */ if (!(localComponent instanceof UIResource)) {
/* 3839 */ int k = BasicTabbedPaneUI.this.tabPane.indexOfTabComponent(localComponent);
/* 3840 */ if (k == -1)
/* 3841 */ super.remove(localComponent);
/* */ }
/* */ }
/* */
/* */ public boolean isOptimizedDrawingEnabled()
/* */ {
/* 3848 */ return (BasicTabbedPaneUI.this.tabScroller != null) && (!BasicTabbedPaneUI.this.tabScroller.croppedEdge.isParamsSet());
/* */ }
/* */
/* */ public void doLayout()
/* */ {
/* 3855 */ if (BasicTabbedPaneUI.this.scrollableTabLayoutEnabled()) {
/* 3856 */ BasicTabbedPaneUI.this.tabScroller.tabPanel.repaint();
/* 3857 */ BasicTabbedPaneUI.this.tabScroller.updateView();
/* */ } else {
/* 3859 */ BasicTabbedPaneUI.this.tabPane.repaint(getBounds());
/* */ }
/* */ }
/* */ }
/* */
/* */ public class TabSelectionHandler
/* */ implements ChangeListener
/* */ {
/* */ public TabSelectionHandler()
/* */ {
/* */ }
/* */
/* */ public void stateChanged(ChangeEvent paramChangeEvent)
/* */ {
/* 3769 */ BasicTabbedPaneUI.this.getHandler().stateChanged(paramChangeEvent);
/* */ }
/* */ }
/* */
/* */ public class TabbedPaneLayout
/* */ implements LayoutManager
/* */ {
/* */ public TabbedPaneLayout()
/* */ {
/* */ }
/* */
/* */ public void addLayoutComponent(String paramString, Component paramComponent)
/* */ {
/* */ }
/* */
/* */ public void removeLayoutComponent(Component paramComponent)
/* */ {
/* */ }
/* */
/* */ public Dimension preferredLayoutSize(Container paramContainer)
/* */ {
/* 2278 */ return calculateSize(false);
/* */ }
/* */
/* */ public Dimension minimumLayoutSize(Container paramContainer) {
/* 2282 */ return calculateSize(true);
/* */ }
/* */
/* */ protected Dimension calculateSize(boolean paramBoolean) {
/* 2286 */ int i = BasicTabbedPaneUI.this.tabPane.getTabPlacement();
/* 2287 */ Insets localInsets1 = BasicTabbedPaneUI.this.tabPane.getInsets();
/* 2288 */ Insets localInsets2 = BasicTabbedPaneUI.this.getContentBorderInsets(i);
/* 2289 */ Insets localInsets3 = BasicTabbedPaneUI.this.getTabAreaInsets(i);
/* */
/* 2291 */ Dimension localDimension1 = new Dimension(0, 0);
/* 2292 */ int j = 0;
/* 2293 */ int k = 0;
/* 2294 */ int m = 0;
/* 2295 */ int n = 0;
/* */
/* 2300 */ for (int i1 = 0; i1 < BasicTabbedPaneUI.this.tabPane.getTabCount(); i1++) {
/* 2301 */ Component localComponent = BasicTabbedPaneUI.this.tabPane.getComponentAt(i1);
/* 2302 */ if (localComponent != null) {
/* 2303 */ Dimension localDimension2 = paramBoolean ? localComponent.getMinimumSize() : localComponent.getPreferredSize();
/* */
/* 2306 */ if (localDimension2 != null) {
/* 2307 */ n = Math.max(localDimension2.height, n);
/* 2308 */ m = Math.max(localDimension2.width, m);
/* */ }
/* */ }
/* */ }
/* */
/* 2313 */ k += m;
/* 2314 */ j += n;
/* */
/* 2320 */ switch (i) {
/* */ case 2:
/* */ case 4:
/* 2323 */ j = Math.max(j, BasicTabbedPaneUI.this.calculateMaxTabHeight(i));
/* 2324 */ i1 = preferredTabAreaWidth(i, j - localInsets3.top - localInsets3.bottom);
/* 2325 */ k += i1;
/* 2326 */ break;
/* */ case 1:
/* */ case 3:
/* */ default:
/* 2330 */ k = Math.max(k, BasicTabbedPaneUI.this.calculateMaxTabWidth(i));
/* 2331 */ i1 = preferredTabAreaHeight(i, k - localInsets3.left - localInsets3.right);
/* 2332 */ j += i1;
/* */ }
/* 2334 */ return new Dimension(k + localInsets1.left + localInsets1.right + localInsets2.left + localInsets2.right, j + localInsets1.bottom + localInsets1.top + localInsets2.top + localInsets2.bottom);
/* */ }
/* */
/* */ protected int preferredTabAreaHeight(int paramInt1, int paramInt2)
/* */ {
/* 2340 */ FontMetrics localFontMetrics = BasicTabbedPaneUI.this.getFontMetrics();
/* 2341 */ int i = BasicTabbedPaneUI.this.tabPane.getTabCount();
/* 2342 */ int j = 0;
/* 2343 */ if (i > 0) {
/* 2344 */ int k = 1;
/* 2345 */ int m = 0;
/* */
/* 2347 */ int n = BasicTabbedPaneUI.this.calculateMaxTabHeight(paramInt1);
/* */
/* 2349 */ for (int i1 = 0; i1 < i; i1++) {
/* 2350 */ int i2 = BasicTabbedPaneUI.this.calculateTabWidth(paramInt1, i1, localFontMetrics);
/* */
/* 2352 */ if ((m != 0) && (m + i2 > paramInt2)) {
/* 2353 */ k++;
/* 2354 */ m = 0;
/* */ }
/* 2356 */ m += i2;
/* */ }
/* 2358 */ j = BasicTabbedPaneUI.this.calculateTabAreaHeight(paramInt1, k, n);
/* */ }
/* 2360 */ return j;
/* */ }
/* */
/* */ protected int preferredTabAreaWidth(int paramInt1, int paramInt2) {
/* 2364 */ FontMetrics localFontMetrics = BasicTabbedPaneUI.this.getFontMetrics();
/* 2365 */ int i = BasicTabbedPaneUI.this.tabPane.getTabCount();
/* 2366 */ int j = 0;
/* 2367 */ if (i > 0) {
/* 2368 */ int k = 1;
/* 2369 */ int m = 0;
/* 2370 */ int n = localFontMetrics.getHeight();
/* */
/* 2372 */ BasicTabbedPaneUI.this.maxTabWidth = BasicTabbedPaneUI.this.calculateMaxTabWidth(paramInt1);
/* */
/* 2374 */ for (int i1 = 0; i1 < i; i1++) {
/* 2375 */ int i2 = BasicTabbedPaneUI.this.calculateTabHeight(paramInt1, i1, n);
/* */
/* 2377 */ if ((m != 0) && (m + i2 > paramInt2)) {
/* 2378 */ k++;
/* 2379 */ m = 0;
/* */ }
/* 2381 */ m += i2;
/* */ }
/* 2383 */ j = BasicTabbedPaneUI.this.calculateTabAreaWidth(paramInt1, k, BasicTabbedPaneUI.this.maxTabWidth);
/* */ }
/* 2385 */ return j;
/* */ }
/* */
/* */ public void layoutContainer(Container paramContainer)
/* */ {
/* 2400 */ BasicTabbedPaneUI.this.setRolloverTab(-1);
/* */
/* 2402 */ int i = BasicTabbedPaneUI.this.tabPane.getTabPlacement();
/* 2403 */ Insets localInsets1 = BasicTabbedPaneUI.this.tabPane.getInsets();
/* 2404 */ int j = BasicTabbedPaneUI.this.tabPane.getSelectedIndex();
/* 2405 */ Component localComponent1 = BasicTabbedPaneUI.this.getVisibleComponent();
/* */
/* 2407 */ calculateLayoutInfo();
/* */
/* 2409 */ Component localComponent2 = null;
/* 2410 */ if (j < 0) {
/* 2411 */ if (localComponent1 != null)
/* */ {
/* 2413 */ BasicTabbedPaneUI.this.setVisibleComponent(null);
/* */ }
/* */ }
/* 2416 */ else localComponent2 = BasicTabbedPaneUI.this.tabPane.getComponentAt(j);
/* */
/* 2419 */ int i2 = 0;
/* 2420 */ int i3 = 0;
/* 2421 */ Insets localInsets2 = BasicTabbedPaneUI.this.getContentBorderInsets(i);
/* */
/* 2423 */ int i4 = 0;
/* */
/* 2432 */ if (localComponent2 != null) {
/* 2433 */ if ((localComponent2 != localComponent1) && (localComponent1 != null))
/* */ {
/* 2435 */ if (SwingUtilities.findFocusOwner(localComponent1) != null) {
/* 2436 */ i4 = 1;
/* */ }
/* */ }
/* 2439 */ BasicTabbedPaneUI.this.setVisibleComponent(localComponent2);
/* */ }
/* */
/* 2442 */ Rectangle localRectangle = BasicTabbedPaneUI.this.tabPane.getBounds();
/* 2443 */ int i5 = BasicTabbedPaneUI.this.tabPane.getComponentCount();
/* */
/* 2445 */ if (i5 > 0)
/* */ {
/* */ int k;
/* */ int m;
/* 2447 */ switch (i) {
/* */ case 2:
/* 2449 */ i2 = BasicTabbedPaneUI.this.calculateTabAreaWidth(i, BasicTabbedPaneUI.this.runCount, BasicTabbedPaneUI.this.maxTabWidth);
/* 2450 */ k = localInsets1.left + i2 + localInsets2.left;
/* 2451 */ m = localInsets1.top + localInsets2.top;
/* 2452 */ break;
/* */ case 4:
/* 2454 */ i2 = BasicTabbedPaneUI.this.calculateTabAreaWidth(i, BasicTabbedPaneUI.this.runCount, BasicTabbedPaneUI.this.maxTabWidth);
/* 2455 */ k = localInsets1.left + localInsets2.left;
/* 2456 */ m = localInsets1.top + localInsets2.top;
/* 2457 */ break;
/* */ case 3:
/* 2459 */ i3 = BasicTabbedPaneUI.this.calculateTabAreaHeight(i, BasicTabbedPaneUI.this.runCount, BasicTabbedPaneUI.this.maxTabHeight);
/* 2460 */ k = localInsets1.left + localInsets2.left;
/* 2461 */ m = localInsets1.top + localInsets2.top;
/* 2462 */ break;
/* */ case 1:
/* */ default:
/* 2465 */ i3 = BasicTabbedPaneUI.this.calculateTabAreaHeight(i, BasicTabbedPaneUI.this.runCount, BasicTabbedPaneUI.this.maxTabHeight);
/* 2466 */ k = localInsets1.left + localInsets2.left;
/* 2467 */ m = localInsets1.top + i3 + localInsets2.top;
/* */ }
/* */
/* 2470 */ int n = localRectangle.width - i2 - localInsets1.left - localInsets1.right - localInsets2.left - localInsets2.right;
/* */
/* 2473 */ int i1 = localRectangle.height - i3 - localInsets1.top - localInsets1.bottom - localInsets2.top - localInsets2.bottom;
/* */
/* 2477 */ for (int i6 = 0; i6 < i5; i6++) {
/* 2478 */ Component localComponent3 = BasicTabbedPaneUI.this.tabPane.getComponent(i6);
/* 2479 */ if (localComponent3 == BasicTabbedPaneUI.this.tabContainer)
/* */ {
/* 2481 */ int i7 = i2 == 0 ? localRectangle.width : i2 + localInsets1.left + localInsets1.right + localInsets2.left + localInsets2.right;
/* */
/* 2484 */ int i8 = i3 == 0 ? localRectangle.height : i3 + localInsets1.top + localInsets1.bottom + localInsets2.top + localInsets2.bottom;
/* */
/* 2488 */ int i9 = 0;
/* 2489 */ int i10 = 0;
/* 2490 */ if (i == 3)
/* 2491 */ i10 = localRectangle.height - i8;
/* 2492 */ else if (i == 4) {
/* 2493 */ i9 = localRectangle.width - i7;
/* */ }
/* 2495 */ localComponent3.setBounds(i9, i10, i7, i8);
/* */ } else {
/* 2497 */ localComponent3.setBounds(k, m, n, i1);
/* */ }
/* */ }
/* */ }
/* 2501 */ layoutTabComponents();
/* 2502 */ if ((i4 != 0) &&
/* 2503 */ (!BasicTabbedPaneUI.this.requestFocusForVisibleComponent()))
/* 2504 */ BasicTabbedPaneUI.this.tabPane.requestFocus();
/* */ }
/* */
/* */ public void calculateLayoutInfo()
/* */ {
/* 2510 */ int i = BasicTabbedPaneUI.this.tabPane.getTabCount();
/* 2511 */ BasicTabbedPaneUI.this.assureRectsCreated(i);
/* 2512 */ calculateTabRects(BasicTabbedPaneUI.this.tabPane.getTabPlacement(), i);
/* 2513 */ BasicTabbedPaneUI.this.isRunsDirty = false;
/* */ }
/* */
/* */ private void layoutTabComponents() {
/* 2517 */ if (BasicTabbedPaneUI.this.tabContainer == null) {
/* 2518 */ return;
/* */ }
/* 2520 */ Rectangle localRectangle = new Rectangle();
/* 2521 */ Point localPoint = new Point(-BasicTabbedPaneUI.this.tabContainer.getX(), -BasicTabbedPaneUI.this.tabContainer.getY());
/* 2522 */ if (BasicTabbedPaneUI.this.scrollableTabLayoutEnabled()) {
/* 2523 */ BasicTabbedPaneUI.this.translatePointToTabPanel(0, 0, localPoint);
/* */ }
/* 2525 */ for (int i = 0; i < BasicTabbedPaneUI.this.tabPane.getTabCount(); i++) {
/* 2526 */ Component localComponent = BasicTabbedPaneUI.this.tabPane.getTabComponentAt(i);
/* 2527 */ if (localComponent != null)
/* */ {
/* 2530 */ BasicTabbedPaneUI.this.getTabBounds(i, localRectangle);
/* 2531 */ Dimension localDimension = localComponent.getPreferredSize();
/* 2532 */ Insets localInsets = BasicTabbedPaneUI.this.getTabInsets(BasicTabbedPaneUI.this.tabPane.getTabPlacement(), i);
/* 2533 */ int j = localRectangle.x + localInsets.left + localPoint.x;
/* 2534 */ int k = localRectangle.y + localInsets.top + localPoint.y;
/* 2535 */ int m = localRectangle.width - localInsets.left - localInsets.right;
/* 2536 */ int n = localRectangle.height - localInsets.top - localInsets.bottom;
/* */
/* 2538 */ int i1 = j + (m - localDimension.width) / 2;
/* 2539 */ int i2 = k + (n - localDimension.height) / 2;
/* 2540 */ int i3 = BasicTabbedPaneUI.this.tabPane.getTabPlacement();
/* 2541 */ boolean bool = i == BasicTabbedPaneUI.this.tabPane.getSelectedIndex();
/* 2542 */ localComponent.setBounds(i1 + BasicTabbedPaneUI.this.getTabLabelShiftX(i3, i, bool), i2 + BasicTabbedPaneUI.this.getTabLabelShiftY(i3, i, bool), localDimension.width, localDimension.height);
/* */ }
/* */ }
/* */ }
/* */
/* */ protected void calculateTabRects(int paramInt1, int paramInt2)
/* */ {
/* 2549 */ FontMetrics localFontMetrics = BasicTabbedPaneUI.this.getFontMetrics();
/* 2550 */ Dimension localDimension = BasicTabbedPaneUI.this.tabPane.getSize();
/* 2551 */ Insets localInsets1 = BasicTabbedPaneUI.this.tabPane.getInsets();
/* 2552 */ Insets localInsets2 = BasicTabbedPaneUI.this.getTabAreaInsets(paramInt1);
/* 2553 */ int i = localFontMetrics.getHeight();
/* 2554 */ int j = BasicTabbedPaneUI.this.tabPane.getSelectedIndex();
/* */
/* 2559 */ int i4 = (paramInt1 == 2) || (paramInt1 == 4) ? 1 : 0;
/* 2560 */ boolean bool = BasicGraphicsUtils.isLeftToRight(BasicTabbedPaneUI.this.tabPane);
/* */ int i1;
/* */ int i2;
/* */ int i3;
/* 2565 */ switch (paramInt1) {
/* */ case 2:
/* 2567 */ BasicTabbedPaneUI.this.maxTabWidth = BasicTabbedPaneUI.this.calculateMaxTabWidth(paramInt1);
/* 2568 */ i1 = localInsets1.left + localInsets2.left;
/* 2569 */ i2 = localInsets1.top + localInsets2.top;
/* 2570 */ i3 = localDimension.height - (localInsets1.bottom + localInsets2.bottom);
/* 2571 */ break;
/* */ case 4:
/* 2573 */ BasicTabbedPaneUI.this.maxTabWidth = BasicTabbedPaneUI.this.calculateMaxTabWidth(paramInt1);
/* 2574 */ i1 = localDimension.width - localInsets1.right - localInsets2.right - BasicTabbedPaneUI.this.maxTabWidth;
/* 2575 */ i2 = localInsets1.top + localInsets2.top;
/* 2576 */ i3 = localDimension.height - (localInsets1.bottom + localInsets2.bottom);
/* 2577 */ break;
/* */ case 3:
/* 2579 */ BasicTabbedPaneUI.this.maxTabHeight = BasicTabbedPaneUI.this.calculateMaxTabHeight(paramInt1);
/* 2580 */ i1 = localInsets1.left + localInsets2.left;
/* 2581 */ i2 = localDimension.height - localInsets1.bottom - localInsets2.bottom - BasicTabbedPaneUI.this.maxTabHeight;
/* 2582 */ i3 = localDimension.width - (localInsets1.right + localInsets2.right);
/* 2583 */ break;
/* */ case 1:
/* */ default:
/* 2586 */ BasicTabbedPaneUI.this.maxTabHeight = BasicTabbedPaneUI.this.calculateMaxTabHeight(paramInt1);
/* 2587 */ i1 = localInsets1.left + localInsets2.left;
/* 2588 */ i2 = localInsets1.top + localInsets2.top;
/* 2589 */ i3 = localDimension.width - (localInsets1.right + localInsets2.right);
/* */ }
/* */
/* 2593 */ int k = BasicTabbedPaneUI.this.getTabRunOverlay(paramInt1);
/* */
/* 2595 */ BasicTabbedPaneUI.this.runCount = 0;
/* 2596 */ BasicTabbedPaneUI.this.selectedRun = -1;
/* */
/* 2598 */ if (paramInt2 == 0)
/* */ return;
/* */ Rectangle localRectangle;
/* 2604 */ for (int m = 0; m < paramInt2; m++) {
/* 2605 */ localRectangle = BasicTabbedPaneUI.this.rects[m];
/* */
/* 2607 */ if (i4 == 0)
/* */ {
/* 2609 */ if (m > 0) {
/* 2610 */ localRectangle.x = (BasicTabbedPaneUI.this.rects[(m - 1)].x + BasicTabbedPaneUI.this.rects[(m - 1)].width);
/* */ } else {
/* 2612 */ BasicTabbedPaneUI.this.tabRuns[0] = 0;
/* 2613 */ BasicTabbedPaneUI.this.runCount = 1;
/* 2614 */ BasicTabbedPaneUI.this.maxTabWidth = 0;
/* 2615 */ localRectangle.x = i1;
/* */ }
/* 2617 */ localRectangle.width = BasicTabbedPaneUI.this.calculateTabWidth(paramInt1, m, localFontMetrics);
/* 2618 */ BasicTabbedPaneUI.this.maxTabWidth = Math.max(BasicTabbedPaneUI.this.maxTabWidth, localRectangle.width);
/* */
/* 2623 */ if ((localRectangle.x != 2 + localInsets1.left) && (localRectangle.x + localRectangle.width > i3)) {
/* 2624 */ if (BasicTabbedPaneUI.this.runCount > BasicTabbedPaneUI.this.tabRuns.length - 1) {
/* 2625 */ BasicTabbedPaneUI.this.expandTabRunsArray();
/* */ }
/* 2627 */ BasicTabbedPaneUI.this.tabRuns[BasicTabbedPaneUI.this.runCount] = m;
/* 2628 */ BasicTabbedPaneUI.this.runCount += 1;
/* 2629 */ localRectangle.x = i1;
/* */ }
/* */
/* 2632 */ localRectangle.y = i2;
/* 2633 */ localRectangle.height = BasicTabbedPaneUI.this.maxTabHeight;
/* */ }
/* */ else
/* */ {
/* 2637 */ if (m > 0) {
/* 2638 */ localRectangle.y = (BasicTabbedPaneUI.this.rects[(m - 1)].y + BasicTabbedPaneUI.this.rects[(m - 1)].height);
/* */ } else {
/* 2640 */ BasicTabbedPaneUI.this.tabRuns[0] = 0;
/* 2641 */ BasicTabbedPaneUI.this.runCount = 1;
/* 2642 */ BasicTabbedPaneUI.this.maxTabHeight = 0;
/* 2643 */ localRectangle.y = i2;
/* */ }
/* 2645 */ localRectangle.height = BasicTabbedPaneUI.this.calculateTabHeight(paramInt1, m, i);
/* 2646 */ BasicTabbedPaneUI.this.maxTabHeight = Math.max(BasicTabbedPaneUI.this.maxTabHeight, localRectangle.height);
/* */
/* 2651 */ if ((localRectangle.y != 2 + localInsets1.top) && (localRectangle.y + localRectangle.height > i3)) {
/* 2652 */ if (BasicTabbedPaneUI.this.runCount > BasicTabbedPaneUI.this.tabRuns.length - 1) {
/* 2653 */ BasicTabbedPaneUI.this.expandTabRunsArray();
/* */ }
/* 2655 */ BasicTabbedPaneUI.this.tabRuns[BasicTabbedPaneUI.this.runCount] = m;
/* 2656 */ BasicTabbedPaneUI.this.runCount += 1;
/* 2657 */ localRectangle.y = i2;
/* */ }
/* */
/* 2660 */ localRectangle.x = i1;
/* 2661 */ localRectangle.width = BasicTabbedPaneUI.this.maxTabWidth;
/* */ }
/* */
/* 2664 */ if (m == j) {
/* 2665 */ BasicTabbedPaneUI.this.selectedRun = (BasicTabbedPaneUI.this.runCount - 1);
/* */ }
/* */ }
/* */
/* 2669 */ if (BasicTabbedPaneUI.this.runCount > 1)
/* */ {
/* 2671 */ normalizeTabRuns(paramInt1, paramInt2, i4 != 0 ? i2 : i1, i3);
/* */
/* 2673 */ BasicTabbedPaneUI.this.selectedRun = BasicTabbedPaneUI.this.getRunForTab(paramInt2, j);
/* */
/* 2676 */ if (BasicTabbedPaneUI.this.shouldRotateTabRuns(paramInt1))
/* 2677 */ rotateTabRuns(paramInt1, BasicTabbedPaneUI.this.selectedRun);
/* */ }
/* */ int i5;
/* 2683 */ for (m = BasicTabbedPaneUI.this.runCount - 1; m >= 0; m--) {
/* 2684 */ i5 = BasicTabbedPaneUI.this.tabRuns[m];
/* 2685 */ int i6 = BasicTabbedPaneUI.this.tabRuns[(m + 1)];
/* 2686 */ int i7 = i6 != 0 ? i6 - 1 : paramInt2 - 1;
/* */ int n;
/* 2687 */ if (i4 == 0) {
/* 2688 */ for (n = i5; n <= i7; n++) {
/* 2689 */ localRectangle = BasicTabbedPaneUI.this.rects[n];
/* 2690 */ localRectangle.y = i2;
/* 2691 */ localRectangle.x += BasicTabbedPaneUI.this.getTabRunIndent(paramInt1, m);
/* */ }
/* 2693 */ if (BasicTabbedPaneUI.this.shouldPadTabRun(paramInt1, m)) {
/* 2694 */ padTabRun(paramInt1, i5, i7, i3);
/* */ }
/* 2696 */ if (paramInt1 == 3)
/* 2697 */ i2 -= BasicTabbedPaneUI.this.maxTabHeight - k;
/* */ else
/* 2699 */ i2 += BasicTabbedPaneUI.this.maxTabHeight - k;
/* */ }
/* */ else {
/* 2702 */ for (n = i5; n <= i7; n++) {
/* 2703 */ localRectangle = BasicTabbedPaneUI.this.rects[n];
/* 2704 */ localRectangle.x = i1;
/* 2705 */ localRectangle.y += BasicTabbedPaneUI.this.getTabRunIndent(paramInt1, m);
/* */ }
/* 2707 */ if (BasicTabbedPaneUI.this.shouldPadTabRun(paramInt1, m)) {
/* 2708 */ padTabRun(paramInt1, i5, i7, i3);
/* */ }
/* 2710 */ if (paramInt1 == 4)
/* 2711 */ i1 -= BasicTabbedPaneUI.this.maxTabWidth - k;
/* */ else {
/* 2713 */ i1 += BasicTabbedPaneUI.this.maxTabWidth - k;
/* */ }
/* */ }
/* */
/* */ }
/* */
/* 2719 */ padSelectedTab(paramInt1, j);
/* */
/* 2723 */ if ((!bool) && (i4 == 0)) {
/* 2724 */ i5 = localDimension.width - (localInsets1.right + localInsets2.right);
/* */
/* 2726 */ for (m = 0; m < paramInt2; m++)
/* 2727 */ BasicTabbedPaneUI.this.rects[m].x = (i5 - BasicTabbedPaneUI.this.rects[m].x - BasicTabbedPaneUI.this.rects[m].width);
/* */ }
/* */ }
/* */
/* */ protected void rotateTabRuns(int paramInt1, int paramInt2)
/* */ {
/* 2737 */ for (int i = 0; i < paramInt2; i++) {
/* 2738 */ int j = BasicTabbedPaneUI.this.tabRuns[0];
/* 2739 */ for (int k = 1; k < BasicTabbedPaneUI.this.runCount; k++) {
/* 2740 */ BasicTabbedPaneUI.this.tabRuns[(k - 1)] = BasicTabbedPaneUI.this.tabRuns[k];
/* */ }
/* 2742 */ BasicTabbedPaneUI.this.tabRuns[(BasicTabbedPaneUI.this.runCount - 1)] = j;
/* */ }
/* */ }
/* */
/* */ protected void normalizeTabRuns(int paramInt1, int paramInt2, int paramInt3, int paramInt4)
/* */ {
/* 2748 */ int i = (paramInt1 == 2) || (paramInt1 == 4) ? 1 : 0;
/* 2749 */ int j = BasicTabbedPaneUI.this.runCount - 1;
/* 2750 */ int k = 1;
/* 2751 */ double d = 1.25D;
/* */
/* 2764 */ while (k != 0) {
/* 2765 */ int m = BasicTabbedPaneUI.this.lastTabInRun(paramInt2, j);
/* 2766 */ int n = BasicTabbedPaneUI.this.lastTabInRun(paramInt2, j - 1);
/* */ int i1;
/* */ int i2;
/* 2770 */ if (i == 0) {
/* 2771 */ i1 = BasicTabbedPaneUI.this.rects[m].x + BasicTabbedPaneUI.this.rects[m].width;
/* 2772 */ i2 = (int)(BasicTabbedPaneUI.this.maxTabWidth * d);
/* */ } else {
/* 2774 */ i1 = BasicTabbedPaneUI.this.rects[m].y + BasicTabbedPaneUI.this.rects[m].height;
/* 2775 */ i2 = (int)(BasicTabbedPaneUI.this.maxTabHeight * d * 2.0D);
/* */ }
/* */
/* 2780 */ if (paramInt4 - i1 > i2)
/* */ {
/* 2783 */ BasicTabbedPaneUI.this.tabRuns[j] = n;
/* 2784 */ if (i == 0)
/* 2785 */ BasicTabbedPaneUI.this.rects[n].x = paramInt3;
/* */ else {
/* 2787 */ BasicTabbedPaneUI.this.rects[n].y = paramInt3;
/* */ }
/* 2789 */ for (int i3 = n + 1; i3 <= m; i3++) {
/* 2790 */ if (i == 0)
/* 2791 */ BasicTabbedPaneUI.this.rects[i3].x = (BasicTabbedPaneUI.this.rects[(i3 - 1)].x + BasicTabbedPaneUI.this.rects[(i3 - 1)].width);
/* */ else {
/* 2793 */ BasicTabbedPaneUI.this.rects[i3].y = (BasicTabbedPaneUI.this.rects[(i3 - 1)].y + BasicTabbedPaneUI.this.rects[(i3 - 1)].height);
/* */ }
/* */ }
/* */ }
/* 2797 */ else if (j == BasicTabbedPaneUI.this.runCount - 1)
/* */ {
/* 2799 */ k = 0;
/* */ }
/* 2801 */ if (j - 1 > 0)
/* */ {
/* 2803 */ j--;
/* */ }
/* */ else
/* */ {
/* 2808 */ j = BasicTabbedPaneUI.this.runCount - 1;
/* 2809 */ d += 0.25D;
/* */ }
/* */ }
/* */ }
/* */
/* */ protected void padTabRun(int paramInt1, int paramInt2, int paramInt3, int paramInt4) {
/* 2815 */ Rectangle localRectangle1 = BasicTabbedPaneUI.this.rects[paramInt3];
/* */ int i;
/* */ int j;
/* */ float f;
/* */ int k;
/* */ Rectangle localRectangle2;
/* 2816 */ if ((paramInt1 == 1) || (paramInt1 == 3)) {
/* 2817 */ i = localRectangle1.x + localRectangle1.width - BasicTabbedPaneUI.this.rects[paramInt2].x;
/* 2818 */ j = paramInt4 - (localRectangle1.x + localRectangle1.width);
/* 2819 */ f = j / i;
/* */
/* 2821 */ for (k = paramInt2; k <= paramInt3; k++) {
/* 2822 */ localRectangle2 = BasicTabbedPaneUI.this.rects[k];
/* 2823 */ if (k > paramInt2) {
/* 2824 */ localRectangle2.x = (BasicTabbedPaneUI.this.rects[(k - 1)].x + BasicTabbedPaneUI.this.rects[(k - 1)].width);
/* */ }
/* 2826 */ localRectangle2.width += Math.round(localRectangle2.width * f);
/* */ }
/* 2828 */ localRectangle1.width = (paramInt4 - localRectangle1.x);
/* */ } else {
/* 2830 */ i = localRectangle1.y + localRectangle1.height - BasicTabbedPaneUI.this.rects[paramInt2].y;
/* 2831 */ j = paramInt4 - (localRectangle1.y + localRectangle1.height);
/* 2832 */ f = j / i;
/* */
/* 2834 */ for (k = paramInt2; k <= paramInt3; k++) {
/* 2835 */ localRectangle2 = BasicTabbedPaneUI.this.rects[k];
/* 2836 */ if (k > paramInt2) {
/* 2837 */ localRectangle2.y = (BasicTabbedPaneUI.this.rects[(k - 1)].y + BasicTabbedPaneUI.this.rects[(k - 1)].height);
/* */ }
/* 2839 */ localRectangle2.height += Math.round(localRectangle2.height * f);
/* */ }
/* 2841 */ localRectangle1.height = (paramInt4 - localRectangle1.y);
/* */ }
/* */ }
/* */
/* */ protected void padSelectedTab(int paramInt1, int paramInt2)
/* */ {
/* 2847 */ if (paramInt2 >= 0) {
/* 2848 */ Rectangle localRectangle = BasicTabbedPaneUI.this.rects[paramInt2];
/* 2849 */ Insets localInsets1 = BasicTabbedPaneUI.this.getSelectedTabPadInsets(paramInt1);
/* 2850 */ localRectangle.x -= localInsets1.left;
/* 2851 */ localRectangle.width += localInsets1.left + localInsets1.right;
/* 2852 */ localRectangle.y -= localInsets1.top;
/* 2853 */ localRectangle.height += localInsets1.top + localInsets1.bottom;
/* */
/* 2855 */ if (!BasicTabbedPaneUI.this.scrollableTabLayoutEnabled())
/* */ {
/* 2857 */ Dimension localDimension = BasicTabbedPaneUI.this.tabPane.getSize();
/* 2858 */ Insets localInsets2 = BasicTabbedPaneUI.this.tabPane.getInsets();
/* */ int i;
/* */ int j;
/* 2860 */ if ((paramInt1 == 2) || (paramInt1 == 4)) {
/* 2861 */ i = localInsets2.top - localRectangle.y;
/* 2862 */ if (i > 0) {
/* 2863 */ localRectangle.y += i;
/* 2864 */ localRectangle.height -= i;
/* */ }
/* 2866 */ j = localRectangle.y + localRectangle.height + localInsets2.bottom - localDimension.height;
/* 2867 */ if (j > 0)
/* 2868 */ localRectangle.height -= j;
/* */ }
/* */ else {
/* 2871 */ i = localInsets2.left - localRectangle.x;
/* 2872 */ if (i > 0) {
/* 2873 */ localRectangle.x += i;
/* 2874 */ localRectangle.width -= i;
/* */ }
/* 2876 */ j = localRectangle.x + localRectangle.width + localInsets2.right - localDimension.width;
/* 2877 */ if (j > 0)
/* 2878 */ localRectangle.width -= j;
/* */ }
/* */ }
/* */ }
/* */ }
/* */ }
/* */
/* */ private class TabbedPaneScrollLayout extends BasicTabbedPaneUI.TabbedPaneLayout {
/* 2886 */ private TabbedPaneScrollLayout() { super(); }
/* */
/* */ protected int preferredTabAreaHeight(int paramInt1, int paramInt2) {
/* 2889 */ return BasicTabbedPaneUI.this.calculateMaxTabHeight(paramInt1);
/* */ }
/* */
/* */ protected int preferredTabAreaWidth(int paramInt1, int paramInt2) {
/* 2893 */ return BasicTabbedPaneUI.this.calculateMaxTabWidth(paramInt1);
/* */ }
/* */
/* */ public void layoutContainer(Container paramContainer)
/* */ {
/* 2908 */ BasicTabbedPaneUI.this.setRolloverTab(-1);
/* */
/* 2910 */ int i = BasicTabbedPaneUI.this.tabPane.getTabPlacement();
/* 2911 */ int j = BasicTabbedPaneUI.this.tabPane.getTabCount();
/* 2912 */ Insets localInsets1 = BasicTabbedPaneUI.this.tabPane.getInsets();
/* 2913 */ int k = BasicTabbedPaneUI.this.tabPane.getSelectedIndex();
/* 2914 */ Component localComponent1 = BasicTabbedPaneUI.this.getVisibleComponent();
/* */
/* 2916 */ calculateLayoutInfo();
/* */
/* 2918 */ Component localComponent2 = null;
/* 2919 */ if (k < 0) {
/* 2920 */ if (localComponent1 != null)
/* */ {
/* 2922 */ BasicTabbedPaneUI.this.setVisibleComponent(null);
/* */ }
/* */ }
/* 2925 */ else localComponent2 = BasicTabbedPaneUI.this.tabPane.getComponentAt(k);
/* */
/* 2928 */ if (BasicTabbedPaneUI.this.tabPane.getTabCount() == 0) {
/* 2929 */ BasicTabbedPaneUI.this.tabScroller.croppedEdge.resetParams();
/* 2930 */ BasicTabbedPaneUI.this.tabScroller.scrollForwardButton.setVisible(false);
/* 2931 */ BasicTabbedPaneUI.this.tabScroller.scrollBackwardButton.setVisible(false);
/* 2932 */ return;
/* */ }
/* */
/* 2935 */ int m = 0;
/* */
/* 2944 */ if (localComponent2 != null) {
/* 2945 */ if ((localComponent2 != localComponent1) && (localComponent1 != null))
/* */ {
/* 2947 */ if (SwingUtilities.findFocusOwner(localComponent1) != null) {
/* 2948 */ m = 1;
/* */ }
/* */ }
/* 2951 */ BasicTabbedPaneUI.this.setVisibleComponent(localComponent2);
/* */ }
/* */
/* 2955 */ Insets localInsets2 = BasicTabbedPaneUI.this.getContentBorderInsets(i);
/* 2956 */ Rectangle localRectangle = BasicTabbedPaneUI.this.tabPane.getBounds();
/* 2957 */ int i8 = BasicTabbedPaneUI.this.tabPane.getComponentCount();
/* */
/* 2959 */ if (i8 > 0)
/* */ {
/* */ int i2;
/* */ int i3;
/* */ int n;
/* */ int i1;
/* */ int i4;
/* */ int i5;
/* */ int i6;
/* */ int i7;
/* 2960 */ switch (i)
/* */ {
/* */ case 2:
/* 2963 */ i2 = BasicTabbedPaneUI.this.calculateTabAreaWidth(i, BasicTabbedPaneUI.this.runCount, BasicTabbedPaneUI.this.maxTabWidth);
/* 2964 */ i3 = localRectangle.height - localInsets1.top - localInsets1.bottom;
/* 2965 */ n = localInsets1.left;
/* 2966 */ i1 = localInsets1.top;
/* */
/* 2969 */ i4 = n + i2 + localInsets2.left;
/* 2970 */ i5 = i1 + localInsets2.top;
/* 2971 */ i6 = localRectangle.width - localInsets1.left - localInsets1.right - i2 - localInsets2.left - localInsets2.right;
/* */
/* 2973 */ i7 = localRectangle.height - localInsets1.top - localInsets1.bottom - localInsets2.top - localInsets2.bottom;
/* */
/* 2975 */ break;
/* */ case 4:
/* 2978 */ i2 = BasicTabbedPaneUI.this.calculateTabAreaWidth(i, BasicTabbedPaneUI.this.runCount, BasicTabbedPaneUI.this.maxTabWidth);
/* 2979 */ i3 = localRectangle.height - localInsets1.top - localInsets1.bottom;
/* 2980 */ n = localRectangle.width - localInsets1.right - i2;
/* 2981 */ i1 = localInsets1.top;
/* */
/* 2984 */ i4 = localInsets1.left + localInsets2.left;
/* 2985 */ i5 = localInsets1.top + localInsets2.top;
/* 2986 */ i6 = localRectangle.width - localInsets1.left - localInsets1.right - i2 - localInsets2.left - localInsets2.right;
/* */
/* 2988 */ i7 = localRectangle.height - localInsets1.top - localInsets1.bottom - localInsets2.top - localInsets2.bottom;
/* */
/* 2990 */ break;
/* */ case 3:
/* 2993 */ i2 = localRectangle.width - localInsets1.left - localInsets1.right;
/* 2994 */ i3 = BasicTabbedPaneUI.this.calculateTabAreaHeight(i, BasicTabbedPaneUI.this.runCount, BasicTabbedPaneUI.this.maxTabHeight);
/* 2995 */ n = localInsets1.left;
/* 2996 */ i1 = localRectangle.height - localInsets1.bottom - i3;
/* */
/* 2999 */ i4 = localInsets1.left + localInsets2.left;
/* 3000 */ i5 = localInsets1.top + localInsets2.top;
/* 3001 */ i6 = localRectangle.width - localInsets1.left - localInsets1.right - localInsets2.left - localInsets2.right;
/* */
/* 3003 */ i7 = localRectangle.height - localInsets1.top - localInsets1.bottom - i3 - localInsets2.top - localInsets2.bottom;
/* */
/* 3005 */ break;
/* */ case 1:
/* */ default:
/* 3009 */ i2 = localRectangle.width - localInsets1.left - localInsets1.right;
/* 3010 */ i3 = BasicTabbedPaneUI.this.calculateTabAreaHeight(i, BasicTabbedPaneUI.this.runCount, BasicTabbedPaneUI.this.maxTabHeight);
/* 3011 */ n = localInsets1.left;
/* 3012 */ i1 = localInsets1.top;
/* */
/* 3015 */ i4 = n + localInsets2.left;
/* 3016 */ i5 = i1 + i3 + localInsets2.top;
/* 3017 */ i6 = localRectangle.width - localInsets1.left - localInsets1.right - localInsets2.left - localInsets2.right;
/* */
/* 3019 */ i7 = localRectangle.height - localInsets1.top - localInsets1.bottom - i3 - localInsets2.top - localInsets2.bottom;
/* */ }
/* */
/* 3023 */ for (int i9 = 0; i9 < i8; i9++) {
/* 3024 */ Component localComponent3 = BasicTabbedPaneUI.this.tabPane.getComponent(i9);
/* */ Object localObject1;
/* */ Object localObject2;
/* */ int i10;
/* */ int i11;
/* */ int i13;
/* */ int i14;
/* 3026 */ if ((BasicTabbedPaneUI.this.tabScroller != null) && (localComponent3 == BasicTabbedPaneUI.this.tabScroller.viewport)) {
/* 3027 */ localObject1 = (JViewport)localComponent3;
/* 3028 */ localObject2 = ((JViewport)localObject1).getViewRect();
/* 3029 */ i10 = i2;
/* 3030 */ i11 = i3;
/* 3031 */ Dimension localDimension = BasicTabbedPaneUI.this.tabScroller.scrollForwardButton.getPreferredSize();
/* 3032 */ switch (i) {
/* */ case 2:
/* */ case 4:
/* 3035 */ i13 = BasicTabbedPaneUI.this.rects[(j - 1)].y + BasicTabbedPaneUI.this.rects[(j - 1)].height;
/* 3036 */ if (i13 > i3)
/* */ {
/* 3038 */ i11 = i3 > 2 * localDimension.height ? i3 - 2 * localDimension.height : 0;
/* 3039 */ if (i13 - ((Rectangle)localObject2).y <= i11)
/* */ {
/* 3042 */ i11 = i13 - ((Rectangle)localObject2).y; } } break;
/* */ case 1:
/* */ case 3:
/* */ default:
/* 3049 */ i14 = BasicTabbedPaneUI.this.rects[(j - 1)].x + BasicTabbedPaneUI.this.rects[(j - 1)].width;
/* 3050 */ if (i14 > i2)
/* */ {
/* 3052 */ i10 = i2 > 2 * localDimension.width ? i2 - 2 * localDimension.width : 0;
/* 3053 */ if (i14 - ((Rectangle)localObject2).x <= i10)
/* */ {
/* 3056 */ i10 = i14 - ((Rectangle)localObject2).x;
/* */ }
/* */ }
/* */ break;
/* */ }
/* 3060 */ localComponent3.setBounds(n, i1, i10, i11);
/* */ }
/* 3062 */ else if ((BasicTabbedPaneUI.this.tabScroller != null) && ((localComponent3 == BasicTabbedPaneUI.this.tabScroller.scrollForwardButton) || (localComponent3 == BasicTabbedPaneUI.this.tabScroller.scrollBackwardButton)))
/* */ {
/* 3065 */ localObject1 = localComponent3;
/* 3066 */ localObject2 = ((Component)localObject1).getPreferredSize();
/* 3067 */ i10 = 0;
/* 3068 */ i11 = 0;
/* 3069 */ int i12 = ((Dimension)localObject2).width;
/* 3070 */ i13 = ((Dimension)localObject2).height;
/* 3071 */ i14 = 0;
/* */
/* 3073 */ switch (i) {
/* */ case 2:
/* */ case 4:
/* 3076 */ int i15 = BasicTabbedPaneUI.this.rects[(j - 1)].y + BasicTabbedPaneUI.this.rects[(j - 1)].height;
/* 3077 */ if (i15 > i3) {
/* 3078 */ i14 = 1;
/* 3079 */ i10 = i == 2 ? n + i2 - ((Dimension)localObject2).width : n;
/* 3080 */ i11 = localComponent3 == BasicTabbedPaneUI.this.tabScroller.scrollForwardButton ? localRectangle.height - localInsets1.bottom - ((Dimension)localObject2).height : localRectangle.height - localInsets1.bottom - 2 * ((Dimension)localObject2).height; } break;
/* */ case 1:
/* */ case 3:
/* */ default:
/* 3089 */ int i16 = BasicTabbedPaneUI.this.rects[(j - 1)].x + BasicTabbedPaneUI.this.rects[(j - 1)].width;
/* */
/* 3091 */ if (i16 > i2) {
/* 3092 */ i14 = 1;
/* 3093 */ i10 = localComponent3 == BasicTabbedPaneUI.this.tabScroller.scrollForwardButton ? localRectangle.width - localInsets1.left - ((Dimension)localObject2).width : localRectangle.width - localInsets1.left - 2 * ((Dimension)localObject2).width;
/* */
/* 3096 */ i11 = i == 1 ? i1 + i3 - ((Dimension)localObject2).height : i1;
/* */ }break;
/* */ }
/* 3099 */ localComponent3.setVisible(i14);
/* 3100 */ if (i14 != 0) {
/* 3101 */ localComponent3.setBounds(i10, i11, i12, i13);
/* */ }
/* */ }
/* */ else
/* */ {
/* 3106 */ localComponent3.setBounds(i4, i5, i6, i7);
/* */ }
/* */ }
/* 3109 */ super.layoutTabComponents();
/* 3110 */ layoutCroppedEdge();
/* 3111 */ if ((m != 0) &&
/* 3112 */ (!BasicTabbedPaneUI.this.requestFocusForVisibleComponent()))
/* 3113 */ BasicTabbedPaneUI.this.tabPane.requestFocus();
/* */ }
/* */ }
/* */
/* */ private void layoutCroppedEdge()
/* */ {
/* 3120 */ BasicTabbedPaneUI.this.tabScroller.croppedEdge.resetParams();
/* 3121 */ Rectangle localRectangle1 = BasicTabbedPaneUI.this.tabScroller.viewport.getViewRect();
/* */
/* 3123 */ for (int j = 0; j < BasicTabbedPaneUI.this.rects.length; j++) {
/* 3124 */ Rectangle localRectangle2 = BasicTabbedPaneUI.this.rects[j];
/* */ int i;
/* 3125 */ switch (BasicTabbedPaneUI.this.tabPane.getTabPlacement()) {
/* */ case 2:
/* */ case 4:
/* 3128 */ i = localRectangle1.y + localRectangle1.height;
/* 3129 */ if ((localRectangle2.y < i) && (localRectangle2.y + localRectangle2.height > i))
/* 3130 */ BasicTabbedPaneUI.this.tabScroller.croppedEdge.setParams(j, i - localRectangle2.y - 1, -BasicTabbedPaneUI.this.currentTabAreaInsets.left, 0); break;
/* */ case 1:
/* */ case 3:
/* */ default:
/* 3137 */ i = localRectangle1.x + localRectangle1.width;
/* 3138 */ if ((localRectangle2.x < i - 1) && (localRectangle2.x + localRectangle2.width > i))
/* 3139 */ BasicTabbedPaneUI.this.tabScroller.croppedEdge.setParams(j, i - localRectangle2.x - 1, 0, -BasicTabbedPaneUI.this.currentTabAreaInsets.top);
/* */ break;
/* */ }
/* */ }
/* */ }
/* */
/* */ protected void calculateTabRects(int paramInt1, int paramInt2)
/* */ {
/* 3147 */ FontMetrics localFontMetrics = BasicTabbedPaneUI.this.getFontMetrics();
/* 3148 */ Dimension localDimension = BasicTabbedPaneUI.this.tabPane.getSize();
/* 3149 */ Insets localInsets1 = BasicTabbedPaneUI.this.tabPane.getInsets();
/* 3150 */ Insets localInsets2 = BasicTabbedPaneUI.this.getTabAreaInsets(paramInt1);
/* 3151 */ int i = localFontMetrics.getHeight();
/* 3152 */ int j = BasicTabbedPaneUI.this.tabPane.getSelectedIndex();
/* */
/* 3154 */ int m = (paramInt1 == 2) || (paramInt1 == 4) ? 1 : 0;
/* 3155 */ boolean bool = BasicGraphicsUtils.isLeftToRight(BasicTabbedPaneUI.this.tabPane);
/* 3156 */ int n = localInsets2.left;
/* 3157 */ int i1 = localInsets2.top;
/* 3158 */ int i2 = 0;
/* 3159 */ int i3 = 0;
/* */
/* 3164 */ switch (paramInt1) {
/* */ case 2:
/* */ case 4:
/* 3167 */ BasicTabbedPaneUI.this.maxTabWidth = BasicTabbedPaneUI.this.calculateMaxTabWidth(paramInt1);
/* 3168 */ break;
/* */ case 1:
/* */ case 3:
/* */ default:
/* 3172 */ BasicTabbedPaneUI.this.maxTabHeight = BasicTabbedPaneUI.this.calculateMaxTabHeight(paramInt1);
/* */ }
/* */
/* 3175 */ BasicTabbedPaneUI.this.runCount = 0;
/* 3176 */ BasicTabbedPaneUI.this.selectedRun = -1;
/* */
/* 3178 */ if (paramInt2 == 0) {
/* 3179 */ return;
/* */ }
/* */
/* 3182 */ BasicTabbedPaneUI.this.selectedRun = 0;
/* 3183 */ BasicTabbedPaneUI.this.runCount = 1;
/* */
/* 3187 */ for (int k = 0; k < paramInt2; k++) {
/* 3188 */ Rectangle localRectangle = BasicTabbedPaneUI.this.rects[k];
/* */
/* 3190 */ if (m == 0)
/* */ {
/* 3192 */ if (k > 0) {
/* 3193 */ localRectangle.x = (BasicTabbedPaneUI.this.rects[(k - 1)].x + BasicTabbedPaneUI.this.rects[(k - 1)].width);
/* */ } else {
/* 3195 */ BasicTabbedPaneUI.this.tabRuns[0] = 0;
/* 3196 */ BasicTabbedPaneUI.this.maxTabWidth = 0;
/* 3197 */ i3 += BasicTabbedPaneUI.this.maxTabHeight;
/* 3198 */ localRectangle.x = n;
/* */ }
/* 3200 */ localRectangle.width = BasicTabbedPaneUI.this.calculateTabWidth(paramInt1, k, localFontMetrics);
/* 3201 */ i2 = localRectangle.x + localRectangle.width;
/* 3202 */ BasicTabbedPaneUI.this.maxTabWidth = Math.max(BasicTabbedPaneUI.this.maxTabWidth, localRectangle.width);
/* */
/* 3204 */ localRectangle.y = i1;
/* 3205 */ localRectangle.height = BasicTabbedPaneUI.this.maxTabHeight;
/* */ }
/* */ else
/* */ {
/* 3209 */ if (k > 0) {
/* 3210 */ localRectangle.y = (BasicTabbedPaneUI.this.rects[(k - 1)].y + BasicTabbedPaneUI.this.rects[(k - 1)].height);
/* */ } else {
/* 3212 */ BasicTabbedPaneUI.this.tabRuns[0] = 0;
/* 3213 */ BasicTabbedPaneUI.this.maxTabHeight = 0;
/* 3214 */ i2 = BasicTabbedPaneUI.this.maxTabWidth;
/* 3215 */ localRectangle.y = i1;
/* */ }
/* 3217 */ localRectangle.height = BasicTabbedPaneUI.this.calculateTabHeight(paramInt1, k, i);
/* 3218 */ i3 = localRectangle.y + localRectangle.height;
/* 3219 */ BasicTabbedPaneUI.this.maxTabHeight = Math.max(BasicTabbedPaneUI.this.maxTabHeight, localRectangle.height);
/* */
/* 3221 */ localRectangle.x = n;
/* 3222 */ localRectangle.width = BasicTabbedPaneUI.this.maxTabWidth;
/* */ }
/* */
/* */ }
/* */
/* 3227 */ if (BasicTabbedPaneUI.this.tabsOverlapBorder)
/* */ {
/* 3229 */ padSelectedTab(paramInt1, j);
/* */ }
/* */
/* 3234 */ if ((!bool) && (m == 0)) {
/* 3235 */ int i4 = localDimension.width - (localInsets1.right + localInsets2.right);
/* */
/* 3237 */ for (k = 0; k < paramInt2; k++) {
/* 3238 */ BasicTabbedPaneUI.this.rects[k].x = (i4 - BasicTabbedPaneUI.this.rects[k].x - BasicTabbedPaneUI.this.rects[k].width);
/* */ }
/* */ }
/* 3241 */ BasicTabbedPaneUI.this.tabScroller.tabPanel.setPreferredSize(new Dimension(i2, i3));
/* */ }
/* */ }
/* */ }
/* Location: C:\Program Files\Java\jdk1.7.0_79\jre\lib\rt.jar
* Qualified Name: javax.swing.plaf.basic.BasicTabbedPaneUI
* JD-Core Version: 0.6.2
*/ | 159,578 | 0.543483 | 0.48862 | 3,398 | 45.962624 | 35.576611 | 282 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.715715 | false | false | 9 |
9a2032d3d4187543a0a41989cb1e01fb6d127ad1 | 16,020,228,040,410 | 3df630ae894902727d84e85b89efcd5019fc0eb6 | /server/src/main/java/com/yqb/personal/web/service/IFavoriteService.java | 8a4b7b497331e7f1926f10078e857a5caa5fbe5d | [] | no_license | Liaomessi/Java-Personal-website | https://github.com/Liaomessi/Java-Personal-website | a999cb6272f446d8857c3be2ebfc2a640216a1fb | aae70e9dd493d0b407465c7c9825c3a11b0ddd53 | refs/heads/master | 2020-07-27T18:35:58.329000 | 2019-10-11T14:02:11 | 2019-10-11T14:02:11 | 209,187,439 | 2 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.yqb.personal.web.service;
import com.yqb.personal.help.entity.Favorite;
import com.baomidou.mybatisplus.extension.service.IService;
/**
* 服务类
*
* @author 杨青波
* @date 2019-09-20
*/
public interface IFavoriteService extends IService<Favorite> {
}
| UTF-8 | Java | 278 | java | IFavoriteService.java | Java | [
{
"context": "sion.service.IService;\n\n/**\n * 服务类\n *\n * @author 杨青波\n * @date 2019-09-20\n */\npublic interface IFavorit",
"end": 175,
"score": 0.9996594190597534,
"start": 172,
"tag": "NAME",
"value": "杨青波"
}
] | null | [] | package com.yqb.personal.web.service;
import com.yqb.personal.help.entity.Favorite;
import com.baomidou.mybatisplus.extension.service.IService;
/**
* 服务类
*
* @author 杨青波
* @date 2019-09-20
*/
public interface IFavoriteService extends IService<Favorite> {
}
| 278 | 0.74812 | 0.718045 | 14 | 18 | 22.058365 | 62 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.214286 | false | false | 9 |
91c1148c7a4b52dd53b8670a700ef2f3655be3c4 | 4,423,816,341,271 | f69fb1f1a9dfa499ed8dc2aceef5c7b80bfc4dc3 | /app/src/main/java/com/github/wedemboys/penpals/User.java | 473ad6afabbb39b2794f5f8787ae192a70a0b1d2 | [] | no_license | WeDemBois/PenPals | https://github.com/WeDemBois/PenPals | 0493022b59c9678d79b82a4942ee1eb28b59d343 | 9528cfd3bf76a8be6dcf58175671c3e6b682e543 | refs/heads/master | 2021-08-23T12:42:55.304000 | 2017-12-04T23:36:05 | 2017-12-04T23:36:05 | 104,374,048 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.github.wedemboys.penpals;
/**
* Created by jakeo on 10/2/2017.
*/
public class User {
public User(String username, String password, String email, String firstname, String lastname, String country, String lang, String gender, String interests) {
this.username = username;
this.password = password;
this.email = email;
this.firstname = firstname;
this.lastname = lastname;
this.country = country;
this.lang = lang;
this.gender = gender;
this.interests = interests;
}
private String username;
private String password;
private String email;
private String firstname;
private String lastname;
private String country;
private String lang;
private String gender;
private String interests;
public User(){}
public String getPassword() {
return password;
}
public String getEmail() {
return email;
}
public String getFirstname() {
return firstname;
}
public String getLastname() {
return lastname;
}
public String getCountry() {
return country;
}
public String getLang() {
return lang;
}
public String getGender() {
return gender;
}
public String getInterests() {
return interests;
}
public String getUsername() {
return username;
}
@Override
public String toString() {
return "User{" +
"username='" + username + '\'' +
", password='" + password + '\'' +
", email='" + email + '\'' +
", firstname='" + firstname + '\'' +
", lastname='" + lastname + '\'' +
", country='" + country + '\'' +
", lang='" + lang + '\'' +
", gender='" + gender + '\'' +
", interests='" + interests + '\'' +
'}';
}
}
| UTF-8 | Java | 1,956 | java | User.java | Java | [
{
"context": "e com.github.wedemboys.penpals;\n\n/**\n * Created by jakeo on 10/2/2017.\n */\n\npublic class User {\n\n publi",
"end": 62,
"score": 0.9996190071105957,
"start": 57,
"tag": "USERNAME",
"value": "jakeo"
},
{
"context": "ender, String interests) {\n this.userna... | null | [] | package com.github.wedemboys.penpals;
/**
* Created by jakeo on 10/2/2017.
*/
public class User {
public User(String username, String password, String email, String firstname, String lastname, String country, String lang, String gender, String interests) {
this.username = username;
this.password = <PASSWORD>;
this.email = email;
this.firstname = firstname;
this.lastname = lastname;
this.country = country;
this.lang = lang;
this.gender = gender;
this.interests = interests;
}
private String username;
private String password;
private String email;
private String firstname;
private String lastname;
private String country;
private String lang;
private String gender;
private String interests;
public User(){}
public String getPassword() {
return <PASSWORD>;
}
public String getEmail() {
return email;
}
public String getFirstname() {
return firstname;
}
public String getLastname() {
return lastname;
}
public String getCountry() {
return country;
}
public String getLang() {
return lang;
}
public String getGender() {
return gender;
}
public String getInterests() {
return interests;
}
public String getUsername() {
return username;
}
@Override
public String toString() {
return "User{" +
"username='" + username + '\'' +
", password='" + <PASSWORD> + '\'' +
", email='" + email + '\'' +
", firstname='" + firstname + '\'' +
", lastname='" + lastname + '\'' +
", country='" + country + '\'' +
", lang='" + lang + '\'' +
", gender='" + gender + '\'' +
", interests='" + interests + '\'' +
'}';
}
}
| 1,962 | 0.529652 | 0.526074 | 83 | 22.566265 | 21.94692 | 162 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.542169 | false | false | 9 |
901334d8e0f3103227f8f1630facdfddda7ce820 | 4,423,816,341,233 | e81cc6fd47b2a355ef4207b70aa13b82be9618a2 | /Login.java | 6ece0311b22e1c6dab5766e3ada13c5749b7d7d2 | [] | no_license | ajir77/aprendiendo-java | https://github.com/ajir77/aprendiendo-java | 00cfe4e578e7b7bc1c4e4fe72b3230a07927b4d4 | 8b48a1bc846986a2dceeb8a62b7293b3018fa61c | refs/heads/master | 2020-04-23T19:48:05.754000 | 2019-05-30T15:31:23 | 2019-05-30T15:31:23 | 171,417,992 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | import javax.swing.*;
import java.awt.event.*;
public class Login extends JFrame implements ActionListener
{
private JTextField txt_usuario;
private JLabel lbl_usuario;
private JButton btn_aceptar;
public Login()
{
setLayout(null);
// Crear etiquetas
lbl_usuario = new JLabel ("Usuario:");
lbl_usuario.setBounds(10,10,100,30);
add(lbl_usuario);
// Crear Textos
txt_usuario = new JTextField();
txt_usuario.setBounds(120,17,150,20);
add(txt_usuario);
// Crear Botones
btn_aceptar = new JButton("Aceptar");
btn_aceptar.setBounds(10,80,100,30);
add(btn_aceptar);
btn_aceptar.addActionListener(this);
}
public void actionPerformed(ActionEvent e)
{
if (e.getSource() == btn_aceptar)
{
String ls_texto = txt_usuario.getText();
setTitle(ls_texto);
txt_usuario.setText("");
}
}
public static void main(String args[])
{
Login frm_login = new Login();
frm_login.setBounds(0,0,300,150);
frm_login.setVisible(true);
frm_login.setResizable(false);
frm_login.setLocationRelativeTo(null);
}
}
| UTF-8 | Java | 1,143 | java | Login.java | Java | [] | null | [] | import javax.swing.*;
import java.awt.event.*;
public class Login extends JFrame implements ActionListener
{
private JTextField txt_usuario;
private JLabel lbl_usuario;
private JButton btn_aceptar;
public Login()
{
setLayout(null);
// Crear etiquetas
lbl_usuario = new JLabel ("Usuario:");
lbl_usuario.setBounds(10,10,100,30);
add(lbl_usuario);
// Crear Textos
txt_usuario = new JTextField();
txt_usuario.setBounds(120,17,150,20);
add(txt_usuario);
// Crear Botones
btn_aceptar = new JButton("Aceptar");
btn_aceptar.setBounds(10,80,100,30);
add(btn_aceptar);
btn_aceptar.addActionListener(this);
}
public void actionPerformed(ActionEvent e)
{
if (e.getSource() == btn_aceptar)
{
String ls_texto = txt_usuario.getText();
setTitle(ls_texto);
txt_usuario.setText("");
}
}
public static void main(String args[])
{
Login frm_login = new Login();
frm_login.setBounds(0,0,300,150);
frm_login.setVisible(true);
frm_login.setResizable(false);
frm_login.setLocationRelativeTo(null);
}
}
| 1,143 | 0.63867 | 0.607174 | 49 | 22.32653 | 16.337496 | 59 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.734694 | false | false | 9 |
706c1c949bfcf980c384ec0b4e212d450a4669d6 | 7,687,991,490,040 | 66413dcfc42d6d4f81d286ac49d15f4882de645b | /groups/src/com/exametrika/impl/groups/cluster/membership/ClusterMembershipChange.java | e671b679ac1295c45a61d5ee17e3eac7cc19fd94 | [] | no_license | exametrika/groups | https://github.com/exametrika/groups | c06d8ab1eadcd7ed2dc1c685a78b33c1c13d195d | eeabcf91d905b132c135f4a976843b0520ab995e | refs/heads/master | 2020-06-10T04:16:09.711000 | 2017-07-25T20:57:40 | 2017-07-25T20:57:40 | 76,091,939 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | /**
* Copyright 2010 Andrey Medvedev. All rights reserved.
*/
package com.exametrika.impl.groups.cluster.membership;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import com.exametrika.api.groups.cluster.IClusterMembershipChange;
import com.exametrika.api.groups.cluster.IDomainMembership;
import com.exametrika.api.groups.cluster.IDomainMembershipChange;
import com.exametrika.common.l10n.DefaultMessage;
import com.exametrika.common.l10n.ILocalizedMessage;
import com.exametrika.common.l10n.Messages;
import com.exametrika.common.utils.Assert;
import com.exametrika.common.utils.Immutables;
import com.exametrika.common.utils.Strings;
/**
* The {@link ClusterMembershipChange} is implementation of {@link IClusterMembershipChange}.
*
* @threadsafety This class and its methods are thread safe.
* @author Medvedev-A
*/
public final class ClusterMembershipChange implements IClusterMembershipChange
{
private static final IMessages messages = Messages.get(IMessages.class);
private final List<IDomainMembership> newDomains;
private final List<IDomainMembershipChange> changedDomains;
private final Map<String, IDomainMembershipChange> changedDomainsMap;
private final Set<IDomainMembership> removedDomains;
private final IDomainMembershipChange coreDomain;
public ClusterMembershipChange(List<IDomainMembership> newDomains, List<IDomainMembershipChange> changedDomains,
Set<IDomainMembership> removedDomains, IDomainMembershipChange coreDomain)
{
Assert.notNull(newDomains);
Assert.notNull(changedDomains);
Assert.notNull(removedDomains);
this.newDomains = Immutables.wrap(newDomains);
this.changedDomains = Immutables.wrap(changedDomains);
this.removedDomains = Immutables.wrap(removedDomains);
this.coreDomain = coreDomain;
Map<String, IDomainMembershipChange> changedDomainsMap = new HashMap<String, IDomainMembershipChange>();
for (IDomainMembershipChange domain : changedDomains)
changedDomainsMap.put(domain.getName(), domain);
this.changedDomainsMap = changedDomainsMap;
}
@Override
public List<IDomainMembership> getNewDomains()
{
return newDomains;
}
@Override
public IDomainMembershipChange findChangedDomain(String name)
{
Assert.notNull(name);
return changedDomainsMap.get(name);
}
@Override
public List<IDomainMembershipChange> getChangedDomains()
{
return changedDomains;
}
@Override
public Set<IDomainMembership> getRemovedDomains()
{
return removedDomains;
}
public IDomainMembershipChange getCoreDomain()
{
return coreDomain;
}
@Override
public String toString()
{
return messages.toString(Strings.toString(newDomains, true), Strings.toString(changedDomains, true),
Strings.toString(removedDomains, true), coreDomain != null ? Strings.indent(coreDomain.toString(), 4) : "").toString();
}
private interface IMessages
{
@DefaultMessage("new domains: \n{0}\nchanged domains: \n{1}\nremoved domains: \n{2}\ncore domain: \n{3}")
ILocalizedMessage toString(String newDomains, String changedDomains, String removedDomains, String coreDomain);
}
}
| UTF-8 | Java | 3,490 | java | ClusterMembershipChange.java | Java | [
{
"context": "/**\r\n * Copyright 2010 Andrey Medvedev. All rights reserved.\r\n */\r\npackage com.exametrik",
"end": 38,
"score": 0.9998739361763,
"start": 23,
"tag": "NAME",
"value": "Andrey Medvedev"
},
{
"context": "class and its methods are thread safe.\r\n * @author Medvedev-A\... | null | [] | /**
* Copyright 2010 <NAME>. All rights reserved.
*/
package com.exametrika.impl.groups.cluster.membership;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import com.exametrika.api.groups.cluster.IClusterMembershipChange;
import com.exametrika.api.groups.cluster.IDomainMembership;
import com.exametrika.api.groups.cluster.IDomainMembershipChange;
import com.exametrika.common.l10n.DefaultMessage;
import com.exametrika.common.l10n.ILocalizedMessage;
import com.exametrika.common.l10n.Messages;
import com.exametrika.common.utils.Assert;
import com.exametrika.common.utils.Immutables;
import com.exametrika.common.utils.Strings;
/**
* The {@link ClusterMembershipChange} is implementation of {@link IClusterMembershipChange}.
*
* @threadsafety This class and its methods are thread safe.
* @author Medvedev-A
*/
public final class ClusterMembershipChange implements IClusterMembershipChange
{
private static final IMessages messages = Messages.get(IMessages.class);
private final List<IDomainMembership> newDomains;
private final List<IDomainMembershipChange> changedDomains;
private final Map<String, IDomainMembershipChange> changedDomainsMap;
private final Set<IDomainMembership> removedDomains;
private final IDomainMembershipChange coreDomain;
public ClusterMembershipChange(List<IDomainMembership> newDomains, List<IDomainMembershipChange> changedDomains,
Set<IDomainMembership> removedDomains, IDomainMembershipChange coreDomain)
{
Assert.notNull(newDomains);
Assert.notNull(changedDomains);
Assert.notNull(removedDomains);
this.newDomains = Immutables.wrap(newDomains);
this.changedDomains = Immutables.wrap(changedDomains);
this.removedDomains = Immutables.wrap(removedDomains);
this.coreDomain = coreDomain;
Map<String, IDomainMembershipChange> changedDomainsMap = new HashMap<String, IDomainMembershipChange>();
for (IDomainMembershipChange domain : changedDomains)
changedDomainsMap.put(domain.getName(), domain);
this.changedDomainsMap = changedDomainsMap;
}
@Override
public List<IDomainMembership> getNewDomains()
{
return newDomains;
}
@Override
public IDomainMembershipChange findChangedDomain(String name)
{
Assert.notNull(name);
return changedDomainsMap.get(name);
}
@Override
public List<IDomainMembershipChange> getChangedDomains()
{
return changedDomains;
}
@Override
public Set<IDomainMembership> getRemovedDomains()
{
return removedDomains;
}
public IDomainMembershipChange getCoreDomain()
{
return coreDomain;
}
@Override
public String toString()
{
return messages.toString(Strings.toString(newDomains, true), Strings.toString(changedDomains, true),
Strings.toString(removedDomains, true), coreDomain != null ? Strings.indent(coreDomain.toString(), 4) : "").toString();
}
private interface IMessages
{
@DefaultMessage("new domains: \n{0}\nchanged domains: \n{1}\nremoved domains: \n{2}\ncore domain: \n{3}")
ILocalizedMessage toString(String newDomains, String changedDomains, String removedDomains, String coreDomain);
}
}
| 3,481 | 0.709742 | 0.705444 | 98 | 33.612244 | 32.605755 | 131 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.561224 | false | false | 9 |
56923f083672ac8ff046358dddf425772fd69dbb | 7,748,121,032,051 | 6013747b07952b05fd7c86b7f763e3af5b0bbcf9 | /.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/wslogix/Doc/UsuarioWS.java | 821007e3cef2a405a72c659407e18abc140c23f2 | [] | no_license | ivohb/wsiurd | https://github.com/ivohb/wsiurd | 6a005479e72a3fcf33668e4b60b7c9c62e8f2745 | fe4d969fdb6e1a1a2b71d794076af1649615e54f | refs/heads/master | 2020-09-09T13:38:11.544000 | 2019-11-13T13:04:37 | 2019-11-13T13:04:37 | 221,460,416 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package servico;
import java.util.ArrayList;
import java.util.List;
import javax.ws.rs.Consumes;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.Response.Status;
import modelo.Destinatario;
import modelo.Usuario;
import org.codehaus.jettison.json.JSONArray;
import org.codehaus.jettison.json.JSONException;
import org.codehaus.jettison.json.JSONObject;
import util.Biblioteca;
import dao.DestinatarioDao;
import dao.EmitenteDao;
import dao.FabricaDao;
import dao.UsuarioDao;
@Path("/usuario")
public class UsuarioWS {
private String mensagem;
private String erro;
private FabricaDao fd = new FabricaDao();
private UsuarioDao dao = fd.getUsuarioDao();
private Biblioteca bib = new Biblioteca();
@POST
@Path("/alterar")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public Response alterar(Usuario usuario){
int index = -1;
List<String> criticas = new ArrayList<String>();
JSONObject jo;
JSONArray ja = new JSONArray();
Response response = null;
if (usuario.getLogin() == null || usuario.getLogin().isEmpty()) {
index++;
criticas.add(index, "O usuário logado não foi informado ao WS");
}
if (usuario.getToken() == null || usuario.getToken().isEmpty()) {
index++;
criticas.add(index, "O token do usuário não foi informado ao WS");
}
if (usuario.getPerfil() == null || usuario.getPerfil().isEmpty()) {
index++;
criticas.add(index, "O campo Perfil é obrigatório");
}
if (index < 0 ) {
this.mensagem = dao.validaSecao(
usuario.getLogin(), usuario.getToken());
if (!this.mensagem.isEmpty()) {
index++;
criticas.add(index, this.mensagem);
}
}
if (index < 0 ) {
try {
String perfil = dao.getPeril(usuario.getCodigo());
if (perfil.isEmpty()) {
index++;
criticas.add(index, "Usuário não cadastrado no Portal");
} else {
if (usuario.getPerfil().trim().equals(perfil)) {
index++;
criticas.add(index, "Modifique antes de salvar");
} else {
dao.alterar(usuario);
}
}
} catch (Exception e) {
index++;
criticas.add(index, e.getMessage());
dao.fechaTransac();
}
}
if (index >= 0 ) {
for (String s : criticas){
jo = new JSONObject();
try {
jo.put("erro", s);
ja.put(jo);
} catch (JSONException e) {
setMensagem(e.getMessage());
}
}
setMensagem("ERRO");
}
jo = new JSONObject();
try {
jo.put("mensagem", getMensagem());
jo.put("token", usuario.getToken());
jo.putOpt("result", ja);
} catch (JSONException e) {
e.printStackTrace();
}
response = Response.status(Status.OK).entity(jo).build();
return response;
}
@POST
@Path("/cadastrar")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public Response cadastro(Usuario usuario){
int index = -1;
List<String> criticas = new ArrayList<String>();
JSONObject jo;
JSONArray ja = new JSONArray();
Response response = null;
boolean email = false;
String senha = "";
if (usuario.getLogin() == null || usuario.getLogin().isEmpty()) {
index++;
criticas.add(index, "O usuário logado não foi informado ao WS");
}
if (usuario.getToken() == null || usuario.getToken().isEmpty()) {
index++;
criticas.add(index, "O token do usuário não foi informado ao WS");
}
if (usuario.getCodigo() == null || usuario.getCodigo().isEmpty()) {
index++;
criticas.add(index, "O campo Usuário é obrigatório");
}
if (usuario.getPerfil() == null || usuario.getPerfil().isEmpty()) {
index++;
criticas.add(index, "O campo Perfil é obrigatório");
}
if (usuario.getSenha() == null || usuario.getSenha().isEmpty()) {
if (index < 0 ) {
usuario.setSenha(bib.geraSenha(usuario.getCodigo()));
}
} else {
if (!bib.validaSenha(usuario.getSenha())) {
index++;
criticas.add(index, "A senha informada não é segura");
}
}
senha = usuario.getSenha();
if (index < 0 ) {
this.mensagem = dao.validaSecao(
usuario.getLogin(), usuario.getToken());
if (!this.mensagem.isEmpty()) {
index++;
criticas.add(index, this.mensagem);
}
}
if (index < 0 ) {
try {
setMensagem(dao.getNome(usuario.getCodigo()));
if (this.mensagem.isEmpty()) {
index++;
criticas.add(index, "Usuário não cadastrado no Logix");
} else {
if (dao.IsUserPortal(usuario.getCodigo())) {
index++;
criticas.add(index, "Usuário já existe no portal");
} else {
usuario.setSenha(bib.getCriptografia(usuario.getSenha()));
dao.incluir(usuario);
email = true;
}
}
} catch (Exception e) {
index++;
criticas.add(index, e.getMessage());
dao.fechaTransac();
}
}
if (email) {
enviarEmail(usuario.getCodigo(), senha);
}
if (index >= 0 ) {
for (String s : criticas){
jo = new JSONObject();
try {
jo.put("erro", s);
ja.put(jo);
} catch (JSONException e) {
setMensagem(e.getMessage());
}
}
setMensagem("ERRO");
}
jo = new JSONObject();
try {
jo.put("mensagem", getMensagem());
jo.put("token", usuario.getToken());
jo.putOpt("result", ja);
} catch (JSONException e) {
e.printStackTrace();
}
response = Response.status(Status.OK).entity(jo).build();
return response;
}
private void enviarEmail(String codigo, String senha) {
modelo.Emitente emit = null;
EmitenteDao eDao = fd.getEmitenteDao();
Destinatario dest = new Destinatario();
DestinatarioDao dDao = fd.getDestinatarioDao();
try {
emit = eDao.getEmitente();
dest = dDao.getDestinatario(codigo);
} catch (Exception e) {
e.printStackTrace();
return;
}
if (emit == null || dest == null) {
return;
}
dest.setMensagem("A seguir, seus dados de login, para aprovação de documentos via APP:");
String corpo = "Login: " + codigo + " - Senha: " + senha + "\n\n";
corpo += "Para alterar sua senha, consulte o adimistrador do TI.";
dest.setCorpo(corpo);
new util.EnviaEmail().Enviar(emit, dest);
}
@POST
@Path("/excluir")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public Response excluir(Usuario usuario){
int index = -1;
List<String> criticas = new ArrayList<String>();
JSONObject jo;
JSONArray ja = new JSONArray();
Response response = null;
if (usuario.getLogin() == null || usuario.getLogin().isEmpty()) {
index++;
criticas.add(index, "O usuário logado não foi informado ao WS");
}
if (usuario.getToken() == null || usuario.getToken().isEmpty()) {
index++;
criticas.add(index, "O token do usuário não foi informado ao WS");
}
if (index < 0 ) {
this.mensagem = dao.validaSecao(
usuario.getLogin(), usuario.getToken());
if (!this.mensagem.isEmpty()) {
index++;
criticas.add(index, this.mensagem);
}
}
if (index < 0 ) {
try {
setMensagem(dao.getNome(usuario.getCodigo()));
if (this.mensagem.isEmpty()) {
index++;
criticas.add(index, "Usuário não cadastrado no Logix");
} else {
dao.excluir(usuario);
}
} catch (Exception e) {
index++;
criticas.add(index, e.getMessage());
dao.fechaTransac();
}
}
if (index >= 0 ) {
for (String s : criticas){
jo = new JSONObject();
try {
jo.put("erro", s);
ja.put(jo);
} catch (JSONException e) {
setMensagem(e.getMessage());
}
}
setMensagem("ERRO");
}
jo = new JSONObject();
try {
jo.put("mensagem", getMensagem());
jo.put("token", usuario.getToken());
jo.putOpt("result", ja);
} catch (JSONException e) {
e.printStackTrace();
}
response = Response.status(Status.OK).entity(jo).build();
return response;
}
@POST
@Path("/logar")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public Response getLogin(Usuario usuario){
int index = -1;
setMensagem("OK");
List<String> criticas = new ArrayList<String>();
JSONObject jo;
JSONArray ja = new JSONArray();
Response response = null;
String login = usuario.getLogin();
if (usuario.getLogin() == null || usuario.getLogin().isEmpty()) {
index++;
criticas.add(index, "Favor informar o código de login");
}
if (usuario.getSenha() == null || usuario.getSenha().isEmpty()) {
index++;
criticas.add(index, "Favor informar a senha");
}
if (index < 0 ) {
try {
String senha = usuario.getSenha();
usuario = dao.getUsuario(usuario.getLogin());
if (usuario == null) {
index++;
criticas.add(index, "Usuário não existe no Logix");
usuario = new Usuario();
} else {
String criptografada = (
bib.getCriptografia(senha));
String gravada = usuario.getSenha().trim();
if (criptografada.equals(gravada)) {
usuario.setSenha("");
jo = new JSONObject();
jo.put("login", login);
jo.put("codigo", usuario.getCodigo());
jo.put("nome", usuario.getNome());
jo.put("perfil", usuario.getPerfil().trim());
ja.put(jo);
usuario.setToken(""+bib.geraToken());
setMensagem(dao.abreSecao(usuario, "logar"));
} else {
index++;
criticas.add(index, "A senha informada não é válida");
}
}
} catch (Exception e) {
index++;
criticas.add(index, e.getMessage());
}
}
if (index >= 0 ) {
for (String s : criticas){
jo = new JSONObject();
try {
jo.put("erro", s);
ja.put(jo);
} catch (JSONException e) {
setMensagem(e.getMessage());
}
}
setMensagem("ERRO");
}
jo = new JSONObject();
try {
jo.put("mensagem", getMensagem());
if (usuario.getToken() == null) {
jo.put("token", "");
} else {
jo.put("token", usuario.getToken());
}
jo.putOpt("result", ja);
} catch (JSONException e) {
e.printStackTrace();
}
response = Response.status(Status.OK).entity(jo).build();
return response;
}
@POST
@Path("/listar")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public Response getListaTudo(Usuario usuario){
int index = -1;
setMensagem("OK");
List<String> criticas = new ArrayList<String>();
List<Usuario> usuarios = null;
JSONObject jo;
JSONArray ja = new JSONArray();
Response response = null;
if (usuario.getToken() == null || usuario.getToken().isEmpty()) {
usuario.setToken("0");
}
if (usuario.getLogin() == null || usuario.getLogin().isEmpty()) {
index++;
criticas.add(index, "Favor informar o código do usuário");
} else {
this.mensagem = dao.validaSecao(
usuario.getLogin(), usuario.getToken());
if (!this.mensagem.isEmpty()) {
index++;
criticas.add(index, this.mensagem);
}
}
if (index < 0 ) {
if (usuario.getCodigo() == null) {
usuario.setCodigo("");
}
if (usuario.getNome() == null) {
usuario.setNome("");
}
if (usuario.getPerfil() == null) {
usuario.setPerfil("");
}
try {
usuarios = dao.getUsuarios(usuario);
if (usuarios.size() > 0) {
for (Usuario u : usuarios){
jo = new JSONObject();
jo.put("codigo", u.getCodigo());
jo.put("nome", u.getNome());
jo.put("perfil", u.getPerfil());
ja.put(jo);
}
} else {
index++;
criticas.add(index, "A pesquisa não encontrou usuários");
}
} catch (Exception e) {
}
}
if (index >= 0 ) {
for (String s : criticas){
jo = new JSONObject();
try {
jo.put("erro", s);
ja.put(jo);
} catch (JSONException e) {
setMensagem(e.getMessage());
}
}
setMensagem("ERRO");
}
jo = new JSONObject();
try {
jo.put("mensagem", getMensagem());
jo.put("token", usuario.getToken());
jo.putOpt("result", ja);
} catch (JSONException e) {
e.printStackTrace();
}
response = Response.status(Status.OK).entity(jo).build();
return response;
}
@POST
@Path("/validar")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public Response getAprovador(Usuario usuario){
int index = -1;
setMensagem("");
List<String> criticas = new ArrayList<String>();
List<Usuario> usuarios;
String data = bib.dataAtual("dd/MM/yyyy");
JSONObject jo;
JSONArray ja = new JSONArray();
Response response = null;
if (usuario.getCodigo().isEmpty()) {
index++;
criticas.add(index, "O código do usuário está nulo");
}
if (usuario.getSenha().isEmpty()) {
index++;
criticas.add(index, "A senha está nula");
}
if (index < 0 ) {
try {
if (!dao.IsUserPortal(usuario.getCodigo())) {
index++;
criticas.add(index, "Usuário não existe no portal");
} else {
String senha = (dao.getSenha(usuario.getCodigo())).trim();
String criptografada = (
bib.getCriptografia(usuario.getSenha()));
if (senha.equals(criptografada)) {
usuario.setEmpresa("01");
usuarios = dao.getAprovantes(usuario.getCodigo(),
usuario.getEmpresa(), data);
if (usuarios.size() > 0) {
for (Usuario u : usuarios){
jo = new JSONObject();
jo.put("codigo", u.getCodigo());
jo.put("nome", u.getNome());
ja.put(jo);
}
usuario.setToken(""+bib.geraToken());
setMensagem(dao.abreSecao(usuario, "validar"));
} else {
index++;
criticas.add(index, "Usuário não é aproante de documentos");
}
} else {
index++;
criticas.add(index, "A senha informada não é válida");
}
}
} catch (Exception e) {
index++;
criticas.add(index, e.getMessage());
}
}
if (index >= 0 ) {
for (String s : criticas){
jo = new JSONObject();
try {
jo.put("erro", s);
ja.put(jo);
} catch (JSONException e) {
setMensagem(e.getMessage());
}
}
setMensagem("ERRO");
}
jo = new JSONObject();
try {
jo.put("mensagem", getMensagem());
if (usuario.getToken() == null) {
jo.put("token", "");
} else {
jo.put("token", usuario.getToken());
}
jo.putOpt("result", ja);
} catch (JSONException e) {
e.printStackTrace();
}
response = Response.status(Status.OK).entity(jo).build();
return response;
}
@POST
@Path("/senha")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public Response alterarSenha(Usuario usuario){
int index = -1;
List<String> criticas = new ArrayList<String>();
JSONObject jo;
JSONArray ja = new JSONArray();
Response response = null;
if (usuario.getLogin() == null || usuario.getLogin().isEmpty()) {
index++;
criticas.add(index, "O usuário logado não foi informado");
}
if (usuario.getToken() == null || usuario.getToken().isEmpty()) {
index++;
criticas.add(index, "O token do usuário não foi informado");
}
if (usuario.getSenha() == null || usuario.getSenha().isEmpty()) {
index++;
criticas.add(index, "A nova senha não foi informada");
} else {
if (!bib.validaSenha(usuario.getSenha())) {
index++;
criticas.add(index, "A nova senha não é segura");
}
}
if (index < 0 ) {
this.mensagem = dao.validaSecao(
usuario.getLogin(), usuario.getToken());
if (!this.mensagem.isEmpty()) {
index++;
criticas.add(index, this.mensagem);
}
}
if (index < 0 ) {
try {
if (dao.IsUserPortal(usuario.getCodigo())) {
usuario.setSenha(bib.getCriptografia(usuario.getSenha()));
dao.alterarSenha(usuario);
} else {
index++;
criticas.add(index, "Usuário já existe no portal");
}
} catch (Exception e) {
index++;
criticas.add(index, e.getMessage());
dao.fechaTransac();
}
}
if (index >= 0 ) {
for (String s : criticas){
jo = new JSONObject();
try {
jo.put("erro", s);
ja.put(jo);
} catch (JSONException e) {
setMensagem(e.getMessage());
}
}
setMensagem("ERRO");
}
jo = new JSONObject();
try {
jo.put("mensagem", getMensagem());
jo.put("token", usuario.getToken());
jo.putOpt("result", ja);
} catch (JSONException e) {
e.printStackTrace();
}
response = Response.status(Status.OK).entity(jo).build();
return response;
}
//getters and setters
public String getMensagem() {
return mensagem;
}
public void setMensagem(String mensagem) {
this.mensagem = mensagem;
}
public String getErro() {
return erro;
}
public void setErro(String erro) {
this.erro = erro;
}
}
| ISO-8859-1 | Java | 19,279 | java | UsuarioWS.java | Java | [
{
"context": "ex < 0 ) {\n \ttry {\n \t\tString senha = usuario.getSenha();\n \t\tusuario = dao.getUsuario(us",
"end": 9770,
"score": 0.8653659820556641,
"start": 9763,
"tag": "PASSWORD",
"value": "usuario"
},
{
"context": "{\n \ttry {\n \t\tString ... | null | [] | package servico;
import java.util.ArrayList;
import java.util.List;
import javax.ws.rs.Consumes;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.Response.Status;
import modelo.Destinatario;
import modelo.Usuario;
import org.codehaus.jettison.json.JSONArray;
import org.codehaus.jettison.json.JSONException;
import org.codehaus.jettison.json.JSONObject;
import util.Biblioteca;
import dao.DestinatarioDao;
import dao.EmitenteDao;
import dao.FabricaDao;
import dao.UsuarioDao;
@Path("/usuario")
public class UsuarioWS {
private String mensagem;
private String erro;
private FabricaDao fd = new FabricaDao();
private UsuarioDao dao = fd.getUsuarioDao();
private Biblioteca bib = new Biblioteca();
@POST
@Path("/alterar")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public Response alterar(Usuario usuario){
int index = -1;
List<String> criticas = new ArrayList<String>();
JSONObject jo;
JSONArray ja = new JSONArray();
Response response = null;
if (usuario.getLogin() == null || usuario.getLogin().isEmpty()) {
index++;
criticas.add(index, "O usuário logado não foi informado ao WS");
}
if (usuario.getToken() == null || usuario.getToken().isEmpty()) {
index++;
criticas.add(index, "O token do usuário não foi informado ao WS");
}
if (usuario.getPerfil() == null || usuario.getPerfil().isEmpty()) {
index++;
criticas.add(index, "O campo Perfil é obrigatório");
}
if (index < 0 ) {
this.mensagem = dao.validaSecao(
usuario.getLogin(), usuario.getToken());
if (!this.mensagem.isEmpty()) {
index++;
criticas.add(index, this.mensagem);
}
}
if (index < 0 ) {
try {
String perfil = dao.getPeril(usuario.getCodigo());
if (perfil.isEmpty()) {
index++;
criticas.add(index, "Usuário não cadastrado no Portal");
} else {
if (usuario.getPerfil().trim().equals(perfil)) {
index++;
criticas.add(index, "Modifique antes de salvar");
} else {
dao.alterar(usuario);
}
}
} catch (Exception e) {
index++;
criticas.add(index, e.getMessage());
dao.fechaTransac();
}
}
if (index >= 0 ) {
for (String s : criticas){
jo = new JSONObject();
try {
jo.put("erro", s);
ja.put(jo);
} catch (JSONException e) {
setMensagem(e.getMessage());
}
}
setMensagem("ERRO");
}
jo = new JSONObject();
try {
jo.put("mensagem", getMensagem());
jo.put("token", usuario.getToken());
jo.putOpt("result", ja);
} catch (JSONException e) {
e.printStackTrace();
}
response = Response.status(Status.OK).entity(jo).build();
return response;
}
@POST
@Path("/cadastrar")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public Response cadastro(Usuario usuario){
int index = -1;
List<String> criticas = new ArrayList<String>();
JSONObject jo;
JSONArray ja = new JSONArray();
Response response = null;
boolean email = false;
String senha = "";
if (usuario.getLogin() == null || usuario.getLogin().isEmpty()) {
index++;
criticas.add(index, "O usuário logado não foi informado ao WS");
}
if (usuario.getToken() == null || usuario.getToken().isEmpty()) {
index++;
criticas.add(index, "O token do usuário não foi informado ao WS");
}
if (usuario.getCodigo() == null || usuario.getCodigo().isEmpty()) {
index++;
criticas.add(index, "O campo Usuário é obrigatório");
}
if (usuario.getPerfil() == null || usuario.getPerfil().isEmpty()) {
index++;
criticas.add(index, "O campo Perfil é obrigatório");
}
if (usuario.getSenha() == null || usuario.getSenha().isEmpty()) {
if (index < 0 ) {
usuario.setSenha(bib.geraSenha(usuario.getCodigo()));
}
} else {
if (!bib.validaSenha(usuario.getSenha())) {
index++;
criticas.add(index, "A senha informada não é segura");
}
}
senha = usuario.getSenha();
if (index < 0 ) {
this.mensagem = dao.validaSecao(
usuario.getLogin(), usuario.getToken());
if (!this.mensagem.isEmpty()) {
index++;
criticas.add(index, this.mensagem);
}
}
if (index < 0 ) {
try {
setMensagem(dao.getNome(usuario.getCodigo()));
if (this.mensagem.isEmpty()) {
index++;
criticas.add(index, "Usuário não cadastrado no Logix");
} else {
if (dao.IsUserPortal(usuario.getCodigo())) {
index++;
criticas.add(index, "Usuário já existe no portal");
} else {
usuario.setSenha(bib.getCriptografia(usuario.getSenha()));
dao.incluir(usuario);
email = true;
}
}
} catch (Exception e) {
index++;
criticas.add(index, e.getMessage());
dao.fechaTransac();
}
}
if (email) {
enviarEmail(usuario.getCodigo(), senha);
}
if (index >= 0 ) {
for (String s : criticas){
jo = new JSONObject();
try {
jo.put("erro", s);
ja.put(jo);
} catch (JSONException e) {
setMensagem(e.getMessage());
}
}
setMensagem("ERRO");
}
jo = new JSONObject();
try {
jo.put("mensagem", getMensagem());
jo.put("token", usuario.getToken());
jo.putOpt("result", ja);
} catch (JSONException e) {
e.printStackTrace();
}
response = Response.status(Status.OK).entity(jo).build();
return response;
}
private void enviarEmail(String codigo, String senha) {
modelo.Emitente emit = null;
EmitenteDao eDao = fd.getEmitenteDao();
Destinatario dest = new Destinatario();
DestinatarioDao dDao = fd.getDestinatarioDao();
try {
emit = eDao.getEmitente();
dest = dDao.getDestinatario(codigo);
} catch (Exception e) {
e.printStackTrace();
return;
}
if (emit == null || dest == null) {
return;
}
dest.setMensagem("A seguir, seus dados de login, para aprovação de documentos via APP:");
String corpo = "Login: " + codigo + " - Senha: " + senha + "\n\n";
corpo += "Para alterar sua senha, consulte o adimistrador do TI.";
dest.setCorpo(corpo);
new util.EnviaEmail().Enviar(emit, dest);
}
@POST
@Path("/excluir")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public Response excluir(Usuario usuario){
int index = -1;
List<String> criticas = new ArrayList<String>();
JSONObject jo;
JSONArray ja = new JSONArray();
Response response = null;
if (usuario.getLogin() == null || usuario.getLogin().isEmpty()) {
index++;
criticas.add(index, "O usuário logado não foi informado ao WS");
}
if (usuario.getToken() == null || usuario.getToken().isEmpty()) {
index++;
criticas.add(index, "O token do usuário não foi informado ao WS");
}
if (index < 0 ) {
this.mensagem = dao.validaSecao(
usuario.getLogin(), usuario.getToken());
if (!this.mensagem.isEmpty()) {
index++;
criticas.add(index, this.mensagem);
}
}
if (index < 0 ) {
try {
setMensagem(dao.getNome(usuario.getCodigo()));
if (this.mensagem.isEmpty()) {
index++;
criticas.add(index, "Usuário não cadastrado no Logix");
} else {
dao.excluir(usuario);
}
} catch (Exception e) {
index++;
criticas.add(index, e.getMessage());
dao.fechaTransac();
}
}
if (index >= 0 ) {
for (String s : criticas){
jo = new JSONObject();
try {
jo.put("erro", s);
ja.put(jo);
} catch (JSONException e) {
setMensagem(e.getMessage());
}
}
setMensagem("ERRO");
}
jo = new JSONObject();
try {
jo.put("mensagem", getMensagem());
jo.put("token", usuario.getToken());
jo.putOpt("result", ja);
} catch (JSONException e) {
e.printStackTrace();
}
response = Response.status(Status.OK).entity(jo).build();
return response;
}
@POST
@Path("/logar")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public Response getLogin(Usuario usuario){
int index = -1;
setMensagem("OK");
List<String> criticas = new ArrayList<String>();
JSONObject jo;
JSONArray ja = new JSONArray();
Response response = null;
String login = usuario.getLogin();
if (usuario.getLogin() == null || usuario.getLogin().isEmpty()) {
index++;
criticas.add(index, "Favor informar o código de login");
}
if (usuario.getSenha() == null || usuario.getSenha().isEmpty()) {
index++;
criticas.add(index, "Favor informar a senha");
}
if (index < 0 ) {
try {
String senha = <PASSWORD>.<PASSWORD>ha();
usuario = dao.getUsuario(usuario.getLogin());
if (usuario == null) {
index++;
criticas.add(index, "Usuário não existe no Logix");
usuario = new Usuario();
} else {
String criptografada = (
bib.getCriptografia(senha));
String gravada = usuario.getSenha().trim();
if (criptografada.equals(gravada)) {
usuario.setSenha("");
jo = new JSONObject();
jo.put("login", login);
jo.put("codigo", usuario.getCodigo());
jo.put("nome", usuario.getNome());
jo.put("perfil", usuario.getPerfil().trim());
ja.put(jo);
usuario.setToken(""+bib.geraToken());
setMensagem(dao.abreSecao(usuario, "logar"));
} else {
index++;
criticas.add(index, "A senha informada não é válida");
}
}
} catch (Exception e) {
index++;
criticas.add(index, e.getMessage());
}
}
if (index >= 0 ) {
for (String s : criticas){
jo = new JSONObject();
try {
jo.put("erro", s);
ja.put(jo);
} catch (JSONException e) {
setMensagem(e.getMessage());
}
}
setMensagem("ERRO");
}
jo = new JSONObject();
try {
jo.put("mensagem", getMensagem());
if (usuario.getToken() == null) {
jo.put("token", "");
} else {
jo.put("token", usuario.getToken());
}
jo.putOpt("result", ja);
} catch (JSONException e) {
e.printStackTrace();
}
response = Response.status(Status.OK).entity(jo).build();
return response;
}
@POST
@Path("/listar")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public Response getListaTudo(Usuario usuario){
int index = -1;
setMensagem("OK");
List<String> criticas = new ArrayList<String>();
List<Usuario> usuarios = null;
JSONObject jo;
JSONArray ja = new JSONArray();
Response response = null;
if (usuario.getToken() == null || usuario.getToken().isEmpty()) {
usuario.setToken("0");
}
if (usuario.getLogin() == null || usuario.getLogin().isEmpty()) {
index++;
criticas.add(index, "Favor informar o código do usuário");
} else {
this.mensagem = dao.validaSecao(
usuario.getLogin(), usuario.getToken());
if (!this.mensagem.isEmpty()) {
index++;
criticas.add(index, this.mensagem);
}
}
if (index < 0 ) {
if (usuario.getCodigo() == null) {
usuario.setCodigo("");
}
if (usuario.getNome() == null) {
usuario.setNome("");
}
if (usuario.getPerfil() == null) {
usuario.setPerfil("");
}
try {
usuarios = dao.getUsuarios(usuario);
if (usuarios.size() > 0) {
for (Usuario u : usuarios){
jo = new JSONObject();
jo.put("codigo", u.getCodigo());
jo.put("nome", u.getNome());
jo.put("perfil", u.getPerfil());
ja.put(jo);
}
} else {
index++;
criticas.add(index, "A pesquisa não encontrou usuários");
}
} catch (Exception e) {
}
}
if (index >= 0 ) {
for (String s : criticas){
jo = new JSONObject();
try {
jo.put("erro", s);
ja.put(jo);
} catch (JSONException e) {
setMensagem(e.getMessage());
}
}
setMensagem("ERRO");
}
jo = new JSONObject();
try {
jo.put("mensagem", getMensagem());
jo.put("token", usuario.getToken());
jo.putOpt("result", ja);
} catch (JSONException e) {
e.printStackTrace();
}
response = Response.status(Status.OK).entity(jo).build();
return response;
}
@POST
@Path("/validar")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public Response getAprovador(Usuario usuario){
int index = -1;
setMensagem("");
List<String> criticas = new ArrayList<String>();
List<Usuario> usuarios;
String data = bib.dataAtual("dd/MM/yyyy");
JSONObject jo;
JSONArray ja = new JSONArray();
Response response = null;
if (usuario.getCodigo().isEmpty()) {
index++;
criticas.add(index, "O código do usuário está nulo");
}
if (usuario.getSenha().isEmpty()) {
index++;
criticas.add(index, "A senha está nula");
}
if (index < 0 ) {
try {
if (!dao.IsUserPortal(usuario.getCodigo())) {
index++;
criticas.add(index, "Usuário não existe no portal");
} else {
String senha = (dao.getSenha(usuario.getCodigo())).trim();
String criptografada = (
bib.getCriptografia(usuario.getSenha()));
if (senha.equals(criptografada)) {
usuario.setEmpresa("01");
usuarios = dao.getAprovantes(usuario.getCodigo(),
usuario.getEmpresa(), data);
if (usuarios.size() > 0) {
for (Usuario u : usuarios){
jo = new JSONObject();
jo.put("codigo", u.getCodigo());
jo.put("nome", u.getNome());
ja.put(jo);
}
usuario.setToken(""+bib.geraToken());
setMensagem(dao.abreSecao(usuario, "validar"));
} else {
index++;
criticas.add(index, "Usuário não é aproante de documentos");
}
} else {
index++;
criticas.add(index, "A senha informada não é válida");
}
}
} catch (Exception e) {
index++;
criticas.add(index, e.getMessage());
}
}
if (index >= 0 ) {
for (String s : criticas){
jo = new JSONObject();
try {
jo.put("erro", s);
ja.put(jo);
} catch (JSONException e) {
setMensagem(e.getMessage());
}
}
setMensagem("ERRO");
}
jo = new JSONObject();
try {
jo.put("mensagem", getMensagem());
if (usuario.getToken() == null) {
jo.put("token", "");
} else {
jo.put("token", usuario.getToken());
}
jo.putOpt("result", ja);
} catch (JSONException e) {
e.printStackTrace();
}
response = Response.status(Status.OK).entity(jo).build();
return response;
}
@POST
@Path("/senha")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public Response alterarSenha(Usuario usuario){
int index = -1;
List<String> criticas = new ArrayList<String>();
JSONObject jo;
JSONArray ja = new JSONArray();
Response response = null;
if (usuario.getLogin() == null || usuario.getLogin().isEmpty()) {
index++;
criticas.add(index, "O usuário logado não foi informado");
}
if (usuario.getToken() == null || usuario.getToken().isEmpty()) {
index++;
criticas.add(index, "O token do usuário não foi informado");
}
if (usuario.getSenha() == null || usuario.getSenha().isEmpty()) {
index++;
criticas.add(index, "A nova senha não foi informada");
} else {
if (!bib.validaSenha(usuario.getSenha())) {
index++;
criticas.add(index, "A nova senha não é segura");
}
}
if (index < 0 ) {
this.mensagem = dao.validaSecao(
usuario.getLogin(), usuario.getToken());
if (!this.mensagem.isEmpty()) {
index++;
criticas.add(index, this.mensagem);
}
}
if (index < 0 ) {
try {
if (dao.IsUserPortal(usuario.getCodigo())) {
usuario.setSenha(bib.getCriptografia(usuario.getSenha()));
dao.alterarSenha(usuario);
} else {
index++;
criticas.add(index, "Usuário já existe no portal");
}
} catch (Exception e) {
index++;
criticas.add(index, e.getMessage());
dao.fechaTransac();
}
}
if (index >= 0 ) {
for (String s : criticas){
jo = new JSONObject();
try {
jo.put("erro", s);
ja.put(jo);
} catch (JSONException e) {
setMensagem(e.getMessage());
}
}
setMensagem("ERRO");
}
jo = new JSONObject();
try {
jo.put("mensagem", getMensagem());
jo.put("token", usuario.getToken());
jo.putOpt("result", ja);
} catch (JSONException e) {
e.printStackTrace();
}
response = Response.status(Status.OK).entity(jo).build();
return response;
}
//getters and setters
public String getMensagem() {
return mensagem;
}
public void setMensagem(String mensagem) {
this.mensagem = mensagem;
}
public String getErro() {
return erro;
}
public void setErro(String erro) {
this.erro = erro;
}
}
| 19,286 | 0.526149 | 0.524536 | 719 | 25.7274 | 20.060568 | 91 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 2.371349 | false | false | 9 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.