blob_id
stringlengths 40
40
| directory_id
stringlengths 40
40
| path
stringlengths 4
410
| content_id
stringlengths 40
40
| detected_licenses
sequencelengths 0
51
| license_type
stringclasses 2
values | repo_name
stringlengths 5
132
| snapshot_id
stringlengths 40
40
| revision_id
stringlengths 40
40
| branch_name
stringlengths 4
80
| visit_date
timestamp[us] | revision_date
timestamp[us] | committer_date
timestamp[us] | github_id
int64 5.85k
689M
⌀ | star_events_count
int64 0
209k
| fork_events_count
int64 0
110k
| gha_license_id
stringclasses 22
values | gha_event_created_at
timestamp[us] | gha_created_at
timestamp[us] | gha_language
stringclasses 131
values | src_encoding
stringclasses 34
values | language
stringclasses 1
value | is_vendor
bool 1
class | is_generated
bool 2
classes | length_bytes
int64 3
9.45M
| extension
stringclasses 32
values | content
stringlengths 3
9.45M
| authors
sequencelengths 1
1
| author_id
stringlengths 0
313
|
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
19cfac32622cebd8e930723bf93c9cacefe4fa7a | 88407296e0dff332d33d82b3e2f8a2aca19e2489 | /00_algorithm/algo_basic/src/rhtn_homework/BOJ_1600_말이되고픈원숭이.java | cfee8ab66bcb7057660a18435bc32307c0e62ebc | [] | no_license | Kwon-Nam-Boo/algorithm | 1ee50de85084503bfea1d3f30ca2dac7094738f5 | 834ea72faf61b7b2f90ac1891bca2e8ef2e16f01 | refs/heads/master | 2023-05-08T14:07:10.009952 | 2021-06-05T07:25:32 | 2021-06-05T07:25:32 | 296,360,983 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,659 | java | package rhtn_homework;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.LinkedList;
import java.util.Queue;
import java.util.StringTokenizer;
public class BOJ_1600_말이되고픈원숭이 {
private static StringBuilder sb = new StringBuilder();
private static int K; // K:말처럼 뛸수 있는 횟수
private static int W,H; // 가로, 세로
private static int[][] map;
private static boolean[][][] visited;
private static int[][] dir_H = {{-2,-1},{-2,1},{-1,2},{1,2},{2,1},{2,-1},{1,-2},{-1,-2}}; // 말의 이동 경우
private static int[][] dir_M = {{-1,0},{1,0},{0,-1},{0,1}}; // 원숭이 이동 경우
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
StringTokenizer st;
K =Integer.parseInt(br.readLine());
st = new StringTokenizer(br.readLine());
W = Integer.parseInt(st.nextToken());
H =Integer.parseInt(st.nextToken());
map = new int[H][W];
for (int r = 0; r < H; r++) {
st = new StringTokenizer(br.readLine());
for (int c = 0; c < W; c++) {
map[r][c] = Integer.parseInt(st.nextToken());
}
}
visited = new boolean[H][W][K+1]; // 3차원 방문처리
bfs(0,0,K,0);
System.out.println(sb);
}
private static void bfs(int x, int y,int k,int cnt) {
Queue<Pair> queue = new LinkedList<>();
queue.offer(new Pair(x,y,k,cnt));
visited[x][y][k] = true;
while(!queue.isEmpty()) {
Pair p = queue.poll();
if(p.x == H-1 && p.y == W-1) { // 해당 위치 도착 cnt 출력
sb.append(p.cnt);
return;
}
for (int i = 0; i < dir_M.length; i++) { // Monkey처럼 뛰기
int mx = dir_M[i][0] + p.x;
int my = dir_M[i][1] + p.y;
if(isIn(mx,my) && map[mx][my]!=1 && !visited[mx][my][p.k]) {
queue.offer(new Pair(mx,my,p.k,p.cnt+1));
visited[mx][my][p.k] =true;
}
}
if(p.k!=0) { // k가 남아있다면 Horse 처럼 뛰기
for (int i = 0; i < dir_H.length; i++) {
int hx = dir_H[i][0] + p.x;
int hy = dir_H[i][1] + p.y;
if(isIn(hx,hy) && map[hx][hy]!=1 && !visited[hx][hy][p.k-1]) {
queue.offer(new Pair(hx,hy,p.k-1,p.cnt+1));
visited[hx][hy][p.k-1] =true;
}
}
}
}
sb.append(-1); // 아예 도착 못함 -1 리턴
return;
}
private static class Pair{
int x,y,k,cnt; // cnt: 뛴 횟수
public Pair(int x, int y, int k, int cnt) {
super();
this.x = x;
this.y = y;
this.k = k;
this.cnt = cnt;
}
}
private static boolean isIn(int r,int c) {
return r>=0 && c>=0 && r<H && c<W;
}
}
| [
"[email protected]"
] | |
ea3c15c9d53f370c41429c275b0cf0e295d16fd0 | aca5a5b0322328ef479b7d375ab6bb990e9f7574 | /jdk1.8.0_66_src/src/org/omg/PortableServer/REQUEST_PROCESSING_POLICY_ID.java | 92ee6420a30b95e2b3fb1689105e163aede1f55f | [
"Apache-2.0"
] | permissive | codecly259/read-source | 8970b37614294622b9d09b78f0b1fba3bfef97c1 | 84f31d4b1f86e8fee3c2a161251e7ccecd4ac223 | refs/heads/master | 2021-01-21T12:52:52.762373 | 2016-04-08T14:47:54 | 2016-04-08T14:47:54 | 53,556,248 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 499 | java | package org.omg.PortableServer;
/**
* org/omg/PortableServer/REQUEST_PROCESSING_POLICY_ID.java .
* Generated by the IDL-to-Java compiler (portable), version "3.2"
* from c:/re/workspace/8-2-build-windows-amd64-cygwin/jdk8u66/5298/corba/src/share/classes/org/omg/PortableServer/poa.idl
* Monday, November 9, 2015 10:52:06 AM PST
*/
public interface REQUEST_PROCESSING_POLICY_ID
{
/**
* The value representing REQUEST_PROCESSING_POLICY_ID.
*/
public static final int value = (int)(22L);
}
| [
"[email protected]"
] | |
488bb233963407e31c9e43d604caa18066b72b4b | 459d0fdc9b9e47070e6816e3df3ea36f2ff17669 | /src/worldjam/time/ClockSettingChange.java | 39fa1c5ceb32ab42a07b908f5093491d8202eed8 | [] | no_license | sebouh137/WorldJam | 9974f187d96004f09a963c7c130b49ffa9f8230a | b6460f78771583f6c23ff393e9e95e91e4630022 | refs/heads/master | 2021-12-24T14:37:49.672727 | 2021-12-17T02:24:52 | 2021-12-17T02:24:52 | 138,897,246 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 130 | java | package worldjam.time;
public class ClockSettingChange {
ClockSetting newSetting;
ClockSetting prevSetting;
long effective;
}
| [
"[email protected]"
] | |
589021ee9fee1fd42a46af00f512b4e06c27404b | 06a4d9e92548237c2f8cc6548ff68d417be5e5ce | /DESIGNPATTERNS/FACTORYMETHODPATTERN/src/Bakery.java | 84005089f201824ecdc80b6f57149ff5a3d23e5a | [] | no_license | ucsp09/UCSPRATHYUSH_DESIGNPATTERNS | 5b27f22716673c613912e59602c1686ad28da40d | 3a8d18f60af81303a53cd38311222bc71b0cc57a | refs/heads/master | 2022-11-17T21:50:31.261470 | 2020-07-14T13:49:02 | 2020-07-14T13:49:02 | 279,538,974 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 415 | java | package FACTORYMETHODPATTERN.src;
public class Bakery {
public Cake makeCake(String cakeType)
{
if(cakeType.equals("Chocolate"))
{
Cake cake=new ChocolateCake();
return cake;
}
else if(cakeType.equals("Strawberry"))
{
Cake cake=new StrawberryCake();
return cake;
}
else
return null;
}
} | [
"[email protected]"
] | |
755e61fcab43f4c4b82ac003719d85805bd9a2c3 | 6ef1e6020f67e52972f8091b42625308aa278a9f | /app/src/main/java/com/WordInTouch/UI/DialogSpinner.java | 9ebcc9540835b47676dd8bcb12103363aa82f019 | [] | no_license | RepoZero/WordInTouch | 8f9a5248f33ad9b9366f82f722532e760b6136c7 | 73ef85883ec5656ae1ce1c11ab05dc1f088a7078 | refs/heads/master | 2021-04-27T03:27:45.658015 | 2018-02-24T07:16:53 | 2018-02-24T07:16:53 | 121,666,658 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 5,963 | java | package com.WordInTouch.UI;
import android.content.Context;
import android.database.Cursor;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.support.v7.widget.Toolbar;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.widget.AdapterView;
import android.widget.BaseAdapter;
import android.widget.Spinner;
import android.widget.TextView;
import android.widget.Toast;
import com.WordInTouch.R;
import java.util.ArrayList;
import butterknife.BindView;
import butterknife.ButterKnife;
import static com.WordInTouch.Application.db;
import static com.WordInTouch.Application.texts;
import static com.WordInTouch.Application.type_parametrs;
public class DialogSpinner extends AppCompatActivity {
ArrayList<Integer> category_id = new ArrayList<Integer>();
ArrayList<String> category = new ArrayList<String>();
ArrayList<Integer> sub_category_id = new ArrayList<Integer>();
ArrayList<String> sub_category = new ArrayList<String>();
@BindView(R.id.dialog_spinner_spn1) Spinner spn1;
@BindView(R.id.dialog_spinner_spn2) Spinner spn2;
private int op;
private int index=-1;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
supportRequestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.activity_dialog_spinner);
ButterKnife.bind(this);
getCategorySpn();
spn1.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
getSubCategorySpn(category_id.get(position));
}
@Override
public void onNothingSelected(AdapterView<?> parent) {
}
});
Bundle extras = getIntent().getExtras();
if (extras != null) {
op = extras.getInt("op_code");
if(op==1){
}
index = extras.getInt("index_edit");
}
Toolbar toolbar = (Toolbar) findViewById(R.id.dialog_spinner_toolbar);
toolbar.setTitle(this.getResources().getString(R.string.Category));
toolbar.inflateMenu(R.menu.apply_title_menu);
toolbar.setOnMenuItemClickListener(new Toolbar.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
// Handle the menu item
if(item.getItemId()==R.id.action_apply){
int selected_item = spn2.getSelectedItemPosition();
if(op==0) {
type_parametrs.add('c');
texts.add(sub_category_id.get(selected_item).toString());
finish();
}else if(op==1){
texts.set(index,sub_category_id.get(selected_item).toString());
finish();
}
}
return true;
}
});
}
public void getCategorySpn(){
String select_query_category = "SELECT * FROM category WHERE parent_id=0 ";
Cursor cursor_category = db.rawQuery(select_query_category, null);
if (cursor_category != null && cursor_category.getCount() > 0) {
if (cursor_category.moveToFirst()) {
do {
category_id.add(cursor_category.getInt(cursor_category.getColumnIndex("id")));
category.add(cursor_category.getString(cursor_category.getColumnIndex("text")));
} while (cursor_category.moveToNext());
}
cursor_category.close();
}
spnAdapter spnAdapterType = new spnAdapter(this,category);
spn1.setAdapter(spnAdapterType);
}
public void getSubCategorySpn(int id){
sub_category_id.clear();
sub_category.clear();
String select_query_sub_category = "SELECT * FROM category WHERE parent_id="+id;
Cursor cursor_sub_category = db.rawQuery(select_query_sub_category, null);
if (cursor_sub_category != null && cursor_sub_category.getCount() > 0) {
if (cursor_sub_category.moveToFirst()) {
do {
sub_category_id.add(cursor_sub_category.getInt(cursor_sub_category.getColumnIndex("id")));
sub_category.add(cursor_sub_category.getString(cursor_sub_category.getColumnIndex("text")));
} while (cursor_sub_category.moveToNext());
}
cursor_sub_category.close();
}
spnAdapter spnAdapter = new spnAdapter(this,sub_category);
spn2.setAdapter(spnAdapter);
}
private class spnAdapter extends BaseAdapter {
Context context;
private ArrayList<String> type = new ArrayList<String>();
public spnAdapter(Context context , ArrayList<String> type){
this.context=context;
this.type=type;
}
@Override
public int getCount() {
return type.size();
}
@Override
public Object getItem(int position) {
return type.get(position);
}
@Override
public long getItemId(int position) {
return position;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
if(convertView==null){
convertView = LayoutInflater.from(context).inflate(R.layout.item_spn,parent,false);
}
TextView txt = (TextView) convertView.findViewById(R.id.item_txt_spn);
txt.setText(type.get(position));
return convertView;
}
}
}
| [
"[email protected]"
] | |
779b40d2030d74f954277b2650f1917f079b14bd | bda7c94f567ec25cba52c1b6d2a946d6bbeaf808 | /Modul01/DataTypes.java | edf6e073f07fa5ac94ff57d63f3906c7479cfd9d | [] | no_license | rahmatulaina/PraktikumJavaa01 | 035875179e6d284c4ca6266830b94c8bf3dcfdf5 | b6745cd9fdbacd5d2bfb2a865e80fe01bbd8e5ac | refs/heads/master | 2022-06-29T13:56:19.741280 | 2020-05-08T09:25:20 | 2020-05-08T09:25:20 | 258,449,239 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,233 | java | import javax.swing.JOptionPane;
import java.util.scanner;
public class DataTypes{
public static void main (String [] args){
Scanner scanner = new Scanner(System.in);
String namaDepan = "Rahmatul";
String namaBelakang = "Aina";
int usia = 18;
int targetTahunKuliah = 4;
double ipk = 3.89764512;
char nilaiAbjad = 'A';
boolean cantik = true;
System.out.print("Input Nama Depan : ");
namaDepan = scanner.nextLine();
System.out.print("Input Usia : ");
usia = scanner.nextInt();
System.out.print("Input IPK : ");
ipk = scanner.nextDouble();
System.out.print("");
System.out.print("Input Nilai Abjad : ");
nilaiAbjad = scanner.next().charAt(0);
System.out.print("Cantik? : ");
cantik = scanner.nextBoolean();
System.out.println("===========OUTPUT=========");
System.out.println("Nama depan : " + namaDepan);
System.out.println("Nama belakang : " + namaBelakang);
System.out.println("Usia : " + usia);
System.out.println("Target Kuliah : " + targetTahunKuliah + " tahun");
System.out.println("IPK : " + ipk);
System.out.println("Nilai PBO : " + nilaiAbjad);
System.out.println("Cantik : " + cantik);
JOptionPane.showMessageDialog(null,"Hai, " + namaDepan + namaBelakang);
}
} | [
"[email protected]"
] | |
a83b9859eb150a00389eee4f549e43e27b772f34 | d6683e977520a16260aaca42c68463e9db11d86f | /a6-design-pattern-23/src/create/builder/hello1/model/Floor.java | ed0de0860b31127dc4687aea793e40ea33a04f32 | [] | no_license | saysky/java-basic | 82217be9d48e111b4a67504adbd9be9d95345b77 | 036d6b81aea7edb72050b563108b6cf11da21dd2 | refs/heads/master | 2022-12-14T11:53:21.585932 | 2020-09-12T09:41:19 | 2020-09-12T09:41:19 | 294,902,537 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 62 | java | package create.builder.hello1.model;
public class Floor {
}
| [
"[email protected]"
] | |
d1ad28a1f387716c8cd6490fc3737f59d18c5788 | fb70e6d16baecf886869e14eb439fe334954b39e | /Lezerkardosjdk/java/org/omg/PortableInterceptor/IORInterceptor_3_0Helper.java | e28a9c2cf25ad3bfc36617d06c51bc7cdd194118 | [] | no_license | Savitar97/Prog2 | ae5dfc46c8fc61974e4c2ddb59ce9e23ab955d23 | 8bc2c19240862218b1b06c4b5abe9081747a54c0 | refs/heads/master | 2020-07-25T00:16:11.948303 | 2020-02-29T23:49:42 | 2020-02-29T23:49:42 | 208,092,693 | 0 | 2 | null | null | null | null | UTF-8 | Java | false | false | 2,341 | java | package org.omg.PortableInterceptor;
/**
* org/omg/PortableInterceptor/IORInterceptor_3_0Helper.java .
* Generated by the IDL-to-Java compiler (portable), version "3.2"
* from /build/openjdk-8-mHow25/openjdk-8-8u222-b10/src/corba/src/share/classes/org/omg/PortableInterceptor/Interceptors.idl
* Thursday, July 18, 2019 8:54:35 PM UTC
*/
abstract public class IORInterceptor_3_0Helper
{
private static String _id = "IDL:omg.org/PortableInterceptor/IORInterceptor_3_0:1.0";
public static void insert (org.omg.CORBA.Any a, org.omg.PortableInterceptor.IORInterceptor_3_0 that)
{
org.omg.CORBA.portable.OutputStream out = a.create_output_stream ();
a.type (type ());
write (out, that);
a.read_value (out.create_input_stream (), type ());
}
public static org.omg.PortableInterceptor.IORInterceptor_3_0 extract (org.omg.CORBA.Any a)
{
return read (a.create_input_stream ());
}
private static org.omg.CORBA.TypeCode __typeCode = null;
synchronized public static org.omg.CORBA.TypeCode type ()
{
if (__typeCode == null)
{
__typeCode = org.omg.CORBA.ORB.init ().create_interface_tc (org.omg.PortableInterceptor.IORInterceptor_3_0Helper.id (), "IORInterceptor_3_0");
}
return __typeCode;
}
public static String id ()
{
return _id;
}
public static org.omg.PortableInterceptor.IORInterceptor_3_0 read (org.omg.CORBA.portable.InputStream istream)
{
throw new org.omg.CORBA.MARSHAL ();
}
public static void write (org.omg.CORBA.portable.OutputStream ostream, org.omg.PortableInterceptor.IORInterceptor_3_0 value)
{
throw new org.omg.CORBA.MARSHAL ();
}
public static org.omg.PortableInterceptor.IORInterceptor_3_0 narrow (org.omg.CORBA.Object obj)
{
if (obj == null)
return null;
else if (obj instanceof org.omg.PortableInterceptor.IORInterceptor_3_0)
return (org.omg.PortableInterceptor.IORInterceptor_3_0)obj;
else
throw new org.omg.CORBA.BAD_PARAM ();
}
public static org.omg.PortableInterceptor.IORInterceptor_3_0 unchecked_narrow (org.omg.CORBA.Object obj)
{
if (obj == null)
return null;
else if (obj instanceof org.omg.PortableInterceptor.IORInterceptor_3_0)
return (org.omg.PortableInterceptor.IORInterceptor_3_0)obj;
else
throw new org.omg.CORBA.BAD_PARAM ();
}
}
| [
"[email protected]"
] | |
cf5fbe431cee2eb693908940051754429280f52f | bbc4dce909498c4594be32f1c47ec02c96fee2ed | /ex02/src/main/java/org/zerock/persistence/ReplyDAOImpl.java | 6d4891a2bb9fd127d4be502cf8496e58857668a6 | [] | no_license | dodo95123/gugu | ec65f1b9ccb52bf0523349f0f31994184ab1a3a3 | 8703853aa4bc4b6028748759fd7958f16430a4fa | refs/heads/master | 2020-03-10T12:14:14.054447 | 2019-05-21T08:33:25 | 2019-05-21T08:33:25 | 129,372,827 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,531 | java | package org.zerock.persistence;
import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.log;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.inject.Inject;
import javax.xml.stream.events.Namespace;
import org.apache.ibatis.session.SqlSession;
import org.springframework.stereotype.Repository;
import org.zerock.domain.Criteria;
import org.zerock.domain.ReplyVO;
@Repository
public class ReplyDAOImpl implements ReplyDAO{
@Inject
private SqlSession session;
private static String namespace = "org.zerock.mapper.ReplyMapper";
@Override
public List<ReplyVO> list(Integer bno) throws Exception {
return session.selectList(namespace + ".list", bno);
}
@Override
public List<ReplyVO> listPage(Integer bno, Criteria cri) throws Exception {
Map<String, Object> paramMap = new HashMap<>();
paramMap.put("bno", bno);
paramMap.put("cri", cri);
return session.selectList(namespace + ".listPage", paramMap);
}
@Override
public void create(ReplyVO vo) throws Exception {
session.insert(namespace+".create", vo);
}
@Override
public void update(ReplyVO vo) throws Exception {
session.update(namespace+".update",vo);
}
@Override
public void delete(Integer rno) throws Exception {
session.delete(namespace+".delete", rno);
}
@Override
public int count(Integer bno) throws Exception {
return session.selectOne(namespace+".count", bno);
}
}
| [
"SIST184@SIST-184"
] | SIST184@SIST-184 |
21993ea2a54ad2c9dd26e2d006a691ab42ca8ba7 | c06f76c0e82d4cf1ce1d9b8d2f15209f47a1aa4a | /src/utils/MathOperation.java | 6c120984ab54daf59cfafe0a515d333ff4898ed1 | [] | no_license | Dryunkaaa/Calculator | 53afcfba661d78bcf16237eed82b02b0d1b47c26 | 3d165c2ea52998e67b379c8ffff60d6639ce5a68 | refs/heads/master | 2020-12-18T15:46:42.932346 | 2020-01-21T21:44:48 | 2020-01-21T21:44:48 | 235,444,438 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 91 | java | package utils;
public interface MathOperation {
float calculate(float a, float b);
}
| [
"[email protected]"
] | |
bbfadb5440e719765931e19d4918b3bdbf64c8d7 | 8a7c933847b996a0aa0cb0919ba0a3ec3ccc294d | /actions/pageObjects/facebook/PORegisterManageGenerator.java | 0f4c23315d8ce916e6d2681b459e49e4346af854 | [] | no_license | vnguyenhuy/Hybrid-famework-bankguru | 9e3e2e0deca12cf37568e949b1bdf73b81c20eb6 | 1e682f9cca3e4bb04b9ad1b0cf82611e2d14ecdc | refs/heads/master | 2023-06-15T10:11:42.505790 | 2021-07-16T13:44:33 | 2021-07-16T13:44:33 | 380,194,445 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 382 | java | package pageObjects.facebook;
import org.openqa.selenium.WebDriver;
public class PORegisterManageGenerator {
private static RegisterPO registerPage;
public static RegisterPO getRegisterPO(WebDriver driver) {
if(registerPage == null || !registerPage.getDriver().equals(driver)) {
registerPage = new RegisterPO(driver);
}
return registerPage;
}
}
| [
"[email protected]"
] | |
565f501ac17d316b3f023db1dadfc265b946f8ca | 7625f5335f43a13a065555ab7368951e0619b948 | /EX4/FOLDER_2_SRC/TokenNames.java | be62a54bdec3309347b4105b5a251c9891c16376 | [] | no_license | Itayventura/COMPILATION | 66b894800e25651c99e48990aaf73d85446e518d | 12a335bceaef18d3aa0d59714b48dff40002670b | refs/heads/master | 2022-04-10T14:23:34.882582 | 2020-03-03T18:44:51 | 2020-03-03T18:44:51 | 220,198,760 | 0 | 1 | null | null | null | null | UTF-8 | Java | false | false | 1,898 | java |
//----------------------------------------------------
// The following code was generated by CUP v0.11b 20160615 (GIT 4ac7450)
//----------------------------------------------------
/** CUP generated class containing symbol constants. */
public class TokenNames {
/* terminals */
public static final int TIMES = 7;
public static final int RBRACK = 13;
public static final int LT = 18;
public static final int CLASS = 19;
public static final int SEMICOLON = 16;
public static final int PLUS = 5;
public static final int INT = 29;
public static final int RBRACE = 15;
public static final int RPAREN = 11;
public static final int WHILE = 8;
public static final int LBRACK = 12;
public static final int RETURN = 27;
public static final int ERROR = 20;
public static final int IF = 2;
public static final int GT = 24;
public static final int NIL = 21;
public static final int LPAREN = 10;
public static final int LBRACE = 14;
public static final int ID = 30;
public static final int STRING = 31;
public static final int COMMA = 22;
public static final int EOF = 0;
public static final int DIVIDE = 9;
public static final int ELLIPSIS = 23;
public static final int MINUS = 6;
public static final int error = 1;
public static final int DOT = 4;
public static final int ASSIGN = 17;
public static final int EQ = 3;
public static final int NEW = 28;
public static final int EXTENDS = 26;
public static final int ARRAY = 25;
public static final String[] terminalNames = new String[] {
"EOF",
"error",
"IF",
"EQ",
"DOT",
"PLUS",
"MINUS",
"TIMES",
"WHILE",
"DIVIDE",
"LPAREN",
"RPAREN",
"LBRACK",
"RBRACK",
"LBRACE",
"RBRACE",
"SEMICOLON",
"ASSIGN",
"LT",
"CLASS",
"ERROR",
"NIL",
"COMMA",
"ELLIPSIS",
"GT",
"ARRAY",
"EXTENDS",
"RETURN",
"NEW",
"INT",
"ID",
"STRING"
};
}
| [
"[email protected]"
] | |
ea2cfcff865a39319ada21bce4c6fe7020a039da | cdd1deb456c263d817972cd4af958ce2d666a922 | /app/src/main/java/com/example/nisch100/call_a_bus/AlarmNotificationReceiver.java | 4d9d18eb366391ba5a1d6f71951c6487a63b1e43 | [] | no_license | knagpal97/CallABus | 358275e95f6cb1cc175fce93632f384f864c4ffe | 58d9fa1b47146f4dd37c3034f62c1b0b012ae763 | refs/heads/master | 2020-09-09T06:18:43.132764 | 2018-12-04T03:11:27 | 2018-12-04T03:11:27 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 4,834 | java | package com.example.nisch100.call_a_bus;
import android.Manifest;
import android.app.Notification;
import android.app.NotificationChannel;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.BroadcastReceiver;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.ServiceConnection;
import android.content.pm.PackageManager;
import android.graphics.Color;
import android.media.AudioAttributes;
import android.net.Uri;
import android.os.Build;
import android.os.IBinder;
import android.os.Vibrator;
import android.support.v4.app.ActivityCompat;
import android.support.v4.app.NotificationCompat;
import android.support.v4.content.ContextCompat;
import android.telephony.SmsManager;
import android.util.Log;
import android.widget.Toast;
import java.text.DateFormat;
import java.util.Calendar;
import java.util.Date;
public class AlarmNotificationReceiver extends BroadcastReceiver {
public static final String channelID = "mychannel";
@Override
public void onReceive(Context context, Intent intent) {
createNotificationChannel(context, intent);
SmsManager smsManager = SmsManager.getDefault();
Log.i("here", "" + intent.getExtras().keySet().size());
if (intent.getExtras().getString("rel1") != null) {
if (!intent.getExtras().getString("time").equals("0")) {
smsManager.sendTextMessage(intent.getExtras().getString("rel1"), null, "My bus from " + intent.getExtras().getString("pickup") + " to " + intent.getExtras().getString("dropoff") + " leaves in " + intent.getExtras().getString("time") + " minutes.", null, null);
}
else {
smsManager.sendTextMessage(intent.getExtras().getString("rel1"), null, "My bus from " + intent.getExtras().getString("pickup") + " to " + intent.getExtras().getString("dropoff") + " has arrived.", null, null);
}
}
if (intent.getExtras().getString("rel2") != null) {
if (!intent.getExtras().getString("time").equals("0")) {
smsManager.sendTextMessage(intent.getExtras().getString("rel2"), null, "My bus from " + intent.getExtras().getString("pickup") + " to " + intent.getExtras().getString("dropoff") + " leaves in " + intent.getExtras().getString("time") + " minutes.", null, null);
}
else {
smsManager.sendTextMessage(intent.getExtras().getString("rel2"), null, "My bus from " + intent.getExtras().getString("pickup") + " to " + intent.getExtras().getString("dropoff") + " has arrived.", null, null);
}
}
if (intent.getExtras().getString("rel3") != null) {
if (!intent.getExtras().getString("time").equals("0")) {
smsManager.sendTextMessage(intent.getExtras().getString("rel3"), null, "My bus from " + intent.getExtras().getString("pickup") + " to " + intent.getExtras().getString("dropoff") + " leaves in " + intent.getExtras().getString("time") + " minutes.", null, null);
}
else {
smsManager.sendTextMessage(intent.getExtras().getString("rel3"), null, "My bus from " + intent.getExtras().getString("pickup") + " to " + intent.getExtras().getString("dropoff") + " has arrived.", null, null);
}
}
}
public void createNotificationChannel(Context context, Intent intent) {
try {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
NotificationChannel n = new NotificationChannel(channelID, "Departure soon", NotificationManager.IMPORTANCE_HIGH);
n.setDescription("departure reminder");
NotificationManager nm = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
nm.createNotificationChannel(n);
Notification.Builder nb = new Notification.Builder(context, channelID);
if (!intent.getExtras().getString("time").equals("0")) {
nb.setContentText("Your bus from " + intent.getExtras().getString("pickup") + " to " + intent.getExtras().getString("dropoff") + " leaves in " + intent.getExtras().getString("time") + " minutes.");
}
else {
nb.setContentText("Your bus from " + intent.getExtras().getString("pickup") + " to " + intent.getExtras().getString("dropoff") + " has arrived.");
}
nb.setContentTitle("CallABus");
nb.setAutoCancel(true);
nb.setSmallIcon(R.drawable.ic_launcher_background);
nm.notify(1, nb.build());
}
} catch(Exception e) {
Toast.makeText(context, e.getMessage(), Toast.LENGTH_LONG).show();
}
}
}
| [
"[email protected]"
] | |
8587d8c2b4c666064c7545a4d405d554110409c2 | 9bc442aa6d126927bb169a6faf4595ab0d399291 | /src/main/java/com/appliance/auth/ApplianceAuthServerApplication.java | 4c2f63f163e43c442e55bfce6421f73f5a11d098 | [] | no_license | codingexam/appliance-auth-server | 0013ba03dda098aea166d702d0b9ac64395d15ce | 614045846eda44d2135e5a332c4fe4b8989c0240 | refs/heads/master | 2023-09-05T08:53:12.512090 | 2021-10-20T04:29:32 | 2021-10-20T04:29:32 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 337 | java | package com.appliance.auth;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class ApplianceAuthServerApplication {
public static void main(String[] args) {
SpringApplication.run(ApplianceAuthServerApplication.class, args);
}
}
| [
"[email protected]"
] | |
7af22caad6cf70c61243085efd407fa27ac15526 | 56fc4669bf59f34dd8a96ba0c128ee7072efec48 | /src/integration/java/org/springframework/data/tarantool/integration/repository/query/CartridgeReactiveTarantoolPartTreeTest.java | 9064e1c6d10e3449bc8857de63b51cffce6d4d65 | [
"Apache-2.0"
] | permissive | selevinia/spring-data-tarantool | b8628146bbb6b7d86e2e5965d9702c5733f35d1f | edadd70e6b98bb8a4612f7c017c0cdb58be02143 | refs/heads/main | 2023-08-14T01:01:54.582671 | 2021-09-22T08:29:01 | 2021-09-22T08:29:01 | 390,988,426 | 0 | 0 | Apache-2.0 | 2021-09-02T08:07:51 | 2021-07-30T08:23:09 | Java | UTF-8 | Java | false | false | 2,518 | java | package org.springframework.data.tarantool.integration.repository.query;
import org.junit.jupiter.api.Test;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.FilterType;
import org.springframework.data.tarantool.config.AbstractReactiveTarantoolConfiguration;
import org.springframework.data.tarantool.config.client.TarantoolClientOptions;
import org.springframework.data.tarantool.integration.config.CartridgeTarantoolClientOptions;
import org.springframework.data.tarantool.integration.core.convert.LocaleToStringConverter;
import org.springframework.data.tarantool.integration.core.convert.StringToLocaleConverter;
import org.springframework.data.tarantool.integration.repository.query.AbstractReactiveTarantoolPartTreeQueryTest;
import org.springframework.data.tarantool.repository.config.EnableReactiveTarantoolRepositories;
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
import reactor.test.StepVerifier;
import java.util.List;
/**
* Runner class for reactive repository tests for standard cartridge Tarantool installation.
* To run test cartridge using Docker, file docker-compose.cartridge.yml may be used.
* To initialize cartridge after first run get terminal to tarantool-router-1 container and run /opt/integration-app/cluster-up.sh
*/
@SpringJUnitConfig
public class CartridgeReactiveTarantoolPartTreeTest extends AbstractReactiveTarantoolPartTreeQueryTest {
@Configuration
@EnableReactiveTarantoolRepositories(basePackages = "org.springframework.data.tarantool.integration.repository",
considerNestedRepositories = true,
includeFilters = {
@ComponentScan.Filter(pattern = ".*UserRepository", type = FilterType.REGEX)
})
static class Config extends AbstractReactiveTarantoolConfiguration {
@Bean
@Override
public TarantoolClientOptions tarantoolClientOptions() {
return new CartridgeTarantoolClientOptions();
}
@Override
protected List<?> customConverters() {
return List.of(new LocaleToStringConverter(), new StringToLocaleConverter());
}
}
@Test
void shouldFindAllByAgeBetween() {
userRepository.findAllByAgeBetween(20, 23).as(StepVerifier::create)
.expectNextCount(5)
.verifyComplete();
}
}
| [
"[email protected]"
] | |
426573386968cf3741e69d27c8ceaa48f94d6cc0 | 966e468acfd8cceaaf37c43094ae5abb09864c25 | /app/src/main/java/com/example/mob204_ps08611/MainActivity.java | baab2414ddda31c6ad17787c0bfda4d906dd7726 | [] | no_license | minhnc0208/MOB204_PS08611_Assignment | 52a3b232f760ea30facf155ad94ea842c4037893 | 64f7f358784edc6b39ccb7be0b8f32e21d1d9cdf | refs/heads/master | 2022-02-21T02:02:35.715686 | 2019-09-25T08:45:50 | 2019-09-25T08:45:50 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,852 | java | package com.example.mob204_ps08611;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.EditText;
import android.widget.Toast;
import androidx.appcompat.app.AppCompatActivity;
import com.example.dell.book.R;
import com.example.mob204_ps08611.book.dao.NguoiDungDao;
import com.example.mob204_ps08611.book.database.DatabaseHelper;
import com.example.mob204_ps08611.book.model.NguoiDung;
import com.example.mob204_ps08611.book.ui.HomeActivity;
public class MainActivity extends AppCompatActivity {
private EditText edtUsername;
private EditText edtPassword;
private CheckBox cbRemember;
private Button btnLogin;
String strUser, strPass;
NguoiDungDao nguoiDungDao;
private DatabaseHelper dbHelper;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
setTitle("ĐĂNG NHẬP");
edtUsername = (EditText) findViewById(R.id.edtUsername);
edtPassword = (EditText) findViewById(R.id.edtPassword);
cbRemember = (CheckBox) findViewById(R.id.cbRemember);
btnLogin = (Button) findViewById(R.id.btnLogin);
nguoiDungDao = new NguoiDungDao(getApplicationContext());
NguoiDung user2;
user2 = nguoiDungDao.getUser("admin");
if (user2 == null) {
NguoiDung user3 = new NguoiDung("admin", "1234567", "0568031652", "Nguyen Cao Minh");
nguoiDungDao.insertNguoiDung(user3);
}
checkLogin();
edtUsername.setText("admin");
edtPassword.setText("1234567");
}
public void checkLogin() {
btnLogin.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
String userName = edtUsername.getText().toString().trim();
String password = edtPassword.getText().toString().trim();
if (password.length() < 6 || userName.isEmpty() || password.isEmpty()) {
if (userName.isEmpty())
edtUsername.setError(getString(R.string.notify_empty_user));
if (password.isEmpty())
edtPassword.setError(getString(R.string.notify_empty_pass));
} else {
NguoiDung user = nguoiDungDao.getUser(userName);
if (user != null && user.getUserName() != null) {
if (password.matches(user.getPassword())) {
Intent intent = new Intent(getApplicationContext(), HomeActivity.class);
startActivity(intent);
finish();
Toast.makeText(MainActivity.this, "Đăng nhập thành công", Toast.LENGTH_SHORT).show();
} else {
Toast.makeText(MainActivity.this, "Tài khoản hoặc mật khẩu chưa chính xác", Toast.LENGTH_SHORT).show();
}
} else {
Toast.makeText(MainActivity.this, "Bạn chưa có tài khoản", Toast.LENGTH_SHORT).show();
}
}
}
});
}
public void rememberUser(String u, String p, boolean status) {
SharedPreferences pref = getSharedPreferences("USER_FILE", MODE_PRIVATE);
SharedPreferences.Editor edit = pref.edit();
if (!status) {
edit.clear();
} else {
edit.putString("USERNAME", u);
edit.putString("PASSWORD", p);
edit.putBoolean("REMEMBER", status);
}
edit.commit();
}
}
| [
"[email protected]"
] | |
99e699110a360a39eabf710e628d383a988993f2 | a26b4763a9e2b07390bbba2860c75c53d9f73a4d | /app/src/test/java/com/example/hal_kumar/testapp/ExampleUnitTest.java | 80c7d32fbff017a3982dda81cd8dd9f956f1332a | [] | no_license | harshmalik/parsepush | 112712cfe43fd0cb64529fc0eb9db54eb57660cc | 9a52e4d82e72fc3c5fbe4223e3bce2a315540410 | refs/heads/master | 2021-01-19T04:22:14.789155 | 2016-12-09T20:28:53 | 2016-12-09T20:28:53 | 62,414,241 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 322 | java | package com.example.hal_kumar.testapp;
import org.junit.Test;
import static org.junit.Assert.*;
/**
* To work on unit tests, switch the Test Artifact in the Build Variants view.
*/
public class ExampleUnitTest {
@Test
public void addition_isCorrect() throws Exception {
assertEquals(4, 2 + 2);
}
} | [
"[email protected]"
] | |
446bdc3c087e1e4cf83278458e11b92d07bd5600 | fca29d54905a2edd7fd4db82500bba9c43701966 | /Java-DB-Fundamentals/DatabasesFrameworks-Hibernate&SpringData/EXAMS/photography_workshops_exam/src/main/java/softuni/dto/Export/LocationsExportXmlDto.java | 5cded0c593322aa9cb0fddc3dc03951d8298ae99 | [
"MIT"
] | permissive | yangra/SoftUni | 4046bd28e445f6cef98d2ee31179ba22892e6589 | 2fe8ac059fe398f8bf229200c5406840f026fb88 | refs/heads/master | 2021-01-13T15:16:53.303291 | 2018-04-22T18:19:58 | 2018-04-22T18:19:58 | 78,928,699 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 723 | java | package softuni.dto.Export;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import java.util.List;
@XmlRootElement(name="locations")
@XmlAccessorType(XmlAccessType.FIELD)
public class LocationsExportXmlDto {
@XmlElement(name="location")
private List<LocationExportXmlDto> locationExportXmlDtos;
public List<LocationExportXmlDto> getLocationExportXmlDtos() {
return locationExportXmlDtos;
}
public void setLocationExportXmlDtos(List<LocationExportXmlDto> locationExportXmlDtos) {
this.locationExportXmlDtos = locationExportXmlDtos;
}
}
| [
"[email protected]"
] | |
1d0d2c0d8f86f9ee0911c64f07000f63241322f4 | 7a789bfdc6968db6a990dc1a47247fa12b5d7fb2 | /src/main/java/com/finneasy/app/controller/BlogController.java | 2bab1603ef5b1339febfafbf5105e62477985b11 | [] | no_license | Brainstormers-HackItOut/finneasy-backend | 3f64455cff347def7b385630982942e5a885ae89 | 3746123d4da2b544db7b7fc3c533cc967644efdf | refs/heads/master | 2023-08-12T11:00:10.693213 | 2021-10-17T05:25:20 | 2021-10-17T05:25:20 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,500 | java | package com.finneasy.app.controller;
import com.finneasy.app.model.BlogModel;
import com.finneasy.app.service.BlogService;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import java.util.List;
@RestController
@RequestMapping("/blog")
public class BlogController {
private BlogService blogService;
public BlogController(BlogService blogService) {
this.blogService = blogService;
}
@PostMapping("/create")
public ResponseEntity<BlogModel> createBlog(@RequestBody BlogModel blogModel){
return ResponseEntity.ok(blogService.createBlog(blogModel));
}
@GetMapping("/{id}")
public ResponseEntity<BlogModel> getBlog(@PathVariable Long id){
return ResponseEntity.ok(blogService.getBlog(id));
}
@GetMapping("/all/{userId}")
public ResponseEntity<List<BlogModel>> getAllBlogsOfUser(@PathVariable Long userId){
return ResponseEntity.ok(blogService.getAllBlogsOfUser(userId));
}
@GetMapping("/all")
public ResponseEntity<List<BlogModel>> getAllBlogs(){
return ResponseEntity.ok(blogService.getAllBlogs());
}
@GetMapping("/like/{id}")
public ResponseEntity<BlogModel> likeBlog(@PathVariable Long id){
return ResponseEntity.ok(blogService.likeBlog(id));
}
@GetMapping("/dislike/{id}")
public ResponseEntity<BlogModel> dislikeBlog(@PathVariable Long id){
return ResponseEntity.ok(blogService.dislikeBlog(id));
}
}
| [
"[email protected]"
] | |
c5ec750f51d042cda26d55a3f55510a6cca2033d | 04965f76110c19e3c856f37b21e3f7b5beab7434 | /src/Play.java | a72f66868b2ab0033a99c625192d3925f995f000 | [] | no_license | AndrewDang-Tran/ColorRunner | e6c4635af2ea2e6de7afcb4587cfcd9b3f4c2439 | a05fb1a7684b565c6d6732987dd35d4a9969bf2d | refs/heads/master | 2021-01-01T20:06:02.469402 | 2015-09-21T17:21:18 | 2015-09-21T17:21:18 | 42,881,343 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 11,149 | java |
import java.util.LinkedList;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Screen;
import com.badlogic.gdx.graphics.GL10;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.BitmapFont;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.math.Rectangle;
/**
*
* @author Andrew
* the class that you actually play the game on,
* has levels in it that create the platforms
*
*/
public class Play implements Screen{
SpriteBatch batch;
//LinkedList<Entity> entities, toAdd, toRemove;
Player player;
Texture background;
Rectangle viewport;
//levels that create the walls
Level[] levels;
// how far you are in the game
int gameProg;
int levelStatus;
// font for score
private BitmapFont white;
//int for the score
private int score = 0;
private long startTime;
//string for the score
public static String scoreString;
@Override
public void dispose() {
}
@Override
public void pause() {
}
@Override
public void render(float delta) {
levels[gameProg].setScore(score);
levels[gameProg].update(delta);//Gdx.graphics.getDeltaTime());
score = (int)(System.currentTimeMillis() - startTime)/10;
Gdx.gl.glClear(GL10.GL_COLOR_BUFFER_BIT);
batch.begin();
batch.draw(background,0,0);
scoreString = "Score: " + score;
white.draw(batch, scoreString, 20, Gdx.graphics.getHeight() - 50);
if(gameProg < 6)levels[gameProg].render(batch);
batch.end();
}
@Override
public void resize(int arg0, int arg1) {
}
@Override
public void resume() {
}
@Override
public void hide()
{
}
@Override
public void show()
{
//creates the sprite batch and font
batch = new SpriteBatch();
white = new BitmapFont(Gdx.files.internal("res/white.fnt"), false);
background = new Texture(Gdx.files.internal("res/background2.png"));
background.setWrap(Texture.TextureWrap.Repeat, Texture.TextureWrap.Repeat);
if(viewport == null){
viewport = new Rectangle(0,0,Gdx.graphics.getWidth(),Gdx.graphics.getHeight());
}
//creates the characterImage
player = new Player("res/CharacterImage.png", 100, 100, 32, 50, "white");
LinkedList<Level> tempLvl = new LinkedList<Level>();
levelStatus = 0;
gameProg = 0;
Level lev1 = lev1();
lev1.addPregen(fab1());
lev1.addPregen(fab2());
//lev1.addPregen(fab3());
lev1.addPregen(fab4());
lev1.addPregen(fab5());
lev1.addPregen(fab6());
lev1.addPregen(fab7());
lev1.addPregen(fab8());
lev1.addPregen(fab9());
lev1.addPregen(fab10());
tempLvl.add(lev1);
levels = (Level[]) tempLvl.toArray(new Level[0]);
levels[gameProg].levelStart(Gdx.graphics.getDeltaTime());
Gdx.input.setInputProcessor(player);
startTime = System.currentTimeMillis();
}
/**
* creates the beginning levels
* @return lev which is a Level object
*/
public Level lev1(){
Level lev = new Level(player, viewport);
/*
lev.makeWall("res/buttonDown.png", 10, 200, 800, 50, "red");
lev.makeWall("res/buttonDown.png", 100, 300, 80, 10, "red");
lev.makeWall("res/bullet.png", 200, 400, 100, 50, "white");
//lev.makeWall("res/bullet.png", 800, 200, 20, 600);
*/
lev.gen.addTexString("res/bullet.png");
lev.setStartPos(260, 300);
return lev;
}
public LinkedList<Entity> fab1(){
LinkedList<Entity> set = new LinkedList<Entity>();
set.add(new Entity("res/bullet.png",0,0,400,20,"white"));
set.add(new Entity("res/bullet.png",180,90,20,630,"white"));
// set.add(new Entity("res/bullet.png",180,90,20,380,"white"));
set.add(new Entity("res/bullet.png",400,0,200,20,"white"));
set.add(new Entity("res/bullet.png",200,90,400,20,"red"));
set.add(new Entity("res/bullet.png",200,180,400,20,"red"));
set.add(new Entity("res/bullet.png",200,270,400,20,"red"));
set.add(new Entity("res/bullet.png",200,360,400,20,"red"));
// set.add(new Entity("res/bullet.png",200,450,400,20,"red"));
// set.add(new Entity("res/bullet.png",200,540,400,20,"red"));
// set.add(new Entity("res/bullet.png",200,700,700,20,"white"));
// set.add(new Entity("res/bullet.png",200,450,700,20,"white"));
set.add(new Entity("res/bullet.png",600,0,70,380,"white"));
return set;
}
//img texture, x, y , width height, color
public LinkedList<Entity> fab2() {
LinkedList<Entity> set = new LinkedList<Entity>();
set.add(new Entity("res/bullet.png",0,340,100,20,"white"));
set.add(new Entity("res/bullet.png",120,0,20,700, "red"));
set.add(new Entity("res/bullet.png", 300,590,100,20,"white"));
set.add(new Entity("res/bullet.png", 300,190,200,20,"white"));
set.add(new Entity("res/bullet.png", 480,350,20,260,"red"));
set.add(new Entity("res/bullet.png", 600,500,20,200,"red"));
set.add(new Entity("res/bullet.png", 600,0,20,400,"white"));
set.add(new Entity("res/bullet.png", 750,300,100,20,"white"));
return set;
}
public LinkedList<Entity> fab3() { // this is pretty hard
LinkedList<Entity> set = new LinkedList<Entity>();
set.add(new Entity("res/bullet.png",0,550,100,20,"white"));
set.add(new Entity("res/bullet.png",0,0,20,550,"white"));
set.add(new Entity("res/bullet.png",20,100,280,20,"red"));
set.add(new Entity("res/bullet.png",80,300,120,20,"red"));
set.add(new Entity("res/bullet.png",200,300,20,400,"white"));
set.add(new Entity("res/bullet.png",250,200,100,20, "blue"));
set.add(new Entity("res/bullet.png", 250,300,100,20,"yellow"));
set.add(new Entity("res/bullet.png", 300,600,300,20,"white"));
set.add(new Entity("res/bullet.png", 900,100,100,20,"white"));
return set;
}
public LinkedList<Entity> fab4(){
LinkedList<Entity> set = new LinkedList<Entity>();
set.add(new Entity("res/bullet.png", 0,400,100,20, "white"));
set.add(new Entity("res/bullet.png", 100,0,20,700, " red"));
set.add(new Entity("res/bullet.png", 200,500, 100, 20, "white"));
set.add(new Entity("res/bullet.png", 350,0,20,700,"yellow"));
set.add(new Entity("res/bullet.png", 450,550,50,20, "white"));
set.add(new Entity("res/bullet.png", 550,0,20,700, "blue"));
set.add(new Entity("res/bullet.png", 650,300,50,20, "white"));
set.add(new Entity("res/bullet.png", 750,0,20,700, "orange"));
set.add(new Entity("res/bullet.png", 810,400,100,20, "white"));
return set;
}
public LinkedList<Entity> fab5() {
LinkedList<Entity> set = new LinkedList<Entity>();
set.add(new Entity("res/bullet.png", 0,592,100,20, "white"));
set.add(new Entity("res/bullet.png", 100,0,20,700, " red"));
set.add(new Entity("res/bullet.png", 200,447, 100, 20, "white"));
set.add(new Entity("res/bullet.png", 350,0,20,700,"yellow"));
set.add(new Entity("res/bullet.png", 450,510,50,20, "white"));
set.add(new Entity("res/bullet.png", 550,0,20,700, "blue"));
set.add(new Entity("res/bullet.png", 650,220,50,20, "white"));
set.add(new Entity("res/bullet.png", 750,0,20,700, "orange"));
set.add(new Entity("res/bullet.png", 810,306,100,20, "white"));
return set;
}
public LinkedList<Entity> fab6() {
LinkedList<Entity> set = new LinkedList<Entity>();
set.add(new Entity("res/bullet.png", 0,222,100,20, "white"));
set.add(new Entity("res/bullet.png", 100,0,20,700, " red"));
set.add(new Entity("res/bullet.png", 200,312, 100, 20, "white"));
set.add(new Entity("res/bullet.png", 350,0,20,700,"yellow"));
set.add(new Entity("res/bullet.png", 450,402,50,20, "white"));
set.add(new Entity("res/bullet.png", 550,0,20,700, "blue"));
set.add(new Entity("res/bullet.png", 650,506,50,20, "white"));
set.add(new Entity("res/bullet.png", 750,0,20,700, "orange"));
set.add(new Entity("res/bullet.png", 810,580,100,20, "white"));
return set;
}
public LinkedList<Entity> fab7() {
LinkedList<Entity> set = new LinkedList<Entity>();
set.add(new Entity("res/bullet.png", 0,53,100,20, "white"));
set.add(new Entity("res/bullet.png", 100,0,20,700, " red"));
set.add(new Entity("res/bullet.png", 200,111, 100, 20, "white"));
set.add(new Entity("res/bullet.png", 350,0,20,700,"yellow"));
set.add(new Entity("res/bullet.png", 450,198,50,20, "white"));
set.add(new Entity("res/bullet.png", 550,0,20,700, "blue"));
set.add(new Entity("res/bullet.png", 650,250,50,20, "white"));
set.add(new Entity("res/bullet.png", 750,0,20,700, "orange"));
set.add(new Entity("res/bullet.png", 810,333,100,20, "white"));
return set;
}
public LinkedList<Entity> fab8() {
LinkedList<Entity> set = new LinkedList<Entity>();
set.add(new Entity("res/bullet.png", 0,200,80,20, "red"));
set.add(new Entity("res/bullet.png",50,330,20,400,"white"));
set.add(new Entity("res/bullet.png",130,70,20,530,"white"));
set.add(new Entity("res/bullet.png",150,400,200,20,"blue"));
set.add(new Entity("res/bullet.png",190,0,280,20,"white"));
set.add(new Entity("res/bullet.png",350,400,20,300,"white"));
set.add(new Entity("res/bullet.png", 480,0,20,700,"yellow"));
set.add(new Entity("res/bullet.png",530,0,30,20, "yellow"));
set.add(new Entity("res/bullet.png",580,0,20,700, "yellow"));
set.add(new Entity("res/bullet.png",620,0,30,20, "yellow"));
return set;
}
public LinkedList<Entity> fab9() {
LinkedList<Entity> set = new LinkedList<Entity>();
set.add(new Entity("res/bullet.png", 0,500,50,20,"white"));
set.add(new Entity("res/bullet.png", 50,500,20,200, "red"));
set.add(new Entity("res/bullet.png", 150,380,50,20,"red"));
set.add(new Entity("res/bullet.png", 200,380,20,200,"yellow"));
set.add(new Entity("res/bullet.png", 300,260,50,20,"yellow"));
set.add(new Entity("res/bullet.png", 350,260,20,200, "blue"));
set.add(new Entity("res/bullet.png", 450,150,100,20, "blue"));
set.add(new Entity("res/bullet.png", 660,0,40,700, "orange"));
set.add(new Entity("res/bullet.png", 720,400,120,20, "orange"));
return set;
}
public LinkedList<Entity> fab10() {
LinkedList<Entity> set = new LinkedList<Entity>();
set.add(new Entity("res/bullet.png", 0,300,400,20, "white"));
set.add(new Entity("res/bullet.png", 0,520,20,180, "white"));
set.add(new Entity("res/bullet.png", 0,500,540,20, "white"));
set.add(new Entity("res/bullet.png", 380,0,20,300, "white"));
set.add(new Entity("res/bullet.png", 520,300,20,200, "white"));
set.add(new Entity("res/bullet.png", 380,0,20,300, "white"));
set.add(new Entity("res/bullet.png", 520,280,20,240, "white"));
set.add(new Entity("res/bullet.png", 380,0,20,320, "white"));
set.add(new Entity("res/bullet.png", 520,280,400,20, "white"));
set.add(new Entity("res/bullet.png", 20,320,20,180, "red"));
set.add(new Entity("res/bullet.png", 140,320,20,180, "yellow"));
set.add(new Entity("res/bullet.png", 260,320,20,180, "blue"));
set.add(new Entity("res/bullet.png", 380,320,20,180, "orange"));
set.add(new Entity("res/bullet.png", 400,300,120,20, "purple"));
set.add(new Entity("res/bullet.png", 520,20,20,260, "green"));
set.add(new Entity("res/bullet.png", 640,20,20,260, "red"));
set.add(new Entity("res/bullet.png", 760,20,20,260, "yellow"));
set.add(new Entity("res/bullet.png", 880,20,20,260, "blue"));
set.add(new Entity("res/bullet.png", 380,0,540,20, "white"));
return set;
}
}
| [
"[email protected]"
] | |
1853cb821acddad787fbfa98c9d5d0ec6bca255f | b7f79bb394d3f9ad7453b43cc798d6a8abf422fb | /src/main/java/chylex/hee/mechanics/brewing/TimedPotion.java | 1142f0948fad465250b9792f11fb9bb21057542f | [] | no_license | soundlogic2236/Hardcore-Ender-Expansion | 665d101de707842ac6b27bd4698513a1dee16276 | f1576e6b891329608921a82d01a4ea1096ff469b | refs/heads/master | 2021-01-22T09:50:39.930925 | 2015-01-17T23:16:43 | 2015-01-17T23:16:43 | 28,930,889 | 0 | 0 | null | 2015-01-16T19:38:30 | 2015-01-07T19:46:51 | Java | UTF-8 | Java | false | false | 1,538 | java | package chylex.hee.mechanics.brewing;
import net.minecraft.item.ItemStack;
import net.minecraft.potion.Potion;
import net.minecraft.potion.PotionEffect;
public class TimedPotion extends AbstractPotionData{
protected int startDuration,maxDuration,durationStep;
public TimedPotion(Potion potion, int requiredDamageValue, int damageValue, int maxLevel, int startDuration, int maxDuration){
this(potion,requiredDamageValue,damageValue,maxLevel,startDuration,maxDuration,45);
}
public TimedPotion(Potion potion, int requiredDamageValue, int damageValue, int maxLevel, int startDuration, int maxDuration, int durationStep){
super(potion,requiredDamageValue,damageValue,maxLevel);
this.startDuration = startDuration*20;
this.maxDuration = maxDuration*20;
this.durationStep = durationStep*20;
}
public int getMaxDuration(){
return maxDuration;
}
public int getDurationStep(){
return durationStep;
}
public int getDurationLevel(int duration){
return (duration-startDuration)/durationStep;
}
@Override
public void onFirstBrewingFinished(ItemStack is){
super.onFirstBrewingFinished(is);
PotionEffect eff = PotionTypes.getEffectIfValid(is);
if (eff != null)PotionTypes.setCustomPotionEffect(is,new PotionEffect(eff.getPotionID(),startDuration,eff.getAmplifier(),eff.getIsAmbient()));
}
public boolean canIncreaseDuration(ItemStack is){
PotionEffect effect = PotionTypes.getEffectIfValid(is);
return effect != null && effect.getPotionID() == potion.id && effect.getDuration() < maxDuration;
}
}
| [
"[email protected]"
] | |
868c1b05a3135e9b63fcfe5219ce7eddf5a7f508 | e47b847cc29a1f5d8db86fc03529604663a958db | /Backend/src/main/java/com/cc/web/entity/SetInfo.java | 5a1ac6a292c6bcb47dc34b46d20ebf48a9c97406 | [] | no_license | AzoriusSergh4/ColorConfluence | 68a8afe191dde20d9d4177b082293246228d034c | 1e0a112c82a7aa49c38d2f496fb5c0a6e7ee374f | refs/heads/master | 2023-01-24T21:23:16.928585 | 2022-05-07T08:44:14 | 2022-05-07T08:44:14 | 206,517,059 | 1 | 1 | null | 2023-01-07T00:55:50 | 2019-09-05T08:45:37 | Java | UTF-8 | Java | false | false | 1,014 | java | package com.cc.web.entity;
import com.fasterxml.jackson.annotation.JsonIdentityInfo;
import com.fasterxml.jackson.annotation.ObjectIdGenerators;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
@Entity
@JsonIdentityInfo(
generator = ObjectIdGenerators.PropertyGenerator.class,
property = "id")
public class SetInfo {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private long id;
private String name;
private String code;
public SetInfo() {
}
public SetInfo(String name, String code) {
this.name = name;
this.code = code;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
public long getId() {
return id;
}
}
| [
"[email protected]"
] | |
00bd43d14ffb3d96a9b8a09d5aee429799e7ad38 | e617129fbeb56a9e26fc5e67f6adfdedbef3a6b3 | /StringAndTextProcessingEXC/src/StringExplosion.java | 1e9dada45ef98c0e331b8a3ad65c95f308d7e1b0 | [] | no_license | vaskot06/TechModule-Java | 862e23880cb7d4dac807e26f3d79a7ec3177c170 | eecbbcbdb7f2d1ef2e604fc7a1495db638fb080e | refs/heads/master | 2020-06-14T20:35:28.921783 | 2019-09-17T18:24:55 | 2019-09-17T18:24:55 | 195,118,699 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,129 | java | import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;
import java.util.stream.Collectors;
public class StringExplosion {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
List<String> input = Arrays.stream(scanner.nextLine().split("")).collect(Collectors.toList());
for (int i = 0; i < input.size(); i++) {
}
// List<String> input = Arrays.stream(scanner.nextLine().split("")).collect(Collectors.toList());
// List<String> toPrint = new ArrayList<>();
//
// for (int i = 0; i <input.size() ; i++) {
// String symbol = input.get(i);
// if (!symbol.equals(">")){
// toPrint.add(symbol);
// }else {
// toPrint.add(">");
// int power = Integer.parseInt(input.get(i + 1));
// i+=power;
// }
// }
// for (String symbol : toPrint) {
// System.out.print(symbol);
// }
}
}
| [
"[email protected]"
] | |
efd08d662e8ea340caa16b9b5ff580398c54701b | ab435a7868626f9936054f52be7f33a6341b41b0 | /src/for_myself_testing/GOF_patterns/visitor/Database.java | be9bb64276995e9d9c107443795c7f97701d7671 | [] | no_license | Eugen02/forMyself | be8a7b2bc5c4f3036230b0b95557408128db6c7e | dc621425ff56f630dc8d04ba3fb9981266e21bda | refs/heads/master | 2022-12-07T16:15:21.414724 | 2020-08-28T10:16:41 | 2020-08-28T10:16:41 | 289,933,868 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 205 | java | package for_myself_testing.GOF_patterns.visitor;
public class Database implements ProjectElement {
@Override
public void beWritten(Developer developer) {
developer.create(this);
}
}
| [
"[email protected]"
] | |
9d96212fda27de87ac5b7f04f446313e4961ffb5 | a19ff30eed0e7add379bbc32c721e68628f28395 | /src/common/AnimationA.java | 7e12367ccdcdd69f17a51bdface943df28407d15 | [] | no_license | oMisterMo/PacMan | 763f76ea060c609840db2c253e71abd5d305f70e | 32c84d95df136b4329f3ed1e8e404fa35aecf68e | refs/heads/master | 2020-03-17T16:00:39.379774 | 2019-03-31T00:35:08 | 2019-03-31T00:35:08 | 133,731,945 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,670 | java | /*
* Copyright (C) 2019 Mohammed Ibrahim
*
* 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 common;
import java.awt.image.BufferedImage;
/**
* The AnimationA class provides .........
*
* The AnimationA class is mainly used by Android applications
* 25-May-2018, 21:35:33.
*
* @author Mohammed Ibrahim
*/
public final class AnimationA {
public static final int ANIMATION_LOOPING = 0;
public static final int ANIMATION_NON_LOOPING = 1;
final BufferedImage[] keyFrames;
final float frameDuration;
public AnimationA(float frameDuration, BufferedImage... keyFrames) {
this.frameDuration = frameDuration;
this.keyFrames = keyFrames;
}
public BufferedImage getKeyFrame(float startTime, int mode) {
int frameNumber = (int) (startTime / frameDuration);
if (mode == ANIMATION_NON_LOOPING) {
frameNumber = Math.min(keyFrames.length - 1, frameNumber);
} else {
frameNumber = frameNumber % keyFrames.length;
}
return keyFrames[frameNumber];
}
}
| [
"[email protected]"
] | |
03f3bdf09dbfd4bb0541ed37204cb0f48a8b3312 | 4a40e89fe380d5a53a5430fbdac6cf798e72feab | /app/src/main/java/com/example/mvpexample/network/ApiService.java | 11aeb867d6aea9de482d39e1da2dbcd0e1c84998 | [] | no_license | OHrydko/GithubProfile | 5a44429c089feaf0613f0e9f1ae950174631388c | 7174a1b1ca3e25718831d032de5093d2ec9283f8 | refs/heads/master | 2020-06-07T06:24:58.265639 | 2020-03-20T18:42:48 | 2020-03-20T18:42:48 | 192,948,764 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 489 | java | package com.example.mvpexample.network;
import com.example.mvpexample.model.Github;
import com.example.mvpexample.model.GithubRepository;
import java.util.ArrayList;
import io.reactivex.Observable;
import retrofit2.http.GET;
import retrofit2.http.Path;
public interface ApiService {
@GET("users/{name}")
Observable<Github> getProfile(@Path("name") String name);
@GET("users/{name}/repos")
Observable<ArrayList<GithubRepository>> getRepos(@Path("name") String name);
}
| [
"[email protected]"
] | |
f602125beecc30445372ece1249ef03213cd868b | 2b438c607ca0b2ee575eec4752cc7c5c7792f4cc | /JDBC_Pool_Connector/database/Connector.java | fb56a0a66c02a128f50c8ef6d2f7df521540a77d | [] | no_license | cherkavi/java-code-example | a94a4c5eebd6fb20274dc4852c13e7e8779a7570 | 9c640b7a64e64290df0b4a6820747a7c6b87ae6d | refs/heads/master | 2023-02-08T09:03:37.056639 | 2023-02-06T15:18:21 | 2023-02-06T15:18:21 | 197,267,286 | 0 | 4 | null | 2022-12-15T23:57:37 | 2019-07-16T21:01:20 | Java | WINDOWS-1251 | Java | false | false | 3,353 | java | package database;
import java.io.File;
import java.io.IOException;
import org.hibernate.Session;
import java.sql.Connection;
import java.sql.DatabaseMetaData;
import java.sql.ResultSet;
import database.wrap.*;
/** класс, который производит соединение с базой данных, посредстом Hibernate и Connection */
public class Connector {
// INFO - место присоединения всех классов для активации отображения объектов базы данных на объекты программы
private Class<?>[] classOfDatabase=new Class[]{
CartridgeModel.class,
CartridgeVendor.class,
Customer.class,
OrderList.class,
Points.class,
PointSettings.class,
OrderGroup.class
};
private IConnector connector=null;
private HibernateConnection hibernateConnection;
public Connector() throws Exception{
this("computer_shop_cartridge");
}
/** произвести соединение с базой данных посредством файла*/
public Connector(File file) throws Exception {
while(true){
if(file.exists()==false){
throw new IOException("file is not exists:"+file.getAbsolutePath());
}
// попытка определения Firebird
if(file.getName().toUpperCase().endsWith(".GDB")){
System.out.println("Connector created:");
try{
this.connector=new FirebirdConnection(file);
}catch(Exception ex){
}
hibernateConnection=new HibernateConnection("org.hibernate.dialect.FirebirdDialect",classOfDatabase);
break;
}
throw new Exception("algorithm is not found");
}
}
/** произвести соединение с базой данных посредством файла*/
public Connector(String path) throws Exception {
System.out.println("Connector created:");
this.connector=new FirebirdConnection(path);
hibernateConnection=new HibernateConnection("org.hibernate.dialect.FirebirdDialect",classOfDatabase);
}
/** получить Hibernate Session */
private Session openSession(Connection connection){
return this.hibernateConnection.openSession(connection);
}
/** получить соединение с базой данных */
private Connection getConnection(){
return this.connector.getConnection();
}
public ConnectWrap getConnector(){
Connection connection=this.getConnection();
Session session=this.openSession(connection);
return new ConnectWrap(connection,session);
}
public static void main(String[] args) throws Exception {
System.out.println("-- begin --");
Connector connector=new Connector("computer_shop_cartridge");
System.out.println("Connector: "+connector.getConnector());
System.out.println("-- end --");
Connection connection=connector.getConnection();
DatabaseMetaData metaData=connection.getMetaData();
ResultSet rs=metaData.getClientInfoProperties();
int columnCount=rs.getMetaData().getColumnCount();
while(rs.next()){
for(int counter=0;counter<columnCount;counter++){
System.out.print(counter+" : "+rs.getString(counter));
}
System.out.println();
}
}
}
| [
"[email protected]"
] | |
606b3d9fce03919a455859c7682c8a9dd7647b03 | 1db0be86554f8461115d27efeac6daebb6677dc4 | /src/com/company/sixthstream/CollectAverager.java | 4e45435aefc7ec04acf6334409c63e7249c9a979 | [] | no_license | vsvdevua/funcJavaprogr | d81aafb5cc4337161c15dbb6b8a5f12894c868d4 | 1e10080a8bc36d50b6e551769ff3efd833ecf037 | refs/heads/master | 2023-02-09T00:45:57.656864 | 2021-01-04T11:28:48 | 2021-01-04T11:28:48 | 326,662,912 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,174 | java | package com.company.sixthstream;
import java.util.concurrent.ThreadLocalRandom;
import java.util.stream.DoubleStream;
class Averager{
private double total;
private long count;
public Averager() {
}
public void include(double d){
total +=d;
count++;
}
public void merge(Averager other){
total +=other.total;
count +=other.count;
}
public double get(){
return total/count;
}
}
public class CollectAverager {
public static void main(String[] args) {
long start = System.nanoTime();
Averager result= DoubleStream.generate( ()-> ThreadLocalRandom.current().nextDouble(-Math.PI, Math.PI) )
// .parallel()
//.unordered()
.limit( 200_000_000L )
// .map(x->Math.sin( x ))
.map(Math::sin)
//.collect( ()->new Averager(),(b,i)->b.include( i ), (b1,b2)->b1.merge( b2 ) );
.collect( Averager::new,Averager::include, Averager::merge );
long end = System.nanoTime();
System.out.println("Average is "+result.get() + " computation took "+ (end-start)/1_000_000 +" ms");
}
}
| [
"[email protected]"
] | |
a8094ddecce034e14a4f941d55beb4abc9e650ed | 703e78795c4b170b402c24a891f1019bdaa119a9 | /plm-payloadprocess-ms/src/main/java/com/jci/payloadprocess/domain/ERPMapperEntity.java | 1708e04a2014b1ad6b037facdd3a6e7f2a75f15a | [] | no_license | santhoshanna/working | b5b7ffdeb8d1e26a157595f46c5cfdaf908f38ef | 519436f78bc996912d0dc4405e49caae1d06b229 | refs/heads/master | 2020-04-11T08:58:41.365276 | 2016-09-14T07:04:20 | 2016-09-14T07:04:20 | 68,181,861 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 468 | java | package com.jci.payloadprocess.domain;
public class ERPMapperEntity {
private String erp;
private String plant;
private String region;
public String getErp() {
return erp;
}
public void setErp(String erp) {
this.erp = erp;
}
public String getPlant() {
return plant;
}
public void setPlant(String plant) {
this.plant = plant;
}
public String getRegion() {
return region;
}
public void setRegion(String region) {
this.region = region;
}
}
| [
"[email protected]"
] | |
47cce4afaa4b3c12cf293063dd324554b31bde60 | 22b4290ed896a33a9407f3364a6f0d25e7230f74 | /src/br/com/wmitrut/cadastrousuarios/ListaPessoasActivity.java | 9d1f89e083e273abdd5b9fab40fc08d610c02028 | [] | no_license | Wmitrut/Calendar_Crud_android | 0dce00a5707c7f3b61baf40fb0b1c87f8ce596f3 | 7454c8362367e54556e2378ba3e178c7b465a20b | refs/heads/master | 2020-04-05T19:32:10.984206 | 2014-09-15T15:50:17 | 2014-09-15T15:50:17 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,527 | java | package br.com.wmitrut.cadastrousuarios;
import java.sql.SQLException;
import java.util.List;
import br.com.wmitrut.cadastrousuarios.R;
import com.j256.ormlite.dao.Dao;
import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.view.Menu;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ListView;
import android.widget.Toast;
public class ListaPessoasActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.lista_pessoas);
}
@Override
protected void onResume() {
super.onResume();
try {
DatabaseHelper db = DatabaseHelper.getInstance(this);
Dao<Pessoa, Long> dao = db.getDao(Pessoa.class);
List<Pessoa> pessoas = dao.queryForAll();
PessoaAdapter<Pessoa> adapter =
new PessoaAdapter<Pessoa>(this, pessoas);
ListView lv = (ListView)findViewById(R.id.lista_pessoas);
lv.setAdapter(adapter);
} catch (Exception e) {
Toast.makeText(this, "Erro recuperando pessoas", Toast.LENGTH_SHORT).show();
e.printStackTrace();
}
}
public void deletar(View v) {
try {
DatabaseHelper db = DatabaseHelper.getInstance(this);
Dao<Pessoa, Integer> dao = db.getDao(Pessoa.class);
int id = (Integer) v.getTag();
Pessoa pessoa = dao.queryForId(id);
dao.delete(pessoa);
onResume();
} catch (SQLException e) {
e.printStackTrace();
}
}
}
| [
"[email protected]"
] | |
7dea4d2cd6c74f9e89a94efbc665910a9e253048 | be57dc3c1c879afee41fe4c019db7674bcf46dfc | /itil/src/main/java/net/eulerframework/web/module/demo/dao/QueueDefinitionDao.java | c1ca0c094f711f9157d78ccff5578bd85810ab42 | [] | no_license | cFrost-sun/itil | 7c63dd39b0338f5680700df30c67a20a38bebbc5 | f0580070e672be852740a36903d96fb43c2ac305 | refs/heads/master | 2021-01-18T16:08:51.247501 | 2017-04-25T14:44:49 | 2017-04-25T14:44:49 | 86,715,536 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 621 | java | package net.eulerframework.web.module.demo.dao;
import java.util.List;
import org.hibernate.criterion.DetachedCriteria;
import org.hibernate.criterion.Order;
import net.eulerframework.web.core.base.dao.impl.hibernate5.BaseDao;
import net.eulerframework.web.module.demo.entity.QueueDefinition;
public class QueueDefinitionDao extends BaseDao<QueueDefinition> {
public List<QueueDefinition> findQueueDefinitions() {
DetachedCriteria detachedCriteria = DetachedCriteria.forClass(this.entityClass);
detachedCriteria.addOrder(Order.asc("name"));
return this.query(detachedCriteria);
}
}
| [
"[email protected]"
] | |
bf15f662506245c06e7c8e888638c15cef4cee29 | c02b2f1f9d841227f19ba2a6ce0a94dc6a1af606 | /src/main/java/cn/jbolt/admin/wechat/user/WechatUserService.java | 458b2a7e02adb709b983c283114e82faa08ce554 | [] | no_license | Freedom-Gundam-X10A/JZ-Industrial-Cloud-Platform | c45755798eead396ff9d6b13e31f3c7342e8ec63 | 6e60e8bb8482051ba9e742ea2fb4decb6d91b195 | refs/heads/master | 2022-09-14T20:03:24.983875 | 2019-12-31T08:56:13 | 2019-12-31T08:56:13 | 232,018,355 | 0 | 2 | null | 2022-09-01T23:18:29 | 2020-01-06T03:39:46 | JavaScript | UTF-8 | Java | false | false | 13,679 | java | package cn.jbolt.admin.wechat.user;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.jfinal.aop.Inject;
import com.jfinal.kit.Kv;
import com.jfinal.kit.Ret;
import com.jfinal.kit.StrKit;
import com.jfinal.plugin.activerecord.Db;
import com.jfinal.plugin.activerecord.Page;
import com.jfinal.plugin.activerecord.Record;
import com.jfinal.weixin.sdk.api.ApiConfigKit;
import com.jfinal.weixin.sdk.api.ApiResult;
import com.jfinal.weixin.sdk.api.UserApi;
import cn.hutool.extra.emoji.EmojiUtil;
import cn.jbolt.admin.wechat.mpinfo.WechatMpinfoService;
import cn.jbolt.base.BaseRecordService;
import cn.jbolt.common.config.Msg;
import cn.jbolt.common.db.sql.Sql;
import cn.jbolt.common.model.WechatMpinfo;
import cn.jbolt.common.model.WechatUser;
import cn.jbolt.common.util.CACHE;
import cn.jbolt.common.util.StringUtil;
/**
* 微信公众号粉丝用户表
* @ClassName: WechatUserService
* @author: JFinal学院-小木 QQ:909854136
* @date: 2019年9月28日
*
* 注意:本内容仅限于JFinal学院 JBolt平台VIP成员内部传阅,请尊重开发者劳动成果,不要外泄出去用于其它商业目的
*/
public class WechatUserService extends BaseRecordService<WechatUser>{
private static boolean syncing=false;
@Inject
private WechatMpinfoService wechatMpinfoService;
@Override
protected Class<WechatUser> mainTableModelClass() {
return WechatUser.class;
}
/**
* 管理列表
* @param mpId
* @param pageNumber
* @param pageSize
* @param sex
* @return
*/
public Page<Record> paginateAdminList(Integer mpId, Integer pageNumber, int pageSize,String keywords, Integer sex) {
if(notOk(mpId)) {return EMPTY_PAGE;}
return dbTemplate(mpId, "wechat.user.paginateAdminList", Kv.by("mpId", mpId).setIfNotNull("sex", sex).setIfNotBlank("keywords",keywords)).paginate(pageNumber, pageSize);
}
/**
* 同步用户数据
* @param mpId
* @return
*/
public Ret sync(Integer mpId) {
Ret checkRet=checkCanSync(mpId);
if(checkRet.isFail()) {return checkRet;}
Kv kv=checkRet.getAs("data");
String appId=kv.getStr("appId");
WechatMpinfo wechatMpinfo=kv.getAs("wechatMpinfo");
syncing=true;
ApiConfigKit.setThreadLocalAppId(appId);
try {
Ret ret=syncByNextOpenId(mpId,wechatMpinfo.getType(),null);
if(ret.isFail()) {return ret;}
if(wechatMpinfo.getIsAuthenticated()&&wechatMpinfo.getType().intValue()!=WechatMpinfo.TYPE_XCX&&wechatMpinfo.getType().intValue()!=WechatMpinfo.TYPE_QYWX) {
return syncUserInfo(mpId,wechatMpinfo.getType());
}
return SUCCESS;
}finally {
ApiConfigKit.removeThreadLocalAppId();
syncing=false;
}
}
/**
* 更新用户信息
* @param mpId
* @param type
* @return
*/
private Ret syncUserInfo(Integer mpId, Integer type) {
List<Record> needSyncUsers=getNeedSyncUsers(mpId,100);
if(needSyncUsers==null||needSyncUsers.size()==0) {
return success("同步用户信息完成");
}
Ret ret;
for(Record user:needSyncUsers) {
ret=processUserInfo(user);
if(ret.isFail()) {
return ret;
}
}
//批量更新
Db.batchUpdate(table(mpId), needSyncUsers, needSyncUsers.size());
return syncUserInfo(mpId, type);
}
/**
* 调用接口 去获取用户信息
* @param user
*/
private Ret processUserInfo(Record user) {
ApiResult apiResult=UserApi.getUserInfo(user.getStr("open_id"));
if(apiResult.isSucceed()==false) {return fail(apiResult.getErrorMsg());}
Integer subscribe=apiResult.getInt("subscribe");
if(isOk(subscribe)&&subscribe.intValue()==1) {
String userNickName=user.getStr("nickname");
//判断如果传进来的user 没有nickname或者有但是是之前自动生成的那种 需要再次设置一下
if(notOk(userNickName)||(userNickName.indexOf("用户_")!=-1&&userNickName.equals("用户_")==false)) {
String nickName=apiResult.getStr("nickname");
if(EmojiUtil.containsEmoji(nickName)) {
nickName=EmojiUtil.toHtml(nickName);
}else {
nickName=StringUtil.filterEmoji(nickName);
}
if(StrKit.isBlank(nickName)) {
nickName="用户_"+user.get("id");
}
user.set("nickname",nickName);
}
user.set("language", apiResult.getStr("language"));
user.set("country", apiResult.getStr("country"));
user.set("province", apiResult.getStr("province"));
user.set("city", apiResult.getStr("city"));
user.set("sex", apiResult.getInt("sex"));
user.set("union_id", apiResult.getStr("unionid"));
user.set("remark", apiResult.getStr("remark"));
user.set("group_id", apiResult.getInt("groupid"));
user.set("subscribe_scene", apiResult.getStr("subscribe_scene"));
user.set("qr_scene", apiResult.getInt("qr_scene"));
user.set("qr_scene_str", apiResult.getStr("qr_scene_str"));
user.set("head_img_url", apiResult.getStr("headimgurl"));
Long subscribeTime=apiResult.getLong("subscribe_time");
user.set("subscribe_time", new Date(subscribeTime*1000L));
}
return SUCCESS;
}
/**
* 获取需要同步的数据
* @param mpId
* @param count
* @return
*/
private List<Record> getNeedSyncUsers(Integer mpId, int count) {
Sql sql=sql(mpId).select("id","open_id").isNull("nickname").firstPage(count);
return Db.find(sql.toSql());
}
/**
* 更新同步
* @param mpId
* @param mpType
* @param nextOpenId
* @return
*/
private Ret syncByNextOpenId(Integer mpId,Integer mpType, String nextOpenId) {
ApiResult apiResult=null;
try {
apiResult=UserApi.getFollowers(nextOpenId);
if(apiResult.isSucceed()==false) {
syncing=true;
return fail(apiResult.getErrorMsg());
}
} catch (RuntimeException e) {
syncing=true;
return fail(e.getMessage());
}
Integer total=apiResult.getInt("total");
if(notOk(total)) {
syncing=true;
return fail("这个公众平台用户总数为0");
}
Integer count=apiResult.getInt("count");
nextOpenId=apiResult.getStr("next_openid");
if(notOk(count)||notOk(nextOpenId)) {
syncing=true;
return success("同步完成");
}
Object data=apiResult.get("data");
JSONObject jsonObject=JSON.parseObject(data.toString());
JSONArray array=jsonObject.getJSONArray("openid");
if(array!=null&&array.size()>0) {
String openId;
List<Record> records=new ArrayList<Record>();
for(int i=0;i<count;i++) {
openId=array.getString(i);
boolean exist=exists(mpId, "open_id", openId);
if(exist) {
continue;
}
records.add(genRecordByOpenId(mpId,mpType,openId));
}
int recordSize=records.size();
if(recordSize>0) {
Db.batchSave(table(mpId), records, recordSize);
}
}
//递归调用
return syncByNextOpenId(mpId,mpType,nextOpenId);
}
/**
* 保存一个不重复的OPENID 进入数据库
* @param mpId
* @param mpType
* @param openId
*/
private Record genRecordByOpenId(Integer mpId,Integer mpType, String openId) {
WechatUser wechatUser=new WechatUser();
wechatUser.setEnable(true);
wechatUser.setIsChecked(false);
wechatUser.setOpenId(openId);
wechatUser.setSubscibe(true);
wechatUser.setSource(mpType);
wechatUser.setMpId(mpId);
return wechatUser.toRecord();
}
/**
* 同步一个用户数据
* @param userId
* @param mpId
* @param id
* @return
*/
public Ret syncOneUserInfo(Integer userId, Integer mpId, Integer id) {
Ret checkRet=checkCanSync(mpId);
if(checkRet.isFail()) {return checkRet;}
Record user=findById(mpId, id);
if(user==null) {return fail(Msg.DATA_NOT_EXIST);}
Kv kv=checkRet.getAs("data");
String appId=kv.getStr("appId");
syncing=true;
ApiConfigKit.setThreadLocalAppId(appId);
try {
Ret syncUserInfo=processUserInfo(user);
if(syncUserInfo.isFail()) {return syncUserInfo;}
Ret updateRet=update(mpId, user);
return updateRet;
}finally {
ApiConfigKit.removeThreadLocalAppId();
syncing=false;
}
}
/**
* 检测是否可以同步
* @param mpId
* @return
*/
private Ret checkCanSync(Integer mpId) {
if(syncing) {return fail("已经在同步了,请耐心等待...");}
if(notOk(mpId)) {return fail(Msg.PARAM_ERROR);}
boolean exist=tableExist(mpId);
if(exist==false) {
return fail(Msg.TABLE_NOT_EXIST);
}
WechatMpinfo wechatMpinfo=wechatMpinfoService.findById(mpId);
if(wechatMpinfo==null){
return fail("微信公众平台信息不存在");
}
String appId=CACHE.me.getWechatConfigAppId(mpId);
if(StrKit.isBlank(appId)){
return fail(wechatMpinfo.getName()+"基础配置不正确!");
}
boolean canSync=(wechatMpinfo.getIsAuthenticated()&&wechatMpinfo.getType().intValue()!=WechatMpinfo.TYPE_XCX&&wechatMpinfo.getType().intValue()!=WechatMpinfo.TYPE_QYWX);
if(!canSync) {return fail("此公众平台无调用API权限");}
return success(Kv.by("appId", appId).set("wechatMpinfo",wechatMpinfo), Msg.SUCCESS);
}
/**
* 切换Enable状态
* @param userId
* @param mpId
* @param id
* @return
*/
public Ret toggleEnable(Integer userId, Integer mpId, Integer id) {
if(notOk(mpId)) {return fail(Msg.PARAM_ERROR);}
boolean exist=tableExist(mpId);
if(exist==false) {
return fail(Msg.TABLE_NOT_EXIST);
}
WechatMpinfo wechatMpinfo=wechatMpinfoService.findById(mpId);
if(wechatMpinfo==null){
return fail("微信公众平台信息不存在");
}
String appId=CACHE.me.getWechatConfigAppId(mpId);
if(StrKit.isBlank(appId)){
return fail(wechatMpinfo.getName()+"基础配置不正确!");
}
Ret ret=toggleBoolean(mpId, id, "enable");
if(ret.isOk()) {
//添加日志
}
return ret;
}
/**
* 同步关注者的用户信息到微信User表
* @param appId
* @param openId
* @return
*/
public Ret syncSubscribeUserInfo(String appId, String openId) {
Integer mpId=CACHE.me.getWechatMpidByAppId(appId);
if(notOk(mpId)) {
return fail("appId为:"+appId+"的公众号信息获取失败");
}
WechatMpinfo wechatMpinfo=wechatMpinfoService.findById(mpId);
if(wechatMpinfo==null) {
return fail("微信公众平台信息不存在");
}
//根据openId去找人 找到就更新 找不到就新增
Record wechatUser=getByOpenId(mpId,openId);
if(wechatUser!=null) {
//说明之前用户信息已经同步到数据库里保存了 这次更新
Ret ret=processUserInfo(wechatUser);
if(ret.isOk()) {
update(mpId, wechatUser);
}
}else {
//说明是个全新用户,存起来
saveOneNewWechatUserInfo(mpId,wechatMpinfo.getType(),openId);
}
return SUCCESS;
}
/**
* 更新用户信息
* @param mpId
* @param apiResult
*/
private void updateOneNewWechatUserInfo(Integer mpId,WechatUser user,ApiResult apiResult) {
Integer subscribe=apiResult.getInt("subscribe");
if(isOk(subscribe)&&subscribe.intValue()==1) {
String userNickName=user.getNickname();
//判断如果传进来的user 没有nickname或者有但是是之前自动生成的那种 需要再次设置一下
if(notOk(userNickName)||(userNickName.indexOf("用户_")!=-1&&userNickName.equals("用户_")==false)) {
String nickName=apiResult.getStr("nickname");
if(EmojiUtil.containsEmoji(nickName)) {
nickName=EmojiUtil.toHtml(nickName);
}else {
nickName=StringUtil.filterEmoji(nickName);
}
if(StrKit.isBlank(nickName)) {
nickName="用户_"+user.getId();
}
user.setNickname(nickName);
}
processUserInfoByApi(user, apiResult);
Record record=user.toRecord();
update(mpId, record);
}
}
/**
* 填充更新必要字段
* @param user
* @param apiResult
*/
private void processUserInfoByApi(WechatUser user, ApiResult apiResult) {
user.setLanguage(apiResult.getStr("language"));
user.setCountry(apiResult.getStr("country"));
user.setProvince(apiResult.getStr("province"));
user.setCity(apiResult.getStr("city"));
user.setSex(apiResult.getInt("sex"));
user.setUnionId(apiResult.getStr("unionid"));
user.setRemark(apiResult.getStr("remark"));
user.setGroupId(apiResult.getInt("groupid"));
user.setSubscribeScene(apiResult.getStr("subscribe_scene"));
user.setQrScene(apiResult.getInt("qr_scene"));
user.setQrSceneStr(apiResult.getStr("qr_scene_str"));
user.setHeadImgUrl(apiResult.getStr("headimgurl"));
Long subscribeTime=apiResult.getLong("subscribe_time");
user.setSubscribeTime(new Date(subscribeTime*1000L));
}
/**
* 保存一个新的关注用户信息
* @param mpId
* @param apiResult
*/
private void saveOneNewWechatUserInfo(Integer mpId,int mpType,String openId) {
Record record=genRecordByOpenId(mpId, mpType, openId);
Ret ret=save(mpId, record);
if(ret.isOk()) {
Ret processRet=processUserInfo(record);
if(processRet.isOk()) {
update(mpId, record);
}
}
}
/**
* 根据openId获取用户
* @param mpId
* @param openId
* @return
*/
public Record getByOpenId(Integer mpId, String openId) {
return findFirst(mpId, Kv.by("open_id", openId));
}
/**
* 根据openId获取用户
* @param mpId
* @param openId
* @return
*/
public WechatUser getWechatUserByOpenId(Integer mpId, String openId) {
Record record=getByOpenId(mpId, openId);
if(record==null) {return null;}
return new WechatUser()._setAttrs(record.getColumns());
}
}
| [
"[email protected]"
] | |
6fc9f1bdce2fa9d680e216ac7e1293133cd39c40 | b1cd9245ecd263b187c12e6264b15b8d2223890b | /src/vista/VistaInventario.java | 386413ad06323cd416a5a14deca32d54918cdd8a | [] | no_license | mgomezu/ProyectoPOO | 3e8433bb65de3ab0a9d7c757265b1667d37456fd | 770b1e60b138dc1c1be20ad5a61f0f7ef3bb0b82 | refs/heads/master | 2023-05-05T10:18:39.652175 | 2021-05-26T19:39:26 | 2021-05-26T19:39:26 | 371,149,211 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,509 | java | package vista;
import Modelo.Auto;
import java.io.File;
import java.util.ArrayList;
import java.util.Scanner;
import javafx.geometry.Insets;
import javafx.geometry.Pos;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.control.ListView;
import javafx.scene.control.TableColumn;
import javafx.scene.control.TableView;
import javafx.scene.control.cell.PropertyValueFactory;
import javafx.scene.layout.BorderPane;
public class VistaInventario implements Vista {
Scene escena;
Label titulo;
ArrayList<Auto> autos = new ArrayList<>();
TableView tabla;
Button volver;
public VistaInventario() {
try {
File archivo = new File("Autos.txt");
Scanner leer = new Scanner(archivo);
while (leer.hasNext()) {
int ID = leer.nextInt();
String marca = leer.next();
String modelo = leer.next();
String tipo = leer.next();
double Precio = Double.parseDouble(leer.next());
boolean disponible;
if (leer.next().equals("disponible")) {
disponible = true;
} else {
disponible = false;
}
String ruta = leer.next();
int numero = Integer.parseInt(leer.next());
Auto auto = new Auto(ID, marca, modelo, tipo, Precio, disponible, ruta, numero);
autos.add(auto);
}
} catch (Exception e) {
}
titulo = new Label("INVENTARIO");
tabla = new TableView();
TableColumn marca = new TableColumn("Marca");
TableColumn modelo = new TableColumn("Modelo");
TableColumn tipo = new TableColumn("Tipo");
TableColumn ID = new TableColumn("ID");
marca.setCellValueFactory(new PropertyValueFactory<>("marca"));
modelo.setCellValueFactory(new PropertyValueFactory<>("modelo"));
tipo.setCellValueFactory(new PropertyValueFactory<>("tipo"));
ID.setCellValueFactory(new PropertyValueFactory<>("ID"));
tabla.getColumns().addAll(marca, modelo, tipo, ID);
for (int i = 0; i < autos.size(); i++) {
Auto autoNuevo = autos.get(i);
tabla.getItems().add(autoNuevo);
}
volver = new Button("Volver");
tabla.getItems().add("ID | MARCA | MODELO | DISPONIBILIDAD");
for (int i = 0; i < autos.size(); i++) {
tabla.getItems().add(autos.get(i).getID() + " | " + autos.get(i).getMarca()
+ " | " + autos.get(i).getModelo() + " | " + autos.get(i).isDisponible());
}
BorderPane panel = new BorderPane();
panel.setMaxSize(Double.MAX_VALUE, Double.MAX_VALUE);
panel.setMargin(titulo, new Insets(8));
panel.setAlignment(titulo, Pos.TOP_CENTER);
panel.setTop(titulo);
panel.setCenter(tabla);
panel.setMargin(tabla, new Insets(8));
panel.setMaxSize(Double.MAX_VALUE, Double.MAX_VALUE);
panel.setMargin(volver, new Insets(8));
panel.setAlignment(volver, Pos.TOP_CENTER);
panel.setBottom(volver);
escena = new Scene(panel, 500, 500);
}
@Override
public Scene getScena() {
return escena;
}
public TableView getTabla() {
return tabla;
}
public Button getVolver() {
return volver;
}
}
| [
"[email protected]"
] | |
0283f70cffd97ceec15553cc555d373f743ce6ab | a02c2a1d858050f594303123b41af72488dcbccd | /service/src/main/java/com/oneday/service/state/ReceiverState.java | 6159c574b59759e79c53278055563817db9db53c | [] | no_license | KiteSquare/oneday | 003844e5cdc6da1f94a3b666f2ac406428591260 | b4de7e06b3d48e213904def4177eb5a75d67b9bc | refs/heads/master | 2021-01-24T10:40:43.223269 | 2017-12-05T10:56:12 | 2017-12-05T10:56:12 | 70,301,155 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 499 | java | package com.oneday.service.state;
/**
* 接受者行为接口
* @author fanyongpeng [[email protected]]
* @version 1.0 2016/9/7 15:56
*/
public interface ReceiverState {
/**
* 接收追求
* @return 目标状态值
*/
Integer receive();
/**
* 拒绝
* @return
*/
Integer reject();
/**
* 接受
* @return 目标状态值
*/
Integer accept();
/**
* 承认
* @return 目标状态值
*/
Integer admit();
}
| [
"[email protected]"
] | |
4a3d8098ae8574ad035cc7ca42743c8e9f1f0a5b | 6a53b62e6cc1fd5a67ba094208d6e92059876357 | /app/src/androidTest/java/com/blacknebula/vocalfinder/ExampleInstrumentedTest.java | bc3fae164c61a8c21c14a8e8c204b3b772624090 | [
"MIT"
] | permissive | kill0u/VocalFinder | 59e6523080ddf834042d3552c12604df39142ae5 | d3f6f235d97267a8b548f49bc8027edafa705287 | refs/heads/master | 2022-12-19T16:49:16.775467 | 2020-10-28T11:53:32 | 2020-10-28T11:53:32 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 758 | java | package com.blacknebula.vocalfinder;
import android.content.Context;
import android.support.test.InstrumentationRegistry;
import android.support.test.runner.AndroidJUnit4;
import org.junit.Test;
import org.junit.runner.RunWith;
import static org.junit.Assert.*;
/**
* Instrumentation test, which will execute on an Android device.
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
@RunWith(AndroidJUnit4.class)
public class ExampleInstrumentedTest {
@Test
public void useAppContext() throws Exception {
// Context of the app under test.
Context appContext = InstrumentationRegistry.getTargetContext();
assertEquals("com.blacknebula.vocalfinder", appContext.getPackageName());
}
}
| [
"[email protected]"
] | |
3e835b9d7aaac07dac96925fe83c441e53ae0e92 | 671ad7e56d8e9909e5470a82398e44d281f3e5b9 | /src/main/java/ru/nsd/exceptions/UserBuildException.java | c8d0563dabef556f2ed8a06e711244c718aecbad | [] | no_license | hwimahw/LifePlanner | f733d88c6dc01f185a5787d069395dc01eee7e42 | 2a40a4ae454f2d24348fb8ef601312da5e67a15d | refs/heads/master | 2023-01-05T20:33:36.898568 | 2022-12-29T07:11:36 | 2022-12-29T07:11:36 | 223,160,731 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 209 | java | package ru.nsd.exceptions;
public class UserBuildException extends RuntimeException {
public UserBuildException() {
}
public UserBuildException(String message) {
super(message);
}
}
| [
"[email protected]"
] | |
a2830a38cd5644d59b3fa9deb46c714d612d37c5 | 7e651dc44a5fd2b636003958d7e5a283e1828318 | /minecraft/net/minecraft/client/renderer/block/statemap/BlockStateMapper.java | 37b961f3252ce89167ba4617ec8e6cf533e345e3 | [] | no_license | Niklas61/CandyClient | b05a1edc0d360dacc84fed7944bce5dc0a873be4 | 97e317aaacdcf029b8e87960adab4251861371eb | refs/heads/master | 2023-04-24T15:48:59.747252 | 2021-05-12T16:54:32 | 2021-05-12T16:54:32 | 352,600,734 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,369 | java | package net.minecraft.client.renderer.block.statemap;
import com.google.common.base.Objects;
import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.resources.model.ModelResourceLocation;
import java.util.Collections;
import java.util.Map;
import java.util.Set;
public class BlockStateMapper
{
private final Map<Block, IStateMapper> blockStateMap = Maps.newIdentityHashMap();
private final Set<Block> setBuiltInBlocks = Sets.newIdentityHashSet();
public void registerBlockStateMapper(Block p_178447_1_, IStateMapper p_178447_2_)
{
this.blockStateMap.put(p_178447_1_, p_178447_2_);
}
public void registerBuiltInBlocks(Block... p_178448_1_)
{
Collections.addAll(this.setBuiltInBlocks, p_178448_1_);
}
public Map<IBlockState, ModelResourceLocation> putAllStateModelLocations()
{
Map<IBlockState, ModelResourceLocation> map = Maps.newIdentityHashMap();
for (Block block : Block.blockRegistry)
{
if (!this.setBuiltInBlocks.contains(block))
{
map.putAll( Objects.firstNonNull(this.blockStateMap.get(block), new DefaultStateMapper()).putStateModelLocations(block));
}
}
return map;
}
}
| [
"[email protected]"
] | |
d79c7e34b1726ffd3f7b7522c7f082136498f6da | 959ed696338217c15c873d33bb86404427be87ef | /src/test/java/com/mcb/creditfactory/repository/CarRepositoryTest.java | 6ee35ee17992fe7d19b880608256920d4d9aa6cb | [] | no_license | nostrilsOfFate/mkb-test-task | 9037ec72715f571140f2e2b67138e51a372c4662 | 21224bfd6673d6890f828f73edbac02b55566f81 | refs/heads/master | 2020-12-06T18:31:58.687837 | 2020-01-09T17:54:02 | 2020-01-09T17:54:02 | 232,526,209 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,125 | java | package com.mcb.creditfactory.repository;
import com.mcb.creditfactory.model.Assessment;
import com.mcb.creditfactory.model.Car;
import com.mcb.creditfactory.util.CarTestData;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.jdbc.Sql;
import java.math.BigDecimal;
import java.time.LocalDate;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import static org.junit.jupiter.api.Assertions.*;
@Sql(scripts = "classpath:populateDB.sql")
@SpringBootTest
class CarRepositoryTest {
@Autowired
private CarRepository repository;
@Autowired
private AssessmentRepository assessmentRepository;
@Test
void create() {
Car car = new Car(null, "brand", "model", (short) 2020, 1.2);
Assessment assessment = new Assessment(null, BigDecimal.valueOf(1000000), LocalDate.now());
Assessment asSaved = assessmentRepository.save(assessment);
assertNotNull(asSaved);
car.setAssessments(Collections.singletonList(assessment));
Car actual = repository.save(car);
assertNotNull(actual);
assertNotNull(actual.getId());
assertNotNull(actual.getAssessments());
}
@Test
void getAll() {
List<Car> cars = repository.findAll();
assertNotNull(cars);
assertTrue(cars.size() > 0);
}
@Test
void get() {
Car car = repository.findById(1L).orElse(null);
assertNotNull(car);
}
@Test
void delete() {
repository.deleteById(1L);
assertEquals(3, repository.findAll().size());
}
@Test
void update() {
Car expected = repository.findById(1L).orElse(null);
assertNotNull(expected);
expected.setBrand("SUPER Brand");
Car savedCar = repository.save(expected);
assertNotNull(savedCar);
Car actual = repository.findById(1L).orElse(null);
assertNotNull(actual);
assertEquals(expected.getBrand(), actual.getBrand());
}
} | [
"[email protected]"
] | |
6775d7ca698e248265f2ce5435ccc238d93eed94 | 874197f5e6ba2abb8cd304d976fb22e3936c4370 | /app/src/main/java/com/vikcandroid/placexpress/comapany_fragments/Accommodation.java | 536651cca09d9cef66bbfa975d08b6946441f4ca | [] | no_license | Vikctar/OnLocation | 61a9e93ce5dde43518c54f9d4063912bce5270ee | 14e8808dbef64397fcd6bdbaa4df379954eb8b87 | refs/heads/master | 2021-01-17T14:22:55.701954 | 2016-07-22T13:32:28 | 2016-07-22T13:32:28 | 36,694,020 | 0 | 0 | null | 2016-07-22T13:32:29 | 2015-06-01T23:00:18 | Java | UTF-8 | Java | false | false | 2,960 | java | package com.vikcandroid.placexpress.comapany_fragments;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import com.vikcandroid.placexpress.Profile;
import com.vikcandroid.placexpress.R;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
public class Accommodation extends Fragment {
//Define an ArrayAdapter
private ArrayAdapter<String> mAccommodationAdapter;
// public constructor
public Accommodation() {
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.fragment_company, container, false);
// Once the rootView for the fragment has been created, it's time to
// populate the ListView with some data
// create the dat for the ListView
String[] accommodationArray = {
"Apartments", "Bed & Breakfast",
"Camping & Caravan", "Cottages",
"Guest Houses", "Hostels",
"Hotels & Motels", "Lodgings",
"Holiday Homes", "Self Catering Accommodation",
"Specialist Accommodation", "Homes", "Equipment"
};
List<String> accommodation = new ArrayList<>(Arrays.asList(accommodationArray));
// Now that we have some data, create an array adapter
// which will take some data from source and use it to
// populate the ListView it's attached to
mAccommodationAdapter =
new ArrayAdapter<>(
// The current context (this fragment's parent activity)
getActivity(),
// The ID of the list item to populate
R.layout.list_item,
// The ID of the text view to populate
R.id.list_item_textView,
// data
accommodation
);
// Get a reference to the listView and attach this adapter to it
ListView listView = (ListView) rootView.findViewById(R.id.listView_company);
listView.setAdapter(mAccommodationAdapter);
// Make the listView items clickable
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
String accommodate = mAccommodationAdapter.getItem(position);
Intent intent = new Intent(getActivity(), Profile.class).putExtra(Intent.EXTRA_TEXT, accommodate);
startActivity(intent);
}
});
return rootView;
}
}
| [
"[email protected]"
] | |
4ea68fb7bec3e31c0be8de5ab4d3f07fd6630519 | fe683ed48fb6d21e981b8a96d35d001a56dd294c | /app/src/main/java/com/weareforge/qms/activities/NewIndustyActivity.java | 795c0d1900757e8704cf90fb28bdbfcd4a3f024d | [] | no_license | amirmhrzan1/industrydiary | 421f187b65fa536a2fb473abf35c90c379f03962 | aa6e4077cfe453bddb90bf1e6f110eeeaeb2109d | refs/heads/master | 2021-01-11T02:11:48.610601 | 2016-08-01T04:03:13 | 2016-08-01T04:03:13 | 70,795,358 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 26,087 | java | package com.weareforge.qms.activities;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentManager;
import android.support.v4.content.ContextCompat;
import android.support.v4.view.PagerAdapter;
import android.support.v4.view.ViewPager;
import android.view.View;
import android.view.animation.AlphaAnimation;
import android.view.inputmethod.InputMethodManager;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.TextView;
import com.android.volley.Request;
import com.weareforge.qms.Objects.IndustryContacts;
import com.weareforge.qms.Objects.IndustryContactsStatic;
import com.weareforge.qms.Objects.UploadedImage;
import com.weareforge.qms.R;
import com.weareforge.qms.adapters.MyIndustryContactArrayAdapter;
import com.weareforge.qms.adapters.MyPageAdapter;
import com.weareforge.qms.alerts.Alerts;
import com.weareforge.qms.asyncTasks.VolleyRequest;
import com.weareforge.qms.fragments.EvidenceFragment;
import com.weareforge.qms.fragments.IndustryActivityFragment;
import com.weareforge.qms.fragments.IndustryContactFragment;
import com.weareforge.qms.fragments.IndustryEngagementFragment;
import com.weareforge.qms.fragments.StandardCompetenciesFragment;
import com.weareforge.qms.helpers.CommonDef;
import com.weareforge.qms.helpers.CommonMethods;
import com.weareforge.qms.helpers.UrlHelper;
import com.weareforge.qms.interfaces.AsyncInterface;
import com.weareforge.qms.utils.ConnectionMngr;
import com.weareforge.qms.utils.FontHelper;
import com.weareforge.qms.utils.Opener;
import com.weareforge.qms.utils.SharedPreference;
import java.util.ArrayList;
import java.util.HashMap;
/**
* Created by Admin on 1/7/2016.
*
*/
public class NewIndustyActivity extends FragmentActivity implements View.OnClickListener, AsyncInterface {
/**
* The pager widget, which handles animation and allows swiping horizontally to access previous
* and next wizard steps.
*/
public static ViewPager mPager = null;
private MyIndustryContactArrayAdapter adapter;
/**
* The pager adapter, which provides the pages to the view pager widget.
*/
private PagerAdapter mPagerAdapter;
private LinearLayout PgRelativeLayout;
private ListView industry_list;
private ImageView homeIcon;
private Button btnSaveProgess;
private TextView txtProgress;
private VolleyRequest vsr;
private HashMap<String, String> params;
private Alerts alerts;
private ConnectionMngr connectionMngr;
private String userid;
private String token;
private UrlHelper urlHelper;
private Opener opener;
private FontHelper fontHelper;
private SharedPreference sharedPreference;
public static int currentStep;
private AlphaAnimation buttonClick = new AlphaAnimation(1F, 0.2F);
private IndustryContactsStatic industryContactsStatic = new IndustryContactsStatic();
private IndustryContacts industryContacts;
ArrayList<IndustryContacts> industryContactStatic = new ArrayList<IndustryContacts>();
private IndustryEngagementFragment industryEngagementFragment;
private IndustryContactFragment industryContactFragment;
private IndustryActivityFragment industryActivityFragment;
private EvidenceFragment evidenceFragment;
private StandardCompetenciesFragment standardCompetenciesFragment;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//Full screen Window
/* getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
AndroidBug5497Workaround.assistActivity();
*/
setContentView(R.layout.activity_new_industry);
CommonMethods.setupUI(findViewById(R.id.relativeLayoutNewIndustry), this);
//Initialize
this.btnSaveProgess = (Button) findViewById(R.id.btnSaveProgress);
this.txtProgress = (TextView) findViewById(R.id.txtProgress);
// Instantiate a ViewPager and a PagerAdapter.
mPager = (ViewPager) findViewById(R.id.pager);
this.homeIcon = (ImageView) findViewById(R.id.homeIcon);
this.industry_list = new ListView(this);
this.opener = new Opener(this);
this.alerts = new Alerts(this);
this.connectionMngr = new ConnectionMngr(this);
this.sharedPreference = new SharedPreference(this);
token = sharedPreference.getStringValues("token");
userid = sharedPreference.getStringValues("userid");
this.currentStep = sharedPreference.getIntValues("Current_Step");
FragmentManager fragmentManager = getSupportFragmentManager();
mPager.setAdapter(new MyPageAdapter(fragmentManager,this.currentStep));
mPager.setOffscreenPageLimit(5);
//Font Helper
fontHelper = new FontHelper(this);
this.btnSaveProgess.setTypeface(fontHelper.getDefaultFont());
this.txtProgress.setTypeface(fontHelper.getDefaultFont("bold"));
btnSaveProgess.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
saveProgress();
}
});
// mPager.addView();
final ArrayList<Button> numButtons = new ArrayList<Button>();
this.PgRelativeLayout = (LinearLayout) findViewById(R.id.PlrelativeLayout);
for (int i = 0; i < 5; i++) {
Button btn_Pg = new Button(this);
btn_Pg.setBackground( ContextCompat.getDrawable(this, R.drawable.one_icon));
ContextCompat.getDrawable(this, R.drawable.one_icon);
final float scale = getResources().getDisplayMetrics().density;
LinearLayout.LayoutParams rel_button1 = new LinearLayout.LayoutParams((int) Math.round(30*scale), (int) Math.round(55*scale));
rel_button1.setMargins((int) Math.round(11 * scale), 0, 0, 0);
btn_Pg.setLayoutParams(rel_button1);
if (i == 0) {
btn_Pg.setBackground(ContextCompat.getDrawable(this, R.drawable.selecte_one_icon));
}else if(i==1)
{
btn_Pg.setBackground(ContextCompat.getDrawable(NewIndustyActivity.this, R.drawable.two_icon));
// if(i<=currentStep)
// {
// btn_Pg.setBackground(ContextCompat.getDrawable(NewIndustyActivity.this, R.drawable.two_icon));
// }
// else
// {
// btn_Pg.setBackground(ContextCompat.getDrawable(NewIndustyActivity.this, R.drawable.ic_two_icon));
// }
}
else if(i==2) {
btn_Pg.setBackground(ContextCompat.getDrawable(NewIndustyActivity.this, R.drawable.three_icon));
// if(i<=currentStep)
// {
// btn_Pg.setBackground(ContextCompat.getDrawable(NewIndustyActivity.this, R.drawable.three_icon));
// }
// else
// {
// btn_Pg.setBackground(ContextCompat.getDrawable(NewIndustyActivity.this, R.drawable.ic_three_icon));
// }
} else if(i==3) {
btn_Pg.setBackground(ContextCompat.getDrawable(NewIndustyActivity.this, R.drawable.four_icon));
// if(i<=currentStep)
// {
// btn_Pg.setBackground(ContextCompat.getDrawable(NewIndustyActivity.this, R.drawable.four_icon));
// }
// else
// {
// btn_Pg.setBackground(ContextCompat.getDrawable(NewIndustyActivity.this, R.drawable.ic_four_icon));
// }
}
else if(i==4) {
btn_Pg.setBackground(ContextCompat.getDrawable(NewIndustyActivity.this, R.drawable.five_icon));
// if (i <=currentStep) {
// btn_Pg.setBackground(ContextCompat.getDrawable(NewIndustyActivity.this, R.drawable.five_icon));
// } else {
// btn_Pg.setBackground(ContextCompat.getDrawable(NewIndustyActivity.this, R.drawable.ic_five_icon));
// }
}
final int finalI = i;
// if(i<=this.currentStep) {
btn_Pg.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
mPager.setCurrentItem(finalI);
View view = NewIndustyActivity.this.getCurrentFocus();
if (view != null) {
try {
InputMethodManager imm = (InputMethodManager) getSystemService(NewIndustyActivity.this.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
}catch (Exception exx){}
}
}
});
// }
this.PgRelativeLayout.addView(btn_Pg);
numButtons.add(btn_Pg);
}
mPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
@Override
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
}
@Override
public void onPageSelected(final int position) {
System.out.println("My current pos is: " + position);
Button imageView = numButtons.get(position);
for (int i = 0; i < 5; i++) {
Button btn_Pg = numButtons.get(i);
if (i == 0) {
btn_Pg.setBackground(ContextCompat.getDrawable(NewIndustyActivity.this, R.drawable.one_icon));
} else if(i==1)
{
btn_Pg.setBackground(ContextCompat.getDrawable(NewIndustyActivity.this, R.drawable.two_icon));
// if(i<=currentStep)
// {
// btn_Pg.setBackground(ContextCompat.getDrawable(NewIndustyActivity.this, R.drawable.two_icon));
// }
// else
// {
// btn_Pg.setBackground(ContextCompat.getDrawable(NewIndustyActivity.this, R.drawable.ic_two_icon));
// }
}
else if(i==2) {
btn_Pg.setBackground(ContextCompat.getDrawable(NewIndustyActivity.this, R.drawable.three_icon));
// if(i<=currentStep)
// {
// btn_Pg.setBackground(ContextCompat.getDrawable(NewIndustyActivity.this, R.drawable.three_icon));
// }
// else
// {
// btn_Pg.setBackground(ContextCompat.getDrawable(NewIndustyActivity.this, R.drawable.ic_three_icon));
// }
} else if(i==3) {
btn_Pg.setBackground(ContextCompat.getDrawable(NewIndustyActivity.this, R.drawable.four_icon));
// if(i<=currentStep)
// {
// btn_Pg.setBackground(ContextCompat.getDrawable(NewIndustyActivity.this, R.drawable.four_icon));
// }
// else
// {
// btn_Pg.setBackground(ContextCompat.getDrawable(NewIndustyActivity.this, R.drawable.ic_four_icon));
// }
}
else if(i==4) {
btn_Pg.setBackground(ContextCompat.getDrawable(NewIndustyActivity.this, R.drawable.five_icon));
// if (i <=currentStep) {
// btn_Pg.setBackground(ContextCompat.getDrawable(NewIndustyActivity.this, R.drawable.five_icon));
// } else {
// btn_Pg.setBackground(ContextCompat.getDrawable(NewIndustyActivity.this, R.drawable.ic_five_icon));
// }
}
}
final int finalI = position;
// if (finalI <= currentStep) {
imageView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
onPageSelected(finalI);
mPager.setCurrentItem(finalI);
}
});
if (position == 0) {
imageView.setBackground(ContextCompat.getDrawable(getApplicationContext(), R.drawable.selecte_one_icon));
// imageView.setTextColor(Color.WHITE);
} else if (position == 1) {
imageView.setBackground(ContextCompat.getDrawable(getApplicationContext(), R.drawable.select_two_icon));
} else if (position == 2) {
imageView.setBackground(ContextCompat.getDrawable(getApplicationContext(), R.drawable.select_three_icon));
} else if (position == 3) {
imageView.setBackground(ContextCompat.getDrawable(getApplicationContext(), R.drawable.selecte_four_icon));
} else if (position == 4) {
imageView.setBackground(ContextCompat.getDrawable(getApplicationContext(), R.drawable.selecte_five_icon));
}
/* else if(position ==5) {
imageView.setBackground(ContextCompat.getDrawable(getApplicationContext(), R.drawable.selecte_six_icon));
}*/
// }
}
@Override
public void onPageScrollStateChanged(int state) {
}
});
this.homeIcon.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if(!sharedPreference.getStringValues("Engagement_Evidence_Id").equalsIgnoreCase("")) {
saveProgress();
IndustryEngagementFragment.activityIds = new ArrayList<Integer>();
IndustryEngagementFragment.purposeIds = new ArrayList<Integer>();
sharedPreference.setKeyValues("flag", 0);
sharedPreference.setKeyValues("Engagement_Evidence_Id", "");
sharedPreference.setKeyValues("Industry_Engagement_Id", "");
sharedPreference.setKeyValues("Industry_Activity_Feedback_Id", "");
sharedPreference.setKeyValues("Evidence_Id", "");
sharedPreference.setKeyValues("Standard_Competency_Id", "");
sharedPreference.setKeyValues("Current_Step", 0);
UploadedImage.isDownloaded = false;
UploadedImage.filepath = "";
// DownloadActivity downloadActivity = new DownloadActivity();
// downloadActivity.DeleteTransfer();
// sharedPreference.setKeyValues("Industry_Engagement_Id","");
opener.Home();
overridePendingTransition(R.anim.slide_in_left, R.anim.slide_out_right);
}
else
{
opener.Home();
}
}
});
}
private void saveProgress() {
// FragmentPagerAdapter adapter = (FragmentPagerAdapter)mPager.getAdapter();
int index = mPager.getCurrentItem();
MyPageAdapter adapter = ((MyPageAdapter)mPager.getAdapter());
IndustryContactFragment fragment = (IndustryContactFragment) adapter.getItem(1);
android.support.v4.app.Fragment page = getSupportFragmentManager().findFragmentByTag("android:switcher:" + R.id.pager + ":" + fragment);
/* if(index == 0)
{
((IndustryEngagementFragment) page).SaveProgress();
}
else if(index == 1)
{
((IndustryContactFragment) page).SaveProgress();
}
else if(index == 2)
{
((IndustryActivityFragment) page).SaveProgress();
}
else if(index == 3)
{
((EvidenceFragment) page).SaveProgress();
}
else if(index == 4)
{
((StandardCompetenciesFragment) page).SaveProgress();
}*/
if(!sharedPreference.getStringValues("Engagement_Evidence_Id").equalsIgnoreCase("")) {
if (connectionMngr.hasConnection()) {
params = new HashMap<String, String>();
params.put("token", token);
params.put("userid", userid);
params.put("engagement_evidence_id", sharedPreference.getStringValues("Engagement_Evidence_Id"));
params.put("title", "");
if(sharedPreference.getStringValues("Standard_Competency_Id") != "")
{
params.put("current_step", "5");
if(sharedPreference.getStringValues("Evidence_Id")!="" && sharedPreference.getStringValues("Industry_Activity_Feedback_Id") != "")
{
params.put("status", "1");
}
else
{
params.put("status", "0");
}
}
else if(sharedPreference.getStringValues("Evidence_Id") != "")
{
params.put("current_step", "4");
params.put("status", "0");
}
else if(sharedPreference.getStringValues("Industry_Activity_Feedback_Id") != "")
{
params.put("current_step", "3");
params.put("status", "0");
}
else if((IndustryContactFragment) page!= null && ((IndustryContactFragment) page).listEngagedIndustry != null && !((IndustryContactFragment) page).listEngagedIndustry.isEmpty())
{
params.put("current_step", "2");
params.put("status", "0");
}
else
{
params.put("current_step", "1");
params.put("status", "0");
}
vsr = new VolleyRequest(NewIndustyActivity.this, Request.Method.POST, params, urlHelper.ENGAGEMENT_EVIDENCE, false, CommonDef.REQUEST_SAVE_PROGRESS_STEP_1,getResources().getString(R.string.saveProgress));
vsr.asyncInterface = NewIndustyActivity.this;
vsr.request();
}
}
else
{
alerts.showCreateEvidenceOkMessage("Please create evidence before proceed");
}
}
@Override
public void onBackPressed() {
if(!sharedPreference.getStringValues("Engagement_Evidence_Id").equalsIgnoreCase("")) {
saveProgress();
IndustryEngagementFragment.activityIds = new ArrayList<Integer>();
IndustryEngagementFragment.purposeIds = new ArrayList<Integer>();
sharedPreference.setKeyValues("flag", 0);
sharedPreference.setKeyValues("Engagement_Evidence_Id", "");
sharedPreference.setKeyValues("Industry_Engagement_Id", "");
sharedPreference.setKeyValues("Industry_Activity_Feedback_Id", "");
sharedPreference.setKeyValues("Evidence_Id", "");
sharedPreference.setKeyValues("Standard_Competency_Id", "");
sharedPreference.setKeyValues("Current_Step", 0);
UploadedImage.isDownloaded = false;
UploadedImage.filepath = "";
// DownloadActivity downloadActivity = new DownloadActivity();
// downloadActivity.DeleteTransfer();
// sharedPreference.setKeyValues("Industry_Engagement_Id","");
finish();
overridePendingTransition(R.anim.slide_in_left, R.anim.slide_out_right);
}
else
{
finish();
}
}
@Override
public void onClick(View v) {
}
@Override
public void processFinish(String result, int requestCode) {
if(industryEngagementFragment==null)
{
industryEngagementFragment = (IndustryEngagementFragment) mPager.getAdapter().instantiateItem(mPager, 0);
}
if(industryContactFragment==null)
{
industryContactFragment = (IndustryContactFragment) mPager.getAdapter().instantiateItem(mPager,1);
}
if(industryActivityFragment==null)
{
industryActivityFragment = (IndustryActivityFragment) mPager.getAdapter().instantiateItem(mPager,2);
}
if(evidenceFragment==null)
{
evidenceFragment = (EvidenceFragment) mPager.getAdapter().instantiateItem(mPager,3);
}
if(standardCompetenciesFragment==null)
{
standardCompetenciesFragment = (StandardCompetenciesFragment) mPager.getAdapter().instantiateItem(mPager,4);
}
switch (requestCode) {
//Industry Engagement Fragment
case CommonDef.REQUEST_INDUSTRY_ENGAGEMENT_ADD:
industryEngagementFragment.industryEngagementAddEdit(result);
break;
case CommonDef.REQUEST_LIST_INDUSTRY_ENGAGEMENT:
industryEngagementFragment.listIndustryengagement(result);
break;
case CommonDef.REQUEST_SAVE_PROGRESS_STEP_1:
industryEngagementFragment.requestSaveProgress(result);
break;
case CommonDef.REQUEST_LIST_ACTIVITY:
// industryEngagementFragment.listActivity(result);
break;
case CommonDef.REQUEST_LIST_PURPOSE:
// industryEngagementFragment.listPurpose(result);
break;
case CommonDef.REQUEST_LIST_ACCRED:
industryEngagementFragment.listAccred(result);
case CommonDef.REQUEST_LIST_FINDOUT:
// industryEngagementFragment.listFindOut(result);
//Industry Contact Fragment
case CommonDef.REQUEST_INDUSTRY_CONTACTS:
industryContactFragment.LoadIndustryContacts(result);
break;
case CommonDef.REQUEST_INDUSTRY_CONTACT_LIST:
industryContactFragment.loadIndustryContactList(result);
break;
case CommonDef.REQUEST_ENGAGEMENT_CONTACT_LIST:
industryContactFragment.loadEngagementConactList(result);
break;
case CommonDef.REQUEST_INDUSTRY_CONTACT_ADD:
industryContactFragment.requestIndustryContact(result);
break;
case CommonDef.REQUEST_ADD_EXISTING_CONTACTS:
industryContactFragment.addExistingContacts(result);
break;
case CommonDef.REQUEST_SAVE_PROGRESS_STEP_2:
industryContactFragment.requestSaveProgress(result);
break;
//Industry Activity Feedback
case CommonDef.REQUEST_INDUSTRY_ACTIVITY_FEEDBACK_UPSERT:
industryActivityFragment.industryActivityUpsert(result);
break;
case CommonDef.REQUEST_INDUSTRY_ACTIVITY_FEEDBACK_LIST:
industryActivityFragment.industryActivityList(result);
break;
case CommonDef.REQUEST_SAVE_PROGRESS_STEP_3:
industryActivityFragment.requestSaveProgress(result);
break;
//Evidence Fragement
case CommonDef.REQUEST_EVIDENCE_UPSERT:
evidenceFragment.evidenceUpsert(result);
break;
case CommonDef.REQUEST_EVIDENCE_LIST:
evidenceFragment.loadEvidenceList(result);
break;
case CommonDef.REQUEST_EVIDENCE_DATA:
evidenceFragment.loadEvidenceData(result);
break;
case CommonDef.REQUEST_SAVE_PROGRESS_STEP_4:
evidenceFragment.requestSaveProgress(result);
break;
//Standard Fragment
case CommonDef.REQUEST_LIST_ASAQ:
// standardCompetenciesFragment.listASAQ(result);
break;
case CommonDef.REQUEST_LIST_COMPETENCIES:
standardCompetenciesFragment.listCompentencies(result);
break;
case CommonDef.REQUEST_UPSERT_STANDARD_COMPETENCIES:
standardCompetenciesFragment.upsertStandardCompitencies(result);
break;
case CommonDef.REQUEST_LIST_STANDARD_COMPETENCIES:
standardCompetenciesFragment.loadStandardCompetenciesData(result);
break;
case CommonDef.REQUEST_SAVE_PROGRESS_STEP_5:
standardCompetenciesFragment.requestSaveProgress(result);
break;
}
}
@Override
protected void onDestroy() {
super.onDestroy();
IndustryEngagementFragment.activityIds.clear();
IndustryEngagementFragment.purposeIds.clear();
}
}
| [
"[email protected]"
] | |
ced0a6b4e93301faa6c0f5f4ceb2f701de8c8450 | 4e390e1d3ee8db4277d7e86c74e67730a3583a1b | /components/jacorb_components_sources/component-1/jacorb/test/regression/src/org/jacorb/test/orb/RecursiveParam.java | 28aa6ede714fedf787178266ce2250c733127e3a | [] | no_license | WasteService/WasteService.github.io | 6dd28b9673895dc53c00bfee751a0378d684813a | fefe1185e6c7a53806f28e759f5104904a80db01 | refs/heads/master | 2023-01-05T09:56:28.057174 | 2020-10-28T10:13:53 | 2020-10-28T10:13:53 | 307,663,150 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,787 | java | package org.jacorb.test.orb;
/*
* JacORB - a free Java ORB
*
* Copyright (C) 1997-2001 Gerald Brose.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library 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
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the Free
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
import junit.framework.Test;
import junit.framework.TestSuite;
import org.jacorb.test.RecursiveParamServer;
import org.jacorb.test.RecursiveParamServerHelper;
import org.jacorb.test.RecursiveParamServerPackage.Parm;
import org.jacorb.test.RecursiveParamServerPackage.blubT;
import org.jacorb.test.RecursiveParamServerPackage.blubTHelper;
import org.jacorb.test.RecursiveParamServerPackage.ParmPackage.ParmValue;
import org.jacorb.test.common.ClientServerSetup;
import org.jacorb.test.common.ClientServerTestCase;
public class RecursiveParam extends ClientServerTestCase
{
private RecursiveParamServer server;
public RecursiveParam(String name, ClientServerSetup setup)
{
super(name, setup);
}
public void setUp() throws Exception
{
server = RecursiveParamServerHelper.narrow( setup.getServerObject() );
}
protected void tearDown() throws Exception
{
server = null;
}
public static Test suite()
{
TestSuite suite = new TestSuite
( "Client/server recursiveparam tests" );
ClientServerSetup setup = new ClientServerSetup
( suite, RecursiveParamServerImpl.class.getName() );
suite.addTest( new RecursiveParam( "test_param1", setup ) );
return setup;
}
public void test_param1()
{
ParmValue pv = new ParmValue();
pv.string_value("inner");
Parm p = new Parm("v", pv );
ParmValue pvi = new ParmValue();
Parm[][] pp = new Parm[1][1];
pp[0] = new Parm[]{p};
pvi.nested_value( pp );
Parm outerParm = new Parm("outer", pvi );
server.passParm( outerParm );
org.omg.CORBA.Any any = setup.getClientOrb().create_any();
blubT union = new blubT();
blubT[] blubs = new blubT[0];
union.b( blubs );
blubTHelper.insert( any, union );
server.passAny( any );
}
}
| [
""
] | |
ee50190379ab0cc5adcd8d753f69c7cbbb4392e4 | bc7370cfb5ccc61072444d1dde0701abb7640cb2 | /lhdc/src/public/nc/vo/sxlhscm/lhdayproduct/AggDayProductHVOMeta.java | 8ee0dd8788d3a7a5b1fef8f54e29d2c80e2f4527 | [] | no_license | guowj1/lhprj | a4cf6f715d864a17dcef656cee02965c223777f2 | 70b5e6fabddeaf1db026591d817f0eab91704b58 | refs/heads/master | 2021-01-01T19:53:53.324175 | 2017-09-25T09:14:17 | 2017-09-25T09:14:17 | 98,713,984 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 537 | java | package nc.vo.sxlhscm.lhdayproduct;
import nc.vo.pubapp.pattern.model.meta.entity.bill.AbstractBillMeta;
public class AggDayProductHVOMeta extends AbstractBillMeta{
public AggDayProductHVOMeta(){
this.init();
}
private void init() {
this.setParent(nc.vo.sxlhscm.lhdayproduct.DayProductHVO.class);
this.addChildren(nc.vo.sxlhscm.lhdayproduct.DayProductBVO.class);
this.addChildren(nc.vo.sxlhscm.lhdayproduct.DayProductSVO.class);
this.addChildren(nc.vo.sxlhscm.lhdayproduct.DayProductIndeVO.class);
}
} | [
"[email protected]"
] | |
8e64ed12996bf86ffde60d5730853c7a6094d15c | 0e6557a73a00f0684a9f40f7f300f78dd633379b | /app/src/main/java/com/febriaroosita/swt/DisambiguatorPrefixRule18b.java | 21c668180ff7ff96bcc04cbdf3941798e34d59ab | [] | no_license | febriaroo/ieditor | 6b031f7d00c160dce23dac81eeca7014d821558a | eaa4b31697fddf83390630bacfd93fed3dbfba02 | refs/heads/master | 2021-01-21T13:07:40.866586 | 2015-12-16T20:37:27 | 2015-12-16T20:37:27 | 42,501,497 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 537 | java | package com.febriaroosita.swt;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
* Created by febria on 11/4/15.
*/
public class DisambiguatorPrefixRule18b implements DisambiguatorInterface
{
public String disambiguate(String word){
String match = "";
String pattern = "^meny([aiueo])(.*)$";
Pattern regEx = Pattern.compile(pattern);
Matcher m = regEx.matcher(word);
if (m.find()) {
match="s"+m.group(1)+m.group(2);
}
return match;
}
}
| [
"[email protected]"
] | |
18d01a4fc55910a392d07a33e8cf5a6736fd1e08 | ac23bc1191d743845bc23cd88fedb957a4bc930d | /MovingAverage/src/main/java/MapReduce/MRFramework/test.java | f3899f5d448e325083ddc30f2c3674ba128a255b | [] | no_license | pingrunhuang/LearningHadoop | 87d2d65577fc49549e38d7dd9f4af256f8707aab | 10a739cf6e540d1b2f5ce814824f713c7749935f | refs/heads/master | 2020-12-30T13:38:26.239353 | 2017-05-27T13:58:54 | 2017-05-27T13:58:54 | 91,230,835 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 696 | java | package MapReduce.MRFramework;
import org.junit.Test;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
public class test {
@Test
public void testCompositeKeyCompareTo(){
CompositeKey key1 = new CompositeKey("abc", 12345L);
CompositeKey key2 = new CompositeKey("abc", 1234L);
CompositeKey key3 = new CompositeKey("ab", 123L);
List<CompositeKey> keys = new ArrayList<CompositeKey>();
keys.add(key2);
keys.add(key3);
keys.add(key1);
Collections.sort(keys);
for (CompositeKey key : keys){
System.out.println(key.toString());
}
}
}
| [
"[email protected]"
] | |
c4eebffb6d27577ca3329ba4cf948953b566b003 | 5cf8888f01beee24b014c9e7525d68b0fa4325dc | /own/course_practise/src/main/java/observer/data_modification_listener/ForecastDisplay.java | 54c65c75e9b1205d56c44153fbca3d291c704bf3 | [
"Apache-2.0"
] | permissive | ljaljushkin/PatternPractise | b5b5272c5e4896d636b72c4b7852773a1fc0d872 | dfbe337f0da2428b37f6171a9522502c1e05e26f | refs/heads/master | 2021-01-10T08:10:49.270243 | 2015-12-09T07:27:33 | 2015-12-09T07:27:33 | 46,216,082 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,039 | java | package observer.data_modification_listener;
public class ForecastDisplay implements DataListener, DisplayElement {
private float currentPressure = 29.92f;
private float lastPressure;
private Initiator weatherData;
public ForecastDisplay(Initiator weatherData) {
this.weatherData = weatherData;
weatherData.registerListener(this);
}
@Override
public void someoneUpdateData(float temp, float humidity, float pressure) {
lastPressure = currentPressure;
currentPressure = pressure;
display();
}
public void display() {
System.out.print(this.getClass().getSimpleName() + "-----> Forecast: ");
if (currentPressure > lastPressure) {
System.out.println("Improving weather on the way!");
} else if (currentPressure == lastPressure) {
System.out.println("More of the same");
} else if (currentPressure < lastPressure) {
System.out.println("Watch out for cooler, rainy weather");
}
}
}
| [
"[email protected]"
] | |
17d046820b140ea30ec19b2e4e9d486a531f4f69 | c39d2f290467db4465ba857c94a3cd152f55513f | /src/main/java/br/com/teste/main/MainDAO.java | 26e04d19aa0c5d6296923e10aaaef0ba955bfe64 | [] | no_license | DfranciscoNogueira/usando-secondary-table-hibernate | 884d8d98d7b39ea4afb075fc46b315ff9dfc7118 | 068efa2a730933b7bfa630cc2641dd7303fa9fcd | refs/heads/master | 2021-01-15T08:36:42.039244 | 2016-09-18T03:09:39 | 2016-09-18T03:09:39 | 68,491,118 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 710 | java | package br.com.teste.main;
import java.util.List;
import org.hibernate.Query;
import br.com.teste.bean.Pessoa;
import br.com.teste.dao.DAO;
/**
*
* @author Diego_Francisco
*
*/
public class MainDAO extends DAO {
public static void main(String[] args) {
List<Pessoa> pessoas = findPessoas();
for (Pessoa pessoa : pessoas) {
System.out.println("Nome : " + pessoa.getNome());
System.out.println("SobreNome : " + pessoa.getSobrenome());
}
}
// obs usando HQL
@SuppressWarnings("unchecked")
public static List<Pessoa> findPessoas() {
Query query = getSession().createQuery("FROM Pessoa");
return query.list();
}
}
| [
"diego.francisco.nogueira"
] | diego.francisco.nogueira |
7cc71e2c82652f45ce1355e5175b0cec6bfdf564 | 77b7f3b87ef44182c5d0efd42ae1539a9b8ca14c | /src/main/java/com/turnengine/client/api/local/action/ActionCache.java | 9277ac2fc0677301be58853c1cd24a10cab61e1b | [] | no_license | robindrew/turnengine-client-api | b4d9e767e9cc8401859758d83b43b0104bce7cd1 | 5bac91a449ad7f55201ecd64e034706b16578c36 | refs/heads/master | 2023-03-16T05:59:14.189396 | 2023-03-08T14:09:24 | 2023-03-08T14:09:24 | 232,931,212 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 4,251 | java | package com.turnengine.client.api.local.action;
import static com.turnengine.client.api.local.action.ActionTargetType.SOURCE;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import com.google.common.collect.ImmutableList;
import com.robindrew.common.collect.indexmap.ArrayIndexMap;
import com.robindrew.common.collect.indexmap.IIndexMap;
import com.turnengine.client.api.local.unit.IUnit;
public class ActionCache implements IActionCache {
private final IIndexMap<IActionDefinition> idToDefinitionMap = new ArrayIndexMap<IActionDefinition>();
public ActionCache() {
}
public ActionCache(Collection<IAction> actions, Collection<IActionTarget> targets, Collection<IActionCondition> conditions) {
addActions(actions);
addTargets(targets);
addConditions(conditions);
}
@Override
public void addActions(Collection<IAction> actions) {
for (IAction action : actions) {
addAction(action);
}
}
@Override
public void addTargets(Collection<IActionTarget> targets) {
for (IActionTarget target : targets) {
addTarget(target);
}
}
@Override
public void addConditions(Collection<IActionCondition> conditions) {
for (IActionCondition condition : conditions) {
addCondition(condition);
}
}
@Override
public void addAction(IAction action) {
int actionId = action.getId();
IActionDefinition definition = idToDefinitionMap.get(actionId);
if (definition != null) {
throw new IllegalArgumentException("action already defined for id=" + actionId);
}
definition = new ActionDefinition(action);
idToDefinitionMap.put(actionId, definition);
}
@Override
public void addTarget(IActionTarget target) {
IActionDefinition definition = getDefinition(target.getId());
if (target.getTargetType().equals(SOURCE)) {
definition.setSource(target);
} else {
definition.setTarget(target);
}
}
@Override
public void addCondition(IActionCondition condition) {
IActionDefinition definition = getDefinition(condition.getId());
// TODO: Sanity checks
definition.addCondition(condition);
}
@Override
public List<IAction> getActions() {
List<IAction> list = new ArrayList<IAction>();
for (IActionDefinition definition : idToDefinitionMap.values()) {
list.add(definition.getAction());
}
return list;
}
@Override
public List<IActionTarget> getTargets() {
List<IActionTarget> list = new ArrayList<IActionTarget>();
for (IActionDefinition definition : idToDefinitionMap.values()) {
if (definition.hasSource()) {
list.add(definition.getSource());
}
if (definition.hasTarget()) {
list.add(definition.getTarget());
}
}
return list;
}
@Override
public List<IActionCondition> getConditions() {
List<IActionCondition> list = new ArrayList<IActionCondition>();
for (IActionDefinition definition : idToDefinitionMap.values()) {
list.addAll(definition.getConditions());
}
return list;
}
@Override
public IActionDefinition getDefinition(int unitId) {
IActionDefinition definition = idToDefinitionMap.get(unitId);
if (definition == null) {
throw new IllegalArgumentException("action not defined: " + unitId);
}
return definition;
}
@Override
public IActionDefinition getDefinition(IUnit unit) {
return getDefinition(unit.getId());
}
@Override
public IActionDefinition getDefinition(IAction action) {
return getDefinition(action.getId());
}
@Override
public int size() {
return idToDefinitionMap.size();
}
@Override
public boolean isEmpty() {
return size() == 0;
}
@Override
public void clear() {
idToDefinitionMap.clear();
}
@Override
public List<IActionDefinition> getAll() {
return idToDefinitionMap.values();
}
@Override
public boolean hasDefinition(int unitId) {
return idToDefinitionMap.containsKey(unitId);
}
@Override
public boolean hasDefinition(IUnit unit) {
return hasDefinition(unit.getId());
}
@Override
public boolean hasDefinition(IAction action) {
return hasDefinition(action.getId());
}
@Override
public Iterator<IActionDefinition> iterator() {
return getAll().iterator();
}
@Override
public List<IActionDefinition> getDefinitions() {
return ImmutableList.copyOf(idToDefinitionMap.values());
}
}
| [
"[email protected]"
] | |
55f86b499ab019ecdd93ff0fceff28d463da4484 | 2624a375473f6fe56233c8560363c286b199416f | /05ExpresionesRegulares/src/mx/com/test/PatternMatches.java | 3108ab02a19e82885ee6336214303d3b6bf28877 | [] | no_license | pablonolasco/Curso-Java-Profundida | 657ed61ab43dfb3f1c6d4a2b13425315de71c03a | 31ef8185ebe85c78d58eac1242cec9747755bb76 | refs/heads/master | 2023-04-02T22:13:42.134222 | 2021-04-18T16:19:50 | 2021-04-18T16:19:50 | 331,140,573 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,675 | java | /*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package mx.com.test;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
*
* @author Windows10
*/
public class PatternMatches {
public static void main(String[] args) {
String texto = "this is the text to matches"
+ "for ocurences of the pattern";
// patron a buscar
String pattern = ".*is.*";
boolean matches = Pattern.matches(pattern, texto);
System.out.println("matches=" + matches);
// split
// Patron o expresion regular
String pString = "for";
// compila la expresion
Pattern pattern1 = Pattern.compile(pString);
// con base al compilado le pasas el texto para que busque
String[] split = pattern1.split(texto);
System.out.println("split.length="+split.length);
for(String palabra: split){
System.out.println(palabra);
}
// Obtiene el patron
String pString1=pattern1.pattern();
System.out.println("patron:"+pString);
// Realiza operaciones de coincidencia
// Creamos la expresion regular;
Pattern pattern2=Pattern.compile("J.*\\d[0-35-9]-\\d\\d-\\d\\d");
// Comparamos la expresion regular
Matcher matcher=pattern2.matcher("Jane nacio el 05-12-75 \n"+
"Dave nacio el 10-12-94 \n");
while(matcher.find()){
System.out.println(matcher.group());
}
}
}
| [
"[email protected]"
] | |
5b0e30e0939ae3732d09f18674bae15215aa26be | b2ca6a40b25d590f0016c4f29c57b3e84bcc2364 | /Chaine de Responsabilité/src/TestDistributeur.java | e90f1203af786453f60a243c929655e23e8224fb | [] | no_license | Fantemis/Java | 7d1add394ecc27f713d72db498c0a217f7261ce6 | d7d89bfda9c4c58b8e0c0d2542bcc86a10cc492e | refs/heads/master | 2021-05-07T09:17:06.044359 | 2017-11-04T11:22:51 | 2017-11-04T11:22:51 | 109,488,883 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,697 | java | import java.util.List;
public class TestDistributeur {
public static void main(String[] args) {
Distributeur d = new Distributeur(10, 10, 10);
List<Couple> proposition = d.donnerBillets(10);
System.out.println(d.toStringProposition(proposition, 10));
d.recharger(10, 10, 10);
proposition = d.donnerBillets(20);
System.out.println(d.toStringProposition(proposition, 20));
d.recharger(10, 10, 10);
proposition = d.donnerBillets(30);
System.out.println(d.toStringProposition(proposition, 30));
d.recharger(10, 10, 10);
proposition = d.donnerBillets(40);
System.out.println(d.toStringProposition(proposition, 40));
d.recharger(10, 10, 10);
proposition = d.donnerBillets(50);
System.out.println(d.toStringProposition(proposition, 50));
d.recharger(10, 10, 10);
proposition = d.donnerBillets(60);
System.out.println(d.toStringProposition(proposition, 60));
d.recharger(10, 10, 10);
proposition = d.donnerBillets(70);
System.out.println(d.toStringProposition(proposition, 70));
d.recharger(10, 10, 10);
proposition = d.donnerBillets(100);
System.out.println(d.toStringProposition(proposition, 100));
d.recharger(10, 10, 10);
proposition = d.donnerBillets(110);
System.out.println(d.toStringProposition(proposition, 110));
d.recharger(10, 10, 10);
proposition = d.donnerBillets(210);
System.out.println(d.toStringProposition(proposition, 210));
d.recharger(10, 10, 10);
proposition = d.donnerBillets(310);
System.out.println(d.toStringProposition(proposition, 310));
d.recharger(10, 10, 10);
proposition = d.donnerBillets(3000);
System.out.println(d.toStringProposition(proposition, 3000));
}
}
| [
"[email protected]"
] | |
29e14be4e679e5a649dbadbf0e0bf97bea998b77 | 76427a65b7da7b1eb28deec9af803632266dbe54 | /src/main/java/com/jeeplus/modules/meiguotong/web/module/ModuleHtmlNameController.java | f1047260401097b3a9eb29183b4712a29632315d | [] | no_license | wmzrPsz/meiguotong | 9225eb103e60769aa46ccefb5c45e91368b40137 | 7eb89d08b0f271fab2544512969015f2ecd1df13 | refs/heads/master | 2022-12-22T09:01:38.852734 | 2019-06-07T07:26:28 | 2019-06-07T07:26:28 | 190,703,947 | 0 | 0 | null | 2022-12-16T10:51:45 | 2019-06-07T07:22:54 | Java | UTF-8 | Java | false | false | 7,825 | java | /**
* Copyright © 2015-2020 <a href="http://www.jeeplus.org/">JeePlus</a> All rights reserved.
*/
package com.jeeplus.modules.meiguotong.web.module;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.validation.ConstraintViolationException;
import org.apache.shiro.authz.annotation.Logical;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.servlet.mvc.support.RedirectAttributes;
import com.google.common.collect.Lists;
import com.jeeplus.common.utils.DateUtils;
import com.jeeplus.common.config.Global;
import com.jeeplus.common.json.AjaxJson;
import com.jeeplus.core.persistence.Page;
import com.jeeplus.core.web.BaseController;
import com.jeeplus.common.utils.StringUtils;
import com.jeeplus.common.utils.excel.ExportExcel;
import com.jeeplus.common.utils.excel.ImportExcel;
import com.jeeplus.modules.meiguotong.entity.module.ModuleHtmlName;
import com.jeeplus.modules.meiguotong.service.module.ModuleHtmlNameService;
/**
* 模块关联表Controller
* @author psz
* @version 2018-12-03
*/
@Controller
@RequestMapping(value = "${adminPath}/meiguotong/module/moduleHtmlName")
public class ModuleHtmlNameController extends BaseController {
@Autowired
private ModuleHtmlNameService moduleHtmlNameService;
@ModelAttribute
public ModuleHtmlName get(@RequestParam(required=false) String id) {
ModuleHtmlName entity = null;
if (StringUtils.isNotBlank(id)){
entity = moduleHtmlNameService.get(id);
}
if (entity == null){
entity = new ModuleHtmlName();
}
return entity;
}
/**
* 模块关联表列表页面
*/
@RequiresPermissions("meiguotong:module:moduleHtmlName:list")
@RequestMapping(value = {"list", ""})
public String list() {
return "modules/meiguotong/module/moduleHtmlNameList";
}
/**
* 模块关联表列表数据
*/
@ResponseBody
@RequiresPermissions("meiguotong:module:moduleHtmlName:list")
@RequestMapping(value = "data")
public Map<String, Object> data(ModuleHtmlName moduleHtmlName, HttpServletRequest request, HttpServletResponse response, Model model) {
Page<ModuleHtmlName> page = moduleHtmlNameService.findPage(new Page<ModuleHtmlName>(request, response), moduleHtmlName);
return getBootstrapData(page);
}
/**
* 查看,增加,编辑模块关联表表单页面
*/
@RequiresPermissions(value={"meiguotong:module:moduleHtmlName:view","meiguotong:module:moduleHtmlName:add","meiguotong:module:moduleHtmlName:edit"},logical=Logical.OR)
@RequestMapping(value = "form")
public String form(ModuleHtmlName moduleHtmlName, Model model) {
model.addAttribute("moduleHtmlName", moduleHtmlName);
if(StringUtils.isBlank(moduleHtmlName.getId())){//如果ID是空为添加
model.addAttribute("isAdd", true);
}
return "modules/meiguotong/module/moduleHtmlNameForm";
}
/**
* 保存模块关联表
*/
@RequiresPermissions(value={"meiguotong:module:moduleHtmlName:add","meiguotong:module:moduleHtmlName:edit"},logical=Logical.OR)
@RequestMapping(value = "save")
public String save(ModuleHtmlName moduleHtmlName, Model model, RedirectAttributes redirectAttributes) throws Exception{
if (!beanValidator(model, moduleHtmlName)){
return form(moduleHtmlName, model);
}
//新增或编辑表单保存
moduleHtmlNameService.save(moduleHtmlName);//保存
addMessage(redirectAttributes, "保存模块关联表成功");
return "redirect:"+Global.getAdminPath()+"/meiguotong/module/moduleHtmlName/?repage";
}
/**
* 删除模块关联表
*/
@ResponseBody
@RequiresPermissions("meiguotong:module:moduleHtmlName:del")
@RequestMapping(value = "delete")
public AjaxJson delete(ModuleHtmlName moduleHtmlName, RedirectAttributes redirectAttributes) {
AjaxJson j = new AjaxJson();
moduleHtmlNameService.delete(moduleHtmlName);
j.setMsg("删除模块关联表成功");
return j;
}
/**
* 批量删除模块关联表
*/
@ResponseBody
@RequiresPermissions("meiguotong:module:moduleHtmlName:del")
@RequestMapping(value = "deleteAll")
public AjaxJson deleteAll(String ids, RedirectAttributes redirectAttributes) {
AjaxJson j = new AjaxJson();
String idArray[] =ids.split(",");
for(String id : idArray){
moduleHtmlNameService.delete(moduleHtmlNameService.get(id));
}
j.setMsg("删除模块关联表成功");
return j;
}
/**
* 导出excel文件
*/
@ResponseBody
@RequiresPermissions("meiguotong:module:moduleHtmlName:export")
@RequestMapping(value = "export", method=RequestMethod.POST)
public AjaxJson exportFile(ModuleHtmlName moduleHtmlName, HttpServletRequest request, HttpServletResponse response, RedirectAttributes redirectAttributes) {
AjaxJson j = new AjaxJson();
try {
String fileName = "模块关联表"+DateUtils.getDate("yyyyMMddHHmmss")+".xlsx";
Page<ModuleHtmlName> page = moduleHtmlNameService.findPage(new Page<ModuleHtmlName>(request, response, -1), moduleHtmlName);
new ExportExcel("模块关联表", ModuleHtmlName.class).setDataList(page.getList()).write(response, fileName).dispose();
j.setSuccess(true);
j.setMsg("导出成功!");
return j;
} catch (Exception e) {
j.setSuccess(false);
j.setMsg("导出模块关联表记录失败!失败信息:"+e.getMessage());
}
return j;
}
/**
* 导入Excel数据
*/
@RequiresPermissions("meiguotong:module:moduleHtmlName:import")
@RequestMapping(value = "import", method=RequestMethod.POST)
public String importFile(MultipartFile file, RedirectAttributes redirectAttributes) {
try {
int successNum = 0;
int failureNum = 0;
StringBuilder failureMsg = new StringBuilder();
ImportExcel ei = new ImportExcel(file, 1, 0);
List<ModuleHtmlName> list = ei.getDataList(ModuleHtmlName.class);
for (ModuleHtmlName moduleHtmlName : list){
try{
moduleHtmlNameService.save(moduleHtmlName);
successNum++;
}catch(ConstraintViolationException ex){
failureNum++;
}catch (Exception ex) {
failureNum++;
}
}
if (failureNum>0){
failureMsg.insert(0, ",失败 "+failureNum+" 条模块关联表记录。");
}
addMessage(redirectAttributes, "已成功导入 "+successNum+" 条模块关联表记录"+failureMsg);
} catch (Exception e) {
addMessage(redirectAttributes, "导入模块关联表失败!失败信息:"+e.getMessage());
}
return "redirect:"+Global.getAdminPath()+"/meiguotong/module/moduleHtmlName/?repage";
}
/**
* 下载导入模块关联表数据模板
*/
@RequiresPermissions("meiguotong:module:moduleHtmlName:import")
@RequestMapping(value = "import/template")
public String importFileTemplate(HttpServletResponse response, RedirectAttributes redirectAttributes) {
try {
String fileName = "模块关联表数据导入模板.xlsx";
List<ModuleHtmlName> list = Lists.newArrayList();
new ExportExcel("模块关联表数据", ModuleHtmlName.class, 1).setDataList(list).write(response, fileName).dispose();
return null;
} catch (Exception e) {
addMessage(redirectAttributes, "导入模板下载失败!失败信息:"+e.getMessage());
}
return "redirect:"+Global.getAdminPath()+"/meiguotong/module/moduleHtmlName/?repage";
}
} | [
"[email protected]"
] | |
548d1c66cd505fd89c710ace0c707bde712c20df | 8a6ad0a4ed3668b116510a4e78a685576218ea96 | /SuperSimpleStocks/src/main/java/gbce/stocks/BuyOrSell.java | 2dc74139a073db1cdada7a70ed08fa7e15004076 | [] | no_license | IainMuir/Super-Simple-Stocks | bb62e886e4b5f550b54841518e9279d7b1337cc1 | 7ad5a6d33abb8402a36fa053b85e89f770756d89 | refs/heads/master | 2021-01-11T22:28:26.737725 | 2017-01-15T02:25:59 | 2017-01-15T02:25:59 | 78,967,604 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 66 | java | package gbce.stocks;
public enum BuyOrSell {
BUY,
SELL
}
| [
"[email protected]"
] | |
1f89822b39f3d28c091d0fe8adf0b1e0eff2d1fa | dcefd96a707d439ca2248eceeb0f63d32a7ae7eb | /spring-boot-jpa-repo/src/main/java/com/example/jpa/entity/Album.java | 277ad748073f44b05e9337391d41ac8a19eca911 | [] | no_license | kavya-amin/FSD-Spring-Boot | d7d0105bbbaa6ace26815e7d26fb3f59d59565d4 | f29bf57a4baf774d09962dee06cd919e76a4aba1 | refs/heads/master | 2023-04-27T17:08:34.639768 | 2019-12-16T05:41:17 | 2019-12-16T05:41:17 | 219,980,316 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 776 | java | package com.example.jpa.entity;
import java.util.List;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import lombok.Data;
@Entity
@Table(name = "album")
@Data
public class Album {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "id")
int id;
@Column(name = "album_name")
String albumName;
@OneToMany(fetch = FetchType.LAZY, mappedBy = "album", cascade = {CascadeType.PERSIST,CascadeType.MERGE,
CascadeType.DETACH, CascadeType.REFRESH})
private List<Image> images;
}
| [
"[email protected]"
] | |
44dfa9ec9885d952155708f08f6ba2fde579e1bf | a1e035b37dca560f0018c1cfb0af938fef273f39 | /gate-server/src/main/java/com/ppdai/stargate/service/ApplyService.java | 767b0be6f47ca5d973ea71e2cd5175d3d68b2209 | [
"Apache-2.0"
] | permissive | IceRedTea/stargate | b80b6f0111d04fbad5b8d026eccb1f0130596ccc | a4ae2540f512f374af149ea5b94303dc1db8a484 | refs/heads/master | 2023-03-08T13:12:26.978566 | 2021-03-01T05:48:55 | 2021-03-01T05:48:55 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,359 | java | package com.ppdai.stargate.service;
import com.alibaba.fastjson.JSON;
import com.ppdai.atlas.client.api.ApplyControllerApi;
import com.ppdai.atlas.client.invoker.ApiException;
import com.ppdai.atlas.client.model.ApplyDto;
import com.ppdai.atlas.client.model.ResponsePageVOApplyDto;
import com.ppdai.auth.common.identity.Identity;
import com.ppdai.auth.utils.PauthTokenUtil;
import com.ppdai.stargate.constant.ApplyStatus;
import com.ppdai.stargate.constant.ApplyType;
import com.ppdai.stargate.controller.response.MessageType;
import com.ppdai.stargate.exception.BaseException;
import com.ppdai.stargate.po.ApplicationEntity;
import com.ppdai.stargate.vi.ApplyNewAppVI;
import com.ppdai.stargate.vi.ChangeAppQuotaVI;
import com.ppdai.stargate.vo.PageVO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@Service
@Slf4j
public class ApplyService {
@Autowired
private ApplyControllerApi atlasApplyControllerApi;
@Autowired
private AppService appService;
@Autowired
private PauthTokenUtil pauthTokenUtil;
public void newApp(ApplyNewAppVI applyNewAppVI) {
Identity identity = pauthTokenUtil.getTokenInfo();
ApplyDto apply = new ApplyDto();
apply.setApplyUser(identity.getName());
apply.setApplyDepartment(identity.getOrganzation());
apply.setType(ApplyType.NEW_APP.name());
apply.setStatus(ApplyStatus.NEW.name());
apply.setRequest(JSON.toJSONString(applyNewAppVI));
try {
atlasApplyControllerApi.createApplyUsingPOST(apply);
} catch (ApiException e) {
log.error(e.getMessage(), e);
throw BaseException.newException(MessageType.ERROR, "向atlas提交应用申请失败: err=" + e.getMessage() + ", responsebody=" + e.getResponseBody());
}
}
public void changeAppQuota(ChangeAppQuotaVI changeAppQuotaVI) {
Identity identity = pauthTokenUtil.getTokenInfo();
ApplyDto apply = new ApplyDto();
apply.setApplyUser(identity.getName());
apply.setApplyDepartment(identity.getOrganzation());
apply.setType(ApplyType.CHANGE_QUOTA.name());
apply.setStatus(ApplyStatus.NEW.name());
ApplicationEntity applicationEntity = appService.getAppByCmdbId(changeAppQuotaVI.getAppId());
changeAppQuotaVI.setAppName(applicationEntity.getName());
apply.setRequest(JSON.toJSONString(changeAppQuotaVI));
try {
atlasApplyControllerApi.createApplyUsingPOST(apply);
} catch (ApiException e) {
log.error(e.getMessage(), e);
throw BaseException.newException(MessageType.ERROR, "向atlas配额修改申请失败: err=" + e.getMessage() + ", responsebody=" + e.getResponseBody());
}
}
public PageVO<ApplyDto> getByPage(String applyUser, String status, int page, int size) throws ApiException {
ResponsePageVOApplyDto responsePageVOApplyDto = atlasApplyControllerApi.queryByPageUsingGET(page - 1, size, applyUser, status);
PageVO<ApplyDto> applyPageVO = new PageVO<>();
applyPageVO.setContent(responsePageVOApplyDto.getDetails().getContent());
applyPageVO.setTotalElements(responsePageVOApplyDto.getDetails().getTotalElements());
return applyPageVO;
}
}
| [
"[email protected]"
] | |
2c5c9a40c0f7d581163bd58bd7cb1dcb8ab1e2de | 1f35fba66d5167a2dc41cba836301e632ade0dc4 | /GameDev/GameMaker/GMBuilder/src/com/cristiano/java/gm/builder/factory/BuilderFactory.java | 968fb534a2c501679f01ed9060da04e17bb47321 | [] | no_license | cristianoferr/projetos | 67ccfaa3d8e6701c70a5135f3675d5fd3099ef9f | 1d00a2ba9cd5180243afdc61730d95caae188c0f | refs/heads/master | 2021-01-17T13:06:38.352334 | 2017-07-31T19:13:46 | 2017-07-31T19:13:46 | 19,613,602 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,504 | java | package com.cristiano.java.gm.builder.factory;
import java.io.IOException;
import java.util.List;
import com.cristiano.consts.Extras;
import com.cristiano.java.bpM.ElementManager;
import com.cristiano.java.bpM.entidade.AbstractElement;
import com.cristiano.java.gm.consts.GameComps;
import com.cristiano.java.gm.ecs.EntityManager;
import com.cristiano.java.gm.ecs.comps.unit.UnitClassComponent;
import com.cristiano.java.gm.interfaces.IGameEntity;
import com.cristiano.java.gm.product.factory.ProductFactory;
import com.cristiano.java.gm.units.UnitStorage;
import com.cristiano.java.gm.units.UnitStorageBuilder;
import com.cristiano.java.product.IGameElement;
import com.cristiano.java.product.IManageElements;
import com.cristiano.jme3.assets.GMAssets;
import com.cristiano.utils.Log;
import com.jme3.asset.AssetManager;
import com.jme3.export.Savable;
import com.jme3.export.xml.XMLExporter;
public class BuilderFactory extends ProductFactory {
private ElementManager elm;
protected XMLExporter exporter=new XMLExporter();
public BuilderFactory(IManageElements em, EntityManager entMan, AssetManager assetManager) {
super(em, entMan,assetManager);
elm = (ElementManager) em;
adicionaComponentesMap();
}
protected void adicionaComponentesMap() {
if (elm==null){
Log.error("ELM is null!");
return;
}
List<IGameElement> components = elm.getElementsWithTag(GameComps.TAG_ALL_COMPONENTS);
for (IGameElement comp : components) {
IGameElement el=(IGameElement) comp;
String classe = getClasseFromComponent(el);
String ident = el.getProperty(Extras.PROPERTY_IDENTIFIER);
String pack = ((AbstractElement) el).getParamH(Extras.LIST_DOMAIN, Extras.DOMAIN_PACKAGE, true).replace("'", "");
addClasse(ident, pack + classe);
}
}
@Override
public IGameEntity createEntityFromTag(String tag) {
return createEntityFromTag(tag, null);
}
@Override
public void loadComponents(IGameEntity entity, String tag){
IGameElement ge = elm.pickFinal(tag, null, null);
if (ge == null) {
Log.error("tag invalida:" + tag);
return;
}
loadComponents(entity, ge);
}
@Override
public IGameEntity createEntityFromTag(String tag, String props) {
IGameElement ge = elm.pickFinal(tag, null, props);
if (ge == null) {
Log.error("tag invalida:" + tag);
return null;
}
return createEntityFrom(ge);
}
@Override
public IGameEntity createEntityFromIdentifier(String identifier) {
IGameElement ge = elm.createFinalElement(elm.getElementByIdentifier(identifier));
if (ge == null) {
Log.error("tag invalida:" + identifier);
return null;
}
String id = ge.id();
return createEntityFrom(ge);
}
@Override
public UnitStorage createUnitStorage( IManageElements em,EntityManager entMan) {
return new UnitStorageBuilder(em,entMan.getFactory(),entMan);
}
@Override
public String exportSavable(String entId, String type,Savable node) {
if (node==null){
return null;
}
String path = GMAssets.getPathForSavableEntity(entId,type);
try {
GMAssets.deleteAsset(path);
exporter.save(node, GMAssets.getOutputStream(path));
if (!GMAssets.assetExists(path)){
Log.fatal("Asset '"+path+"' was not found...");
}
} catch (IOException e) {
e.printStackTrace();
}
return path;
}
@Override
public String exportSavable(int entId, String type,Savable node) {
return exportSavable(Integer.toString(entId),type,node);
}
public void setElementManager(ElementManager em) {
this.elm=em;
this.em=em;
}
}
| [
"[email protected]"
] | |
51406c1298df6c31ba5a898bca1a95c6b458a3cc | 39d47ee091b6de167905791945687fc7426a2792 | /src/main/java/com/ge/predix/cyber/csam/ehsender/services/StatsService.java | 552d3f8e25562b349eb51ff34e18b57a7bee6304 | [] | no_license | saggik/eh-sender | 107dbcd3041114da3f7b858475c282fbfa0cde44 | 9d741cb2258c5487a8e283f42fad1cb322330259 | refs/heads/master | 2020-12-02T19:17:56.910443 | 2017-07-05T13:06:31 | 2017-07-05T13:06:31 | 96,320,121 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 291 | java | package com.ge.predix.cyber.csam.ehsender.services;
public interface StatsService {
String getStats();
int incrementAndGetSent();
int incrementAndGetAccepted();
int incrementAndGetFailed();
int incrementAndGetExceptions();
int incrementAndGetReconnects();
void clearAllCounters();
}
| [
"[email protected]"
] | |
6b34230c65a76bf2f681f8fc7eb09246a9fe81a4 | c2d9b3ba042ec2121cbbbc0b0d4305097085a67f | /src/main/java/springframework/converters/IngredientCommandToIngredient.java | 0bcfad0c22958d3a348797fe5648fdc852326d9b | [] | no_license | siddharthashankarblore/spring5-mongo-recipe-app | 9722de6a623772e2e2c94775b05a8a85484e5e69 | 4d95222135e9589f5a29716f9bb98d779701c3b4 | refs/heads/master | 2020-06-26T22:51:20.513364 | 2019-07-31T14:37:41 | 2019-07-31T14:37:41 | 199,778,856 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,371 | java | package springframework.converters;
import springframework.commands.IngredientCommand;
import springframework.domain.Ingredient;
import springframework.domain.Recipe;
import org.springframework.core.convert.converter.Converter;
import org.springframework.lang.Nullable;
import org.springframework.stereotype.Component;
/**
* Created by jt on 6/21/17.
*/
@Component
public class IngredientCommandToIngredient implements Converter<IngredientCommand, Ingredient> {
private final UnitOfMeasureCommandToUnitOfMeasure uomConverter;
public IngredientCommandToIngredient(UnitOfMeasureCommandToUnitOfMeasure uomConverter) {
this.uomConverter = uomConverter;
}
@Nullable
@Override
public Ingredient convert(IngredientCommand source) {
if (source == null) {
return null;
}
final Ingredient ingredient = new Ingredient();
ingredient.setId(source.getId());
if(source.getRecipeId() != null){
Recipe recipe = new Recipe();
recipe.setId(source.getRecipeId());
ingredient.setRecipe(recipe);
recipe.addIngredient(ingredient);
}
ingredient.setAmount(source.getAmount());
ingredient.setDescription(source.getDescription());
ingredient.setUom(uomConverter.convert(source.getUom()));
return ingredient;
}
}
| [
"[email protected]"
] | |
3163601d19a2c55db3580bb4642492e70d6cca63 | bca9e0f6bc8da05f151b15af4e7c5aef9e7c12ab | /ch02/HelloWorldApp.java | bea0b7f42f99b538fad739625d8ba39db8f91dbf | [] | no_license | PengShanshan99/SoftwareDevelopmentPractice | 5a0fdae26a70136c75f268f6873e1ff1b17dccc7 | 4cf0b11681c9fab0132f62962bcbbf8ea3a64756 | refs/heads/master | 2020-03-20T20:40:07.564569 | 2018-08-17T08:02:44 | 2018-08-17T08:02:44 | 137,699,874 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 124 | java | public class HelloWorldApp {
public static void main (String args[] ){
System.out.println("Hello World!")
}
}
| [
"[email protected]"
] | |
83d394563e5f589867c4ced5bcd9a3152de97c39 | 18ef51388272d898489ff95217583b54a7db001e | /MainApp/Servers/SAGA-API/src/main/java/saga/events/vehiclePartsEvents/CategoryRollbackEvent.java | c2cce50c4e36a9f9875054ac60a3cd0ad97ebe46 | [] | no_license | mihajlo-perendija/XML_WS | 3af15ac23bf59bf7115debe54a2818f2b13b8ba1 | c824109180c948d2801d86a9f710af1f4206dfc9 | refs/heads/master | 2022-11-24T12:49:22.675449 | 2020-07-11T19:35:10 | 2020-07-11T19:35:10 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 761 | java | package saga.events.vehiclePartsEvents;
import saga.commands.TypeOfCommand;
public class CategoryRollbackEvent {
private Long categoryId;
private TypeOfCommand typeOfCommand;
public CategoryRollbackEvent(){
}
public CategoryRollbackEvent(Long categoryId, TypeOfCommand typeOfCommand) {
this.categoryId = categoryId;
this.typeOfCommand = typeOfCommand;
}
public Long getCategoryId() {
return categoryId;
}
public void setCategoryId(Long categoryId) {
this.categoryId = categoryId;
}
public TypeOfCommand getTypeOfCommand() {
return typeOfCommand;
}
public void setTypeOfCommand(TypeOfCommand typeOfCommand) {
this.typeOfCommand = typeOfCommand;
}
}
| [
"[email protected]"
] | |
9728a8b2b0fd8d38750e266e1a5f2bb6405c5174 | 0f67df05f6f62556a9bb9883cc355d3cd0d095eb | /Assertion.java | efaea745434c06d3810567484ba81393a9866b5b | [] | no_license | Shailendra-Java/Basics-of-java | 884f173047c7b89e86b550807810f870c0944a2d | 92be749b1828ccee737fd335c3bcb690d127c179 | refs/heads/master | 2022-12-21T02:48:58.369318 | 2022-12-10T14:46:35 | 2022-12-10T14:46:35 | 117,135,657 | 5 | 6 | null | 2022-12-10T14:48:49 | 2018-01-11T18:13:32 | Java | UTF-8 | Java | false | false | 296 | java | class Assertion
{
static int val = 3;
// Return an integer.
static int getnum()
{
return val--;
}
public static void main(String args[])
{
int n;
for(int i=0; i < 10; i++)
{
n = getnum();
assert n > 0; // will fail when n is 0
System.out.println("n is " + n);
}
}
}
| [
"[email protected]"
] | |
59d8aa1aa8e3a8755baf397f9c636a5cbdd70390 | 3ea2af490a593c179bda8bfa53fa150c4fe2e494 | /hasib/Face.java | 4a4879635046e9f8f42dd7648e06f09dd4f63bc4 | [] | no_license | hasibulhasib18/CG-Lab | 03660ccd2771b1b750a46f9f60686089466361f1 | 23a0d790b530d6912573492e449f65eb66a5c610 | refs/heads/master | 2020-03-26T05:02:44.968416 | 2018-08-13T06:01:50 | 2018-08-13T06:01:50 | 144,535,783 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 731 | java | package h1;
import java.awt.Graphics;
import java.awt.Color;
import javax.swing.JFrame;
public class Face extends JFrame
{
public Face()
{
setTitle("FaceDraw");
setSize(960,960);
setVisible(true);
setDefaultCloseOperation(EXIT_ON_CLOSE);
}
public void paint(Graphics g)
{
g.setColor(Color.yellow);
g.fillOval(250, 200, 350, 350);
//g.setColor(Color.YELLOW)
//g.dOval(250,200,350,350);
g.setColor(Color.black);
g.fillOval(350,290,40,10);
g.setColor(Color.black);
g.fillOval(460,290,40,10);
g.setColor(Color.black);
g.fillRect(355,460,150,8);
}
public static void main(String[] args)
{
Face f = new Face();
}
}
| [
"[email protected]"
] | |
dededf18cefd1eb2aef99b895b8aced87e6fb19d | f1ee6daa3bc85dc958acda6a95bf24b16ab17a0b | /src/main/java/com/rbac/domain/User.java | 6a105d4d536686a259d38e640bbd4ac66fc3c8ea | [] | no_license | rRupeshRanjan/spring-security-demo | 4aea82406e4e96ba4b338291883cfe59d0d76891 | 26fa3dc069d75ce79ea31646d469c5ace8557372 | refs/heads/master | 2023-03-02T16:54:10.323912 | 2021-02-02T07:02:25 | 2021-02-02T07:02:25 | 289,476,564 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 810 | java | package com.rbac.domain;
import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import javax.persistence.*;
import java.util.Collection;
@Data
@AllArgsConstructor
@NoArgsConstructor
@Entity
public class User {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
private String firstName;
private String lastName;
private String email;
private boolean enabled;
@JsonIgnore
private String password;
@ManyToMany
@JoinTable(name = "users_roles",
joinColumns = @JoinColumn(name = "user_id", referencedColumnName = "id"),
inverseJoinColumns = @JoinColumn(name = "role_id", referencedColumnName = "id"))
private Collection<Role> roles;
}
| [
"[email protected]"
] | |
3a3835b6e16cf5792cf2cc8f667bea369620d031 | 0831dfb10b82f6d97c1eecf33d8cbf538effe0e1 | /photoselecter/src/main/java/utils/ViewPagerFixed.java | 632da4ab4b220ee07f0ed5960dcb426c57933983 | [] | no_license | choubaguai/PhotoSelecter | 628a9f7ea9a27104f8d19518f7a1d4d79222789e | 15ea734f5f3b45b9b0349db7ef99dc1ea227cdf3 | refs/heads/master | 2021-01-20T20:53:34.694221 | 2016-07-22T09:02:33 | 2016-07-22T09:02:33 | 63,753,596 | 3 | 0 | null | null | null | null | UTF-8 | Java | false | false | 952 | java | package utils;
import android.content.Context;
import android.support.v4.view.ViewPager;
import android.util.AttributeSet;
import android.view.MotionEvent;
/**
* 修复图片在ViewPager控件中缩放报错的BUG
*/
public class ViewPagerFixed extends ViewPager {
public ViewPagerFixed(Context context) {
super(context);
}
public ViewPagerFixed(Context context, AttributeSet attrs) {
super(context, attrs);
}
@Override
public boolean onTouchEvent(MotionEvent ev) {
try {
return super.onTouchEvent(ev);
} catch (IllegalArgumentException ex) {
ex.printStackTrace();
}
return false;
}
@Override
public boolean onInterceptTouchEvent(MotionEvent ev) {
try {
return super.onInterceptTouchEvent(ev);
} catch (IllegalArgumentException ex) {
ex.printStackTrace();
}
return false;
}
}
| [
"[email protected]"
] | |
ee9b8198d23ccde3312a17d70c7195600f0fc932 | 2fc471ee2198ca596bd7fbdbb6b4cd5227d55db1 | /src/main/java/se2xb3/data/processing/IProcessor.java | 69d353ab5ed4258748138300be872932a88d1761 | [] | no_license | DawsonMyers/TwitterTrends | cf78595e43129c820edf76ff0f38e42b3d578ac1 | 50cd021e8b0521bec99736f368b3d2641ee8aad4 | refs/heads/master | 2021-01-20T18:39:32.380990 | 2017-05-11T02:16:10 | 2017-05-11T02:16:10 | 90,926,500 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 289 | java | package se2xb3.data.processing;
/**
* Classes that implement this interface provide a strategy for processing an
* instance of a generic parametrized type.
* @author Dawson
* @version 1.0
* @since 3/11/2017
*/
public interface IProcessor<T> {
Object process(T t);
}
| [
"[email protected]"
] | |
d8be026e4deff11ded6fb62cc915b37a50ef40a8 | 79bb32e1e964e4e31d444e548b839ba783a14f3a | /FigureDrawingPractis/src/util/Util.java | 3ebb0bef273151a11a2de9ba753607e800cd6ede | [] | no_license | Kay-Bernhardt/Figure-Drawing-Practice | 277c9e8762e86a7d6f65993a52089c91075653a2 | 212232a8e656055e9deb53f94eef3f0c062ca561 | refs/heads/master | 2021-04-30T18:07:40.257969 | 2017-01-30T22:09:54 | 2017-01-30T22:09:54 | 80,320,387 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,531 | java | package util;
import java.io.File;
import java.net.URLConnection;
import java.util.ArrayList;
import java.util.Random;
import javafx.application.Platform;
import javafx.scene.control.Alert;
import javafx.scene.control.Alert.AlertType;
import javafx.scene.control.DialogPane;
import javafx.scene.media.Media;
import javafx.scene.media.MediaPlayer;
public class Util
{
/**
* This method randomizes the given list with the current time as the seed
* @param fileList list to be randomized
* @return the randomized list
*/
public static ArrayList<File> randomizeList(ArrayList<File> fileList)
{
ArrayList<File> randomList = new ArrayList<File>();
Random rnd = new Random(System.currentTimeMillis());
int index = 0;
int fileListSize = fileList.size();
for(int i = 0; i < fileListSize; i++)
{
index = rnd.nextInt(fileList.size());
randomList.add(fileList.remove(index));
}
return randomList;
}
/**
* Reads the contents of the specified folder and sorts out all image files
*
* @param dir
* directory path
*
* @return array of Files
*/
public static ArrayList<File> readFolderContent(File dir)
{
// reading all files in a folder
File folder = new File(dir.getAbsolutePath());
File[] listOfFiles = folder.listFiles();
ArrayList<File> imageList = new ArrayList<File>();
for (int i = 0; i < listOfFiles.length; i++)
{
String mimeType = URLConnection.guessContentTypeFromName(listOfFiles[i].getAbsolutePath());
if (mimeType != null)
{
String type = mimeType.split("/")[0].toLowerCase();
if (type.equals("image"))
{
imageList.add(listOfFiles[i]);
}
}
}
return imageList;
}
/**
* Creates and shows an error dialog
* @param title
* @param header
* @param content
*/
public static void errorDialog(String title, String header, String content)
{
Platform.runLater(new Runnable()
{
@Override
public void run()
{
Alert alert = new Alert(AlertType.ERROR);
DialogPane dialogPane = alert.getDialogPane();
dialogPane.getStylesheets().add(
getClass().getResource("/application/style/application.css").toExternalForm());
alert.setTitle(title);
alert.setHeaderText(header);
alert.setContentText(content);
alert.showAndWait();
}
});
}
public static void informationDialogWithoutHeader(String message)
{
Platform.runLater(new Runnable()
{
@Override
public void run()
{
Alert alert = new Alert(AlertType.INFORMATION);
DialogPane dialogPane = alert.getDialogPane();
dialogPane.getStylesheets().add(
getClass().getResource("/application/style/application.css").toExternalForm());
alert.setTitle(null);
alert.setHeaderText(null);
alert.setContentText(message);
alert.showAndWait();
}
});
}
public static String makeTimeLabelString(int currTime)
{
String str = "";
int minute = currTime / 60;
int second = currTime % 60;
str = "";
if(minute > 0)
{
str = str + minute + "m ";
}
if(second > 0)
{
str = str + second + "s ";
}
return str;
}
public static void playWarningSound()
{
Platform.runLater(new Runnable()
{
@Override
public void run()
{
String filepath = "sound.mp3";
Media sound = new Media(filepath);
MediaPlayer mediaPlayer = new MediaPlayer(sound);
mediaPlayer.play();
}
});
}
}
| [
"Lord [email protected]"
] | Lord [email protected] |
81cd912dda78c07470f05a00f66016f9edf40e0f | e73025430f98612b4bce8faa13abdee1243bb9cd | /module03-examples/module03-question13/src/main/java/com/spring/professional/exam/tutorial/module03/question13/Runner.java | 20b8f0b27f61a2d753db9faca7c544ddd4e10387 | [] | no_license | a2ankitrai/spring-cert-code-examples | 938ddb647518e735c0ddba3b3809f95ea58750b3 | 491718751129bb0c09cb7bc2608934f7aedb2e81 | refs/heads/master | 2023-03-29T22:16:25.459200 | 2021-03-31T06:32:13 | 2021-03-31T06:32:13 | 331,714,577 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,238 | java | package com.spring.professional.exam.tutorial.module03.question13;
import com.spring.professional.exam.tutorial.module03.question13.service.EmployeeService;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.ComponentScan;
@ComponentScan
public class Runner {
public static void main(String[] args) {
AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(Runner.class);
context.registerShutdownHook();
EmployeeService employeeService = context.getBean(EmployeeService.class);
try {
employeeService.saveEmployeesWithoutTransaction();
} catch (Exception e) {
System.out.println("Exception during saving employees: " + e.getMessage());
}
employeeService.printEmployees();
employeeService.deleteAllEmployees();
try {
employeeService.saveEmployeesInTransaction();
} catch (Exception e) {
System.out.println("Exception during saving employees: " + e.getMessage());
}
employeeService.printEmployees();
employeeService.deleteAllEmployees();
}
}
| [
"[email protected]"
] | |
c87b350541e034ba0de52b16903a2cb3c468001c | 493de7ac514e61503ecb8016a9dd1f429ea789de | /src/main/java/br/com/escolaapi/security/TokenAuthenticationService.java | 59bc5a772e8be7fe9f8652b4b0e0c23db6435d44 | [] | no_license | ovofilho/escolaapi | 21060ba826df257476e9d29002ed18d41085946b | f2ea979bfe51afea126c7f25f953afbb909e0dc3 | refs/heads/master | 2023-02-11T03:18:25.684242 | 2021-01-15T22:10:12 | 2021-01-15T22:10:12 | 330,000,436 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,770 | java | package br.com.escolaapi.security;
import java.io.IOException;
import java.util.Collections;
import java.util.Date;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
import org.springframework.security.core.Authentication;
import io.jsonwebtoken.Jwts;
import io.jsonwebtoken.SignatureAlgorithm;
public class TokenAuthenticationService {
// EXPIRATION_TIME = 10 dias
static final long EXPIRATION_TIME = 860_000_000;
static final String SECRET = "MySecret";
static final String TOKEN_PREFIX = "Bearer";
static final String HEADER_STRING = "Authorization";
static void addAuthentication(HttpServletResponse response, String username) {
String JWT = Jwts.builder()
.setSubject(username)
.setExpiration(new Date(System.currentTimeMillis() + EXPIRATION_TIME))
.signWith(SignatureAlgorithm.HS512, SECRET)
.compact();
response.addHeader("Content-Type", "application/json");
try {
response.getWriter().write(String.format("{ \"token\": \"%s\" }", JWT));
response.getWriter().flush();
response.getWriter().close();
} catch (IOException e) {
e.printStackTrace();
}
}
static Authentication getAuthentication(HttpServletRequest request) {
String token = request.getHeader(HEADER_STRING);
if (token != null) {
String user = Jwts.parser()
.setSigningKey(SECRET)
.parseClaimsJws(token.replace(TOKEN_PREFIX, ""))
.getBody()
.getSubject();
if (user != null) {
return new UsernamePasswordAuthenticationToken(user, null, Collections.emptyList());
}
}
return null;
}
} | [
"[email protected]"
] | |
3138386c6b16ec9d8facf37cfd903b8c2c7a0427 | 32b769224a0fcd5cfd4746c2911c87b733b04375 | /app/src/main/java/id/ardpratama/arth/jadwalku/TugasHar.java | 21396ac756629d007ae0a65fb9834a624e14fd53 | [] | no_license | nadhirfr/Jadwalku | 8f1f86109fcc0c9b2139b600e5488be3668bb0de | 7a1dbb0187558eb94b187f798f678ae5137dad38 | refs/heads/master | 2020-12-24T21:37:12.682980 | 2016-04-26T15:47:36 | 2016-04-26T15:47:36 | 57,141,293 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 7,387 | java | package id.ardpratama.arth.jadwalku;
import android.app.ActionBar;
import android.app.ListActivity;
import android.app.ProgressDialog;
import android.content.Intent;
import android.os.AsyncTask;
import android.os.Bundle;
import android.util.Log;
import android.view.MenuItem;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ListAdapter;
import android.widget.ListView;
import android.widget.SimpleAdapter;
import android.widget.TextView;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import java.util.ArrayList;
import java.util.HashMap;
/**
* Created by de_arth on 28/03/2016.
*/
public class TugasHar extends ListActivity {
private ProgressDialog pDialog;
// URL to get contacts JSON
private static String url = "http://ardpratama.web.id/asro/jadwalku/gettgsharian.php";
//private static String url = "http://192.168.137.1/android/jadwalku/jdwfull.php";
// JSON Node names
private static final String TAG_TUGAS = "tugas";
private static final String TAG_PELAJARAN = "pelajaran";
private static final String TAG_SUBMIT = "submit";
private static final String TAG_ISI = "isi";
private static final String TAG_ID = "id";
// contacts JSONArray
JSONArray tugas = null;
// Hashmap for ListView
ArrayList<HashMap<String, String>> tugasList;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_tgsfull);
ActionBar actionBar = getActionBar();
TextView jdl = (TextView)findViewById(R.id.judulkon);
jdl.setText("Tugas Besok");
actionBar.setDisplayHomeAsUpEnabled(true);
tugasList = new ArrayList<HashMap<String, String>>();
ListView lv = getListView();
// Listview on item click listener
lv.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view,
int position, long id) {
// getting values from selected ListItem
String pelajaran = ((TextView) view.findViewById(R.id.pelajaran))
.getText().toString();
String isi = ((TextView) view.findViewById(R.id.isi))
.getText().toString();
String submit = ((TextView) view.findViewById(R.id.submit))
.getText().toString();
// Starting single contact activity
Intent in = new Intent(getApplicationContext(), SingleTugas.class);
in.putExtra(TAG_PELAJARAN, pelajaran);
in.putExtra(TAG_ISI, isi);
in.putExtra(TAG_SUBMIT, submit);
startActivity(in);
}
});
// Calling async task to get json
new GetContacts().execute();
}
/**
* Async task class to get json by making HTTP call
* */
private class GetContacts extends AsyncTask<Void, Void, Void> {
@Override
protected void onPreExecute() {
super.onPreExecute();
// Showing progress dialog
pDialog = new ProgressDialog(TugasHar.this);
pDialog.setMessage("Mengambil Data...");
pDialog.setCancelable(false);
pDialog.show();
}
@Override
protected Void doInBackground(Void... arg0) {
// Creating service handler class instance
ServerHandler sh = new ServerHandler();
// Making a request to url and getting response
String jsonStr = sh.makeServiceCall(url, ServerHandler.GET);
Log.d("Response: ", "> " + jsonStr);
if (jsonStr != null) {
try {
JSONObject jsonObj = new JSONObject(jsonStr);
// Getting JSON Array node
tugas = jsonObj.getJSONArray(TAG_TUGAS);
// looping through All Contacts
for (int i = 0; i < tugas.length(); i++) {
JSONObject c = tugas.getJSONObject(i);
String pelajaran = c.getString(TAG_PELAJARAN);
String submit = c.getString(TAG_SUBMIT);
String isi = c.getString(TAG_ISI);
//String = c.getString(TAG_GENDER);
// Phone node is JSON Object
// JSONObject phone = c.getJSONObject(TAG_PHONE); // jika ada cabang lagi. db head
// String mobile = phone.getString(TAG_PHONE_MOBILE);
//;/ String home = phone.getString(TAG_PHONE_HOME);
//String office = phone.getString(TAG_PHONE_OFFICE);
// tmp hashmap for single contact
HashMap<String, String> contact = new HashMap<String, String>();
// adding each child node to HashMap key => value
contact.put(TAG_PELAJARAN, pelajaran);
contact.put(TAG_SUBMIT, submit);
contact.put(TAG_ISI, isi);
// adding contact to contact list
tugasList.add(contact);
}
} catch (JSONException e) {
e.printStackTrace();
}
} else {
Log.e("ServiceHandler", "Couldn't get any data from the url");
}
return null;
}
@Override
protected void onPostExecute(Void result) {
super.onPostExecute(result);
// Dismiss the progress dialog
if (pDialog.isShowing())
pDialog.dismiss();
/**
* Updating parsed JSON data into ListView
* */
ListAdapter adapter = new SimpleAdapter(
TugasHar.this, tugasList,
R.layout.list_tugas, new String[] { TAG_PELAJARAN,TAG_SUBMIT,
TAG_ISI}, new int[]{R.id.pelajaran, R.id.submit,
R.id.isi});
setListAdapter(adapter);
}
}
@Override
public void onContentChanged() {
super.onContentChanged();
View empty = findViewById(R.id.empty);
ListView list = (ListView) findViewById(android.R.id.list);
list.setEmptyView(empty);
}
@Override
public void onBackPressed() {
super.onBackPressed();
Intent i = new Intent(this, MainActivity.class);
startActivity(i);
finish();
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
//Menentukan aksi saat suatu menu diklik
switch (id) {
case android.R.id.home:
Intent i = new Intent(TugasHar.this, MainActivity.class);
startActivity(i);
finish();
return true;
}
return super.onOptionsItemSelected(item);
}
}
| [
"[email protected]"
] | |
59679bc52ebb608657a08d300a2850036a46dc74 | 18d6e1fb411ae6ce1ef95098ede41ae67c9cf2b5 | /dogs-api/src/main/java/org/woofenterprise/dogs/validator/DateBeforeValidator.java | c61742c78f20be33cd1f33db21f68de29322aced | [
"MIT"
] | permissive | WoofEnterprise/DogOrientedGroomingSystem | f829c92b2068df1f5e7f6682e4d7a18ff3264743 | 15a94dac8232e8e854333ffe854c6ddeb8584a9d | refs/heads/master | 2021-01-10T14:37:14.937899 | 2016-01-23T16:56:07 | 2016-01-23T16:56:07 | 44,673,008 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,025 | java | /*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package org.woofenterprise.dogs.validator;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;
/**
*
* @author michal
*/
class DateBeforeValidator implements ConstraintValidator<DateBefore, Date> {
private Date upperBound;
@Override
public void initialize(DateBefore a) {
DateFormat dateFormat = new SimpleDateFormat(a.pattern());
try {
upperBound = dateFormat.parse(a.value());
} catch (ParseException ex) {
throw new RuntimeException(ex);
}
}
@Override
public boolean isValid(Date t, ConstraintValidatorContext cvc) {
return t == null || t.before(upperBound);
}
}
| [
"[email protected]"
] | |
29a0f54f4e9728f71d13e671ccec5fe14b1d8c8e | ab44c89cfa179bd7a5e90f19634363eed12c572d | /laba5/src/Main.java | 25a988c76031cfc536a4578bec469df9223ebdbb | [] | no_license | vrnchll/PI-6sem | 8aa427a625ddb657c774d64116aafcda9324eeb6 | 43f95ffad0fd52a7bbe7900c06a57cd012c1ab2c | refs/heads/main | 2023-05-14T11:26:59.201578 | 2021-06-09T07:15:52 | 2021-06-09T07:15:52 | 360,947,126 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 893 | java | import First.Second.Third.AAA;
import java.util.Date;
public class Main {
public static void main(String[] args) {
AAA person = new AAA();
person.setName("Veronika");
person.setFatherName("Sergeevna");
person.setSurname("Bobrik");
person.setBirthday(100,9,20);//100 тк считает от 1900
person.setUniversity("BSTU");
person.setFirstDate(new Date(118,8,01));
System.out.println("Info about person:");
System.out.println("Name: "+person.getName());
System.out.println("Fathername: "+person.getFatherName());
System.out.println("Surname: "+person.getSurname());
System.out.println("Birthday: "+person.getBirhtday());
System.out.println("University: "+person.getUniversity());
System.out.println("FirstDate: "+person.getFirstDate());
}
}
| [
"[email protected]"
] | |
bc2e5c13bd65db4c3c366ea66b574f90ac098291 | 63a1dfd2b676360488285a1047286270114bdac4 | /src/main/java/model/Student.java | b717601784b5e8521d59c4d4b70e6531fc5b6ce5 | [] | no_license | it-academy-pl/tdd-and-mockito | 8af0316ce765caacd2334846e13d070137e499df | 6cc7909a1119580deb488382aaa580c53885ed79 | refs/heads/master | 2020-04-27T20:56:23.346038 | 2019-03-17T00:02:37 | 2019-03-17T00:02:37 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 142 | java | package model;
public class Student {
private long id;
private String name;
private String surname;
private String pesel;
}
| [
"[email protected]"
] | |
7a1df5656e5ef6fa206ac9bd4133b83788708731 | eb0aea06af80dc7618b353b361aededded9d7ec4 | /hzed-services/mall-admin/src/main/java/com/central/mall/admin/service/OmsOrderService.java | 6cb0c8d76cfae901abb49bd0faa1404c9a7c2e06 | [
"Apache-2.0"
] | permissive | lailvliang/mall-cloud | c00c029755cc2ab81e3dc541ce43f9f003cc0d0d | fc108f04f658321f6fac18cb1528bb9f412739ec | refs/heads/master | 2022-07-10T14:48:28.102999 | 2020-01-11T14:49:38 | 2020-01-11T14:49:38 | 230,188,342 | 0 | 0 | Apache-2.0 | 2022-06-17T02:47:49 | 2019-12-26T03:27:34 | Java | UTF-8 | Java | false | false | 1,217 | java | package com.central.mall.admin.service;
import com.central.mall.admin.dto.*;
import com.central.mall.admin.model.OmsOrder;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
/**
* 订单管理Service
* Created by macro on 2018/10/11.
*/
public interface OmsOrderService {
/**
* 订单查询
*/
List<OmsOrder> list(OmsOrderQueryParam queryParam, Integer pageSize, Integer pageNum);
/**
* 批量发货
*/
@Transactional
int delivery(List<OmsOrderDeliveryParam> deliveryParamList);
/**
* 批量关闭订单
*/
@Transactional
int close(List<Long> ids, String note);
/**
* 批量删除订单
*/
int delete(List<Long> ids);
/**
* 获取指定订单详情
*/
OmsOrderDetail detail(Long id);
/**
* 修改订单收货人信息
*/
@Transactional
int updateReceiverInfo(OmsReceiverInfoParam receiverInfoParam);
/**
* 修改订单费用信息
*/
@Transactional
int updateMoneyInfo(OmsMoneyInfoParam moneyInfoParam);
/**
* 修改订单备注
*/
@Transactional
int updateNote(Long id, String note, Integer status);
}
| [
"123456"
] | 123456 |
a2ad825c9a5701f2cfd1808e3cded5fcbae8d2e8 | b15e90860c66444388ae39d2b13e3617685fff2f | /app/src/main/java/com/dewii/mpeapp/constants/Constants.java | 4f53f7d14f267034a976f1cace805356aae472be | [] | no_license | deviprasaddayal12/MPE | 5414de78d127bf6b99ebafef8890a9dc68309334 | 01100d07989578ee502f16282c1c47f465eb60dc | refs/heads/master | 2022-04-11T09:46:03.128755 | 2020-03-29T21:56:16 | 2020-03-29T21:56:16 | 251,141,704 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 501 | java | package com.dewii.mpeapp.constants;
import com.dewii.mpeapp.BuildConfig;
public final class Constants {
private Constants() {
}
public static final String APP_ID = BuildConfig.APPLICATION_ID;
public static final class Api {
private Api() {
// last = 0
}
}
public static final class Broadcast {
public static final String NETWORK_STATE_CHANGE = "android.net.conn.CONNECTIVITY_CHANGE";
private Broadcast() {
}
}
}
| [
"[email protected]"
] | |
787fa3cda70e005c61a4674e3e0e4612f4dc6917 | e432c689d2c5813b52df2e5d3737bc9210c9f822 | /src/server/GameServer.java | b59ab196afee4885f6395a4caa33774e55a6dd70 | [] | no_license | Martinch0/Sknat | ac9332b970c7e192a60bed6d19ff53b39c57c551 | 3b5440c635cc26526300bed1fbd1148dae36fcad | refs/heads/master | 2021-01-20T17:19:26.959737 | 2016-06-11T15:23:55 | 2016-06-11T15:23:55 | 60,778,098 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 23,270 | java | package server;
import game.GameData;
import game.objects.Key;
import game.objects.Objective;
import game.objects.Obstacle;
import game.objects.Projectile;
import game.objects.Tank;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Random;
import map.Maps;
import networking.Server2Client;
import networking.TCPServer;
import ai.Point;
/**
* Class responsible for establishing the connection with the clients, for
* providing the communication between the clients, updating the game state,
* based on the current state and making sure every client has the newest game
* state.
*
* @author Bella Dunovska, Martin Mihov, Alexandre Portugal, Samuel Hill
*/
public class GameServer {
private TCPServer server;
private GameData gameData;
private int idCounter = 0;
private final Server2Client parser;
private final int NUMBER_OF_PLAYERS;
public final String GAME_TYPE;
private long gameStartTime = 0;
private final long GAME_TIME_LIMIT = 300000; // 5 minutes 300000
private final long TIME_FOR_CAPTURE = 3000; // 5 seconds
private final int TIME_FOR_RESPAWN = 5000; // 5 seconds
public final static int SCORES_FOR_OBJECTIVE = 3;
private final int SCORES_FOR_KILL = 1;
private boolean gameEnd = false;
private Thread connectPlayers;
/**
* Constructor to initialise the GameServer and a corresponding parser for
* it.
*
* @param num
* the number of players
* @param gameType
* @throws IOException
* when unable to create a server
*/
public GameServer(int num, String gameType) throws IOException {
server = new TCPServer();
setGameData(new GameData());
initialiseMap(num);
NUMBER_OF_PLAYERS = num;
GAME_TYPE = gameType;
parser = new Server2Client(this);
}
/**
* Initialises the tank character for the number of players.
*
* @param numberOfPlayers
*/
private void initialiseMap(int numberOfPlayers) {
gameData = Maps.map1(numberOfPlayers);
}
/**
* Method to start the communication between the server and the players.
*/
public void startServer() {
connectPlayers = new Thread(new NetworkingThread());
connectPlayers.start();
}
/**
* Method to stop the game.
*/
public void stopServer() {
while (!server.isEverythingSent())
;
gameEnd = true;
server.stopSocket();
}
/**
* Method to be used when updating the tank data.
*
* @param id
* @param x
* @param y
* @param bAngle
* @param tAngle
*/
public void updateTank(int id, int x, int y, double bAngle, double tAngle) {
getGameData().updateTank(id, x, y, bAngle, tAngle);
}
/**
* Method to be used for adding a projectile.
*
* @param x
* @param y
* @param xD
* @param yD
*/
public void addProjectile(int x, int y, int xD, int yD, int team) {
getGameData().addProjectile(x, y, xD, yD, team);
}
/**
* Method to get the game data corresponding to the server.
*
* @return
*/
public GameData getGameData() {
return gameData;
}
/**
* Method to set the game data for the server.
*
* @param gameData
*/
public void setGameData(GameData gameData) {
this.gameData = gameData;
}
/**
* Class to represent the networking thread responsible for connecting the
* players and updating the game states.
*
* @author TeamA5
*
*/
public class NetworkingThread implements Runnable {
private long objectiveCaptured = 0; // The time when the objective has
// been entered.
/**
* Method to accept a connection from multiple players.
*
* A unique Id is assigned to each player.
*/
public void acceptPlayers() {
Thread accept = new Thread(new Runnable() {
@Override
public void run() {
while (idCounter < NUMBER_OF_PLAYERS) {
try {
// Accept a client connection and assign unique
// value
// for each new player.
server.acceptConnection(idCounter);
int teamNumber = assignTeam(idCounter);
Tank[] tanks = gameData.getTanks();
tanks[idCounter].setTeamId(teamNumber);
String s = parser.code("[I]", idCounter);
String teams = parser.code("[TI]", idCounter,
teamNumber);
String num = parser.code("[NP]", NUMBER_OF_PLAYERS);
String gType = parser.code("[GT]", GAME_TYPE);
// sends important pre game information to all
// players as and when they connect
// To the current player we will send their ID and
// their number of players
server.send(idCounter, s + num + gType);
for (int i = 0; i < idCounter; i++) {
System.out.println(idCounter
+ " I am working "
+ parser.code("[TI]", i,
tanks[i].getTeamId()));
// To the new player we send all the old players
// teamID
server.send(
idCounter,
parser.code("[TI]", i,
tanks[i].getTeamId()));
// To the new players, we should inform them of
// who are ready
if (tanks[i].isReady()) {
server.send(idCounter,
parser.code("[R]", i));
System.out
.println("Sending Ready status to new player "
+ idCounter
+ " for player " + i);
}
// To the new players we should inform them of
// what everyones nicknames now are
String currentName = tanks[i].getName();
if (currentName != null) {
server.send(idCounter,
parser.code("[NC]", i, currentName));
}
}
// To old players, we send the new player's team ID
// s
for (int i = 0; i <= idCounter; i++) {
server.send(i, teams);
}
// if the connection is successful increment the
// counter
// for the next player.
idCounter++;
} catch (IOException e) {
System.out
.println("Socket closed. Unable to add a player.");
break;
}
}
}
/**
* Method to assign initial teams according to the number of
* players.
*
* @param idCounter
* id counter represents number of connected players
* @return teamID returns which team should be joined for
* connecting player
*/
private Integer assignTeam(int idCounter) {
int[] teamIds = new int[2];
Tank[] tanks = gameData.getTanks();
for (int i = 0; i < idCounter; i++) {
if (tanks[i].getTeamId() == 0) {
teamIds[0]++;
} else {
teamIds[1]++;
}
}
if (teamIds[0] > teamIds[1]) {
return 1;
} else {
return 0;
}
}
});
accept.start();
}
/**
* Method to apply the corresponding updates.
*/
public void doUpdates() {
while (!gameEnd) {
String s = server.receive();
while (s != null) {
// The parser will decode the received string in order to
// get the actual values for updating.
parser.decode(s);
s = server.receive();
// System.out.println("Receive: "+s);
}
if (TCPServer.isGameRunning) {
// Method to count the game time
checkTimeLimit();
// Methods that calculate and amend the game state.
moveProjectile();
checkForHits();
checkForKey();
// moveKey();
checkForObjective();
// The new state is being passed to all players.
sendNewState();
}
try {
Thread.sleep(30);
} catch (InterruptedException e) {
System.out.println("Game Server Thread interrupted!");
}
}
}
/**
* Method to set a time of 3 minutes in which the game is supposed to be
* played. After the time has elapsed compare the scores of each time.
* Chooses a winner based on the highest score.
*/
private void checkTimeLimit() {
if (gameStartTime != 0
&& System.currentTimeMillis() - gameStartTime >= GAME_TIME_LIMIT) {
Tank[] tanks = gameData.getTanks();
int[] teamScores = gameData.getTeamScores();
// the winner which corresponds to a teamID.
int winner = 0;
// flag to indicate a draw.
int draw = 0;
for (int i = 1; i < teamScores.length; i++) {
// if the 0 team has less score then team 1 wins.
if (teamScores[winner] < teamScores[i]) {
winner = i;
draw = 0;
} else if (teamScores[winner] == teamScores[i]) {
draw = 1;
}
}
String s = "";
// if the result is the same send -1.
if (draw == 1) {
s = parser.code("[END]", -1);
} else {
// send the winner
s = parser.code("[END]", winner);
}
for (int i = 0; i < tanks.length; i++) {
server.send(i, s);
}
// after the time has passed the game stops.
stopServer();
}
}
/**
* Method to check whether a tank has reached the objective holding the
* key.
*/
private void checkForObjective() {
// We are concerned only with the tank who is holding the key.
if (gameData.getKeyHolder() != -1) {
// The main objective.
Objective objective = gameData.getObjective();
// All the tanks
Tank[] tanks = getGameData().getTanks();
// Just the keyholder.
Tank keyHolder = tanks[gameData.getKeyHolder()];
// The parameters of the keyholder.
int xT = keyHolder.getX();
int yT = keyHolder.getY();
int xT1 = xT + keyHolder.getWidth();
int yT1 = yT + keyHolder.getHeight();
// The parameters of the objective.
int xO = objective.getX();
int yO = objective.getY();
int xO1 = xO + objective.getWidth();
int yO1 = yO + objective.getHeight();
// If the parameters interfere then add point and reset the key
// position.
if (((xT > xO && xT < xO1) || (xT1 > xO && xT1 < xO1))
&& ((yT > yO && yT < yO1) || (yT1 > yO && yT1 < yO1))) {
if (objectiveCaptured != 0
&& System.currentTimeMillis() - objectiveCaptured > TIME_FOR_CAPTURE) {
// Objective has been captured for more than
// TIME_FOR_CAPTURE
incrementScoreAndResetKey(keyHolder, tanks);
} else if (objectiveCaptured == 0) {
// The keyHolder has entered the objective
objectiveCaptured = System.currentTimeMillis();
}
// Send time remaining for capturing the objective.
long timeRemaining = (TIME_FOR_CAPTURE - (System
.currentTimeMillis() - objectiveCaptured)) / 1000 + 1;
for (int i = 0; i < NUMBER_OF_PLAYERS; i++) {
server.send(i, parser.code("[O]", (int) timeRemaining));
}
} else {
// The keyHolder is outside of the objective
objectiveCaptured = 0;
}
}
}
/**
* Increments the score of the corresponding team and respawns the key
* at a random position.
*
* @param keyHolder
* The tanks that is currently holding the key.
* @param tanks
* The array of tanks.
*/
private void incrementScoreAndResetKey(Tank keyHolder, Tank[] tanks) {
gameData.incrementTeamScores(keyHolder.getTeamId(),
SCORES_FOR_OBJECTIVE);
resetKey();
String s = parser.code("[S]", keyHolder.getTeamId(),
gameData.getTeamScores()[keyHolder.getTeamId()]);
s += parser.code("[K]", -1);
s += parser.code("[KP]", gameData.getKey());
// System.out.println(s);
for (int i = 0; i < tanks.length; i++) {
server.send(i, s);
}
objectiveCaptured = 0;
}
/**
* Method to return the key on a random position after a team has
* received a point. Makes sure that the key does not appear on top of
* an obstacle. Also, makes sure that the key does not appear on a tank.
*/
public void resetKey() {
// Flag to represent a safe state to leave the key(indicate that
// there is nothing on this position)
boolean flagKey = true;
Random random = new Random();
// All possible obstacles.
Obstacle[] obstacles = gameData.getObstacles();
int xK, yK;
// while a valid position for the key has been found
while (true) {
flagKey = true;
// Generate new random coordinates for the key.
xK = random.nextInt(900);
yK = random.nextInt(600);
int xK1 = xK + gameData.getKey().getKeySize();
int yK1 = yK + gameData.getKey().getKeySize();
// Get the parameters of all obstacles.
for (int i = 0; i < obstacles.length; i++) {
int x = obstacles[i].getX();
int y = obstacles[i].getY();
int x2 = x + obstacles[i].getWidth();
int y2 = y + obstacles[i].getHeight();
// If the newly generated coordinates interfere with an
// obstacle then go back
// and generate new random position.
if (((xK > x && xK < x2) || (xK1 > x && xK1 < x2))
&& ((yK > y && yK < y2) || (yK1 > y && yK1 < y2))) {
flagKey = false;
}
}
// Get the parameters of all tanks.
Tank[] tanks = gameData.getTanks();
for (int i = 0; i < tanks.length; i++) {
int xT = tanks[i].getX();
int yT = tanks[i].getY();
int xT1 = xT + tanks[i].getWidth();
int yT1 = yT + tanks[i].getHeight();
// If the newly generated coordinates interfere with a tank
// then go back
// and generate new random position.
if (((xK > xT && xK < xT1) || (xK1 > xT && xK1 < xT1))
&& ((yK > yT && yK < yT1) || (yK1 > yT && yK1 < yT1))) {
flagKey = false;
}
}
// If there is no interference place the key.
if (flagKey) {
// Add the new key to the game data and reset the keyholder.
gameData.setKey(new Key(xK, yK, 1));
gameData.setKeyHolder(-1);
String s = parser.code("[KP]", gameData.getKey());
for (int i = 0; i < tanks.length; i++) {
server.send(i, s);
}
break;
}
}
}
/**
* Method to decrement the health points of a tank and kill it
* accordingly.
*
* @param id
*/
public void hitTank(int id) {
final Tank[] tanks = getGameData().getTanks();
final Tank tank = tanks[id];
int health = tank.getHealth();
health--;
if (health == 0) {
// increment score
int killed = tank.getTeamId();
gameData.incrementTeamScores(killed ^ 1, SCORES_FOR_KILL);
String s = parser.code("[S]", killed ^ 1,
gameData.getTeamScores()[killed ^ 1]);
// reset the key if the dead tank is the keyholder
if (tank.getId() == gameData.getKeyHolder()) {
resetKey();
}
tank.setHealth(0);
String healths = s + parser.code("[H]", id, 0);
for (int i = 0; i < tanks.length; i++) {
server.send(i, healths);
}
Thread killingThread = new Thread(new Runnable() {
@Override
public void run() {
try {
Thread.sleep(TIME_FOR_RESPAWN);
} catch (InterruptedException e) {
e.printStackTrace();
}
/*
* If a tank has been killed (the health point reaches
* 0) send an event and respawn it. If the tank that has
* been killed has the key respawn the key at a random
* position.
*/
String s = parser.code("[RES]", tank.getId());
tank.resetTank();
for (int i = 0; i < tanks.length; i++) {
server.send(i, s);
}
}
});
killingThread.start();
// Reset key, send keyHolder, reset tank
} else if (health > 0) {
/*
* If a tank is shot but there are still health points available
* decrement them by 1 per hit.
*/
tank.setHealth(health);
String s = parser.code("[H]", id, tank.getHealth());
for (int i = 0; i < tanks.length; i++) {
server.send(i, s);
}
}
}
/**
* Method to check whether a tank has been hit by a projectile. For
* every tank, compare its position with all the projectiles. If a tank
* is hit decrease the health points and delete the projectile.
*/
public void checkForHits() {
// All existing projectiles.
ArrayList<Projectile> projectile = getGameData().getProjectiles();
// The ones to be deleted.
ArrayList<Projectile> projectilesToBeDeleted = new ArrayList<Projectile>();
// All tanks.
Tank[] tanks = getGameData().getTanks();
// For each tank and projectile compare their coordinates
for (int i = 0; i < tanks.length; i++) {
for (Projectile p : projectile) {
int xT = tanks[i].getX();
int yT = tanks[i].getY();
int xTs = xT + tanks[i].getTankSize();
int yTs = yT + tanks[i].getTankSize();
int xP = p.getX();
int yP = p.getY();
int xPs = xP + p.getProjectSize();
int yPs = yP + p.getProjectSize();
// If they interfere note the hit and delete the projectiles
// that performed the
// hit.
if ((((xP > xT && xP < xTs) || (xPs > xT && xPs < xTs)) && tanks[i]
.getTeamId() != p.getTeam())
&& (((yP > yT && yP < yTs) || (yPs > yT && yPs < yTs)) && tanks[i]
.getTeamId() != p.getTeam())) {
hitTank(i);
// System.out.println("hit");
projectilesToBeDeleted.add(p);
}
}
projectile.removeAll(projectilesToBeDeleted);
}
}
/**
* Method to check whether a tank currently holds a key, if so it
* assigns the keyholder.
*
*/
public void checkForKey() {
if (gameData.getKeyHolder() == -1) {
// All tanks.
Tank[] tanks = getGameData().getTanks();
// The key.
Key key = getGameData().getKey();
// For all tanks compare their coordinates with the key's ones.
for (int i = 0; i < tanks.length; i++) {
int xT = tanks[i].getX();
int yT = tanks[i].getY();
int xTs = xT + tanks[i].getTankSize();
int yTs = yT + tanks[i].getTankSize();
int xK = key.getX();
int yK = key.getY();
int xKs = xK + key.getKeySize();
int yKs = yK + key.getKeySize();
// If they interfere set the keyholder to be the according
// tank.
if (((xK > xT && xK < xTs) || (xKs > xT && xKs < xTs))
&& ((yK > yT && yK < yTs) || (yKs > yT && yKs < yTs))) {
gameData.setKeyHolder(i);
// Send an event notifying every player that the key has
// been collected.
String s = parser.code("[K]", i);
for (int j = 0; j < tanks.length; j++) {
server.send(j, s);
}
break;
}
}
}
}
/**
* Method to compute the movement of projectiles and to delete them if
* they are out of range.
*/
public void moveProjectile() {
// All projectiles.
ArrayList<Projectile> projectiles = getGameData().getProjectiles();
// The ones that need to be deleted.
ArrayList<Projectile> projectilesToBeDeleted = new ArrayList<Projectile>();
// For each projectile get its parameters.
for (Projectile p : projectiles) {
double xI = p.getXIncrement();
double yI = p.getYIncrement();
double realX = p.getRealX() + xI;
double realY = p.getRealY() + yI;
p.setRealX(realX);
p.setRealY(realY);
p.setX((int) realX);
p.setY((int) realY);
// Computing the distance which a projectile has moved and
// comparing it to the range.
double distance = Math.sqrt(xI * xI + yI * yI);
p.incrementDistance(distance);
if (p.getDistance() > p.getRange()) {
projectilesToBeDeleted.add(p);
} else {
// For all obstacles on the map check their parameters
// against the projectiles.
Obstacle[] obstacles = gameData.getObstacles();
for (int i = 0; i < obstacles.length; i++) {
int x = obstacles[i].getX();
int y = obstacles[i].getY();
int x2 = x + obstacles[i].getWidth();
int y2 = y + obstacles[i].getHeight();
int xP = p.getX();
int yP = p.getY();
int xPs = xP + p.getProjectSize();
int yPs = yP + p.getProjectSize();
// If they interfere delete the projectile.
if (((xP > x && xP < x2) || (xPs > x && xPs < x2))
&& ((yP > y && yP < y2) || (yPs > y && yPs < y2))) {
projectilesToBeDeleted.add(p);
break;
}
}
}
}
projectiles.removeAll(projectilesToBeDeleted);
getGameData().setProjectiles(projectiles);
}
/**
* Method to send the updated states.
*/
private void sendNewState() {
long timeElapsed = System.currentTimeMillis() - gameStartTime;
long timeRemaining = GAME_TIME_LIMIT - timeElapsed;
String timeString = timeRemaining / 60000 + ":";
if ((timeRemaining % 60000) / 1000 < 10) {
timeString += "0" + (timeRemaining % 60000) / 1000;
} else {
timeString += (timeRemaining % 60000) / 1000;
}
String s = parser.code("[T][P][TIMER]", getGameData().getTanks(),
getGameData().getProjectiles(), timeString);
// Iterates through all players to send them the state.
for (int i = 0; i < NUMBER_OF_PLAYERS; i++) {
server.send(i, s);
}
}
/**
* Method to start the game server.
*/
@Override
public void run() {
acceptPlayers();
doUpdates();
}
}
/**
* Method to notify the ready state to the client.
*
* @param id
*/
public void sendReadyState(int id) {
gameData.getTanks()[id].setReady(true);
String s = parser.code("[R]", id);
for (int i = 0; i < NUMBER_OF_PLAYERS; i++) {
if (i != id) {
server.send(i, s);
}
}
}
/**
* Method to send the start state.
*/
public void sendStartState() {
TCPServer.isGameRunning = true;
gameStartTime = System.currentTimeMillis();
String s = parser.code("[SG]");
String pos = initialiseTankPositions();
for (int i = 0; i < NUMBER_OF_PLAYERS; i++) {
server.send(i, pos + s);
}
}
/**
* Method to get the tanks initial position.
*
* @return the initial position of tanks.
*/
public String initialiseTankPositions() {
Tank[] tanks = gameData.getTanks();
String posString = "";
int[] team = { -1, -1 };
for (int i = 0; i < tanks.length; i++) {
team[tanks[i].getTeamId()]++;
Point pos = Maps.getPosition(team[tanks[i].getTeamId()],
tanks[i].getTeamId());
tanks[i].setX(pos.getX());
tanks[i].setY(pos.getY());
tanks[i].setOriginalX(pos.getX());
tanks[i].setOriginalY(pos.getY());
posString += parser.code("[INITP]", i, tanks[i].getX(),
tanks[i].getY());
}
return posString;
}
/**
* Method to send messages.
*
* @param id
*/
public void sendIM(int id, String message) {
String s = parser.code("[IM]", id, message);
for (int i = 0; i < NUMBER_OF_PLAYERS; i++) {
server.send(i, s);
}
}
/**
* Method to send the new nickname.
*
* @param id
* the player which nickname is to be set.
* @param newName
* the desired name.
*/
public void sendNC(int id, String newName) {
gameData.getTanks()[id].setName(newName);
String s = parser.code("[NC]", id, newName);
for (int i = 0; i < NUMBER_OF_PLAYERS; i++) {
server.send(i, s);
}
}
/**
* Method for changing the team. The teams are differentiated by id. So we
* only need to change the team id.
*
* @param pID
* the team id to be changed
*/
public void changeTeam(int pID) {
Tank[] tanks = gameData.getTanks();
int oldTeamID = tanks[pID].getTeamId();
int newTeamID = oldTeamID ^ 1;
tanks[pID].setTeamId(newTeamID);
String s = parser.code("[TI]", pID, newTeamID);
for (int i = 0; i < NUMBER_OF_PLAYERS; i++) {
server.send(i, s);
}
}
/**
* Gets the scores give for objective's fullfilment.
*
* @return the SCORES_FOR_OBJECTIVE
*/
public int getSCORES_FOR_OBJECTIVE() {
return SCORES_FOR_OBJECTIVE;
}
/**
* Getting the type of the game.
*
* @return
*/
public String getGameType() {
return GAME_TYPE;
}
}
| [
"[email protected]"
] | |
c87e55fd48324706540e1f11d8155286c6f62cd6 | 97621af47796887e9da819c044ac7bb234cc2fab | /src/main/java/learn/classloader/ManagerFactory.java | 200faa4d0edd774531c9d4b65fe826b804f40712 | [] | no_license | hkruni/learn | eef920f0b6c2f3dc57237c637100562d473cdab3 | acf7ac38c81ae7d10212e0c20febd804cbdfeb01 | refs/heads/master | 2022-12-22T18:55:52.177587 | 2019-07-23T07:15:31 | 2019-07-23T07:15:31 | 141,568,519 | 0 | 0 | null | 2022-12-16T00:55:21 | 2018-07-19T11:14:03 | Java | UTF-8 | Java | false | false | 375 | java | package learn.classloader;
import java.util.HashMap;
import java.util.Map;
public class ManagerFactory {
//记录热加载类的加载信息
private static final Map<String ,LoadInfo> loadTimeMap = new HashMap<String ,LoadInfo>();
public static final String CLASS_PATH = "";
public static final String MY_MANAGER = "com.imooc.classloader.MyManager";
}
| [
"[email protected]"
] | |
7bf3e04ffecb348f20343c70957fcefd9d8a7422 | 5b82e2f7c720c49dff236970aacd610e7c41a077 | /QueryReformulation-master 2/data/ExampleSourceCodeFiles/Parameter.java | 542d01d4115bdde52d5b8768fa3aeddaaf6ab734 | [] | no_license | shy942/EGITrepoOnlineVersion | 4b157da0f76dc5bbf179437242d2224d782dd267 | f88fb20497dcc30ff1add5fe359cbca772142b09 | refs/heads/master | 2021-01-20T16:04:23.509863 | 2016-07-21T20:43:22 | 2016-07-21T20:43:22 | 63,737,385 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,646 | java | /Users/user/eclipse.platform.ui/bundles/org.eclipse.e4.ui.workbench/src/org/eclipse/e4/ui/internal/workbench/Parameter.java
org eclipse internal workbench java util collections java util map org eclipse core commands parameter org eclipse core commands parameter values org eclipse core commands typed parameter org eclipse core commands parameter type org eclipse core commands parameter values exception org eclipse core commands common handle object org eclipse core runtime core exception org eclipse core runtime configuration element parameter command parameter identifies type command accept for show view command accept view display this parameter identifies values display user parameters mutable change command notifications parameter listeners attached command parameter parameter typed parameter configuration element attribute values this retrieve executable extension code parameter values code string values constant integer hash code meaning hash code computed factor computing hash code schemes seed hash code schemes handle object name hash code hash code object this computed lazily marked invalid values based hash code identifier object this identifier unique objects type change this code null code string externalized parameter parameter map this code null code string whether parameter optional opposed required optional type parameter this code null code parameter typed parameter type parameter type string representation object this string debugging purposes meant displayed user this computed lazily cleared dependent values string string null actual code parameter values code implementation this lazily loaded code values configuration element code avoid unnecessary loading parameter values values null configuration element values configuration element constructs instance code parameter code values pre defined param identifier parameter code null code param parameter code null code param values values parameter code null code param parameter type type parameter code null code parmeter doesn declare type param optional whether parameter optional opposed required parameter string string configuration element values parameter type parameter type optional null null pointer exception cannot create parameter null null null pointer exception parameter null values configuration element values parameter type parameter type optional optional tests object equal object parameter equal parameter properties param object object compare code null code code true code objects equal code false code override equals object object object true object parameter false parameter parameter parameter object util equals parameter false util equals parameter false util equals values parameter values false util equals optional parameter optional override string override string name override parameter type parameter type parameter type override parameter values values parameter values exception values null values configuration element null values parameter values values configuration element create executable extension core exception parameter values exception problem creating parameter values class cast exception parameter values exception parameter values instance parameter values values parameter values override map parameter values collections values override hash code hash code hash code util hash code hash code hash code hash code override optional optional override string string string null string buffer buffer string buffer buffer append parameter buffer append buffer append buffer append buffer append buffer append values buffer append buffer append optional buffer append string buffer string string | [
"[email protected]"
] | |
62705d56e572d45372559665a7beb99c876d3c33 | c18cc42afdc0c2a7a20f63b882b97f3329d77d69 | /src/main/java/com/testing/web/rest/dto/package-info.java | 63860573b4e6ef1882f1fc699324bb009f2ae0f6 | [] | no_license | nilpaco/testing | 7e6883d7a2e20f41b51a6ebee736bc18e2e9a176 | 04559d10a52fb0ca2f112f3b858539c71918b8b1 | refs/heads/master | 2021-01-10T06:24:27.261245 | 2016-02-23T18:29:53 | 2016-02-23T18:29:53 | 52,381,875 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 104 | java | /**
* Data Transfer Objects used by Spring MVC REST controllers.
*/
package com.testing.web.rest.dto;
| [
"[email protected]"
] | |
ac07ed46dbd460c291d0b45328ac348405d7cbc9 | d8d363290bd92a866058f37eb7eecce295038d8a | /src/main/java/com/liyan/store/repository/ShopingCarRepositry.java | 2025d0a9fbbd3634b5b5329a0f432a04a8cbb12a | [] | no_license | iamsmartloser/store-service | ef9709972afe7228b9714ef89d3b298e9f1677fb | cd46618ef6a23a54d33a3626ba70aa87e0d5c7ec | refs/heads/master | 2022-03-01T10:00:54.655479 | 2019-10-14T07:19:25 | 2019-10-14T07:19:25 | 214,617,055 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 757 | java | package com.liyan.store.repository;
import com.liyan.store.domain.Product;
import com.liyan.store.domain.ShopingCar;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.List;
public interface ShopingCarRepositry extends JpaRepository<ShopingCar,Long>,PagingAndSortingRepository<ShopingCar,Long>
,JpaSpecificationExecutor<ShopingCar>
{
//查询某一个用户的购物车
public ShopingCar getByUserUserId(Long userId);
}
| [
"[email protected]"
] | |
2b613ecb7fd2bfcce0bb79ec46f8d2448de6e3db | 9db4f6236479404bccc03ae106a1c46fe2e44b63 | /src/net/margaritov/preference/colorpicker/ColorPickerDialog.java | f41f258ea67f889d2a10de540fab03c995b92bdd | [
"Apache-2.0"
] | permissive | mintkat/packages_apps_Settings | cb046acfe00f80ed041321f7347602c8e6fd1426 | 5491954573d3b08dad1c10cce1983d2ebf763983 | refs/heads/marshmallow | 2021-01-22T15:21:30.779562 | 2016-05-05T02:04:36 | 2016-05-20T03:51:00 | 47,557,039 | 0 | 0 | null | 2015-12-07T14:29:14 | 2015-12-07T14:29:13 | null | UTF-8 | Java | false | false | 22,024 | java | /*
* Copyright (C) 2010 Daniel Nilsson
* Copyright (C) 2013 Slimroms
* Copyright (C) 2015 DarkKat
*
* 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 net.margaritov.preference.colorpicker;
import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.animation.ValueAnimator;
import android.app.Activity;
import android.app.Dialog;
import android.content.ContentResolver;
import android.content.Context;
import android.content.SharedPreferences;
import android.content.res.Resources;
import android.content.res.TypedArray;
import android.graphics.Color;
import android.graphics.PixelFormat;
import android.os.Bundle;
import android.provider.Settings;
import android.support.v4.view.ViewCompat;
import android.text.Editable;
import android.text.TextWatcher;
import android.view.inputmethod.InputMethodManager;
import android.view.LayoutInflater;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewGroup.LayoutParams;
import android.view.ViewTreeObserver;
import android.view.Window;
import android.widget.EditText;
import android.widget.ImageButton;
import android.widget.LinearLayout;
import android.widget.PopupMenu;
import android.widget.TextView;
import com.android.settings.R;
public class ColorPickerDialog extends Dialog implements
ColorPickerView.OnColorChangedListener, PopupMenu.OnMenuItemClickListener,
TextWatcher, View.OnClickListener, View.OnLongClickListener, View.OnFocusChangeListener {
private static final String PREFERENCE_NAME =
"color_picker_dialog";
private static final String FAVORITE_COLOR_BUTTON =
"favorite_color_button_";
private static final int PALETTE_DARKKAT = 0;
private static final int PALETTE_MATERIAL = 1;
private static final int PALETTE_RGB = 2;
private View mColorPickerView;
private LinearLayout mActionBarMain;
private LinearLayout mActionBarEditHex;
private ImageButton mBackButton;
private ImageButton mEditHexButton;
private ImageButton mPaletteSwitchButton;
private ImageButton mResetButton;
private ImageButton mHexBackButton;
private EditText mHex;
private ImageButton mSetButton;
private View mDivider;
private ColorPickerView mColorPicker;
private TextView mPaletteColorButtonsTitle;
private ColorPickerColorButton[] mFavoriteColorButtons;
private ColorPickerColorButton[] mPaletteColorButtons;
private ColorPickerPanelView mOldColor;
private ColorPickerPanelView mNewColor;
private Animator mEditHexBarFadeInAnimator;
private Animator mEditHexBarFadeOutAnimator;
private boolean mHideEditHexBar = false;
private Animator mColorTransitionAnimator;
private boolean mAnimateColorTransition = true;
private boolean mIsPaletteColorButtons = true;
private final int mInitialColor;
private final int mAndroidColor;
private final int mDarkKatColor;
private int mNewColorValue;
private final ContentResolver mResolver;
private final Resources mResources;
private OnColorChangedListener mListener;
public interface OnColorChangedListener {
public void onColorChanged(int color);
}
public ColorPickerDialog(Context context, int theme, int initialColor,
int androidColor, int darkkatColor) {
super(context, theme);
mInitialColor = initialColor;
mAndroidColor = androidColor;
mDarkKatColor = darkkatColor;
mResolver = context.getContentResolver();
mResources = context.getResources();
setUp();
}
private void setUp() {
// To fight color branding.
getWindow().setFormat(PixelFormat.RGBA_8888);
getWindow().setLayout(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
requestWindowFeature(Window.FEATURE_NO_TITLE);
LayoutInflater inflater = (LayoutInflater) getContext().getSystemService(
Context.LAYOUT_INFLATER_SERVICE);
mColorPickerView = inflater.inflate(R.layout.dialog_color_picker, null);
setContentView(mColorPickerView);
mActionBarMain = (LinearLayout) mColorPickerView.findViewById(R.id.action_bar_main);
mActionBarEditHex = (LinearLayout) mColorPickerView.findViewById(R.id.action_bar_edit_hex);
mActionBarEditHex.setVisibility(View.GONE);
mDivider = mColorPickerView.findViewById(R.id.divider);
mDivider.setVisibility(View.GONE);
mBackButton = (ImageButton) mColorPickerView.findViewById(R.id.back);
mBackButton.setOnClickListener(this);
mEditHexButton = (ImageButton) mColorPickerView.findViewById(R.id.edit_hex);
mEditHexButton.setOnClickListener(this);
mPaletteSwitchButton = (ImageButton) mColorPickerView.findViewById(R.id.palette);
mPaletteSwitchButton.setOnClickListener(this);
mResetButton = (ImageButton) mColorPickerView.findViewById(R.id.reset);
if (mAndroidColor != 0x00000000 && mDarkKatColor != 0x00000000) {
mResetButton.setOnClickListener(this);
} else {
mResetButton.setVisibility(View.GONE);
}
mHexBackButton = (ImageButton) mColorPickerView.findViewById(R.id.action_bar_edit_hex_back);
mHexBackButton.setOnClickListener(this);
mHex = (EditText) mColorPickerView.findViewById(R.id.hex);
mHex.setText(ColorPickerPreference.convertToARGB(mInitialColor));
mHex.setOnFocusChangeListener(this);
mSetButton = (ImageButton) mColorPickerView.findViewById(R.id.enter);
mSetButton.setOnClickListener(this);
mColorPicker = (ColorPickerView) mColorPickerView.findViewById(R.id.color_picker_view);
mColorPicker.setOnColorChangedListener(this);
mPaletteColorButtonsTitle = (TextView) mColorPickerView.findViewById(R.id.palette_color_buttons_title);
setUpFavoriteColorButtons();
setUpPaletteColorButtons();
mOldColor = (ColorPickerPanelView) mColorPickerView.findViewById(R.id.old_color_panel);
mOldColor.setOnClickListener(this);
mNewColor = (ColorPickerPanelView) mColorPickerView.findViewById(R.id.new_color_panel);
mNewColor.setOnClickListener(this);
mNewColorValue = mInitialColor;
mOldColor.setColor(mInitialColor);
setupAnimators();
mAnimateColorTransition = false;
mColorPicker.setColor(mInitialColor, true);
}
private void setUpFavoriteColorButtons() {
TypedArray ta = mResources.obtainTypedArray(R.array.color_picker_favorite_color_buttons);
mFavoriteColorButtons = new ColorPickerColorButton[4];
for (int i=0; i<mFavoriteColorButtons.length; i++) {
int resId = ta.getResourceId(i, 0);
mFavoriteColorButtons[i] = (ColorPickerColorButton) mColorPickerView.findViewById(resId);
mFavoriteColorButtons[i].setOnLongClickListener(this);
if (getFavoriteButtonValue(i) != 0) {
mFavoriteColorButtons[i].setImageResource(R.drawable.color_picker_color_button_color);
mFavoriteColorButtons[i].setColor(getFavoriteButtonValue(i));
mFavoriteColorButtons[i].setOnClickListener(this);
}
}
ta.recycle();
}
private void setUpPaletteColorButtons() {
TypedArray ta = mResources.obtainTypedArray(R.array.color_picker_palette_color_buttons);
mPaletteColorButtons = new ColorPickerColorButton[8];
for (int i=0; i<mPaletteColorButtons.length; i++) {
int resId = ta.getResourceId(i, 0);
mPaletteColorButtons[i] = (ColorPickerColorButton) mColorPickerView.findViewById(resId);
mPaletteColorButtons[i].setOnClickListener(this);
}
ta.recycle();
updatePaletteColorButtonsColor();
}
private void setupAnimators() {
mColorPickerView.getViewTreeObserver().addOnPreDrawListener(
new ViewTreeObserver.OnPreDrawListener() {
@Override
public boolean onPreDraw() {
mColorPickerView.getViewTreeObserver().removeOnPreDrawListener(this);
mHideEditHexBar = false;
mEditHexBarFadeInAnimator = createAlphaAnimator(0, 100);
mHideEditHexBar = true;
mEditHexBarFadeOutAnimator = createAlphaAnimator(100, 0);
return true;
}
});
mColorTransitionAnimator = createColorTransitionAnimator(0, 1);
}
private ValueAnimator createAlphaAnimator(int start, int end) {
ValueAnimator animator = ValueAnimator.ofInt(start, end);
animator.setDuration(500);
animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator valueAnimator) {
int value = (Integer) valueAnimator.getAnimatedValue();
float currentAlpha = value / 100f;
mActionBarMain.setAlpha(1f - currentAlpha);
mActionBarEditHex.setAlpha(currentAlpha);
mDivider.setAlpha(currentAlpha);
}
});
if (mHideEditHexBar) {
animator.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationStart(Animator animation) {
mActionBarMain.setVisibility(View.VISIBLE);
ViewCompat.jumpDrawablesToCurrentState(mActionBarMain);
}
});
animator.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
mActionBarEditHex.setVisibility(View.GONE);
mDivider.setVisibility(View.GONE);
}
});
} else {
animator.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationStart(Animator animation) {
mActionBarEditHex.setVisibility(View.VISIBLE);
ViewCompat.jumpDrawablesToCurrentState(mActionBarEditHex);
mDivider.setVisibility(View.VISIBLE);
}
});
animator.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
mActionBarMain.setVisibility(View.GONE);
}
});
}
return animator;
}
private ValueAnimator createColorTransitionAnimator(float start, float end) {
ValueAnimator animator = ValueAnimator.ofFloat(start, end);
animator.setDuration(500);
animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener(){
@Override public void onAnimationUpdate(ValueAnimator animation) {
float position = animation.getAnimatedFraction();
if (mIsPaletteColorButtons) {
int[] blended = new int[8];
for (int i=0; i<mPaletteColorButtons.length; i++) {
blended[i] = blendColors(
mPaletteColorButtons[i].getColor(),
getPaletteColorButtonColor(getPalette(), i),
position);
mPaletteColorButtons[i].setColor(blended[i]);
}
} else {
int blended = blendColors(mNewColor.getColor(), mNewColorValue, position);
mNewColor.setColor(blended);
}
}
});
animator.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
if (mIsPaletteColorButtons) {
updatePaletteColorButtonsTitle();
} else {
mIsPaletteColorButtons = true;
}
}
});
return animator;
}
/**
* Set a OnColorChangedListener to get notified when the color selected by the user has changed.
*
* @param listener
*/
public void setOnColorChangedListener(OnColorChangedListener listener) {
mListener = listener;
}
@Override
public void onColorChanged(int color) {
mNewColorValue = color;
if (mAnimateColorTransition == false) {
mAnimateColorTransition = true;
mNewColor.setColor(mNewColorValue);
} else {
mIsPaletteColorButtons = false;
mColorTransitionAnimator.start();
}
try {
if (mHex != null) {
mHex.setText(ColorPickerPreference.convertToARGB(color));
}
} catch (Exception e) {
}
}
@Override
public void onClick(View v) {
if (v.getId() == R.id.back ||
v.getId() == R.id.old_color_panel ||
v.getId() == R.id.new_color_panel) {
if (mListener != null && v.getId() == R.id.new_color_panel) {
mListener.onColorChanged(mNewColor.getColor());
}
dismiss();
} else if (v.getId() == R.id.palette) {
showPalettePopupMenu(v);
} else if (v.getId() == R.id.edit_hex) {
showActionBarEditHex();
} else if (v.getId() == R.id.reset) {
showResetPopupMenu(v);
} else if (v.getId() == R.id.action_bar_edit_hex_back) {
hideActionBarEditHex();
} else if (v.getId() == R.id.enter) {
String text = mHex.getText().toString();
try {
int newColor = ColorPickerPreference.convertToColorInt(text);
mColorPicker.setColor(newColor, true);
} catch (Exception e) {
}
hideActionBarEditHex();
} else {
boolean isFavoriteColorButton = false;
for (int j=0; j<mFavoriteColorButtons.length; j++) {
int favoriteButtonId = mFavoriteColorButtons[j].getId();
if (v.getId() == favoriteButtonId) {
isFavoriteColorButton = true;
try {
mColorPicker.setColor(mFavoriteColorButtons[j].getColor(), true);
} catch (Exception e) {
}
}
}
if (!isFavoriteColorButton) {
for (int i=0; i<mPaletteColorButtons.length; i++) {
int paletteColorButtonId = mPaletteColorButtons[i].getId();
if (v.getId() == paletteColorButtonId) {
try {
mColorPicker.setColor(getPaletteColorButtonColor(getPalette(), i), true);
} catch (Exception e) {
}
}
}
}
}
}
@Override
public boolean onLongClick(View v) {
for (int i=0; i<mFavoriteColorButtons.length; i++) {
int favoriteButtonId = mFavoriteColorButtons[i].getId();
if (v.getId() == favoriteButtonId) {
if (!v.hasOnClickListeners()) {
mFavoriteColorButtons[i].setImageResource(R.drawable.color_picker_color_button_color);
mFavoriteColorButtons[i].setOnClickListener(this);
}
mFavoriteColorButtons[i].setColor(mNewColor.getColor());
writeFavoriteButtonValue(i);
}
}
return true;
}
@Override
public boolean onMenuItemClick(MenuItem item) {
if (item.getItemId() == R.id.palette_darkkat) {
setPalette(PALETTE_DARKKAT);
mColorTransitionAnimator.start();
return true;
} else if (item.getItemId() == R.id.palette_material) {
setPalette(PALETTE_MATERIAL);
mColorTransitionAnimator.start();
return true;
} else if (item.getItemId() == R.id.palette_rgb) {
setPalette(PALETTE_RGB);
mColorTransitionAnimator.start();
return true;
} else if (item.getItemId() == R.id.reset_android) {
mColorPicker.setColor(mAndroidColor, true);
return true;
} else if (item.getItemId() == R.id.reset_darkkat) {
mColorPicker.setColor(mDarkKatColor, true);
return true;
}
return false;
}
private void showPalettePopupMenu(View v) {
PopupMenu popup = new PopupMenu(getContext(), v);
popup.setOnMenuItemClickListener(this);
popup.inflate(R.menu.palette);
popup.show();
}
private void showResetPopupMenu(View v) {
PopupMenu popup = new PopupMenu(getContext(), v);
popup.setOnMenuItemClickListener(this);
popup.inflate(R.menu.reset);
popup.show();
}
private void showActionBarEditHex() {
mEditHexBarFadeInAnimator.start();
}
private void hideActionBarEditHex() {
mEditHexBarFadeOutAnimator.start();
}
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
}
@Override
public void afterTextChanged(Editable s) {
}
@Override
public void onFocusChange(View v, boolean hasFocus) {
if (!hasFocus) {
mHex.removeTextChangedListener(this);
InputMethodManager inputMethodManager = (InputMethodManager) getContext()
.getSystemService(Activity.INPUT_METHOD_SERVICE);
inputMethodManager.hideSoftInputFromWindow(v.getWindowToken(), 0);
} else {
mHex.addTextChangedListener(this);
}
}
private int blendColors(int from, int to, float ratio) {
final float inverseRatio = 1f - ratio;
final float a = Color.alpha(to) * ratio + Color.alpha(from) * inverseRatio;
final float r = Color.red(to) * ratio + Color.red(from) * inverseRatio;
final float g = Color.green(to) * ratio + Color.green(from) * inverseRatio;
final float b = Color.blue(to) * ratio + Color.blue(from) * inverseRatio;
return Color.argb((int) a, (int) r, (int) g, (int) b);
}
private int getColor() {
return mColorPicker.getColor();
}
public void setAlphaSliderVisible(boolean visible) {
mColorPicker.setAlphaSliderVisible(visible);
}
private void updatePaletteColorButtonsColor() {
for (int i=0; i<mPaletteColorButtons.length; i++) {
mPaletteColorButtons[i].setColor(getPaletteColorButtonColor(getPalette(), i));
}
updatePaletteColorButtonsTitle();
}
private void updatePaletteColorButtonsTitle() {
int resId = R.string.palette_darkkat_title;
if (getPalette() == PALETTE_MATERIAL) {
resId = R.string.palette_material_title;
} else if (getPalette() == PALETTE_RGB) {
resId = R.string.palette_rgb_title;
}
mPaletteColorButtonsTitle.setText(resId);
}
private int getPalette() {
return Settings.System.getInt(mResolver,
Settings.System.COLOR_PICKER_PALETTE, PALETTE_DARKKAT);
}
private void setPalette(int palette) {
Settings.System.putInt(mResolver,
Settings.System.COLOR_PICKER_PALETTE, palette);
}
private int getPaletteColorButtonColor(int pallete, int index) {
TypedArray ta;
if (pallete == PALETTE_DARKKAT) {
ta = mResources.obtainTypedArray(R.array.color_picker_darkkat_palette);
} else if (pallete == PALETTE_MATERIAL) {
ta = mResources.obtainTypedArray(R.array.color_picker_material_palette);
} else {
ta = mResources.obtainTypedArray(R.array.color_picker_rgb_palette);
}
int palettecolor = mResources.getColor(ta.getResourceId(index, 0));
ta.recycle();
return palettecolor;
}
private void writeFavoriteButtonValue(int index) {
int buttonIndex = index + 1;
SharedPreferences preferences =
getContext().getSharedPreferences(PREFERENCE_NAME, Activity.MODE_PRIVATE);
preferences.edit().putInt(FAVORITE_COLOR_BUTTON + buttonIndex,
mFavoriteColorButtons[index].getColor()).commit();
}
private int getFavoriteButtonValue(int index) {
int buttonIndex = index + 1;
SharedPreferences preferences =
getContext().getSharedPreferences(PREFERENCE_NAME, Activity.MODE_PRIVATE);
return preferences.getInt(FAVORITE_COLOR_BUTTON + buttonIndex, 0);
}
@Override
public Bundle onSaveInstanceState() {
Bundle state = super.onSaveInstanceState();
state.putInt("old_color", mOldColor.getColor());
state.putInt("new_color", mNewColor.getColor());
return state;
}
@Override
public void onRestoreInstanceState(Bundle savedInstanceState) {
super.onRestoreInstanceState(savedInstanceState);
mOldColor.setColor(savedInstanceState.getInt("old_color"));
mColorPicker.setColor(savedInstanceState.getInt("new_color"), true);
updatePaletteColorButtonsColor();
}
}
| [
"[email protected]"
] | |
ffe79f7fc98cf114ddc7e439f6923b71cb6a76e1 | afe2f284d88becc93277be6690dd8582e83443f9 | /Spring-enviroment/spring-core-demo/src/main/java/com/revature/spring_core_demo/Student.java | d2915637b8e0cd4c4bfa4f058bc608fc097fdce8 | [] | no_license | LeylaShams/RevatureDeveloper | 8735feada9e63778337db46f6d4a0ce0be551678 | 7524fcb8b190c9e8e135486d9bb91f4628e14500 | refs/heads/main | 2023-08-13T21:09:52.751162 | 2021-09-21T02:53:59 | 2021-09-21T02:53:59 | 386,102,779 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,060 | java | package com.revature.spring_core_demo;
public class Student {
private int studentId;
private String studentName;
private String studentAddress;
public int getStudentId() {
return studentId;
}
public void setStudentId(int studentId) {
System.out.println("set Id");
this.studentId = studentId;
}
public String getStudentName() {
return studentName;
}
public void setStudentName(String studentName) {
System.out.println("set Name");
this.studentName = studentName;
}
public String getStudentAddress() {
return studentAddress;
}
public void setStudentAddress(String studentAddress) {
System.out.println("set Address");
this.studentAddress = studentAddress;
}
@Override
public String toString() {
return "Student{" +
"studentId=" + studentId +
", studentName='" + studentName + '\'' +
", studentAddress='" + studentAddress + '\'' +
'}';
}
}
| [
"[email protected]"
] | |
1966d6a7f9b63c0d0c504681d8216c0148162f58 | 353fd25040f0b2780ad9c1525882e41fb2b556f5 | /android/app/src/main/java/com/tutorialrootmodalstore/MainApplication.java | 0e1cb5c2365d327e1cb7ba02f8be94295ba88741 | [] | no_license | lfkwtz/tutorial-root-modal-store | 2fe456518125bfcf01aafae1356672436d6db3eb | c8ab122c051a6c041ae8907c0c21814514f46b07 | refs/heads/master | 2023-01-13T01:47:38.105031 | 2020-01-09T16:59:45 | 2020-01-09T16:59:45 | 231,470,301 | 0 | 0 | null | 2023-01-05T04:49:44 | 2020-01-02T22:35:03 | JavaScript | UTF-8 | Java | false | false | 2,289 | java | package com.tutorialrootmodalstore;
import android.app.Application;
import android.content.Context;
import com.facebook.react.PackageList;
import com.facebook.react.ReactApplication;
import com.facebook.react.ReactNativeHost;
import com.facebook.react.ReactPackage;
import com.facebook.soloader.SoLoader;
import java.lang.reflect.InvocationTargetException;
import java.util.List;
public class MainApplication extends Application implements ReactApplication {
private final ReactNativeHost mReactNativeHost =
new ReactNativeHost(this) {
@Override
public boolean getUseDeveloperSupport() {
return BuildConfig.DEBUG;
}
@Override
protected List<ReactPackage> getPackages() {
@SuppressWarnings("UnnecessaryLocalVariable")
List<ReactPackage> packages = new PackageList(this).getPackages();
// Packages that cannot be autolinked yet can be added manually here, for example:
// packages.add(new MyReactNativePackage());
return packages;
}
@Override
protected String getJSMainModuleName() {
return "index";
}
};
@Override
public ReactNativeHost getReactNativeHost() {
return mReactNativeHost;
}
@Override
public void onCreate() {
super.onCreate();
SoLoader.init(this, /* native exopackage */ false);
initializeFlipper(this); // Remove this line if you don't want Flipper enabled
}
/**
* Loads Flipper in React Native templates.
*
* @param context
*/
private static void initializeFlipper(Context context) {
if (BuildConfig.DEBUG) {
try {
/*
We use reflection here to pick up the class that initializes Flipper,
since Flipper library is not available in release mode
*/
Class<?> aClass = Class.forName("com.facebook.flipper.ReactNativeFlipper");
aClass.getMethod("initializeFlipper", Context.class).invoke(null, context);
} catch (ClassNotFoundException e) {
e.printStackTrace();
} catch (NoSuchMethodException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (InvocationTargetException e) {
e.printStackTrace();
}
}
}
}
| [
"[email protected]"
] | |
85fdcc93732218339c603024c5449680782dd028 | eb132b54c6255942d632d195791b6fe124c0e6a3 | /spring-security-oauth2-content-resource/src/main/java/com/tang/oauth/content/resource/web/TbContentController.java | 3a9df4b74ef6a8ac974118cc37d8db488cf50aa8 | [] | no_license | tangxiaonian/spring-security-oauth2 | bfd553c3924444b829c6392fce6d8cbe5f5709aa | bbfbaecd8c94cdfc6c1606d0ce6903d807b190ff | refs/heads/master | 2020-07-06T08:41:47.353012 | 2019-08-18T04:12:07 | 2019-08-18T04:12:07 | 202,957,867 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 878 | java | package com.tang.oauth.content.resource.web;
import com.tang.oauth.content.resource.domain.Tb_content;
import com.tang.oauth.content.resource.dto.ResponseResult;
import com.tang.oauth.content.resource.service.TbContentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
/**
* @author ASUS
* @create 2019-08-17 18:11
*/
@RestController
public class TbContentController {
@Autowired
public TbContentService tbContentServiceImpl;
@GetMapping("/alls")
public ResponseResult<List<Tb_content>> selectAll() {
return new ResponseResult<List<Tb_content>>(HttpStatus.OK.value(),"成功取到数据!",tbContentServiceImpl.selectAll());
}
}
| [
"[email protected]"
] | |
35cab2598b30b9a36ea63cba03a12b02e8ac2ecf | d237437f471853bc45767b724cba0573aa970b54 | /app/src/main/java/com/alabhya/Shaktiman/Adapters/ProducerOrderViewPagerAdapter.java | b473eb959de28fe73c2268e510b1c8c0ed417471 | [] | no_license | cracken47/ShaktimanApp | 0a6a8cbbb8caf6067cc6345061111495eb8a47dc | 029418245f206dda62fb98c85a669271716ddea7 | refs/heads/master | 2020-06-10T16:57:22.135733 | 2019-02-04T02:26:29 | 2019-02-04T02:26:29 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,076 | java | package com.alabhya.Shaktiman.Adapters;
import java.util.ArrayList;
import java.util.List;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentPagerAdapter;
public class ProducerOrderViewPagerAdapter extends FragmentPagerAdapter {
private List<Fragment> fragmentList = new ArrayList<>();
private List<String> fragmentTitle = new ArrayList<>();
public ProducerOrderViewPagerAdapter(@NonNull FragmentManager fm) {
super(fm);
}
@NonNull
@Override
public Fragment getItem(int position) {
return fragmentList.get(position);
}
@Override
public int getCount() {
return fragmentTitle.size();
}
@Nullable
@Override
public CharSequence getPageTitle(int position) {
return fragmentTitle.get(position);
}
public void addFragment(Fragment fragment, String title){
fragmentList.add(fragment);
fragmentTitle.add(title);
}
}
| [
"[email protected]"
] | |
193d1ccf0851a1103db1129eef64c8904948f60b | ed49254b278b48473c9bdf1c3e70ef8010e83cf7 | /BayesBaseNew/src/edu/cmuO/tetrad/search/fastica/swing/NumberDialog.java | d7e8f22f690a0d3fc69cf242b1139e287c7ba9a4 | [] | no_license | sfu-cl-lab/exception-mining | 5ac1e70a9a527d4129d77df66e536c287e5b4e25 | 7b80481f7d906a49db99901adb4059b273ac6af6 | refs/heads/master | 2021-05-31T22:36:21.973306 | 2016-05-15T22:05:14 | 2016-05-15T22:05:14 | 58,755,606 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,219 | java | package edu.cmu.tetrad.search.fastica.swing;
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowEvent;
/**
* This dialog can be used to input a number.
*
* @author Michael Lambertz
*/
public class NumberDialog extends JDialog {
private static final long serialVersionUID = 3257562910472550704L;
private enum State {
PROCESSING,
OKAY,
CANCEL
}
private State state;
private int number;
private JTextField numberTF;
private int min;
private int max;
public NumberDialog(
Frame owner,
String title,
int number,
int min,
int max) {
// create dialog
super(owner, title, true);
// create data
this.number = number;
this.min = min;
this.max = max;
// create dialog content
JPanel mainPn = new JPanel(new BorderLayout(4, 4));
setContentPane(mainPn);
numberTF = new JTextField(Integer.toBinaryString(number));
mainPn.add(numberTF, BorderLayout.CENTER);
JPanel buttonPn = new JPanel();
mainPn.add(buttonPn, BorderLayout.SOUTH);
JButton okBt = new JButton(" OK ");
okBt.addActionListener(
new ActionListener() {
@Override
public void actionPerformed(ActionEvent event) {
actionOk();
}
});
buttonPn.add(okBt);
JButton cancelBt = new JButton("Cancel");
cancelBt.addActionListener(
new ActionListener() {
@Override
public void actionPerformed(ActionEvent event) {
actionCancel();
}
});
buttonPn.add(cancelBt);
mainPn.add(new JLabel(" "), BorderLayout.NORTH);
mainPn.add(new JLabel(" "), BorderLayout.WEST);
mainPn.add(new JLabel(" "), BorderLayout.EAST);
// set frame's size and position
pack();
setLocation(owner.getLocation().x + 16, owner.getLocation().y + 16);
setSize((int) (getSize().width * 1.1), (int) (getSize().height * 1.05));
}
public boolean open() {
state = State.PROCESSING;
setVisible(true);
while (state == State.PROCESSING) ;
return (state == State.OKAY);
}
public int getNumber() {
return (number);
}
private void actionOk() {
int temp;
try {
temp = Integer.parseInt(numberTF.getText());
}
catch (NumberFormatException exc) {
return;
}
if (temp > max)
return;
if (temp < min)
return;
number = temp;
state = State.OKAY;
setVisible(false);
}
private void actionCancel() {
state = State.CANCEL;
setVisible(false);
}
@Override
protected void processWindowEvent(
WindowEvent event) {
if (event.getID() == WindowEvent.WINDOW_CLOSING) {
actionCancel();
}
super.processWindowEvent(event);
}
}
| [
"[email protected]"
] | |
38b6dfd5d3e90b871772244adc8dfc0f086fa1a7 | 96196a9b6c8d03fed9c5b4470cdcf9171624319f | /decompiled/com/google/android/gms/wearable/internal/r.java | 198a90a1091f10d4f4658cc796e60c76225c94a6 | [] | no_license | manciuszz/KTU-Asmens-Sveikatos-Ugdymas | 8ef146712919b0fb9ad211f6cb7cbe550bca10f9 | 41e333937e8e62e1523b783cdb5aeedfa1c7fcc2 | refs/heads/master | 2020-04-27T03:40:24.436539 | 2019-03-05T22:39:08 | 2019-03-05T22:39:08 | 174,031,152 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 700 | java | package com.google.android.gms.wearable.internal;
import android.os.Parcel;
import android.os.Parcelable.Creator;
import com.google.android.gms.common.internal.safeparcel.SafeParcelable;
import com.google.android.gms.wearable.c;
public class r implements SafeParcelable {
public static final Creator<r> CREATOR = new s();
public final c alM;
public final int statusCode;
public final int versionCode;
r(int i, int i2, c cVar) {
this.versionCode = i;
this.statusCode = i2;
this.alM = cVar;
}
public int describeContents() {
return 0;
}
public void writeToParcel(Parcel dest, int flags) {
s.a(this, dest, flags);
}
}
| [
"[email protected]"
] | |
9ce8b7faff2319e57d0516e57112cc7baa280171 | 5a60a659463684241d6113a2176ed10adf1ad4a8 | /FileOpreraitons/src/main/java/com/model/RegUser.java | 1155b36e710af1a988504d9e5ea556687c42388f | [] | no_license | jainnneel/FileOperation | f23abef4680792e3f35b12e764c15f848d2cbcc7 | 26be7406d82280ca1812493a6ca0cab8ec973cce | refs/heads/master | 2023-04-15T22:22:54.997274 | 2021-04-23T07:18:39 | 2021-04-23T07:18:39 | 307,987,000 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,371 | java | package com.model;
import java.sql.Date;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
@Entity
public class RegUser {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private int id;
private String name;
private String email;
private String pass;
private Date d;
private String mobile;
private String role = "USER";
private boolean isEnable;
private Date freeTierExpire;
public RegUser() {
super();
// TODO Auto-generated constructor stub
}
public RegUser(int id, String name, String email, String pass, Date d, String mobile, String role, boolean isEnable,
Date freeTierExpire) {
super();
this.id = id;
this.name = name;
this.email = email;
this.pass = pass;
this.d = d;
this.mobile = mobile;
this.role = role;
this.isEnable = isEnable;
this.freeTierExpire = freeTierExpire;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public String getPass() {
return pass;
}
public void setPass(String pass) {
this.pass = pass;
}
public Date getD() {
return d;
}
public void setD(Date d) {
this.d = d;
}
public String getMobile() {
return mobile;
}
public void setMobile(String mobile) {
this.mobile = mobile;
}
public String getRole() {
return role;
}
public void setRole(String role) {
this.role = role;
}
public boolean isEnable() {
return isEnable;
}
public void setEnable(boolean isEnable) {
this.isEnable = isEnable;
}
public Date getFreeTierExpire() {
return freeTierExpire;
}
public void setFreeTierExpire(Date freeTierExpire) {
this.freeTierExpire = freeTierExpire;
}
}
| [
"[email protected]"
] | |
1129d23972063a3fdb8b0d359e888d20847ddaa3 | 677aca602c03bc9279549b357065cc80cfc934ad | /sources/spring-interceptor/src/test/java/com/schlimm/springcdi/interceptor/ct/_92_C1/interceptors/OldSecurityInterceptor.java | 9fd934ec80ce83dd85bf7dd8c00566ac1c66d789 | [
"MIT"
] | permissive | nschlimm/spring-interceptor | 6e0e8353b18e50649fbd4c4bc71c87dd37dba200 | a8982b9daae3d301a714771eeec494fb55fd9008 | refs/heads/master | 2022-05-03T03:06:10.582277 | 2018-12-22T18:56:16 | 2018-12-22T18:56:16 | 2,148,480 | 6 | 4 | MIT | 2020-10-12T18:26:38 | 2011-08-03T13:13:03 | Java | UTF-8 | Java | false | false | 673 | java | package com.schlimm.springcdi.interceptor.ct._92_C1.interceptors;
import javax.interceptor.AroundInvoke;
import javax.interceptor.Interceptor;
import javax.interceptor.InvocationContext;
import com.schlimm.springcdi.interceptor.ct._92_C1.bindingtypes.Secured;
@Interceptor @Secured
public class OldSecurityInterceptor {
@AroundInvoke
public Object manageTransaction(InvocationContext ctx) throws Exception {
String result = null;
ctx.getContextData().put(this.getClass().getName(), "");
try {
result = (String)ctx.proceed();
} catch (Exception e) {
throw new RuntimeException(e);
}
return result + "_oldinterceptor_";
}
}
| [
"[email protected]"
] | |
e6c1ced07b6fd9398def701fb327dc636088702f | 44949d8b10bed9dbcaeb8b5ba9beac4f0a31016a | /app/src/main/java/com/shun/campuswork/activity/SplashActivity.java | 9efe15b3736d025e820e4266f0ea829944aafa7e | [] | no_license | yankaics/CampusWork | 7856b8806afab03932d11dc6c793757f18b0ca5d | ca3876ab98bccedb90b1e531f414a7780dcf14a9 | refs/heads/master | 2021-01-16T01:07:11.322303 | 2016-02-24T07:19:02 | 2016-02-24T07:19:02 | 62,309,810 | 0 | 1 | null | 2016-06-30T12:43:55 | 2016-06-30T12:43:55 | null | UTF-8 | Java | false | false | 1,267 | java | package com.shun.campuswork.activity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import com.google.gson.Gson;
import com.shun.campuswork.R;
import com.shun.campuswork.domain.UserInfo;
import com.shun.campuswork.global.GlobalContants;
import com.shun.campuswork.tools.SharedPreferencesUtils;
/**
* 起始页
*/
public class SplashActivity extends BaseActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_splash);
initFirst();
new Thread() {
@Override
public void run() {
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
e.printStackTrace();
}
startActivity(new Intent(SplashActivity.this, MainActivity.class));
//跳转后结束当前引导页
SplashActivity.this.finish();
}
}.start();
}
private void initFirst() {
Boolean isFirst = SharedPreferencesUtils.getBoolean("first", true);
if (isFirst) {
}
SharedPreferencesUtils.putBoolean("first", false);
}
}
| [
"[email protected]"
] | |
57e4344e61df0839386e796f0fb13eba297d7c6f | e80c98cb01ec399f9591bae8bd0f0146a6dd8dc3 | /varsql-core/src/main/java/com/varsql/core/db/VarSqlDbDataType.java | 973f6ad3687c55fc1e9d38f8e817394a12408cba | [] | no_license | pencake-squad/varsql | e1de151d7a24bf36e1a41f7b195a96aca31df600 | 4aeec201e4dd2e68513886328f9069509664b023 | refs/heads/master | 2022-12-26T01:33:44.954011 | 2020-10-11T14:25:29 | 2020-10-11T14:25:29 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 395 | java | package com.varsql.core.db;
public enum VarSqlDbDataType {
NUMBER(1)
,STRING(2)
,DATE(3)
,BINARY(4)
,OTHER(99);
private int typeNum;
VarSqlDbDataType(int typeNum){
this.typeNum = typeNum;
}
public boolean isNumber() {
return this.typeNum ==1;
}
public boolean isString() {
return this.typeNum ==2;
}
public boolean isDate() {
return this.typeNum ==3;
}
}
| [
"0skym@ytkim"
] | 0skym@ytkim |
fa4048ce351c759041ccd47d66336f66af89adc2 | 8947af914429e8d6399401f4c40e18978ad5ed4c | /src/main/java/org/gbif/api/model/collections/AlternativeCode.java | de21a82040045b2e323f856a3d75e88c5ec55ace | [
"Apache-2.0"
] | permissive | gbif/gbif-api | 899d09328ce5d2bd0c70da3f0ca6a8a25d4a4c00 | a014a17eca88cf3ab5357a0fc5b6b9458c53db81 | refs/heads/dev | 2023-08-18T16:09:06.973670 | 2023-08-18T10:28:48 | 2023-08-18T10:28:48 | 15,052,119 | 24 | 8 | Apache-2.0 | 2023-06-14T22:56:26 | 2013-12-09T16:12:41 | Java | UTF-8 | Java | false | false | 2,064 | java | /*
* Copyright 2020 Global Biodiversity Information Facility (GBIF)
*
* 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.gbif.api.model.collections;
import java.io.Serializable;
import java.util.Objects;
import java.util.StringJoiner;
/**
* Models a GrSciColl alternative code.
*
* <p>It contains the code and a description to specify why this code exists.
*/
public class AlternativeCode implements Serializable {
private String code;
private String description;
public AlternativeCode() {}
public AlternativeCode(String code, String description) {
this.code = code;
this.description = description;
}
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
AlternativeCode that = (AlternativeCode) o;
return Objects.equals(code, that.code) && Objects.equals(description, that.description);
}
@Override
public int hashCode() {
return Objects.hash(code, description);
}
@Override
public String toString() {
return new StringJoiner(", ", AlternativeCode.class.getSimpleName() + "[", "]")
.add("code='" + code + "'")
.add("description='" + description + "'")
.toString();
}
}
| [
"[email protected]"
] | |
e45677e7220b9bfdbf42c1b1c766e3731addc0c2 | bcc6301d9d827e24b1238316383597f5cbff1a70 | /teamcity-atmosphere-chat-example-server/src/main/java/ru/mail/teamcity/ChatPageController.java | a945fcaebffce3f3cf2ea0585bf77ec31dacc341 | [] | no_license | grundic/teamcity-atmosphere-chat-example | 18ade7460a9691c7f709c56da34e84c4c914def9 | 835561ebf3ca15c5eee6b5201cdb8b764fe74cf6 | refs/heads/master | 2021-03-12T20:35:11.932939 | 2015-04-20T08:12:55 | 2015-04-20T08:13:43 | 34,247,549 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,192 | java | package ru.mail.teamcity;
import jetbrains.buildServer.controllers.BaseController;
import jetbrains.buildServer.web.openapi.PluginDescriptor;
import jetbrains.buildServer.web.openapi.WebControllerManager;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.springframework.web.servlet.ModelAndView;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
/**
* Author: g.chernyshev
* Date: 20.04.15
*/
public class ChatPageController extends BaseController {
private final String myJspPagePath;
public ChatPageController(
@NotNull WebControllerManager webControllerManager,
@NotNull final PluginDescriptor pluginDescriptor
) {
myJspPagePath = pluginDescriptor.getPluginResourcesPath("chat.jsp");
webControllerManager.registerController("/chatPage.html", this);
}
@Nullable
@Override
protected ModelAndView doHandle(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) throws Exception {
final ModelAndView modelAndView = new ModelAndView(myJspPagePath);
return modelAndView;
}
}
| [
"[email protected]"
] | |
623f0a3711fc4dd88c34c8da97b715896e5fdcf9 | 065c1f648e8dd061a20147ff9c0dbb6b5bc8b9be | /eclipseswt_cluster/27089/src_1.java | a4bef17b04db9caeaf21b4bc6b35942675c7fabd | [] | no_license | martinezmatias/GenPat-data-C3 | 63cfe27efee2946831139747e6c20cf952f1d6f6 | b360265a6aa3bb21bd1d64f1fc43c3b37d0da2a4 | refs/heads/master | 2022-04-25T17:59:03.905613 | 2020-04-15T14:41:34 | 2020-04-15T14:41:34 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 133,881 | java | /*******************************************************************************
* Copyright (c) 2000, 2007 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
package org.eclipse.swt.widgets;
import org.eclipse.swt.internal.carbon.ATSFontMetrics;
import org.eclipse.swt.internal.carbon.HIThemeTextInfo;
import org.eclipse.swt.internal.carbon.OS;
import org.eclipse.swt.internal.carbon.CGRect;
import org.eclipse.swt.internal.carbon.CGPoint;
import org.eclipse.swt.internal.carbon.ControlFontStyleRec;
import org.eclipse.swt.internal.carbon.HMHelpContentRec;
import org.eclipse.swt.internal.carbon.HIThemeFrameDrawInfo;
import org.eclipse.swt.internal.carbon.Rect;
import org.eclipse.swt.*;
import org.eclipse.swt.events.*;
import org.eclipse.swt.graphics.*;
import org.eclipse.swt.accessibility.Accessible;
/**
* Control is the abstract superclass of all windowed user interface classes.
* <p>
* <dl>
* <dt><b>Styles:</b>
* <dd>BORDER</dd>
* <dd>LEFT_TO_RIGHT, RIGHT_TO_LEFT</dd>
* <dt><b>Events:</b>
* <dd>DragDetect, FocusIn, FocusOut, Help, KeyDown, KeyUp, MenuDetect, MouseDoubleClick, MouseDown, MouseEnter,
* MouseExit, MouseHover, MouseUp, MouseMove, Move, Paint, Resize, Traverse</dd>
* </dl>
* </p><p>
* Only one of LEFT_TO_RIGHT or RIGHT_TO_LEFT may be specified.
* </p><p>
* IMPORTANT: This class is intended to be subclassed <em>only</em>
* within the SWT implementation.
* </p>
*/
public abstract class Control extends Widget implements Drawable {
/**
* the handle to the OS resource
* (Warning: This field is platform dependent)
* <p>
* <b>IMPORTANT:</b> This field is <em>not</em> part of the SWT
* public API. It is marked public only so that it can be shared
* within the packages provided by SWT. It is not available on all
* platforms and should never be accessed from application code.
* </p>
*/
public int handle;
Composite parent;
String toolTipText;
Object layoutData;
int drawCount, visibleRgn;
Menu menu;
float [] foreground, background;
Image backgroundImage;
Font font;
Cursor cursor;
Region region;
GCData gcs[];
Accessible accessible;
static final String RESET_VISIBLE_REGION = "org.eclipse.swt.internal.resetVisibleRegion"; //$NON-NLS-1$
Control () {
/* Do nothing */
}
/**
* Constructs a new instance of this class given its parent
* and a style value describing its behavior and appearance.
* <p>
* The style value is either one of the style constants defined in
* class <code>SWT</code> which is applicable to instances of this
* class, or must be built by <em>bitwise OR</em>'ing together
* (that is, using the <code>int</code> "|" operator) two or more
* of those <code>SWT</code> style constants. The class description
* lists the style constants that are applicable to the class.
* Style bits are also inherited from superclasses.
* </p>
*
* @param parent a composite control which will be the parent of the new instance (cannot be null)
* @param style the style of control to construct
*
* @exception IllegalArgumentException <ul>
* <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
* </ul>
* @exception SWTException <ul>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
* <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
* </ul>
*
* @see SWT#BORDER
* @see Widget#checkSubclass
* @see Widget#getStyle
*/
public Control (Composite parent, int style) {
super (parent, style);
this.parent = parent;
createWidget ();
}
int actionProc (int theControl, int partCode) {
int result = super.actionProc (theControl, partCode);
if (result == OS.noErr) return result;
if (isDisposed ()) return OS.noErr;
sendTrackEvents ();
return result;
}
/**
* Adds the listener to the collection of listeners who will
* be notified when the control is moved or resized, by sending
* it one of the messages defined in the <code>ControlListener</code>
* interface.
*
* @param listener the listener which should be notified
*
* @exception IllegalArgumentException <ul>
* <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
* </ul>
* @exception SWTException <ul>
* <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*
* @see ControlListener
* @see #removeControlListener
*/
public void addControlListener(ControlListener listener) {
checkWidget();
if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
TypedListener typedListener = new TypedListener (listener);
addListener (SWT.Resize,typedListener);
addListener (SWT.Move,typedListener);
}
/**
* Adds the listener to the collection of listeners who will
* be notified when a drag gesture occurs, by sending it
* one of the messages defined in the <code>DragDetectListener</code>
* interface.
*
* @param listener the listener which should be notified
*
* @exception IllegalArgumentException <ul>
* <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
* </ul>
* @exception SWTException <ul>
* <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*
* @see DragDetectListener
* @see #removeDragDetectListener
*
* @since 3.3
*/
public void addDragDetectListener (DragDetectListener listener) {
checkWidget ();
if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
TypedListener typedListener = new TypedListener (listener);
addListener (SWT.DragDetect,typedListener);
}
/**
* Adds the listener to the collection of listeners who will
* be notified when the control gains or loses focus, by sending
* it one of the messages defined in the <code>FocusListener</code>
* interface.
*
* @param listener the listener which should be notified
*
* @exception IllegalArgumentException <ul>
* <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
* </ul>
* @exception SWTException <ul>
* <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*
* @see FocusListener
* @see #removeFocusListener
*/
public void addFocusListener(FocusListener listener) {
checkWidget();
if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
TypedListener typedListener = new TypedListener (listener);
addListener(SWT.FocusIn,typedListener);
addListener(SWT.FocusOut,typedListener);
}
/**
* Adds the listener to the collection of listeners who will
* be notified when help events are generated for the control,
* by sending it one of the messages defined in the
* <code>HelpListener</code> interface.
*
* @param listener the listener which should be notified
*
* @exception IllegalArgumentException <ul>
* <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
* </ul>
* @exception SWTException <ul>
* <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*
* @see HelpListener
* @see #removeHelpListener
*/
public void addHelpListener (HelpListener listener) {
checkWidget();
if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
TypedListener typedListener = new TypedListener (listener);
addListener (SWT.Help, typedListener);
}
/**
* Adds the listener to the collection of listeners who will
* be notified when keys are pressed and released on the system keyboard, by sending
* it one of the messages defined in the <code>KeyListener</code>
* interface.
* <p>
* When a key listener is added to a control, the control
* will take part in widget traversal. By default, all
* traversal keys (such as the tab key and so on) are
* delivered to the control. In order for a control to take
* part in traversal, it should listen for traversal events.
* Otherwise, the user can traverse into a control but not
* out. Note that native controls such as table and tree
* implement key traversal in the operating system. It is
* not necessary to add traversal listeners for these controls,
* unless you want to override the default traversal.
* </p>
* @param listener the listener which should be notified
*
* @exception IllegalArgumentException <ul>
* <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
* </ul>
* @exception SWTException <ul>
* <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*
* @see KeyListener
* @see #removeKeyListener
*/
public void addKeyListener(KeyListener listener) {
checkWidget();
if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
TypedListener typedListener = new TypedListener (listener);
addListener(SWT.KeyUp,typedListener);
addListener(SWT.KeyDown,typedListener);
}
/**
* Adds the listener to the collection of listeners who will
* be notified when the platform-specific context menu trigger
* has occurred, by sending it one of the messages defined in
* the <code>MenuDetectListener</code> interface.
*
* @param listener the listener which should be notified
*
* @exception IllegalArgumentException <ul>
* <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
* </ul>
* @exception SWTException <ul>
* <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*
* @see MenuDetectListener
* @see #removeMenuDetectListener
*
* @since 3.3
*/
public void addMenuDetectListener (MenuDetectListener listener) {
checkWidget ();
if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
TypedListener typedListener = new TypedListener (listener);
addListener (SWT.MenuDetect, typedListener);
}
/**
* Adds the listener to the collection of listeners who will
* be notified when mouse buttons are pressed and released, by sending
* it one of the messages defined in the <code>MouseListener</code>
* interface.
*
* @param listener the listener which should be notified
*
* @exception IllegalArgumentException <ul>
* <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
* </ul>
* @exception SWTException <ul>
* <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*
* @see MouseListener
* @see #removeMouseListener
*/
public void addMouseListener(MouseListener listener) {
checkWidget();
if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
TypedListener typedListener = new TypedListener (listener);
addListener(SWT.MouseDown,typedListener);
addListener(SWT.MouseUp,typedListener);
addListener(SWT.MouseDoubleClick,typedListener);
}
/**
* Adds the listener to the collection of listeners who will
* be notified when the mouse passes or hovers over controls, by sending
* it one of the messages defined in the <code>MouseTrackListener</code>
* interface.
*
* @param listener the listener which should be notified
*
* @exception IllegalArgumentException <ul>
* <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
* </ul>
* @exception SWTException <ul>
* <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*
* @see MouseTrackListener
* @see #removeMouseTrackListener
*/
public void addMouseTrackListener (MouseTrackListener listener) {
checkWidget();
if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
TypedListener typedListener = new TypedListener (listener);
addListener (SWT.MouseEnter,typedListener);
addListener (SWT.MouseExit,typedListener);
addListener (SWT.MouseHover,typedListener);
}
/**
* Adds the listener to the collection of listeners who will
* be notified when the mouse moves, by sending it one of the
* messages defined in the <code>MouseMoveListener</code>
* interface.
*
* @param listener the listener which should be notified
*
* @exception IllegalArgumentException <ul>
* <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
* </ul>
* @exception SWTException <ul>
* <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*
* @see MouseMoveListener
* @see #removeMouseMoveListener
*/
public void addMouseMoveListener(MouseMoveListener listener) {
checkWidget();
if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
TypedListener typedListener = new TypedListener (listener);
addListener(SWT.MouseMove,typedListener);
}
/**
* Adds the listener to the collection of listeners who will
* be notified when the mouse wheel is scrolled, by sending
* it one of the messages defined in the
* <code>MouseWheelListener</code> interface.
*
* @param listener the listener which should be notified
*
* @exception IllegalArgumentException <ul>
* <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
* </ul>
* @exception SWTException <ul>
* <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*
* @see MouseWheelListener
* @see #removeMouseWheelListener
*
* @since 3.3
*/
public void addMouseWheelListener (MouseWheelListener listener) {
checkWidget ();
if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
TypedListener typedListener = new TypedListener (listener);
addListener (SWT.MouseWheel, typedListener);
}
/**
* Adds the listener to the collection of listeners who will
* be notified when the receiver needs to be painted, by sending it
* one of the messages defined in the <code>PaintListener</code>
* interface.
*
* @param listener the listener which should be notified
*
* @exception IllegalArgumentException <ul>
* <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
* </ul>
* @exception SWTException <ul>
* <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*
* @see PaintListener
* @see #removePaintListener
*/
public void addPaintListener(PaintListener listener) {
checkWidget();
if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
TypedListener typedListener = new TypedListener (listener);
addListener(SWT.Paint,typedListener);
}
/**
* Adds the listener to the collection of listeners who will
* be notified when traversal events occur, by sending it
* one of the messages defined in the <code>TraverseListener</code>
* interface.
*
* @param listener the listener which should be notified
*
* @exception IllegalArgumentException <ul>
* <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
* </ul>
* @exception SWTException <ul>
* <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*
* @see TraverseListener
* @see #removeTraverseListener
*/
public void addTraverseListener (TraverseListener listener) {
checkWidget();
if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
TypedListener typedListener = new TypedListener (listener);
addListener (SWT.Traverse,typedListener);
}
int colorProc (int inControl, int inMessage, int inDrawDepth, int inDrawInColor) {
switch (inMessage) {
case OS.kControlMsgApplyTextColor: {
if (foreground != null) {
OS.RGBForeColor (toRGBColor (foreground));
} else {
OS.SetThemeTextColor ((short) OS.kThemeTextColorDialogActive, (short) inDrawDepth, inDrawInColor != 0);
}
return OS.noErr;
}
case OS.kControlMsgSetUpBackground: {
float [] background = this.background != null ? this.background : getParentBackground ();
if (background != null) {
OS.RGBBackColor (toRGBColor (background));
} else {
OS.SetThemeBackground ((short) OS.kThemeBrushDialogBackgroundActive, (short) inDrawDepth, inDrawInColor != 0);
}
return OS.noErr;
}
}
return OS.eventNotHandledErr;
}
int callFocusEventHandler (int nextHandler, int theEvent) {
return OS.CallNextEventHandler (nextHandler, theEvent);
}
void checkBackground () {
Shell shell = getShell ();
if (this == shell) return;
state &= ~PARENT_BACKGROUND;
Composite composite = parent;
do {
int mode = composite.backgroundMode;
if (mode != 0) {
if (mode == SWT.INHERIT_DEFAULT) {
Control control = this;
do {
if ((control.state & THEME_BACKGROUND) == 0) {
return;
}
control = control.parent;
} while (control != composite);
}
state |= PARENT_BACKGROUND;
return;
}
if (composite == shell) break;
composite = composite.parent;
} while (true);
}
void checkBuffered () {
style |= SWT.DOUBLE_BUFFERED;
}
/**
* Returns the preferred size of the receiver.
* <p>
* The <em>preferred size</em> of a control is the size that it would
* best be displayed at. The width hint and height hint arguments
* allow the caller to ask a control questions such as "Given a particular
* width, how high does the control need to be to show all of the contents?"
* To indicate that the caller does not wish to constrain a particular
* dimension, the constant <code>SWT.DEFAULT</code> is passed for the hint.
* </p>
*
* @param wHint the width hint (can be <code>SWT.DEFAULT</code>)
* @param hHint the height hint (can be <code>SWT.DEFAULT</code>)
* @return the preferred size of the control
*
* @exception SWTException <ul>
* <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*
* @see Layout
* @see #getBorderWidth
* @see #getBounds
* @see #getSize
* @see #pack(boolean)
* @see "computeTrim, getClientArea for controls that implement them"
*/
public Point computeSize (int wHint, int hHint) {
return computeSize (wHint, hHint, true);
}
/**
* Returns the preferred size of the receiver.
* <p>
* The <em>preferred size</em> of a control is the size that it would
* best be displayed at. The width hint and height hint arguments
* allow the caller to ask a control questions such as "Given a particular
* width, how high does the control need to be to show all of the contents?"
* To indicate that the caller does not wish to constrain a particular
* dimension, the constant <code>SWT.DEFAULT</code> is passed for the hint.
* </p><p>
* If the changed flag is <code>true</code>, it indicates that the receiver's
* <em>contents</em> have changed, therefore any caches that a layout manager
* containing the control may have been keeping need to be flushed. When the
* control is resized, the changed flag will be <code>false</code>, so layout
* manager caches can be retained.
* </p>
*
* @param wHint the width hint (can be <code>SWT.DEFAULT</code>)
* @param hHint the height hint (can be <code>SWT.DEFAULT</code>)
* @param changed <code>true</code> if the control's contents have changed, and <code>false</code> otherwise
* @return the preferred size of the control.
*
* @exception SWTException <ul>
* <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*
* @see Layout
* @see #getBorderWidth
* @see #getBounds
* @see #getSize
* @see #pack(boolean)
* @see "computeTrim, getClientArea for controls that implement them"
*/
public Point computeSize (int wHint, int hHint, boolean changed) {
checkWidget();
int width = DEFAULT_WIDTH;
int height = DEFAULT_HEIGHT;
if (wHint != SWT.DEFAULT) width = wHint;
if (hHint != SWT.DEFAULT) height = hHint;
int border = getBorderWidth ();
width += border * 2;
height += border * 2;
return new Point (width, height);
}
Control computeTabGroup () {
if (isTabGroup()) return this;
return parent.computeTabGroup ();
}
Control[] computeTabList() {
if (isTabGroup()) {
if (getVisible() && getEnabled()) {
return new Control[] {this};
}
}
return new Control[0];
}
Control computeTabRoot () {
Control[] tabList = parent._getTabList();
if (tabList != null) {
int index = 0;
while (index < tabList.length) {
if (tabList [index] == this) break;
index++;
}
if (index == tabList.length) {
if (isTabGroup ()) return this;
}
}
return parent.computeTabRoot ();
}
void createWidget () {
state |= DRAG_DETECT;
checkOrientation (parent);
super.createWidget ();
checkBackground ();
checkBuffered ();
setDefaultFont ();
setZOrder ();
}
Color defaultBackground () {
return display.getSystemColor (SWT.COLOR_WIDGET_BACKGROUND);
}
Font defaultFont () {
byte [] family = new byte [256];
short [] size = new short [1];
byte [] style = new byte [1];
OS.GetThemeFont ((short) defaultThemeFont (), (short) OS.smSystemScript, family, size, style);
short id = OS.FMGetFontFamilyFromName (family);
int [] font = new int [1];
OS.FMGetFontFromFontFamilyInstance (id, style [0], font, null);
return Font.carbon_new (display, OS.FMGetATSFontRefFromFont (font [0]), style [0], size [0]);
}
Color defaultForeground () {
return display.getSystemColor (SWT.COLOR_WIDGET_FOREGROUND);
}
int defaultThemeFont () {
if (display.smallFonts) return OS.kThemeSmallSystemFont;
return OS.kThemeSystemFont;
}
void deregister () {
super.deregister ();
display.removeWidget (handle);
}
void destroyWidget () {
Display display = this.display;
int theControl = topHandle ();
releaseHandle ();
if (theControl != 0) {
if (display.delayDispose) {
display.addToDisposeWindow (theControl);
} else {
OS.DisposeControl (theControl);
}
}
}
/**
* Detects a drag and drop gesture. This method is used
* to detect a drag gesture when called from within a mouse
* down listener.
*
* <p>By default, a drag is detected when the gesture
* occurs anywhere within the client area of a control.
* Some controls, such as tables and trees, override this
* behavior. In addition to the operating system specific
* drag gesture, they require the mouse to be inside an
* item. Custom widget writers can use <code>setDragDetect</code>
* to disable the default detection, listen for mouse down,
* and then call <code>dragDetect()</code> from within the
* listener to conditionally detect a drag.
* </p>
*
* @param event the mouse down event
*
* @return <code>true</code> if the gesture occurred, and <code>false</code> otherwise.
*
* @exception IllegalArgumentException <ul>
* <li>ERROR_NULL_ARGUMENT when the event is null</li>
* </ul>
* @exception SWTException <ul>
* <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*
* @see DragDetectListener
* @see #addDragDetectListener
*
* @see #getDragDetect
* @see #setDragDetect
*
* @since 3.3
*/
public boolean dragDetect (Event event) {
checkWidget ();
if (event == null) error (SWT.ERROR_NULL_ARGUMENT);
return dragDetect (event.button, event.count, event.stateMask, event.x, event.y);
}
/**
* Detects a drag and drop gesture. This method is used
* to detect a drag gesture when called from within a mouse
* down listener.
*
* <p>By default, a drag is detected when the gesture
* occurs anywhere within the client area of a control.
* Some controls, such as tables and trees, override this
* behavior. In addition to the operating system specific
* drag gesture, they require the mouse to be inside an
* item. Custom widget writers can use <code>setDragDetect</code>
* to disable the default detection, listen for mouse down,
* and then call <code>dragDetect()</code> from within the
* listener to conditionally detect a drag.
* </p>
*
* @param event the mouse down event
*
* @return <code>true</code> if the gesture occurred, and <code>false</code> otherwise.
*
* @exception IllegalArgumentException <ul>
* <li>ERROR_NULL_ARGUMENT when the event is null</li>
* </ul>
* @exception SWTException <ul>
* <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*
* @see DragDetectListener
* @see #addDragDetectListener
*
* @see #getDragDetect
* @see #setDragDetect
*
* @since 3.3
*/
public boolean dragDetect (MouseEvent event) {
checkWidget ();
if (event == null) error (SWT.ERROR_NULL_ARGUMENT);
return dragDetect (event.button, event.count, event.stateMask, event.x, event.y);
}
boolean dragDetect (int button, int count, int stateMask, int x, int y) {
if (button != 1 || count != 1) return false;
if (!dragDetect (x, y, false, null)) return false;
return sendDragEvent (button, stateMask, x, y);
}
boolean dragDetect (int x, int y, boolean filter, boolean [] consume) {
Rect rect = new Rect ();
int window = OS.GetControlOwner (handle);
CGPoint pt = new CGPoint ();
OS.HIViewConvertPoint (pt, handle, 0);
x += (int) pt.x;
y += (int) pt.y;
OS.GetWindowBounds (window, (short) OS.kWindowStructureRgn, rect);
x += rect.left;
y += rect.top;
org.eclipse.swt.internal.carbon.Point pt1 = new org.eclipse.swt.internal.carbon.Point ();
pt1.h = (short) x;
pt1.v = (short) y;
return OS.WaitMouseMoved (pt1);
}
void drawFocus (int control, int context, boolean hasFocus, boolean hasBorder, boolean drawBackground, Rect inset) {
if (drawBackground) fillBackground (control, context, null);
CGRect rect = new CGRect ();
OS.HIViewGetBounds (control, rect);
rect.x += inset.left;
rect.y += inset.top;
rect.width -= inset.right + inset.left;
rect.height -= inset.bottom + inset.top;
int state;
if (OS.IsControlEnabled (control)) {
state = OS.IsControlActive (control) ? OS.kThemeStateActive : OS.kThemeStateInactive;
} else {
state = OS.IsControlActive (control) ? OS.kThemeStateUnavailable : OS.kThemeStateUnavailableInactive;
}
if (hasBorder) {
HIThemeFrameDrawInfo info = new HIThemeFrameDrawInfo ();
info.state = state;
info.kind = OS.kHIThemeFrameTextFieldSquare;
info.isFocused = hasFocus;
OS.HIThemeDrawFrame (rect, info, context, OS.kHIThemeOrientationNormal);
} else {
OS.HIThemeDrawFocusRect (rect, hasFocus, context, OS.kHIThemeOrientationNormal);
}
}
boolean drawFocusRing () {
return hasBorder ();
}
boolean drawGripper (int x, int y, int width, int height, boolean vertical) {
return false;
}
void drawWidget (int control, int context, int damageRgn, int visibleRgn, int theEvent) {
if (control != handle) return;
if (!hooks (SWT.Paint) && !filters (SWT.Paint)) return;
/* Retrieve the damage rect */
Rect rect = new Rect ();
OS.GetRegionBounds (visibleRgn, rect);
/* Send paint event */
int [] port = new int [1];
OS.GetPort (port);
GCData data = new GCData ();
data.port = port [0];
data.paintEvent = theEvent;
data.visibleRgn = visibleRgn;
GC gc = GC.carbon_new (this, data);
Event event = new Event ();
event.gc = gc;
event.x = rect.left;
event.y = rect.top;
event.width = rect.right - rect.left;
event.height = rect.bottom - rect.top;
sendEvent (SWT.Paint, event);
event.gc = null;
gc.dispose ();
}
void enableWidget (boolean enabled) {
int topHandle = topHandle ();
if (enabled) {
OS.EnableControl (topHandle);
} else {
OS.DisableControl (topHandle);
}
}
boolean equals(float[] color1, float[] color2) {
if (color1 == color2) return true;
if (color1 == null) return color2 == null;
if (color2 == null) return color1 == null;
for (int i = 0; i < color1.length; i++) {
if (color1 [i] != color2 [i]) return false;
}
return true;
}
void fillBackground (int control, int context, Rectangle bounds) {
OS.CGContextSaveGState (context);
CGRect rect = new CGRect ();
if (bounds != null) {
rect.x = bounds.x;
rect.y = bounds.y;
rect.width = bounds.width;
rect.height = bounds.height;
} else {
OS.HIViewGetBounds (control, rect);
}
Control widget = findBackgroundControl ();
if (widget != null && widget.backgroundImage != null) {
CGPoint pt = new CGPoint();
OS.HIViewConvertPoint (pt, control, widget.handle);
OS.CGContextTranslateCTM (context, -pt.x, -pt.y);
Pattern pattern = new Pattern (display, widget.backgroundImage);
GCData data = new GCData ();
data.device = display;
data.background = widget.getBackgroundColor ().handle;
GC gc = GC.carbon_new (context, data);
gc.setBackgroundPattern (pattern);
gc.fillRectangle ((int) (rect.x + pt.x), (int) (rect.y + pt.y), (int) rect.width, (int) rect.height);
gc.dispose ();
pattern.dispose();
} else if (widget != null && widget.background != null) {
int colorspace = OS.CGColorSpaceCreateDeviceRGB ();
OS.CGContextSetFillColorSpace (context, colorspace);
OS.CGContextSetFillColor (context, widget.background);
OS.CGColorSpaceRelease (colorspace);
OS.CGContextSetAlpha (context, getThemeAlpha ());
OS.CGContextFillRect (context, rect);
} else {
if (OS.VERSION >= 0x1040) {
OS.HIThemeSetFill (OS.kThemeBrushDialogBackgroundActive, 0, context, OS.kHIThemeOrientationNormal);
OS.CGContextSetAlpha (context, getThemeAlpha ());
OS.CGContextFillRect (context, rect);
} else {
Rect rect1 = new Rect ();
rect1.left = (short) rect.x;
rect1.top = (short) rect.y;
rect1.right = (short) (rect.x + rect.width);
rect1.bottom = (short) (rect.y + rect.height);
OS.SetThemeBackground ((short) OS.kThemeBrushDialogBackgroundActive, (short) 0, true);
OS.EraseRect (rect1);
}
}
OS.CGContextRestoreGState (context);
}
Cursor findCursor () {
if (cursor != null) return cursor;
return parent.findCursor ();
}
Control findBackgroundControl () {
if (backgroundImage != null || background != null) return this;
return (state & PARENT_BACKGROUND) != 0 ? parent.findBackgroundControl () : null;
}
Menu [] findMenus (Control control) {
if (menu != null && this != control) return new Menu [] {menu};
return new Menu [0];
}
void fixChildren (Shell newShell, Shell oldShell, Decorations newDecorations, Decorations oldDecorations, Menu [] menus) {
oldShell.fixShell (newShell, this);
oldDecorations.fixDecorations (newDecorations, this, menus);
}
void fixFocus (Control focusControl) {
Shell shell = getShell ();
Control control = this;
while (control != shell && (control = control.parent) != null) {
if (control.setFocus ()) return;
}
shell.setSavedFocus (focusControl);
int window = OS.GetControlOwner (handle);
OS.ClearKeyboardFocus (window);
}
int focusHandle () {
return handle;
}
int focusPart () {
return OS.kControlFocusNextPart;
}
/**
* Forces the receiver to have the <em>keyboard focus</em>, causing
* all keyboard events to be delivered to it.
*
* @return <code>true</code> if the control got focus, and <code>false</code> if it was unable to.
*
* @exception SWTException <ul>
* <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*
* @see #setFocus
*/
public boolean forceFocus () {
checkWidget();
if (display.focusEvent == SWT.FocusOut) return false;
Decorations shell = menuShell ();
shell.setSavedFocus (this);
if (!isEnabled () || !isVisible ()/* || !isActive ()*/) return false;
if (isFocusControl ()) return true;
shell.setSavedFocus (null);
shell.bringToTop (false);
if (isDisposed ()) return false;
/*
* Feature in the Macintosh. SetKeyboardFocus() sends kEventControlSetFocusPart
* with the part code equal to kControlFocusNoPart to the control that is about
* to lose focus and then sends kEventControlSetFocusPart with part code equal
* to kControlFocusNextPart to this control (the one that is about to get focus).
* If the control does not accept focus because of the full keyboard access mode,
* kEventControlSetFocusPart is sent again to the control in focus causing multiple
* focus events to happen. The fix is to ignore focus events and issue them only
* if the focus control changed.
*/
int focusHandle = focusHandle ();
int window = OS.GetControlOwner (focusHandle);
Control oldFocus = display.getFocusControl (window, true);
if (oldFocus == this) return true;
display.ignoreFocus = true;
OS.SetKeyboardFocus (window, focusHandle, (short) focusPart ());
display.ignoreFocus = false;
Control newFocus = display.getFocusControl ();
if (oldFocus != newFocus) {
if (oldFocus != null && !oldFocus.isDisposed ()) oldFocus.sendFocusEvent (SWT.FocusOut, false);
if (newFocus != null && !newFocus.isDisposed () && newFocus.isEnabled ()) newFocus.sendFocusEvent (SWT.FocusIn, false);
}
if (isDisposed ()) return false;
shell.setSavedFocus (this);
return hasFocus ();
}
/**
* Returns the accessible object for the receiver.
* If this is the first time this object is requested,
* then the object is created and returned.
*
* @return the accessible object
*
* @exception SWTException <ul>
* <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*
* @see Accessible#addAccessibleListener
* @see Accessible#addAccessibleControlListener
*
* @since 2.0
*/
public Accessible getAccessible () {
checkWidget ();
if (accessible == null) accessible = new_Accessible (this);
return accessible;
}
/**
* Returns the receiver's background color.
*
* @return the background color
*
* @exception SWTException <ul>
* <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
public Color getBackground () {
checkWidget();
Control control = findBackgroundControl ();
if (control == null) control = this;
return control.getBackgroundColor ();
}
Color getBackgroundColor () {
return background != null ? Color.carbon_new (display, background) : defaultBackground ();
}
/**
* Returns the receiver's background image.
*
* @return the background image
*
* @exception SWTException <ul>
* <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*
* @since 3.2
*/
public Image getBackgroundImage () {
checkWidget();
Control control = findBackgroundControl ();
if (control == null) control = this;
return control.backgroundImage;
}
/**
* Returns the receiver's border width.
*
* @return the border width
*
* @exception SWTException <ul>
* <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
public int getBorderWidth () {
checkWidget();
return 0;
}
/**
* Returns a rectangle describing the receiver's size and location
* relative to its parent (or its display if its parent is null),
* unless the receiver is a shell. In this case, the location is
* relative to the display.
*
* @return the receiver's bounding rectangle
*
* @exception SWTException <ul>
* <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
public Rectangle getBounds () {
checkWidget();
return getControlBounds (topHandle ());
}
/**
* Returns <code>true</code> if the receiver is detecting
* drag gestures, and <code>false</code> otherwise.
*
* @return the receiver's drag detect state
*
* @exception SWTException <ul>
* <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*
* @since 3.3
*/
public boolean getDragDetect () {
checkWidget ();
return (state & DRAG_DETECT) != 0;
}
int getDrawCount (int control) {
if (!isTrimHandle (control) && drawCount > 0) return drawCount;
return parent.getDrawCount (control);
}
/**
* Returns the receiver's cursor, or null if it has not been set.
* <p>
* When the mouse pointer passes over a control its appearance
* is changed to match the control's cursor.
* </p>
* </ul>
* @exception SWTException <ul>
* <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*
* @since 3.3
*/
public Cursor getCursor () {
checkWidget();
return cursor;
}
/**
* Returns <code>true</code> if the receiver is enabled, and
* <code>false</code> otherwise. A disabled control is typically
* not selectable from the user interface and draws with an
* inactive or "grayed" look.
*
* @return the receiver's enabled state
*
* @exception SWTException <ul>
* <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*
* @see #isEnabled
*/
public boolean getEnabled () {
checkWidget();
return (state & DISABLED) == 0;
}
/**
* Returns the font that the receiver will use to paint textual information.
*
* @return the receiver's font
*
* @exception SWTException <ul>
* <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
public Font getFont () {
checkWidget();
return font != null ? font : defaultFont ();
}
/**
* Returns the foreground color that the receiver will use to draw.
*
* @return the receiver's foreground color
*
* @exception SWTException <ul>
* <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
public Color getForeground () {
checkWidget();
return getForegroundColor ();
}
Color getForegroundColor () {
return foreground != null ? Color.carbon_new (display, foreground) : defaultForeground ();
}
/**
* Returns layout data which is associated with the receiver.
*
* @return the receiver's layout data
*
* @exception SWTException <ul>
* <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
public Object getLayoutData () {
checkWidget();
return layoutData;
}
/**
* Returns a point describing the receiver's location relative
* to its parent (or its display if its parent is null), unless
* the receiver is a shell. In this case, the point is
* relative to the display.
*
* @return the receiver's location
*
* @exception SWTException <ul>
* <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
public Point getLocation () {
checkWidget();
Rectangle rect = getControlBounds (topHandle ());
return new Point (rect.x, rect.y);
}
/**
* Returns the receiver's pop up menu if it has one, or null
* if it does not. All controls may optionally have a pop up
* menu that is displayed when the user requests one for
* the control. The sequence of key strokes, button presses
* and/or button releases that are used to request a pop up
* menu is platform specific.
*
* @return the receiver's menu
*
* @exception SWTException <ul>
* <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
public Menu getMenu () {
checkWidget();
return menu;
}
int getMininumHeight () {
return 0;
}
/**
* Returns the receiver's monitor.
*
* @return the receiver's monitor
*
* @since 3.0
*/
public Monitor getMonitor () {
checkWidget();
Monitor [] monitors = display.getMonitors ();
if (monitors.length == 1) return monitors [0];
int index = -1, value = -1;
Rectangle bounds = getBounds ();
if (this != getShell ()) {
bounds = display.map (this.parent, null, bounds);
}
for (int i=0; i<monitors.length; i++) {
Rectangle rect = bounds.intersection (monitors [i].getBounds ());
int area = rect.width * rect.height;
if (area > 0 && area > value) {
index = i;
value = area;
}
}
if (index >= 0) return monitors [index];
int centerX = bounds.x + bounds.width / 2, centerY = bounds.y + bounds.height / 2;
for (int i=0; i<monitors.length; i++) {
Rectangle rect = monitors [i].getBounds ();
int x = centerX < rect.x ? rect.x - centerX : centerX > rect.x + rect.width ? centerX - rect.x - rect.width : 0;
int y = centerY < rect.y ? rect.y - centerY : centerY > rect.y + rect.height ? centerY - rect.y - rect.height : 0;
int distance = x * x + y * y;
if (index == -1 || distance < value) {
index = i;
value = distance;
}
}
return monitors [index];
}
/**
* Returns the receiver's parent, which must be a <code>Composite</code>
* or null when the receiver is a shell that was created with null or
* a display for a parent.
*
* @return the receiver's parent
*
* @exception SWTException <ul>
* <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
public Composite getParent () {
checkWidget();
return parent;
}
float [] getParentBackground () {
return parent.background;
}
Control [] getPath () {
int count = 0;
Shell shell = getShell ();
Control control = this;
while (control != shell) {
count++;
control = control.parent;
}
control = this;
Control [] result = new Control [count];
while (control != shell) {
result [--count] = control;
control = control.parent;
}
return result;
}
public Region getRegion () {
checkWidget ();
return region;
}
/**
* Returns the receiver's shell. For all controls other than
* shells, this simply returns the control's nearest ancestor
* shell. Shells return themselves, even if they are children
* of other shells.
*
* @return the receiver's shell
*
* @exception SWTException <ul>
* <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*
* @see #getParent
*/
public Shell getShell () {
checkWidget();
return parent.getShell ();
}
/**
* Returns a point describing the receiver's size. The
* x coordinate of the result is the width of the receiver.
* The y coordinate of the result is the height of the
* receiver.
*
* @return the receiver's size
*
* @exception SWTException <ul>
* <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
public Point getSize () {
checkWidget();
return getControlSize (topHandle ());
}
/**
* Returns the receiver's tool tip text, or null if it has
* not been set.
*
* @return the receiver's tool tip text
*
* @exception SWTException <ul>
* <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
public String getToolTipText () {
checkWidget();
return toolTipText;
}
float getThemeAlpha () {
return 1 * parent.getThemeAlpha ();
}
/**
* Returns <code>true</code> if the receiver is visible, and
* <code>false</code> otherwise.
* <p>
* If one of the receiver's ancestors is not visible or some
* other condition makes the receiver not visible, this method
* may still indicate that it is considered visible even though
* it may not actually be showing.
* </p>
*
* @return the receiver's visibility state
*
* @exception SWTException <ul>
* <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
public boolean getVisible () {
checkWidget();
return (state & HIDDEN) == 0;
}
int getVisibleRegion (int control, boolean clipChildren) {
if (!clipChildren) return super.getVisibleRegion (control, clipChildren);
if (visibleRgn == 0) {
visibleRgn = OS.NewRgn ();
calculateVisibleRegion (control, visibleRgn, clipChildren);
}
int result = OS.NewRgn ();
OS.CopyRgn (visibleRgn, result);
return result;
}
boolean hasBorder () {
return (style & SWT.BORDER) != 0;
}
boolean hasFocus () {
return this == display.getFocusControl ();
}
int helpProc (int inControl, int inGlobalMouse, int inRequest, int outContentProvided, int ioHelpContent) {
switch (inRequest) {
case OS.kHMSupplyContent: {
short [] contentProvided = {OS.kHMContentNotProvidedDontPropagate};
if (toolTipText != null && toolTipText.length () != 0) {
char [] buffer = new char [toolTipText.length ()];
toolTipText.getChars (0, buffer.length, buffer, 0);
int length = fixMnemonic (buffer);
if (display.helpString != 0) OS.CFRelease (display.helpString);
display.helpString = OS.CFStringCreateWithCharacters (OS.kCFAllocatorDefault, buffer, length);
HMHelpContentRec helpContent = new HMHelpContentRec ();
OS.memmove (helpContent, ioHelpContent, HMHelpContentRec.sizeof);
helpContent.version = OS.kMacHelpVersion;
/*
* Feature in the Macintosh. Despite the fact that the Mac
* provides 23 different types of alignment for the help text,
* it does not allow the text to be positioned at the current
* mouse position. The fix is to center the text in a rectangle
* that surrounds the original position of the mouse. As the
* mouse is moved, this rectangle is grown to include the new
* location of the mouse. The help text is then centered by
* the Mac in the new rectangle that was carefully constructed
* such that the help text will stay in the same position.
*/
int cursorHeight = 16;
helpContent.tagSide = (short) OS.kHMAbsoluteCenterAligned;
org.eclipse.swt.internal.carbon.Point pt = new org.eclipse.swt.internal.carbon.Point ();
OS.memmove(pt, new int[] {inGlobalMouse}, 4);
int x = pt.h;
int y = pt.v;
if (display.helpWidget != this) {
display.lastHelpX = x + cursorHeight / 2;
display.lastHelpY = y + cursorHeight + cursorHeight / 2;
}
int jitter = 4;
int deltaX = Math.abs (display.lastHelpX - x) + jitter;
int deltaY = Math.abs (display.lastHelpY - y) + jitter;
x = display.lastHelpX - deltaX;
y = display.lastHelpY - deltaY;
int width = deltaX * 2;
int height = deltaY * 2;
display.helpWidget = this;
helpContent.absHotRect_left = (short) x;
helpContent.absHotRect_top = (short) y;
helpContent.absHotRect_right = (short) (x + width);
helpContent.absHotRect_bottom = (short) (y + height);
helpContent.content0_contentType = OS.kHMCFStringContent;
helpContent.content0_tagCFString = display.helpString;
helpContent.content1_contentType = OS.kHMCFStringContent;
helpContent.content1_tagCFString = display.helpString;
OS.memmove (ioHelpContent, helpContent, HMHelpContentRec.sizeof);
contentProvided [0] = OS.kHMContentProvided;
}
OS.memmove (outContentProvided, contentProvided, 2);
break;
}
case OS.kHMDisposeContent: {
if (display.helpString != 0) OS.CFRelease (display.helpString);
display.helpWidget = null;
display.helpString = 0;
break;
}
}
return OS.noErr;
}
void hookEvents () {
super.hookEvents ();
int controlProc = display.controlProc;
int [] mask = new int [] {
OS.kEventClassControl, OS.kEventControlActivate,
OS.kEventClassControl, OS.kEventControlApplyBackground,
OS.kEventClassControl, OS.kEventControlBoundsChanged,
OS.kEventClassControl, OS.kEventControlClick,
OS.kEventClassControl, OS.kEventControlContextualMenuClick,
OS.kEventClassControl, OS.kEventControlDeactivate,
OS.kEventClassControl, OS.kEventControlDraw,
OS.kEventClassControl, OS.kEventControlGetClickActivation,
OS.kEventClassControl, OS.kEventControlGetFocusPart,
OS.kEventClassControl, OS.kEventControlGetPartRegion,
OS.kEventClassControl, OS.kEventControlHit,
OS.kEventClassControl, OS.kEventControlHitTest,
OS.kEventClassControl, OS.kEventControlSetCursor,
OS.kEventClassControl, OS.kEventControlSetFocusPart,
OS.kEventClassControl, OS.kEventControlTrack,
};
int controlTarget = OS.GetControlEventTarget (handle);
OS.InstallEventHandler (controlTarget, controlProc, mask.length / 2, mask, handle, null);
int accessibilityProc = display.accessibilityProc;
mask = new int [] {
OS.kEventClassAccessibility, OS.kEventAccessibleGetChildAtPoint,
OS.kEventClassAccessibility, OS.kEventAccessibleGetFocusedChild,
OS.kEventClassAccessibility, OS.kEventAccessibleGetAllAttributeNames,
OS.kEventClassAccessibility, OS.kEventAccessibleGetNamedAttribute,
};
OS.InstallEventHandler (controlTarget, accessibilityProc, mask.length / 2, mask, handle, null);
int helpProc = display.helpProc;
OS.HMInstallControlContentCallback (handle, helpProc);
int colorProc = display.colorProc;
OS.SetControlColorProc (handle, colorProc);
if (OS.GetControlAction (handle) == 0) {
OS.SetControlAction (handle, display.actionProc);
}
}
/**
* Invokes platform specific functionality to allocate a new GC handle.
* <p>
* <b>IMPORTANT:</b> This method is <em>not</em> part of the public
* API for <code>Control</code>. It is marked public only so that it
* can be shared within the packages provided by SWT. It is not
* available on all platforms, and should never be called from
* application code.
* </p>
*
* @param data the platform specific GC data
* @return the platform specific GC handle
*/
public int internal_new_GC (GCData data) {
checkWidget();
int window = OS.GetControlOwner (handle);
int port = data != null ? data.port : 0;
if (port == 0) port = OS.GetWindowPort (window);
int context;
int [] buffer = new int [1];
boolean isPaint = data != null && data.paintEvent != 0;
if (isPaint) {
OS.GetEventParameter (data.paintEvent, OS.kEventParamCGContextRef, OS.typeCGContextRef, null, 4, null, buffer);
} else {
OS.CreateCGContextForPort (port, buffer);
}
context = buffer [0];
if (context == 0) SWT.error (SWT.ERROR_NO_HANDLES);
int visibleRgn = 0;
if (data != null && data.paintEvent != 0) {
visibleRgn = data.visibleRgn;
} else {
if (getDrawCount (handle) > 0) {
visibleRgn = OS.NewRgn ();
} else {
visibleRgn = getVisibleRegion (handle, true);
}
}
Rect rect = new Rect ();
Rect portRect = new Rect ();
OS.GetControlBounds (handle, rect);
OS.GetPortBounds (port, portRect);
if (isPaint) {
rect.right += rect.left;
rect.bottom += rect.top;
rect.left = rect.top = 0;
} else {
int [] contentView = new int [1];
OS.HIViewFindByID (OS.HIViewGetRoot (window), OS.kHIViewWindowContentID (), contentView);
CGPoint pt = new CGPoint ();
OS.HIViewConvertPoint (pt, OS.HIViewGetSuperview (handle), contentView [0]);
rect.left += (int) pt.x;
rect.top += (int) pt.y;
rect.right += (int) pt.x;
rect.bottom += (int) pt.y;
OS.ClipCGContextToRegion (context, portRect, visibleRgn);
int portHeight = portRect.bottom - portRect.top;
OS.CGContextScaleCTM (context, 1, -1);
OS.CGContextTranslateCTM (context, rect.left, -portHeight + rect.top);
}
if (data != null) {
int mask = SWT.LEFT_TO_RIGHT | SWT.RIGHT_TO_LEFT;
if ((data.style & mask) == 0) {
data.style |= style & (mask | SWT.MIRRORED);
}
data.device = display;
data.thread = display.thread;
data.foreground = getForegroundColor ().handle;
Control control = findBackgroundControl ();
if (control == null) control = this;
data.background = control.getBackgroundColor ().handle;
data.font = font != null ? font : defaultFont ();
data.visibleRgn = visibleRgn;
data.control = handle;
data.portRect = portRect;
data.controlRect = rect;
data.insetRect = getInset ();
if (data.paintEvent == 0) {
if (gcs == null) gcs = new GCData [4];
int index = 0;
while (index < gcs.length && gcs [index] != null) index++;
if (index == gcs.length) {
GCData [] newGCs = new GCData [gcs.length + 4];
System.arraycopy (gcs, 0, newGCs, 0, gcs.length);
gcs = newGCs;
}
gcs [index] = data;
}
}
return context;
}
/**
* Invokes platform specific functionality to dispose a GC handle.
* <p>
* <b>IMPORTANT:</b> This method is <em>not</em> part of the public
* API for <code>Control</code>. It is marked public only so that it
* can be shared within the packages provided by SWT. It is not
* available on all platforms, and should never be called from
* application code.
* </p>
*
* @param hDC the platform specific GC handle
* @param data the platform specific GC data
*/
public void internal_dispose_GC (int context, GCData data) {
checkWidget ();
if (data != null) {
if (data.paintEvent == 0) {
if (data.visibleRgn != 0) {
OS.DisposeRgn (data.visibleRgn);
data.visibleRgn = 0;
}
int index = 0;
while (index < gcs.length && gcs [index] != data) index++;
if (index < gcs.length) {
gcs [index] = null;
index = 0;
while (index < gcs.length && gcs [index] == null) index++;
if (index == gcs.length) gcs = null;
}
} else {
return;
}
}
/*
* This code is intentionally commented. Use CGContextSynchronize
* instead of CGContextFlush to improve performance.
*/
// OS.CGContextFlush (context);
OS.CGContextSynchronize (context);
OS.CGContextRelease (context);
}
void invalidateChildrenVisibleRegion (int control) {
}
void invalidateVisibleRegion (int control) {
int index = 0;
Control[] siblings = parent._getChildren ();
while (index < siblings.length && siblings [index] != this) index++;
for (int i=index; i<siblings.length; i++) {
Control sibling = siblings [i];
sibling.resetVisibleRegion (control);
sibling.invalidateChildrenVisibleRegion (control);
}
parent.resetVisibleRegion (control);
}
void invalWindowRgn (int window, int rgn) {
parent.invalWindowRgn (window, rgn);
}
/**
* Returns <code>true</code> if the receiver is enabled and all
* ancestors up to and including the receiver's nearest ancestor
* shell are enabled. Otherwise, <code>false</code> is returned.
* A disabled control is typically not selectable from the user
* interface and draws with an inactive or "grayed" look.
*
* @return the receiver's enabled state
*
* @exception SWTException <ul>
* <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*
* @see #getEnabled
*/
public boolean isEnabled () {
checkWidget();
return getEnabled () && parent.isEnabled ();
}
boolean isEnabledCursor () {
return isEnabled ();
}
boolean isEnabledModal () {
//NOT DONE - fails for multiple APP MODAL shells
Shell [] shells = display.getShells ();
for (int i = 0; i < shells.length; i++) {
Shell modal = shells [i];
if (modal != this && modal.isVisible ()) {
if ((modal.style & SWT.PRIMARY_MODAL) != 0) {
Shell shell = getShell ();
if (modal.parent == shell) {
return false;
}
}
int bits = SWT.APPLICATION_MODAL | SWT.SYSTEM_MODAL;
if ((modal.style & bits) != 0) {
Control control = this;
while (control != null) {
if (control == modal) break;
control = control.parent;
}
if (control != modal) return false;
}
}
}
return true;
}
boolean isFocusAncestor (Control control) {
while (control != null && control != this && !(control instanceof Shell)) {
control = control.parent;
}
return control == this;
}
/**
* Returns <code>true</code> if the receiver has the user-interface
* focus, and <code>false</code> otherwise.
*
* @return the receiver's focus state
*
* @exception SWTException <ul>
* <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
public boolean isFocusControl () {
checkWidget();
Control focusControl = display.focusControl;
if (focusControl != null && !focusControl.isDisposed ()) {
return this == focusControl;
}
return hasFocus ();
}
/**
* Returns <code>true</code> if the underlying operating
* system supports this reparenting, otherwise <code>false</code>
*
* @return <code>true</code> if the widget can be reparented, otherwise <code>false</code>
*
* @exception SWTException <ul>
* <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
public boolean isReparentable () {
checkWidget();
return true;
}
boolean isShowing () {
/*
* This is not complete. Need to check if the
* widget is obscurred by a parent or sibling.
*/
if (!isVisible ()) return false;
Control control = this;
while (control != null) {
Point size = control.getSize ();
if (size.x == 0 || size.y == 0) {
return false;
}
control = control.parent;
}
return true;
}
boolean isTabGroup () {
Control [] tabList = parent._getTabList ();
if (tabList != null) {
for (int i=0; i<tabList.length; i++) {
if (tabList [i] == this) return true;
}
}
int code = traversalCode (0, 0);
if ((code & (SWT.TRAVERSE_ARROW_PREVIOUS | SWT.TRAVERSE_ARROW_NEXT)) != 0) return false;
return (code & (SWT.TRAVERSE_TAB_PREVIOUS | SWT.TRAVERSE_TAB_NEXT)) != 0;
}
boolean isTabItem () {
Control [] tabList = parent._getTabList ();
if (tabList != null) {
for (int i=0; i<tabList.length; i++) {
if (tabList [i] == this) return false;
}
}
int code = traversalCode (0, 0);
return (code & (SWT.TRAVERSE_ARROW_PREVIOUS | SWT.TRAVERSE_ARROW_NEXT)) != 0;
}
/**
* Returns <code>true</code> if the receiver is visible and all
* ancestors up to and including the receiver's nearest ancestor
* shell are visible. Otherwise, <code>false</code> is returned.
*
* @return the receiver's visibility state
*
* @exception SWTException <ul>
* <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*
* @see #getVisible
*/
public boolean isVisible () {
checkWidget();
return getVisible () && parent.isVisible ();
}
Decorations menuShell () {
return parent.menuShell ();
}
int kEventAccessibleGetChildAtPoint (int nextHandler, int theEvent, int userData) {
if (accessible != null) {
return accessible.internal_kEventAccessibleGetChildAtPoint (nextHandler, theEvent, userData);
}
return OS.eventNotHandledErr;
}
int kEventAccessibleGetFocusedChild (int nextHandler, int theEvent, int userData) {
if (accessible != null) {
return accessible.internal_kEventAccessibleGetFocusedChild (nextHandler, theEvent, userData);
}
return OS.eventNotHandledErr;
}
int kEventAccessibleGetAllAttributeNames (int nextHandler, int theEvent, int userData) {
if (accessible != null) {
return accessible.internal_kEventAccessibleGetAllAttributeNames (nextHandler, theEvent, userData);
}
return OS.eventNotHandledErr;
}
int kEventAccessibleGetNamedAttribute (int nextHandler, int theEvent, int userData) {
if (accessible != null) {
return accessible.internal_kEventAccessibleGetNamedAttribute (nextHandler, theEvent, userData);
}
return OS.eventNotHandledErr;
}
int kEventControlContextualMenuClick (int nextHandler, int theEvent, int userData) {
int [] theControl = new int [1];
OS.GetEventParameter (theEvent, OS.kEventParamDirectObject, OS.typeControlRef, null, 4, null, theControl);
Widget widget = display.getWidget (theControl [0]);
while (widget != null && !(widget instanceof Control)) {
OS.GetSuperControl (theControl [0], theControl);
widget = display.getWidget (theControl [0]);
}
if (widget == this && isEnabled ()) {
int x, y;
Rect rect = new Rect ();
int window = OS.GetControlOwner (handle);
CGPoint pt = new CGPoint ();
OS.GetEventParameter (theEvent, OS.kEventParamWindowMouseLocation, OS.typeHIPoint, null, CGPoint.sizeof, null, pt);
x = (int) pt.x;
y = (int) pt.y;
OS.GetWindowBounds (window, (short) OS.kWindowStructureRgn, rect);
x += rect.left;
y += rect.top;
Event event = new Event ();
event.x = x;
event.y = y;
sendEvent (SWT.MenuDetect, event);
if (event.doit) {
if (menu != null && !menu.isDisposed ()) {
if (event.x != x || event.y != y) {
menu.setLocation (event.x, event.y);
}
menu.setVisible (true);
}
}
}
return OS.eventNotHandledErr;
}
int kEventControlGetClickActivation (int nextHandler, int theEvent, int userData) {
if ((getShell ().style & SWT.ON_TOP) != 0) {
OS.SetEventParameter (theEvent, OS.kEventParamClickActivation, OS.typeClickActivationResult, 4, new int [] {OS.kActivateAndHandleClick});
return OS.noErr;
}
return super.kEventControlGetClickActivation (nextHandler, theEvent, userData);
}
int kEventControlGetPartRegion (int nextHandler, int theEvent, int userData) {
int result = super.kEventControlGetPartRegion (nextHandler, theEvent, userData);
if (result == OS.noErr) return result;
if (region != null && this != getShell ()) {
short [] part = new short [1];
OS.GetEventParameter (theEvent, OS.kEventParamControlPart, OS.typeControlPartCode , null, 2, null, part);
if (part [0] == OS.kControlStructureMetaPart) {
int [] rgn = new int [1];
OS.GetEventParameter (theEvent, OS.kEventParamControlRegion, OS.typeQDRgnHandle , null, 4, null, rgn);
OS.CopyRgn (region.handle, rgn[0]);
Rect rect = getInset ();
OS.OffsetRgn (rgn [0], (short)-rect.left, (short)-rect.top);
return OS.noErr;
}
}
return result;
}
int kEventControlHitTest (int nextHandler, int theEvent, int userData) {
int result = super.kEventControlHitTest (nextHandler, theEvent, userData);
if (result == OS.noErr) return result;
if ((state & GRAB) != 0) {
CGRect rect = new CGRect ();
OS.HIViewGetBounds (handle, rect);
CGPoint pt = new CGPoint ();
OS.GetEventParameter (theEvent, OS.kEventParamMouseLocation, OS.typeHIPoint, null, CGPoint.sizeof, null, pt);
if (OS.CGRectContainsPoint (rect, pt) != 0) {
OS.SetEventParameter (theEvent, OS.kEventParamControlPart, OS.typeControlPartCode, 2, new short[]{1});
}
return OS.noErr;
}
if (region != null && this != getShell ()) {
int code = OS.CallNextEventHandler (nextHandler, theEvent);
CGPoint pt = new CGPoint ();
OS.GetEventParameter (theEvent, OS.kEventParamMouseLocation, OS.typeHIPoint, null, CGPoint.sizeof, null, pt);
if (!region.contains ((int) pt.x, (int) pt.y)) {
OS.SetEventParameter (theEvent, OS.kEventParamControlPart, OS.typeControlPartCode, 2, new short [1]);
}
return code;
}
return result;
}
int kEventControlSetCursor (int nextHandler, int theEvent, int userData) {
if (!isEnabledCursor ()) return OS.noErr;
Cursor cursor = null;
if (isEnabledModal ()) {
if ((cursor = findCursor ()) != null) display.setCursor (cursor.handle);
}
return cursor != null ? OS.noErr : OS.eventNotHandledErr;
}
int kEventControlSetFocusPart (int nextHandler, int theEvent, int userData) {
display.focusCombo = null;
int result = callFocusEventHandler (nextHandler, theEvent);
if (!display.ignoreFocus) {
if (result == OS.noErr) {
int window = OS.GetControlOwner (handle);
if (window == OS.GetUserFocusWindow ()) {
int focusHandle = focusHandle ();
int [] focusControl = new int [1];
OS.GetKeyboardFocus (window, focusControl);
short [] part = new short [1];
OS.GetEventParameter (theEvent, OS.kEventParamControlPart, OS.typeControlPartCode, null, 2, null, part);
Display display = this.display;
display.delayDispose = true;
if (part [0] == OS.kControlFocusNoPart) {
if (focusControl [0] == focusHandle) sendFocusEvent (SWT.FocusOut, false);
} else {
if (focusControl [0] != focusHandle) sendFocusEvent (SWT.FocusIn, false);
}
display.delayDispose = false;
}
// widget could be disposed at this point
if (isDisposed ()) return OS.noErr;
}
}
return result;
}
int kEventControlTrack (int nextHandler, int theEvent, int userData) {
/*
* Feature in the Macintosh. The default handler of kEventControlTrack
* calls TrackControl() which consumes key and mouse events until the
* tracking is canceled. The fix is to send those events from the
* action proc of the widget by diffing the mouse and modifier keys
* state.
*/
Display display = this.display;
// display.runDeferredEvents ();
if (isDisposed ()) return OS.noErr;
if (display.runPopups ()) return OS.noErr;
if (isDisposed ()) return OS.noErr;
display.lastState = OS.GetCurrentEventButtonState ();
display.lastModifiers = OS.GetCurrentEventKeyModifiers ();
display.grabControl = this;
int result = super.kEventControlTrack (nextHandler, theEvent, userData);
display.grabControl = null;
if (isDisposed ()) return OS.noErr;
sendTrackEvents ();
return result;
}
int kEventMouseDown (int nextHandler, int theEvent, int userData) {
Shell shell = getShell ();
display.dragging = false;
boolean [] consume = new boolean [1];
short [] button = new short [1];
OS.GetEventParameter (theEvent, OS.kEventParamMouseButton, OS.typeMouseButton, null, 2, null, button);
int [] clickCount = new int [1];
OS.GetEventParameter (theEvent, OS.kEventParamClickCount, OS.typeUInt32, null, 4, null, clickCount);
if (button [0] == 1 && clickCount [0] == 1 && (state & DRAG_DETECT) != 0 && hooks (SWT.DragDetect)) {
CGPoint pt = new CGPoint ();
OS.GetEventParameter (theEvent, OS.kEventParamWindowMouseLocation, OS.typeHIPoint, null, CGPoint.sizeof, null, pt);
OS.HIViewConvertPoint (pt, 0, handle);
int x = (int) pt.x;
int y = (int) pt.y;
if (dragDetect (x, y, true, consume)) {
display.dragging = true;
display.dragButton = button [0];
display.dragX = x;
display.dragY = y;
int [] chord = new int [1];
OS.GetEventParameter (theEvent, OS.kEventParamMouseChord, OS.typeUInt32, null, 4, null, chord);
display.dragState = chord [0];
int [] modifiers = new int [1];
OS.GetEventParameter (theEvent, OS.kEventParamKeyModifiers, OS.typeUInt32, null, 4, null, modifiers);
display.dragModifiers = modifiers [0];
}
if (isDisposed ()) return OS.noErr;
}
if (!sendMouseEvent (SWT.MouseDown, button [0], display.clickCount, 0, false, theEvent)) consume [0] = true;
if (isDisposed ()) return OS.noErr;
if (display.clickCount == 2) {
if (!sendMouseEvent (SWT.MouseDoubleClick, button [0], display.clickCount, 0, false, theEvent)) consume [0] = true;
if (isDisposed ()) return OS.noErr;
}
if (!shell.isDisposed ()) shell.setActiveControl (this);
return consume [0] ? OS.noErr : OS.eventNotHandledErr;
}
int kEventMouseDragged (int nextHandler, int theEvent, int userData) {
if (isEnabledModal ()) {
if (display.dragging) {
display.dragging = false;
sendDragEvent (display.dragButton, display.dragState, display.dragModifiers, display.dragX, display.dragY);
if (isDisposed ()) return OS.noErr;
}
int result = sendMouseEvent (SWT.MouseMove, (short) 0, 0, 0, false, theEvent) ? OS.eventNotHandledErr : OS.noErr;
if (isDisposed ()) return OS.noErr;
return result;
}
return OS.eventNotHandledErr;
}
int kEventMouseMoved (int nextHandler, int theEvent, int userData) {
if (isEnabledModal ()) {
return sendMouseEvent (SWT.MouseMove, (short) 0, 0, 0, false, theEvent) ? OS.eventNotHandledErr : OS.noErr;
}
return OS.eventNotHandledErr;
}
int kEventMouseUp (int nextHandler, int theEvent, int userData) {
short [] button = new short [1];
OS.GetEventParameter (theEvent, OS.kEventParamMouseButton, OS.typeMouseButton, null, 2, null, button);
return sendMouseEvent (SWT.MouseUp, button [0], display.clickCount, 0, false, theEvent) ? OS.eventNotHandledErr : OS.noErr;
}
int kEventMouseWheelMoved (int nextHandler, int theEvent, int userData) {
if ((state & IGNORE_WHEEL) != 0) return OS.eventNotHandledErr;
short [] wheelAxis = new short [1];
OS.GetEventParameter (theEvent, OS.kEventParamMouseWheelAxis, OS.typeMouseWheelAxis, null, 2, null, wheelAxis);
int [] wheelDelta = new int [1];
OS.GetEventParameter (theEvent, OS.kEventParamMouseWheelDelta, OS.typeSInt32, null, 4, null, wheelDelta);
Shell shell = getShell ();
Control control = this;
while (control != null) {
if (!control.sendMouseEvent (SWT.MouseWheel, (short) 0, wheelDelta [0], SWT.SCROLL_LINE, true, theEvent)) {
break;
}
if (control.sendMouseWheel (wheelAxis [0], wheelDelta [0])) break;
if (control == this) {
/*
* Feature in the Macintosh. For some reason, the kEventMouseWheelMoved
* event is sent twice to each application handler with the same mouse wheel
* data. The fix is to set an ignore flag before calling the next handler
* in the handler chain.
*/
state |= IGNORE_WHEEL;
int result = OS.CallNextEventHandler (nextHandler, theEvent);
state &= ~IGNORE_WHEEL;
if (result == OS.noErr) break;
}
if (control == shell) break;
control = control.parent;
}
return OS.noErr;
}
int kEventTextInputUnicodeForKeyEvent (int nextHandler, int theEvent, int userData) {
int [] keyboardEvent = new int [1];
OS.GetEventParameter (theEvent, OS.kEventParamTextInputSendKeyboardEvent, OS.typeEventRef, null, keyboardEvent.length * 4, null, keyboardEvent);
int [] keyCode = new int [1];
OS.GetEventParameter (keyboardEvent [0], OS.kEventParamKeyCode, OS.typeUInt32, null, keyCode.length * 4, null, keyCode);
boolean [] consume = new boolean [1];
if (translateTraversal (keyCode [0], keyboardEvent [0], consume)) return OS.noErr;
if (isDisposed ()) return OS.noErr;
if (keyCode [0] == 114) { /* Help */
Control control = this;
while (control != null) {
if (control.hooks (SWT.Help)) {
control.postEvent (SWT.Help);
break;
}
control = control.parent;
}
}
int result = kEventUnicodeKeyPressed (nextHandler, theEvent, userData);
if (result == OS.noErr || consume [0]) return OS.noErr;
/*
* Feature in the Macintosh. If the focus target is changed
* before the default handler for the widget has run, the key
* goes to the new focus widget. The fix is to explicitly
* send the event to the original focus widget and stop
* the chain of handlers.
*/
if (!isDisposed () && !hasFocus ()) {
Control focusControl = display.getFocusControl ();
int focusHandle = focusHandle ();
int window = OS.GetControlOwner (focusHandle);
display.ignoreFocus = true;
OS.SetKeyboardFocus (window, focusHandle, (short) focusPart ());
display.ignoreFocus = false;
result = OS.CallNextEventHandler (nextHandler, theEvent);
if (focusControl != null) {
focusHandle = focusControl.focusHandle ();
window = OS.GetControlOwner (focusHandle);
display.ignoreFocus = true;
OS.SetKeyboardFocus (window, focusHandle, (short) focusControl.focusPart ());
display.ignoreFocus = false;
} else {
display.ignoreFocus = true;
OS.ClearKeyboardFocus (window);
display.ignoreFocus = false;
}
}
return result;
}
int kEventUnicodeKeyPressed (int nextHandler, int theEvent, int userData) {
int [] keyboardEvent = new int [1];
OS.GetEventParameter (theEvent, OS.kEventParamTextInputSendKeyboardEvent, OS.typeEventRef, null, keyboardEvent.length * 4, null, keyboardEvent);
if (!sendKeyEvent (SWT.KeyDown, keyboardEvent [0])) return OS.noErr;
return OS.eventNotHandledErr;
}
void markLayout (boolean changed, boolean all) {
/* Do nothing */
}
/**
* Moves the receiver above the specified control in the
* drawing order. If the argument is null, then the receiver
* is moved to the top of the drawing order. The control at
* the top of the drawing order will not be covered by other
* controls even if they occupy intersecting areas.
*
* @param control the sibling control (or null)
*
* @exception IllegalArgumentException <ul>
* <li>ERROR_INVALID_ARGUMENT - if the control has been disposed</li>
* </ul>
* @exception SWTException <ul>
* <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*
* @see Control#moveBelow
* @see Composite#getChildren
*/
public void moveAbove (Control control) {
checkWidget();
if (control != null) {
if (control.isDisposed ()) error (SWT.ERROR_INVALID_ARGUMENT);
if (parent != control.parent) return;
}
setZOrder (control, true);
}
/**
* Moves the receiver below the specified control in the
* drawing order. If the argument is null, then the receiver
* is moved to the bottom of the drawing order. The control at
* the bottom of the drawing order will be covered by all other
* controls which occupy intersecting areas.
*
* @param control the sibling control (or null)
*
* @exception IllegalArgumentException <ul>
* <li>ERROR_INVALID_ARGUMENT - if the control has been disposed</li>
* </ul>
* @exception SWTException <ul>
* <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*
* @see Control#moveAbove
* @see Composite#getChildren
*/
public void moveBelow (Control control) {
checkWidget();
if (control != null) {
if (control.isDisposed ()) error (SWT.ERROR_INVALID_ARGUMENT);
if (parent != control.parent) return;
}
setZOrder (control, false);
}
Accessible new_Accessible (Control control) {
return Accessible.internal_new_Accessible (this);
}
/**
* Causes the receiver to be resized to its preferred size.
* For a composite, this involves computing the preferred size
* from its layout, if there is one.
*
* @exception SWTException <ul>
* <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*
* @see #computeSize(int, int, boolean)
*/
public void pack () {
checkWidget();
pack (true);
}
/**
* Causes the receiver to be resized to its preferred size.
* For a composite, this involves computing the preferred size
* from its layout, if there is one.
* <p>
* If the changed flag is <code>true</code>, it indicates that the receiver's
* <em>contents</em> have changed, therefore any caches that a layout manager
* containing the control may have been keeping need to be flushed. When the
* control is resized, the changed flag will be <code>false</code>, so layout
* manager caches can be retained.
* </p>
*
* @param changed whether or not the receiver's contents have changed
*
* @exception SWTException <ul>
* <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*
* @see #computeSize(int, int, boolean)
*/
public void pack (boolean changed) {
checkWidget();
setSize (computeSize (SWT.DEFAULT, SWT.DEFAULT, changed));
}
public boolean print (GC gc) {
checkWidget ();
if (gc == null) error (SWT.ERROR_NULL_ARGUMENT);
if (gc.isDisposed ()) error (SWT.ERROR_INVALID_ARGUMENT);
int [] outImage = new int [1];
CGRect outFrame = new CGRect ();
if (OS.HIViewCreateOffscreenImage (handle, 0, outFrame, outImage) == OS.noErr) {
int width = OS.CGImageGetWidth (outImage [0]);
int height = OS.CGImageGetHeight (outImage [0]);
CGRect rect = new CGRect();
rect.width = width;
rect.height = height;
//TODO - does not draw the browser (cocoa widgets?)
OS.HIViewDrawCGImage (gc.handle, rect, outImage [0]);
OS.CGImageRelease (outImage [0]);
}
return true;
}
/**
* Causes the entire bounds of the receiver to be marked
* as needing to be redrawn. The next time a paint request
* is processed, the control will be completely painted,
* including the background.
*
* @exception SWTException <ul>
* <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*
* @see #update()
* @see PaintListener
* @see SWT#Paint
* @see SWT#NO_BACKGROUND
* @see SWT#NO_REDRAW_RESIZE
* @see SWT#NO_MERGE_PAINTS
* @see SWT#DOUBLE_BUFFERED
*/
public void redraw () {
checkWidget();
redrawWidget (handle, false);
}
void redraw (boolean children) {
// checkWidget();
redrawWidget (handle, children);
}
/**
* Causes the rectangular area of the receiver specified by
* the arguments to be marked as needing to be redrawn.
* The next time a paint request is processed, that area of
* the receiver will be painted, including the background.
* If the <code>all</code> flag is <code>true</code>, any
* children of the receiver which intersect with the specified
* area will also paint their intersecting areas. If the
* <code>all</code> flag is <code>false</code>, the children
* will not be painted.
*
* @param x the x coordinate of the area to draw
* @param y the y coordinate of the area to draw
* @param width the width of the area to draw
* @param height the height of the area to draw
* @param all <code>true</code> if children should redraw, and <code>false</code> otherwise
*
* @exception SWTException <ul>
* <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*
* @see #update()
* @see PaintListener
* @see SWT#Paint
* @see SWT#NO_BACKGROUND
* @see SWT#NO_REDRAW_RESIZE
* @see SWT#NO_MERGE_PAINTS
* @see SWT#DOUBLE_BUFFERED
*/
public void redraw (int x, int y, int width, int height, boolean all) {
checkWidget ();
redrawWidget (handle, x, y, width, height, all);
}
void register () {
super.register ();
display.addWidget (handle, this);
}
void releaseHandle () {
super.releaseHandle ();
handle = 0;
parent = null;
}
void releaseParent () {
setVisible (topHandle (), false);
parent.removeControl (this);
}
void releaseWidget () {
super.releaseWidget ();
if (menu != null && !menu.isDisposed ()) {
menu.dispose ();
}
if (visibleRgn != 0) OS.DisposeRgn (visibleRgn);
visibleRgn = 0;
menu = null;
layoutData = null;
if (accessible != null) {
accessible.internal_dispose_Accessible ();
}
accessible = null;
region = null;
}
/**
* Removes the listener from the collection of listeners who will
* be notified when the control is moved or resized.
*
* @param listener the listener which should no longer be notified
*
* @exception IllegalArgumentException <ul>
* <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
* </ul>
* @exception SWTException <ul>
* <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*
* @see ControlListener
* @see #addControlListener
*/
public void removeControlListener (ControlListener listener) {
checkWidget();
if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
if (eventTable == null) return;
eventTable.unhook (SWT.Move, listener);
eventTable.unhook (SWT.Resize, listener);
}
/**
* Removes the listener from the collection of listeners who will
* be notified when a drag gesture occurs.
*
* @param listener the listener which should no longer be notified
*
* @exception IllegalArgumentException <ul>
* <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
* </ul>
* @exception SWTException <ul>
* <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*
* @see DragDetectListener
* @see #addDragDetectListener
*
* @since 3.3
*/
public void removeDragDetectListener(DragDetectListener listener) {
checkWidget ();
if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
if (eventTable == null) return;
eventTable.unhook (SWT.DragDetect, listener);
}
/**
* Removes the listener from the collection of listeners who will
* be notified when the control gains or loses focus.
*
* @param listener the listener which should no longer be notified
*
* @exception IllegalArgumentException <ul>
* <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
* </ul>
* @exception SWTException <ul>
* <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*
* @see FocusListener
* @see #addFocusListener
*/
public void removeFocusListener(FocusListener listener) {
checkWidget();
if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
if (eventTable == null) return;
eventTable.unhook(SWT.FocusIn, listener);
eventTable.unhook(SWT.FocusOut, listener);
}
/**
* Removes the listener from the collection of listeners who will
* be notified when the help events are generated for the control.
*
* @param listener the listener which should no longer be notified
*
* @exception IllegalArgumentException <ul>
* <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
* </ul>
* @exception SWTException <ul>
* <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*
* @see HelpListener
* @see #addHelpListener
*/
public void removeHelpListener (HelpListener listener) {
checkWidget();
if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
if (eventTable == null) return;
eventTable.unhook (SWT.Help, listener);
}
/**
* Removes the listener from the collection of listeners who will
* be notified when keys are pressed and released on the system keyboard.
*
* @param listener the listener which should no longer be notified
*
* @exception IllegalArgumentException <ul>
* <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
* </ul>
* @exception SWTException <ul>
* <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*
* @see KeyListener
* @see #addKeyListener
*/
public void removeKeyListener(KeyListener listener) {
checkWidget();
if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
if (eventTable == null) return;
eventTable.unhook(SWT.KeyUp, listener);
eventTable.unhook(SWT.KeyDown, listener);
}
/**
* Removes the listener from the collection of listeners who will
* be notified when the platform-specific context menu trigger has
* occurred.
*
* @param listener the listener which should no longer be notified
*
* @exception IllegalArgumentException <ul>
* <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
* </ul>
* @exception SWTException <ul>
* <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*
* @see MenuDetectListener
* @see #addMenuDetectListener
*
* @since 3.3
*/
public void removeMenuDetectListener (MenuDetectListener listener) {
checkWidget ();
if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
if (eventTable == null) return;
eventTable.unhook (SWT.MenuDetect, listener);
}
/**
* Removes the listener from the collection of listeners who will
* be notified when mouse buttons are pressed and released.
*
* @param listener the listener which should no longer be notified
*
* @exception IllegalArgumentException <ul>
* <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
* </ul>
* @exception SWTException <ul>
* <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*
* @see MouseListener
* @see #addMouseListener
*/
public void removeMouseListener(MouseListener listener) {
checkWidget();
if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
if (eventTable == null) return;
eventTable.unhook(SWT.MouseDown, listener);
eventTable.unhook(SWT.MouseUp, listener);
eventTable.unhook(SWT.MouseDoubleClick, listener);
}
/**
* Removes the listener from the collection of listeners who will
* be notified when the mouse moves.
*
* @param listener the listener which should no longer be notified
*
* @exception IllegalArgumentException <ul>
* <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
* </ul>
* @exception SWTException <ul>
* <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*
* @see MouseMoveListener
* @see #addMouseMoveListener
*/
public void removeMouseMoveListener(MouseMoveListener listener) {
checkWidget();
if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
if (eventTable == null) return;
eventTable.unhook(SWT.MouseMove, listener);
}
/**
* Removes the listener from the collection of listeners who will
* be notified when the mouse passes or hovers over controls.
*
* @param listener the listener which should no longer be notified
*
* @exception IllegalArgumentException <ul>
* <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
* </ul>
* @exception SWTException <ul>
* <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*
* @see MouseTrackListener
* @see #addMouseTrackListener
*/
public void removeMouseTrackListener(MouseTrackListener listener) {
checkWidget();
if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
if (eventTable == null) return;
eventTable.unhook (SWT.MouseEnter, listener);
eventTable.unhook (SWT.MouseExit, listener);
eventTable.unhook (SWT.MouseHover, listener);
}
/**
* Removes the listener from the collection of listeners who will
* be notified when the mouse wheel is scrolled.
*
* @param listener the listener which should no longer be notified
*
* @exception IllegalArgumentException <ul>
* <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
* </ul>
* @exception SWTException <ul>
* <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*
* @see MouseWheelListener
* @see #addMouseWheelListener
*
* @since 3.3
*/
public void removeMouseWheelListener (MouseWheelListener listener) {
checkWidget ();
if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
if (eventTable == null) return;
eventTable.unhook (SWT.MouseWheel, listener);
}
/**
* Removes the listener from the collection of listeners who will
* be notified when the receiver needs to be painted.
*
* @param listener the listener which should no longer be notified
*
* @exception IllegalArgumentException <ul>
* <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
* </ul>
* @exception SWTException <ul>
* <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*
* @see PaintListener
* @see #addPaintListener
*/
public void removePaintListener(PaintListener listener) {
checkWidget();
if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
if (eventTable == null) return;
eventTable.unhook(SWT.Paint, listener);
}
/**
* Removes the listener from the collection of listeners who will
* be notified when traversal events occur.
*
* @param listener the listener which should no longer be notified
*
* @exception IllegalArgumentException <ul>
* <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
* </ul>
* @exception SWTException <ul>
* <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*
* @see TraverseListener
* @see #addTraverseListener
*/
public void removeTraverseListener(TraverseListener listener) {
checkWidget();
if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
if (eventTable == null) return;
eventTable.unhook (SWT.Traverse, listener);
}
void resetVisibleRegion (int control) {
if (visibleRgn != 0) {
OS.DisposeRgn (visibleRgn);
visibleRgn = 0;
}
if (gcs != null) {
int visibleRgn = getVisibleRegion (handle, true);
for (int i=0; i<gcs.length; i++) {
GCData data = gcs [i];
if (data != null) {
data.updateClip = true;
OS.CopyRgn (visibleRgn, data.visibleRgn);
}
}
OS.DisposeRgn (visibleRgn);
}
Object runnable = getData (RESET_VISIBLE_REGION);
if (runnable != null && runnable instanceof Runnable) {
((Runnable) runnable).run ();
}
}
boolean sendDragEvent (int button, int stateMask, int x, int y) {
Event event = new Event ();
event.button = button;
event.x = x;
event.y = y;
event.stateMask = stateMask;
postEvent (SWT.DragDetect, event);
return event.doit;
}
boolean sendDragEvent (int button, int chord, int modifiers, int x, int y) {
Event event = new Event ();
switch (button) {
case 1: event.button = 1; break;
case 2: event.button = 3; break;
case 3: event.button = 2; break;
case 4: event.button = 4; break;
case 5: event.button = 5; break;
}
event.x = x;
event.y = y;
setInputState (event, SWT.DragDetect, chord, modifiers);
postEvent (SWT.DragDetect, event);
return event.doit;
}
void sendFocusEvent (int type, boolean post) {
Display display = this.display;
Shell shell = getShell ();
/*
* Feature in the Macintosh. GetKeyboardFocus() returns NULL during
* kEventControlSetFocusPart if the focus part is not kControlFocusNoPart.
* The fix is to remember the focus control and return it during
* kEventControlSetFocusPart.
*/
display.focusControl = this;
display.focusEvent = type;
if (post) {
postEvent (type);
} else {
sendEvent (type);
}
/*
* It is possible that the shell may be
* disposed at this point. If this happens
* don't send the activate and deactivate
* events.
*/
if (!shell.isDisposed ()) {
switch (type) {
case SWT.FocusIn:
shell.setActiveControl (this);
break;
case SWT.FocusOut:
if (shell != display.getActiveShell ()) {
shell.setActiveControl (null);
}
break;
}
}
display.focusEvent = SWT.None;
display.focusControl = null;
}
boolean sendMouseEvent (int type, short button, int count, int detail, boolean send, int theEvent) {
CGPoint pt = new CGPoint ();
OS.GetEventParameter (theEvent, OS.kEventParamWindowMouseLocation, OS.typeHIPoint, null, CGPoint.sizeof, null, pt);
OS.HIViewConvertPoint (pt, 0, handle);
int x = (int) pt.x;
int y = (int) pt.y;
display.lastX = x;
display.lastY = y;
int [] chord = new int [1];
OS.GetEventParameter (theEvent, OS.kEventParamMouseChord, OS.typeUInt32, null, 4, null, chord);
int [] modifiers = new int [1];
OS.GetEventParameter (theEvent, OS.kEventParamKeyModifiers, OS.typeUInt32, null, 4, null, modifiers);
return sendMouseEvent (type, button, count, detail, send, chord [0], (short) x, (short) y, modifiers [0]);
}
boolean sendMouseEvent (int type, short button, int count, boolean send, int chord, short x, short y, int modifiers) {
return sendMouseEvent (type, button, count, 0, send, chord, x, y, modifiers);
}
boolean sendMouseEvent (int type, short button, int count, int detail, boolean send, int chord, short x, short y, int modifiers) {
if (!hooks (type) && !filters (type)) return true;
if ((state & SAFARI_EVENTS_FIX) != 0) {
switch (type) {
case SWT.MouseUp:
case SWT.MouseMove:
case SWT.MouseDoubleClick: {
return true;
}
case SWT.MouseDown: {
if (button == 1) return true;
break;
}
}
}
Event event = new Event ();
switch (button) {
case 1: event.button = 1; break;
case 2: event.button = 3; break;
case 3: event.button = 2; break;
case 4: event.button = 4; break;
case 5: event.button = 5; break;
}
event.x = x;
event.y = y;
event.count = count;
event.detail = detail;
setInputState (event, type, chord, modifiers);
if (send) {
sendEvent (type, event);
if (isDisposed ()) return false;
} else {
postEvent (type, event);
}
return event.doit;
}
boolean sendMouseWheel (short wheelAxis, int wheelDelta) {
return false;
}
void sendTrackEvents () {
Display display = this.display;
display.runDeferredEvents ();
if (isDisposed ()) return;
boolean events = false;
if (display.dragging) {
display.dragging = false;
sendDragEvent (display.dragButton, display.dragState, display.dragModifiers, display.dragX, display.dragY);
if (isDisposed ()) return;
events = true;
}
org.eclipse.swt.internal.carbon.Point outPt = new org.eclipse.swt.internal.carbon.Point ();
OS.GetGlobalMouse (outPt);
Rect rect = new Rect ();
int window = OS.GetControlOwner (handle);
int newX, newY;
CGPoint pt = new CGPoint ();
pt.x = outPt.h;
pt.y = outPt.v;
OS.HIViewConvertPoint (pt, 0, handle);
newX = (int) pt.x;
newY = (int) pt.y;
OS.GetWindowBounds (window, (short) OS.kWindowStructureRgn, rect);
newX -= rect.left;
newY -= rect.top;
int newModifiers = OS.GetCurrentEventKeyModifiers ();
int newState = OS.GetCurrentEventButtonState ();
int oldX = display.lastX;
int oldY = display.lastY;
int oldState = display.lastState;
int oldModifiers = display.lastModifiers;
display.lastX = newX;
display.lastY = newY;
display.lastModifiers = newModifiers;
display.lastState = newState;
if (newState != oldState) {
int button = 0, type = SWT.MouseDown;
if ((oldState & 0x1) == 0 && (newState & 0x1) != 0) button = 1;
if ((oldState & 0x2) == 0 && (newState & 0x2) != 0) button = 2;
if ((oldState & 0x4) == 0 && (newState & 0x4) != 0) button = 3;
if ((oldState & 0x8) == 0 && (newState & 0x8) != 0) button = 4;
if ((oldState & 0x10) == 0 && (newState & 0x10) != 0) button = 5;
if (button == 0) {
type = SWT.MouseUp;
if ((oldState & 0x1) != 0 && (newState & 0x1) == 0) button = 1;
if ((oldState & 0x2) != 0 && (newState & 0x2) == 0) button = 2;
if ((oldState & 0x4) != 0 && (newState & 0x4) == 0) button = 3;
if ((oldState & 0x8) != 0 && (newState & 0x8) == 0) button = 4;
if ((oldState & 0x10) != 0 && (newState & 0x10) == 0) button = 5;
}
if (button != 0) {
sendMouseEvent (type, (short)button, 1, false, newState, (short)newX, (short)newY, newModifiers);
events = true;
}
}
if (newModifiers != oldModifiers && !isDisposed ()) {
int key = 0, type = SWT.KeyDown;
if ((newModifiers & OS.alphaLock) != 0 && (oldModifiers & OS.alphaLock) == 0) key = SWT.CAPS_LOCK;
if ((newModifiers & OS.shiftKey) != 0 && (oldModifiers & OS.shiftKey) == 0) key = SWT.SHIFT;
if ((newModifiers & OS.controlKey) != 0 && (oldModifiers & OS.controlKey) == 0) key = SWT.CONTROL;
if ((newModifiers & OS.cmdKey) != 0 && (oldModifiers & OS.cmdKey) == 0) key = SWT.COMMAND;
if ((newModifiers & OS.optionKey) != 0 && (oldModifiers & OS.optionKey) == 0) key = SWT.ALT;
if (key == 0) {
type = SWT.KeyUp;
if ((newModifiers & OS.alphaLock) == 0 && (oldModifiers & OS.alphaLock) != 0) key = SWT.CAPS_LOCK;
if ((newModifiers & OS.shiftKey) == 0 && (oldModifiers & OS.shiftKey) != 0) key = SWT.SHIFT;
if ((newModifiers & OS.controlKey) == 0 && (oldModifiers & OS.controlKey) != 0) key = SWT.CONTROL;
if ((newModifiers & OS.cmdKey) == 0 && (oldModifiers & OS.cmdKey) != 0) key = SWT.COMMAND;
if ((newModifiers & OS.optionKey) == 0 && (oldModifiers & OS.optionKey) != 0) key = SWT.ALT;
}
if (key != 0) {
Event event = new Event ();
event.keyCode = key;
setInputState (event, type, newState, newModifiers);
sendKeyEvent (type, event);
events = true;
}
}
if (newX != oldX || newY != oldY && !isDisposed ()) {
display.mouseMoved = true;
sendMouseEvent (SWT.MouseMove, (short)0, 0, false, newState, (short)newX, (short)newY, newModifiers);
events = true;
}
if (events) display.runDeferredEvents ();
}
void setBackground () {
redrawWidget (handle, false);
}
/**
* Sets the receiver's background color to the color specified
* by the argument, or to the default system color for the control
* if the argument is null.
* <p>
* Note: This operation is a hint and may be overridden by the platform.
* For example, on Windows the background of a Button cannot be changed.
* </p>
* @param color the new color (or null)
*
* @exception IllegalArgumentException <ul>
* <li>ERROR_INVALID_ARGUMENT - if the argument has been disposed</li>
* </ul>
* @exception SWTException <ul>
* <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
public void setBackground (Color color) {
checkWidget();
if (color != null) {
if (color.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
}
float[] background = color != null ? color.handle : null;
if (equals (background, this.background)) return;
this.background = background;
setBackground (background);
redrawWidget (handle, false);
}
/**
* Sets the receiver's background image to the image specified
* by the argument, or to the default system color for the control
* if the argument is null. The background image is tiled to fill
* the available space.
* <p>
* Note: This operation is a hint and may be overridden by the platform.
* For example, on Windows the background of a Button cannot be changed.
* </p>
* @param image the new image (or null)
*
* @exception IllegalArgumentException <ul>
* <li>ERROR_INVALID_ARGUMENT - if the argument has been disposed</li>
* <li>ERROR_INVALID_ARGUMENT - if the argument is not a bitmap</li>
* </ul>
* @exception SWTException <ul>
* <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*
* @since 3.2
*/
public void setBackgroundImage (Image image) {
checkWidget();
if (image != null && image.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
if (image == backgroundImage) return;
backgroundImage = image;
redrawWidget (handle, false);
}
void setBackground (float [] color) {
setBackground (handle, color);
}
void setBackground (int control, float [] color) {
ControlFontStyleRec fontStyle = new ControlFontStyleRec ();
OS.GetControlData (control, (short) OS.kControlEntireControl, OS.kControlFontStyleTag, ControlFontStyleRec.sizeof, fontStyle, null);
if (color != null) {
fontStyle.backColor_red = (short) (color [0] * 0xffff);
fontStyle.backColor_green = (short) (color [1] * 0xffff);
fontStyle.backColor_blue = (short) (color [2] * 0xffff);
fontStyle.flags |= OS.kControlUseBackColorMask;
} else {
fontStyle.flags &= ~OS.kControlUseBackColorMask;
}
OS.SetControlFontStyle (control, fontStyle);
}
/**
* Sets the receiver's size and location to the rectangular
* area specified by the arguments. The <code>x</code> and
* <code>y</code> arguments are relative to the receiver's
* parent (or its display if its parent is null), unless
* the receiver is a shell. In this case, the <code>x</code>
* and <code>y</code> arguments are relative to the display.
* <p>
* Note: Attempting to set the width or height of the
* receiver to a negative number will cause that
* value to be set to zero instead.
* </p>
*
* @param x the new x coordinate for the receiver
* @param y the new y coordinate for the receiver
* @param width the new width for the receiver
* @param height the new height for the receiver
*
* @exception SWTException <ul>
* <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
public void setBounds (int x, int y, int width, int height) {
checkWidget();
setBounds (x, y, Math.max (0, width), Math.max (0, height), true, true, true);
}
int setBounds (int x, int y, int width, int height, boolean move, boolean resize, boolean events) {
return setBounds (topHandle (), x, y, width, height, move, resize, events);
}
/**
* Sets the receiver's size and location to the rectangular
* area specified by the argument. The <code>x</code> and
* <code>y</code> fields of the rectangle are relative to
* the receiver's parent (or its display if its parent is null).
* <p>
* Note: Attempting to set the width or height of the
* receiver to a negative number will cause that
* value to be set to zero instead.
* </p>
*
* @param rect the new bounds for the receiver
*
* @exception SWTException <ul>
* <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
public void setBounds (Rectangle rect) {
checkWidget ();
if (rect == null) error (SWT.ERROR_NULL_ARGUMENT);
setBounds (rect.x, rect.y, Math.max (0, rect.width), Math.max (0, rect.height), true, true, true);
}
/**
* If the argument is <code>true</code>, causes the receiver to have
* all mouse events delivered to it until the method is called with
* <code>false</code> as the argument.
*
* @param capture <code>true</code> to capture the mouse, and <code>false</code> to release it
*
* @exception SWTException <ul>
* <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
public void setCapture (boolean capture) {
checkWidget();
}
/**
* Sets the receiver's cursor to the cursor specified by the
* argument, or to the default cursor for that kind of control
* if the argument is null.
* <p>
* When the mouse pointer passes over a control its appearance
* is changed to match the control's cursor.
* </p>
*
* @param cursor the new cursor (or null)
*
* @exception IllegalArgumentException <ul>
* <li>ERROR_INVALID_ARGUMENT - if the argument has been disposed</li>
* </ul>
* @exception SWTException <ul>
* <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
public void setCursor (Cursor cursor) {
checkWidget();
if (cursor != null && cursor.isDisposed ()) error (SWT.ERROR_INVALID_ARGUMENT);
this.cursor = cursor;
if (!isEnabled ()) return;
org.eclipse.swt.internal.carbon.Point where = new org.eclipse.swt.internal.carbon.Point ();
OS.GetGlobalMouse (where);
int [] theWindow = new int [1];
if (display.grabControl == this) {
theWindow [0] = OS.GetControlOwner (handle);
} else {
if (OS.FindWindow (where, theWindow) != OS.inContent) return;
if (theWindow [0] == 0) return;
}
Rect rect = new Rect ();
OS.GetWindowBounds (theWindow [0], (short) OS.kWindowContentRgn, rect);
int [] theControl = new int [1];
if (display.grabControl == this) {
theControl [0] = handle;
} else {
CGPoint inPoint = new CGPoint ();
inPoint.x = where.h - rect.left;
inPoint.y = where.v - rect.top;
int [] theRoot = new int [1];
OS.GetRootControl (theWindow [0], theRoot);
OS.HIViewGetSubviewHit (theRoot [0], inPoint, true, theControl);
int cursorControl = theControl [0];
while (theControl [0] != 0 && theControl [0] != handle) {
OS.GetSuperControl (theControl [0], theControl);
}
if (theControl [0] == 0) return;
theControl [0] = cursorControl;
do {
Widget widget = display.getWidget (theControl [0]);
if (widget != null) {
if (widget instanceof Control) {
Control control = (Control) widget;
if (control.isEnabled ()) break;
}
}
OS.GetSuperControl (theControl [0], theControl);
} while (theControl [0] != 0);
if (theControl [0] == 0) {
theControl [0] = theRoot [0];
Widget widget = display.getWidget (theControl [0]);
if (widget != null && widget instanceof Control) {
Control control = (Control) widget;
theControl [0] = control.handle;
}
}
}
CGPoint pt = new CGPoint ();
OS.HIViewConvertPoint (pt, theControl [0], 0);
where.h -= (int) pt.x;
where.v -= (int) pt.y;
OS.GetWindowBounds (theWindow [0], (short) OS.kWindowStructureRgn, rect);
where.h -= rect.left;
where.v -= rect.top;
int modifiers = OS.GetCurrentEventKeyModifiers ();
boolean [] cursorWasSet = new boolean [1];
OS.HandleControlSetCursor (theControl [0], where, (short) modifiers, cursorWasSet);
if (!cursorWasSet [0]) OS.SetThemeCursor (OS.kThemeArrowCursor);
}
void setDefaultFont () {
if (display.smallFonts) setFontStyle (defaultFont ());
}
/**
* Sets the receiver's drag detect state. If the argument is
* <code>true</code>, the receiver will detect drag gestures,
* otherwise these gestures will be ignored.
*
* @param dragDetect the new drag detect state
*
* @exception SWTException <ul>
* <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*
* @since 3.3
*/
public void setDragDetect (boolean dragDetect) {
checkWidget ();
if (dragDetect) {
state |= DRAG_DETECT;
} else {
state &= ~DRAG_DETECT;
}
}
/**
* Enables the receiver if the argument is <code>true</code>,
* and disables it otherwise. A disabled control is typically
* not selectable from the user interface and draws with an
* inactive or "grayed" look.
*
* @param enabled the new enabled state
*
* @exception SWTException <ul>
* <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
public void setEnabled (boolean enabled) {
checkWidget();
if (((state & DISABLED) == 0) == enabled) return;
Control control = null;
boolean fixFocus = false;
if (!enabled) {
if (display.focusEvent != SWT.FocusOut) {
control = display.getFocusControl ();
fixFocus = isFocusAncestor (control);
}
}
if (enabled) {
state &= ~DISABLED;
} else {
state |= DISABLED;
}
enableWidget (enabled);
if (fixFocus) fixFocus (control);
}
/**
* Causes the receiver to have the <em>keyboard focus</em>,
* such that all keyboard events will be delivered to it. Focus
* reassignment will respect applicable platform constraints.
*
* @return <code>true</code> if the control got focus, and <code>false</code> if it was unable to.
*
* @exception SWTException <ul>
* <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*
* @see #forceFocus
*/
public boolean setFocus () {
checkWidget();
if ((style & SWT.NO_FOCUS) != 0) return false;
return forceFocus ();
}
/**
* Sets the font that the receiver will use to paint textual information
* to the font specified by the argument, or to the default font for that
* kind of control if the argument is null.
*
* @param font the new font (or null)
*
* @exception IllegalArgumentException <ul>
* <li>ERROR_INVALID_ARGUMENT - if the argument has been disposed</li>
* </ul>
* @exception SWTException <ul>
* <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
public void setFont (Font font) {
checkWidget();
if (font != null) {
if (font.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
}
this.font = font;
setFontStyle (display.smallFonts ? (font != null ? font : defaultFont ()) : font);
redrawWidget (handle, false);
}
void setFontStyle (Font font) {
setFontStyle (handle, font);
}
void setFontStyle (int control, Font font) {
ControlFontStyleRec fontStyle = new ControlFontStyleRec ();
OS.GetControlData (control, (short) OS.kControlEntireControl, OS.kControlFontStyleTag, ControlFontStyleRec.sizeof, fontStyle, null);
fontStyle.flags &= ~(OS.kControlUseFontMask | OS.kControlUseSizeMask | OS.kControlUseFaceMask | OS.kControlUseThemeFontIDMask);
if (font != null) {
short [] family = new short [1], style = new short [1];
OS.FMGetFontFamilyInstanceFromFont (font.handle, family, style);
fontStyle.flags |= OS.kControlUseFontMask | OS.kControlUseSizeMask | OS.kControlUseFaceMask;
fontStyle.font = family [0];
fontStyle.style = (short) (style [0] | font.style);
fontStyle.size = (short) font.size;
}
OS.SetControlFontStyle (control, fontStyle);
}
/**
* Sets the receiver's foreground color to the color specified
* by the argument, or to the default system color for the control
* if the argument is null.
* <p>
* Note: This operation is a hint and may be overridden by the platform.
* </p>
* @param color the new color (or null)
*
* @exception IllegalArgumentException <ul>
* <li>ERROR_INVALID_ARGUMENT - if the argument has been disposed</li>
* </ul>
* @exception SWTException <ul>
* <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
public void setForeground (Color color) {
checkWidget();
if (color != null) {
if (color.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
}
float[] foreground = color != null ? color.handle : null;
if (equals (foreground, this.foreground)) return;
this.foreground = foreground;
setForeground (foreground);
redrawWidget (handle, false);
}
void setForeground (float [] color) {
setForeground (handle, color);
}
void setForeground (int control, float [] color) {
ControlFontStyleRec fontStyle = new ControlFontStyleRec ();
OS.GetControlData (control, (short) OS.kControlEntireControl, OS.kControlFontStyleTag, ControlFontStyleRec.sizeof, fontStyle, null);
if (color != null) {
fontStyle.foreColor_red = (short) (color [0] * 0xffff);
fontStyle.foreColor_green = (short) (color [1] * 0xffff);
fontStyle.foreColor_blue = (short) (color [2] * 0xffff);
fontStyle.flags |= OS.kControlUseForeColorMask;
} else {
fontStyle.flags &= ~OS.kControlUseForeColorMask;
}
OS.SetControlFontStyle (control, fontStyle);
}
/**
* Sets the layout data associated with the receiver to the argument.
*
* @param layoutData the new layout data for the receiver.
*
* @exception SWTException <ul>
* <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
public void setLayoutData (Object layoutData) {
checkWidget();
this.layoutData = layoutData;
}
/**
* Sets the receiver's location to the point specified by
* the arguments which are relative to the receiver's
* parent (or its display if its parent is null), unless
* the receiver is a shell. In this case, the point is
* relative to the display.
*
* @param x the new x coordinate for the receiver
* @param y the new y coordinate for the receiver
*
* @exception SWTException <ul>
* <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
public void setLocation (int x, int y) {
checkWidget();
setBounds (x, y, 0, 0, true, false, true);
}
/**
* Sets the receiver's location to the point specified by
* the arguments which are relative to the receiver's
* parent (or its display if its parent is null), unless
* the receiver is a shell. In this case, the point is
* relative to the display.
*
* @param location the new location for the receiver
*
* @exception SWTException <ul>
* <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
public void setLocation (Point location) {
checkWidget();
if (location == null) error (SWT.ERROR_NULL_ARGUMENT);
setBounds (location.x, location.y, 0, 0, true, false, true);
}
/**
* Sets the receiver's pop up menu to the argument.
* All controls may optionally have a pop up
* menu that is displayed when the user requests one for
* the control. The sequence of key strokes, button presses
* and/or button releases that are used to request a pop up
* menu is platform specific.
* <p>
* Note: Disposing of a control that has a pop up menu will
* dispose of the menu. To avoid this behavior, set the
* menu to null before the control is disposed.
* </p>
*
* @param menu the new pop up menu
*
* @exception IllegalArgumentException <ul>
* <li>ERROR_MENU_NOT_POP_UP - the menu is not a pop up menu</li>
* <li>ERROR_INVALID_PARENT - if the menu is not in the same widget tree</li>
* <li>ERROR_INVALID_ARGUMENT - if the menu has been disposed</li>
* </ul>
* @exception SWTException <ul>
* <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
public void setMenu (Menu menu) {
checkWidget();
if (menu != null) {
if (menu.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
if ((menu.style & SWT.POP_UP) == 0) {
error (SWT.ERROR_MENU_NOT_POP_UP);
}
if (menu.parent != menuShell ()) {
error (SWT.ERROR_INVALID_PARENT);
}
}
this.menu = menu;
}
/**
* Changes the parent of the widget to be the one provided if
* the underlying operating system supports this feature.
* Returns <code>true</code> if the parent is successfully changed.
*
* @param parent the new parent for the control.
* @return <code>true</code> if the parent is changed and <code>false</code> otherwise.
*
* @exception IllegalArgumentException <ul>
* <li>ERROR_INVALID_ARGUMENT - if the argument has been disposed</li>
* <li>ERROR_NULL_ARGUMENT - if the parent is <code>null</code></li>
* </ul>
* @exception SWTException <ul>
* <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
public boolean setParent (Composite parent) {
checkWidget();
if (parent == null) error (SWT.ERROR_NULL_ARGUMENT);
if (parent.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
if (this.parent == parent) return true;
if (!isReparentable ()) return false;
releaseParent ();
Shell newShell = parent.getShell (), oldShell = getShell ();
Decorations newDecorations = parent.menuShell (), oldDecorations = menuShell ();
if (oldShell != newShell || oldDecorations != newDecorations) {
Menu [] menus = oldShell.findMenus (this);
fixChildren (newShell, oldShell, newDecorations, oldDecorations, menus);
}
int topHandle = topHandle ();
OS.HIViewAddSubview (parent.handle, topHandle);
OS.HIViewSetVisible (topHandle, (state & HIDDEN) == 0);
OS.HIViewSetZOrder (topHandle, OS.kHIViewZOrderBelow, 0);
this.parent = parent;
return true;
}
/**
* If the argument is <code>false</code>, causes subsequent drawing
* operations in the receiver to be ignored. No drawing of any kind
* can occur in the receiver until the flag is set to true.
* Graphics operations that occurred while the flag was
* <code>false</code> are lost. When the flag is set to <code>true</code>,
* the entire widget is marked as needing to be redrawn. Nested calls
* to this method are stacked.
* <p>
* Note: This operation is a hint and may not be supported on some
* platforms or for some widgets.
* </p>
*
* @param redraw the new redraw state
*
* @exception SWTException <ul>
* <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*
* @see #redraw(int, int, int, int, boolean)
* @see #update()
*/
public void setRedraw (boolean redraw) {
checkWidget();
if (redraw) {
if (--drawCount == 0) {
OS.HIViewSetDrawingEnabled (handle, true);
invalidateVisibleRegion (handle);
redrawWidget (handle, true);
}
} else {
if (drawCount == 0) {
OS.HIViewSetDrawingEnabled (handle, false);
invalidateVisibleRegion (handle);
}
drawCount++;
}
}
public void setRegion (Region region) {
checkWidget ();
if (region != null && region.isDisposed()) error (SWT.ERROR_INVALID_ARGUMENT);
this.region = region;
redrawWidget (handle, true);
}
boolean setRadioSelection (boolean value){
return false;
}
/**
* Sets the receiver's size to the point specified by the arguments.
* <p>
* Note: Attempting to set the width or height of the
* receiver to a negative number will cause that
* value to be set to zero instead.
* </p>
*
* @param width the new width for the receiver
* @param height the new height for the receiver
*
* @exception SWTException <ul>
* <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
public void setSize (int width, int height) {
checkWidget();
setBounds (0, 0, Math.max (0, width), Math.max (0, height), false, true, true);
}
/**
* Sets the receiver's size to the point specified by the argument.
* <p>
* Note: Attempting to set the width or height of the
* receiver to a negative number will cause them to be
* set to zero instead.
* </p>
*
* @param size the new size for the receiver
*
* @exception IllegalArgumentException <ul>
* <li>ERROR_NULL_ARGUMENT - if the point is null</li>
* </ul>
* @exception SWTException <ul>
* <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
public void setSize (Point size) {
checkWidget ();
if (size == null) error (SWT.ERROR_NULL_ARGUMENT);
setBounds (0, 0, Math.max (0, size.x), Math.max (0, size.y), false, true, true);
}
boolean setTabGroupFocus () {
return setTabItemFocus ();
}
boolean setTabItemFocus () {
if (!isShowing ()) return false;
return forceFocus ();
}
/**
* Sets the receiver's tool tip text to the argument, which
* may be null indicating that no tool tip text should be shown.
*
* @param string the new tool tip text (or null)
*
* @exception SWTException <ul>
* <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
public void setToolTipText (String string) {
checkWidget();
toolTipText = string;
if (display.helpWidget == this) {
display.helpWidget = null;
OS.HMInstallControlContentCallback (handle, 0);
OS.HMInstallControlContentCallback (handle, display.helpProc);
}
}
/**
* Marks the receiver as visible if the argument is <code>true</code>,
* and marks it invisible otherwise.
* <p>
* If one of the receiver's ancestors is not visible or some
* other condition makes the receiver not visible, marking
* it visible may not actually cause it to be displayed.
* </p>
*
* @param visible the new visibility state
*
* @exception SWTException <ul>
* <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
public void setVisible (boolean visible) {
checkWidget();
if (visible) {
if ((state & HIDDEN) == 0) return;
state &= ~HIDDEN;
} else {
if ((state & HIDDEN) != 0) return;
state |= HIDDEN;
}
if (visible) {
/*
* It is possible (but unlikely), that application
* code could have disposed the widget in the show
* event. If this happens, just return.
*/
sendEvent (SWT.Show);
if (isDisposed ()) return;
}
/*
* Feature in the Macintosh. If the receiver has focus, hiding
* the receiver causes no control to have focus. Also, the focus
* needs to be cleared from any TXNObject so that it stops blinking
* the caret. The fix is to assign focus to the first ancestor
* control that takes focus. If no control will take focus, clear
* the focus control.
*/
Control control = null;
boolean fixFocus = false;
if (!visible) {
if (display.focusEvent != SWT.FocusOut) {
control = display.getFocusControl ();
fixFocus = isFocusAncestor (control);
}
}
setVisible (topHandle (), visible);
if (!visible) {
/*
* It is possible (but unlikely), that application
* code could have disposed the widget in the show
* event. If this happens, just return.
*/
sendEvent (SWT.Hide);
if (isDisposed ()) return;
}
if (fixFocus) fixFocus (control);
}
void setZOrder () {
int topHandle = topHandle ();
int parentHandle = parent.handle;
OS.HIViewAddSubview (parentHandle, topHandle);
OS.HIViewSetZOrder (topHandle, OS.kHIViewZOrderBelow, 0);
Rect rect = getInset ();
rect.right = rect.left;
rect.bottom = rect.top;
OS.SetControlBounds (topHandle, rect);
}
void setZOrder (Control control, boolean above) {
int otherControl = control == null ? 0 : control.topHandle ();
setZOrder (topHandle (), otherControl, above);
}
void sort (int [] items) {
/* Shell Sort from K&R, pg 108 */
int length = items.length;
for (int gap=length/2; gap>0; gap/=2) {
for (int i=gap; i<length; i++) {
for (int j=i-gap; j>=0; j-=gap) {
if (items [j] <= items [j + gap]) {
int swap = items [j];
items [j] = items [j + gap];
items [j + gap] = swap;
}
}
}
}
}
Point textExtent (int ptr, int wHint) {
if (ptr != 0 && OS.CFStringGetLength (ptr) > 0) {
float [] w = new float [1], h = new float [1];
HIThemeTextInfo info = new HIThemeTextInfo ();
info.state = OS.kThemeStateActive;
if (font != null) {
short [] family = new short [1], style = new short [1];
OS.FMGetFontFamilyInstanceFromFont (font.handle, family, style);
OS.TextFont (family [0]);
OS.TextFace ((short) (style [0] | font.style));
OS.TextSize ((short) font.size);
info.fontID = (short) OS.kThemeCurrentPortFont;
} else {
info.fontID = (short) defaultThemeFont ();
}
OS.HIThemeGetTextDimensions (ptr, wHint == SWT.DEFAULT ? 0 : wHint, info, w, h, null);
return new Point((int) w [0], (int) h [0]);
} else {
Font font = getFont ();
ATSFontMetrics metrics = new ATSFontMetrics();
OS.ATSFontGetVerticalMetrics(font.handle, OS.kATSOptionFlagsDefault, metrics);
OS.ATSFontGetHorizontalMetrics(font.handle, OS.kATSOptionFlagsDefault, metrics);
return new Point(0, (int)(0.5f + (metrics.ascent -metrics.descent + metrics.leading) * font.size));
}
}
Point textExtent(char[] chars, int wHint) {
int ptr = OS.CFStringCreateWithCharacters (OS.kCFAllocatorDefault, chars, chars.length);
Point result = textExtent (ptr, wHint);
if (ptr != 0) OS.CFRelease (ptr);
return result;
}
/**
* Returns a point which is the result of converting the
* argument, which is specified in display relative coordinates,
* to coordinates relative to the receiver.
* <p>
* @param x the x coordinate to be translated
* @param y the y coordinate to be translated
* @return the translated coordinates
*
* @exception SWTException <ul>
* <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*
* @since 2.1
*/
public Point toControl (int x, int y) {
checkWidget();
Rect rect = new Rect ();
int window = OS.GetControlOwner (handle);
CGPoint pt = new CGPoint ();
OS.HIViewConvertPoint (pt, handle, 0);
x -= (int) pt.x;
y -= (int) pt.y;
OS.GetWindowBounds (window, (short) OS.kWindowStructureRgn, rect);
x -= rect.left;
y -= rect.top;
Rect inset = getInset ();
x += inset.left;
y += inset.top;
return new Point (x, y);
}
/**
* Returns a point which is the result of converting the
* argument, which is specified in display relative coordinates,
* to coordinates relative to the receiver.
* <p>
* @param point the point to be translated (must not be null)
* @return the translated coordinates
*
* @exception IllegalArgumentException <ul>
* <li>ERROR_NULL_ARGUMENT - if the point is null</li>
* </ul>
* @exception SWTException <ul>
* <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
public Point toControl (Point point) {
checkWidget();
if (point == null) error (SWT.ERROR_NULL_ARGUMENT);
return toControl (point.x, point.y);
}
/**
* Returns a point which is the result of converting the
* argument, which is specified in coordinates relative to
* the receiver, to display relative coordinates.
* <p>
* @param x the x coordinate to be translated
* @param y the y coordinate to be translated
* @return the translated coordinates
*
* @exception SWTException <ul>
* <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*
* @since 2.1
*/
public Point toDisplay (int x, int y) {
checkWidget();
Rect rect = new Rect ();
int window = OS.GetControlOwner (handle);
CGPoint pt = new CGPoint ();
OS.HIViewConvertPoint (pt, handle, 0);
x += (int) pt.x;
y += (int) pt.y;
OS.GetWindowBounds (window, (short) OS.kWindowStructureRgn, rect);
x += rect.left;
y += rect.top;
Rect inset = getInset ();
x -= inset.left;
y -= inset.top;
return new Point (x, y);
}
/**
* Returns a point which is the result of converting the
* argument, which is specified in coordinates relative to
* the receiver, to display relative coordinates.
* <p>
* @param point the point to be translated (must not be null)
* @return the translated coordinates
*
* @exception IllegalArgumentException <ul>
* <li>ERROR_NULL_ARGUMENT - if the point is null</li>
* </ul>
* @exception SWTException <ul>
* <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
public Point toDisplay (Point point) {
checkWidget();
if (point == null) error (SWT.ERROR_NULL_ARGUMENT);
return toDisplay (point.x, point.y);
}
int topHandle () {
return handle;
}
boolean translateTraversal (int key, int theEvent, boolean [] consume) {
int detail = SWT.TRAVERSE_NONE;
int code = traversalCode (key, theEvent);
boolean all = false;
switch (key) {
case 53: /* Esc */ {
all = true;
detail = SWT.TRAVERSE_ESCAPE;
break;
}
case 76: /* KP Enter */
case 36: /* Return */ {
all = true;
detail = SWT.TRAVERSE_RETURN;
break;
}
case 48: /* Tab */ {
int [] modifiers = new int [1];
OS.GetEventParameter (theEvent, OS.kEventParamKeyModifiers, OS.typeUInt32, null, 4, null, modifiers);
boolean next = (modifiers [0] & OS.shiftKey) == 0;
detail = next ? SWT.TRAVERSE_TAB_NEXT : SWT.TRAVERSE_TAB_PREVIOUS;
break;
}
case 126: /* Up arrow */
case 123: /* Left arrow */
case 125: /* Down arrow */
case 124: /* Right arrow */ {
boolean next = key == 125 /* Down arrow */ || key == 124 /* Right arrow */;
detail = next ? SWT.TRAVERSE_ARROW_NEXT : SWT.TRAVERSE_ARROW_PREVIOUS;
break;
}
case 116: /* Page up */
case 121: /* Page down */ {
all = true;
int [] modifiers = new int [1];
OS.GetEventParameter (theEvent, OS.kEventParamKeyModifiers, OS.typeUInt32, null, 4, null, modifiers);
if ((modifiers [0] & OS.controlKey) == 0) return false;
detail = key == 121 /* Page down */ ? SWT.TRAVERSE_PAGE_NEXT : SWT.TRAVERSE_PAGE_PREVIOUS;
break;
}
default:
return false;
}
Event event = new Event ();
event.doit = consume [0] = (code & detail) != 0;
event.detail = detail;
if (!setKeyState (event, SWT.Traverse, theEvent)) return false;
Shell shell = getShell ();
Control control = this;
do {
if (control.traverse (event)) return true;
if (!event.doit && control.hooks (SWT.Traverse)) {
return false;
}
if (control == shell) return false;
control = control.parent;
} while (all && control != null);
return false;
}
int traversalCode (int key, int theEvent) {
int code = SWT.TRAVERSE_RETURN | SWT.TRAVERSE_TAB_NEXT | SWT.TRAVERSE_TAB_PREVIOUS;
Shell shell = getShell ();
if (shell.parent != null) code |= SWT.TRAVERSE_ESCAPE;
return code;
}
boolean traverseMnemonic (char key) {
return false;
}
/**
* Based on the argument, perform one of the expected platform
* traversal action. The argument should be one of the constants:
* <code>SWT.TRAVERSE_ESCAPE</code>, <code>SWT.TRAVERSE_RETURN</code>,
* <code>SWT.TRAVERSE_TAB_NEXT</code>, <code>SWT.TRAVERSE_TAB_PREVIOUS</code>,
* <code>SWT.TRAVERSE_ARROW_NEXT</code> and <code>SWT.TRAVERSE_ARROW_PREVIOUS</code>.
*
* @param traversal the type of traversal
* @return true if the traversal succeeded
*
* @exception SWTException <ul>
* <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
public boolean traverse (int traversal) {
checkWidget();
Event event = new Event ();
event.doit = true;
event.detail = traversal;
return traverse (event);
}
boolean traverse (Event event) {
sendEvent (SWT.Traverse, event);
if (isDisposed ()) return true;
if (!event.doit) return false;
switch (event.detail) {
case SWT.TRAVERSE_NONE: return true;
case SWT.TRAVERSE_ESCAPE: return traverseEscape ();
case SWT.TRAVERSE_RETURN: return traverseReturn ();
case SWT.TRAVERSE_TAB_NEXT: return traverseGroup (true);
case SWT.TRAVERSE_TAB_PREVIOUS: return traverseGroup (false);
case SWT.TRAVERSE_ARROW_NEXT: return traverseItem (true);
case SWT.TRAVERSE_ARROW_PREVIOUS: return traverseItem (false);
case SWT.TRAVERSE_MNEMONIC: return traverseMnemonic (event);
case SWT.TRAVERSE_PAGE_NEXT: return traversePage (true);
case SWT.TRAVERSE_PAGE_PREVIOUS: return traversePage (false);
}
return false;
}
boolean traverseEscape () {
return false;
}
boolean traverseGroup (boolean next) {
Control root = computeTabRoot ();
Control group = computeTabGroup ();
Control [] list = root.computeTabList ();
int length = list.length;
int index = 0;
while (index < length) {
if (list [index] == group) break;
index++;
}
/*
* It is possible (but unlikely), that application
* code could have disposed the widget in focus in
* or out events. Ensure that a disposed widget is
* not accessed.
*/
if (index == length) return false;
int start = index, offset = (next) ? 1 : -1;
while ((index = ((index + offset + length) % length)) != start) {
Control control = list [index];
if (!control.isDisposed () && control.setTabGroupFocus ()) {
return true;
}
}
if (group.isDisposed ()) return false;
return group.setTabGroupFocus ();
}
boolean traverseItem (boolean next) {
Control [] children = parent._getChildren ();
int length = children.length;
int index = 0;
while (index < length) {
if (children [index] == this) break;
index++;
}
/*
* It is possible (but unlikely), that application
* code could have disposed the widget in focus in
* or out events. Ensure that a disposed widget is
* not accessed.
*/
if (index == length) return false;
int start = index, offset = (next) ? 1 : -1;
while ((index = (index + offset + length) % length) != start) {
Control child = children [index];
if (!child.isDisposed () && child.isTabItem ()) {
if (child.setTabItemFocus ()) return true;
}
}
return false;
}
boolean traverseReturn () {
return false;
}
boolean traversePage (boolean next) {
return false;
}
boolean traverseMnemonic (Event event) {
return false;
}
/**
* Forces all outstanding paint requests for the widget
* to be processed before this method returns. If there
* are no outstanding paint request, this method does
* nothing.
* <p>
* Note: This method does not cause a redraw.
* </p>
*
* @exception SWTException <ul>
* <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*
* @see #redraw()
* @see #redraw(int, int, int, int, boolean)
* @see PaintListener
* @see SWT#Paint
*/
public void update () {
checkWidget();
update (false);
}
void update (boolean all) {
// checkWidget();
//TODO - not all
if (display.inPaint) return;
OS.HIViewRender (handle);
if (isDisposed()) return;
OS.HIWindowFlush (OS.GetControlOwner (handle));
}
void updateBackgroundMode () {
int oldState = state & PARENT_BACKGROUND;
checkBackground ();
if (oldState != (state & PARENT_BACKGROUND)) {
setBackground ();
}
}
void updateLayout (boolean all) {
/* Do nothing */
}
}
| [
"[email protected]"
] | |
7dd7a29f4345bd8c31f0c23260361d21049478a6 | 3ec9afe192d80941888595083aaaef8b7b569fc5 | /content/content-tool/tool/src/java/org/sakaiproject/content/tool/ResourceTypeLabeler.java | bc63db54daa18e5713008355406346830a32c507 | [
"ECL-2.0",
"LicenseRef-scancode-warranty-disclaimer"
] | permissive | marktriggs/nyu-sakai-10.4 | 570912a2a00f2ea26aa079b11e91a35d048f1000 | 022f2e81599260500e5c17f16f856b7b1bac378c | refs/heads/scormcloud | 2021-01-15T18:08:50.060553 | 2015-08-10T06:32:41 | 2015-08-10T06:32:41 | 38,663,237 | 0 | 2 | null | 2016-03-10T00:10:19 | 2015-07-07T04:04:56 | Java | UTF-8 | Java | false | false | 3,505 | java | /**********************************************************************************
* $URL$
* $Id$
***********************************************************************************
*
* Copyright (c) 2007, 2008 The Sakai Foundation
*
* Licensed under the Educational Community 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.opensource.org/licenses/ECL-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.sakaiproject.content.tool;
import org.sakaiproject.component.cover.ComponentManager;
import org.sakaiproject.content.api.ResourceToolAction;
import org.sakaiproject.content.api.ResourceType;
import org.sakaiproject.content.api.ResourceTypeRegistry;
public class ResourceTypeLabeler
{
public String getLabel(ResourceToolAction action)
{
String label = null;
if(action == null)
{
ResourcesAction.logger.info("Null action passed to labeler ");
label = "";
}
else
{
label = action.getLabel();
}
if(label == null)
{
switch(action.getActionType())
{
case NEW_UPLOAD:
label = ResourcesAction.trb.getString("create.uploads");
break;
case NEW_FOLDER:
label = ResourcesAction.trb.getString("create.folder");
break;
case NEW_URLS:
label = ResourcesAction.trb.getString("create.urls");
break;
case CREATE:
ResourceTypeRegistry registry = (ResourceTypeRegistry) ComponentManager.get("org.sakaiproject.content.api.ResourceTypeRegistry");
ResourceType typedef = registry.getType(action.getTypeId());
String[] args = { typedef.getLabel() };
label = ResourcesAction.trb.getFormattedMessage("create.unknown", args);
break;
case COPY:
label = ResourcesAction.trb.getString("action.copy");
break;
case DUPLICATE:
label = ResourcesAction.trb.getString("action.duplicate");
break;
case DELETE:
label = ResourcesAction.trb.getString("action.delete");
break;
case MOVE:
label = ResourcesAction.trb.getString("action.move");
break;
case VIEW_METADATA:
label = ResourcesAction.trb.getString("action.info");
break;
case REVISE_METADATA:
label = ResourcesAction.trb.getString("action.props");
break;
case VIEW_CONTENT:
label = ResourcesAction.trb.getString("action.access");
break;
case REVISE_CONTENT:
label = ResourcesAction.trb.getString("action.revise");
break;
case REPLACE_CONTENT:
label = ResourcesAction.trb.getString("action.replace");
break;
case PASTE_COPIED:
label = ResourcesAction.trb.getString("action.pastecopy");
break;
case PASTE_MOVED:
label = ResourcesAction.trb.getString("action.pastemove");
break;
case PRINT_FILE:
label = ResourcesAction.trb.getString("action.printfile");
break;
default:
ResourcesAction.logger.info("No label provided for ResourceToolAction: " + action.getTypeId() + ResourceToolAction.ACTION_DELIMITER + action.getId());
label = action.getId();
break;
}
}
return label;
}
} | [
"[email protected]@66ffb92e-73f9-0310-93c1-f5514f145a0a"
] | [email protected]@66ffb92e-73f9-0310-93c1-f5514f145a0a |
718229733c4f20def8383787082096fdde3f29bc | 8ee6ac79b9d2c403d04c1bccd63df022395491ec | /microservice-cloud-consumer-product-80/src/main/java/com/wangweichao/springcloud/service/ProductClientService.java | abe4f7c30482dfc1357afcd888e83a1322adbe83 | [] | no_license | 13127766006/microservice-cloud | 85eab67a56d31eb09c86a6d55b9f8b59d5a04ea8 | ee464f048f90acf2aed2e7b9527fa91aed1f04aa | refs/heads/master | 2022-06-21T22:13:09.380376 | 2020-02-25T07:39:30 | 2020-02-25T07:39:30 | 242,938,770 | 0 | 0 | null | 2022-06-21T02:51:50 | 2020-02-25T07:37:13 | Java | UTF-8 | Java | false | false | 974 | java | package com.wangweichao.springcloud.service;
import com.wangweichao.springcloud.entities.Product;
import com.wangweichao.springcloud.service.ipml.ProductClientServiceFallBack;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import java.util.List;
@FeignClient(value = "microservice-product", fallback = ProductClientServiceFallBack.class)
public interface ProductClientService {
@RequestMapping(value = "/product/get/{id}",method = RequestMethod.GET)
Product get(@PathVariable("id") Long id);
@RequestMapping(value = "/product/list",method = RequestMethod.GET)
List<Product> list();
@RequestMapping(value = "/product/add",method = RequestMethod.POST)
boolean add(@RequestBody Product product);
} | [
"[email protected]"
] | |
f4e7d46f84f7b619490c88170a3da37e4162da82 | 902cf40a647426eb4bb2eaee697f57fd29bf885c | /Lesson5/src/ru/khusyainov/hw5/KnapsackObjectImpl.java | 1c9c7dd444752b50376c3dcfd599f17a86756b36 | [] | no_license | PaLoMaster/AlgorithmsOnJava | 294ac0af9c95e404e029c92929c186f3d5efd93f | 55f3be367e190220fe12dc4d91fd42cdc41f6c00 | refs/heads/master | 2020-04-06T11:44:49.688472 | 2018-12-16T05:45:34 | 2018-12-16T05:45:34 | 157,428,496 | 0 | 0 | null | 2018-12-16T05:45:35 | 2018-11-13T18:41:17 | Java | UTF-8 | Java | false | false | 1,554 | java | package ru.khusyainov.hw5;
import java.util.Objects;
public class KnapsackObjectImpl implements KnapsackObject {
private final String name;
private final int weight;
private int price;
public KnapsackObjectImpl(String name, int price, int weight) {
this.name = name;
this.price = price;
this.weight = weight;
}
@Override
public String getName() {
return name;
}
@Override
public int getPrice() {
return price;
}
@Override
public int getWeight() {
return weight;
}
@Override
public void setPrice(int price) {
this.price = price;
}
@Override
public int hashCode() {
int hash = 5;
hash = 83 * hash + Objects.hashCode(this.name);
hash = 83 * hash + this.price;
hash = 83 * hash + this.weight;
return hash;
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
final KnapsackObjectImpl other = (KnapsackObjectImpl) obj;
if (price != other.price || weight != other.weight) {
return false;
}
return name.equals(other.name);
}
@Override
public String toString() {
return name + ": цена - " + price + ", вес - " + weight;
}
}
| [
"[email protected]"
] | |
afffbd09f41ae580303df92aa40f24f414de7e1e | 708ea6601698302043640f760f7bfd0edbc47d1a | /nimble-dagger2/src/main/java/com/lenguyenthanh/nimbledagger2/data/model/User.java | 6282204c5a16ed1167cd8f26cbc61375f790ef40 | [
"Apache-2.0"
] | permissive | lenguyenthanh/nimble | a8cb67856d0b798da4392e5e360b4de1e406c5fb | 94d88bcf9f89382ed7e2c8ea7bc26658defc81fe | refs/heads/master | 2021-01-21T13:48:40.969076 | 2016-05-09T14:32:38 | 2016-05-09T14:32:38 | 52,316,952 | 30 | 4 | null | 2016-05-09T14:32:38 | 2016-02-23T00:30:21 | Java | UTF-8 | Java | false | false | 936 | java | /*
* Copyright 2016 Thanh Le.
*
* 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 com.lenguyenthanh.nimbledagger2.data.model;
public class User {
public final String firstName;
public final String lastName;
public User(String firstName, String lastName) {
this.firstName = firstName;
this.lastName = lastName;
}
@Override
public String toString() {
return firstName + " " + lastName;
}
}
| [
"[email protected]"
] | |
dcddd92727f85d488788292ed0254a877a7a93bf | 3b64171aac3099ace432b44f975a1f00abef26dc | /src/suparnaNJune20/Assignment_35/GetUniqueValue.java | 1de4e0de4468bf7310392e30d28b601eb27f5e91 | [] | no_license | KrishnaKTechnocredits/JAVATechnoJun20 | a80b97c0c80f3a70bd5205bcf1de0db76e1d7b25 | 197e81594254cd05cb42d576720f473edb446b72 | refs/heads/master | 2022-12-22T23:48:51.680861 | 2020-09-24T04:45:23 | 2020-09-24T04:45:23 | 272,046,021 | 0 | 0 | null | 2020-09-24T09:02:14 | 2020-06-13T16:31:43 | Java | UTF-8 | Java | false | false | 1,553 | java | package suparnaNJune20.Assignment_35;
/*
Assignment 35: Retrieve all unique names from given array.
String[] name1 = {"Palak", "Viresh", "Yash", "Aavruti"};
String[] name2 = {"Deavina","Palak","Viresh", "Nikhil"};
output : [Palak, Viresh, Yash, Aavruti,Deavina,Nikhil]
*/
import java.util.ArrayList;
import java.util.Arrays;
public class GetUniqueValue {
// First option
void retrieveUniqueNameByMethod1(ArrayList<String> nameList1,ArrayList<String> nameList2) {
nameList2.removeAll(nameList1);
nameList1.addAll(nameList2);
System.out.println("Unique List of names is :"+nameList1);
}
// Second option
void retrieveUniqueNameByMethod2(ArrayList<String> nameList1,ArrayList<String> nameList2) {
for (int index = 0; index < nameList2.size(); index++) {
if (!nameList1.contains(nameList2.get(index))) {
nameList1.add(nameList2.get(index));
}
}
System.out.println("Unique List of names is: "+nameList1);
}
public static void main(String[] args) {
String[] name1 = { "Palak", "Viresh", "Yash", "Aavruti" };
String[] name2 = { "Deavina", "Palak", "Viresh", "Nikhil" };
ArrayList<String> nameList1 = new ArrayList<String>(Arrays.asList(name1));
ArrayList<String> nameList2 = new ArrayList<String>(Arrays.asList(name2));
System.out.println("Input List1 : " + nameList1);
System.out.println("Input List2 : " + nameList2);
GetUniqueValue uniqueValue = new GetUniqueValue();
uniqueValue.retrieveUniqueNameByMethod1(nameList1, nameList2);
uniqueValue.retrieveUniqueNameByMethod2(nameList1, nameList2);
}
}
| [
"[email protected]"
] | |
0b7bf5810e0ef6bb8e6ccf718bd28b23f53ec874 | d8c5d5675a323b7532bd11b98546eef4fd076029 | /app/src/main/java/com/example/todolist/data/TaskDbHelper.java | ffc18e7616594dcd994af8a5fb9c945bfe461105 | [] | no_license | kebie98/ToDoList | 79051d7d6e58af106860c9ca409880f44caec720 | 48d8053267e1d9f4ec24ce992ff0f1ab7f38237d | refs/heads/master | 2023-04-01T03:44:42.016626 | 2021-04-06T21:53:51 | 2021-04-06T21:53:51 | 354,427,503 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,304 | java | package com.example.todolist.data;
import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import com.example.todolist.data.TaskContract.TaskEntry;
public class TaskDbHelper extends SQLiteOpenHelper {
//The name of the database
private static final String DATABASE_NAME = "tasksDb.db ";
//If you change the database schema you must increment the database version
private static final int VERSION = 1;
TaskDbHelper(Context context) {
super(context, DATABASE_NAME, null, VERSION);
}
//Called when the tasks database is created for the first time.
@Override
public void onCreate(SQLiteDatabase db) {
final String CREATE_TABLE = "CREATE TABLE " + TaskEntry.TABLE_NAME + " (" +
TaskEntry._ID + "INTEGER PRIMARY KEY, " + TaskEntry.COLUMN_DESCRIPTION +
" TEXT NOT NULL, " + TaskEntry.COLUMN_PRIORITY + " INTEGER NOT NULL);";
db.execSQL(CREATE_TABLE);
}
//This method discards the old table of data and calls onCreate to recreate a new one.
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
db.execSQL("DROP TABLE IF EXISTS " + TaskEntry.TABLE_NAME);
onCreate(db);
}
}
| [
"[email protected]"
] | |
5a52300238628915181bbec14d496790787a3725 | f3035291d1bcb099501da0e0974929f7c3d5ecbb | /src/main/java/com/chipmunk/dao/UserDao.java | fa3490995b11cac7ef1c13053dcff4424cb59c79 | [] | no_license | mengyonglong/chipmunk | 11b8fe313237e808a07a4e6d8807d1164df4ef9f | 77e223b6e28c357d4c2391f71cf59f7140655bb0 | refs/heads/master | 2023-01-23T15:36:21.074434 | 2020-11-14T02:46:40 | 2020-11-14T02:46:40 | 312,722,694 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 223 | java | package com.chipmunk.dao;
import com.chipmunk.model.User;
public interface UserDao {
//登录
public int userRegister(User user);
//注册
public User userLogin(String user_name, String user_password);
}
| [
"[email protected]"
] | |
b09c3c3281f3b7274db5a840ad24617e2c516bba | f696c50d279279106ad570550294171e747c8984 | /src/Interface/ObjectSelectorPanel.java | 90eb38d94e088ec3a935905a11923ec498053526 | [] | no_license | EeroLempio/SoftwareRenderer | 50fa17fc3339380daeaf3b4dc016e3df6ed83cf9 | f00364e9be43165b981ebc5acd4360b77aaeeea2 | refs/heads/master | 2021-04-30T12:34:12.642116 | 2018-02-12T17:26:40 | 2018-02-12T17:26:40 | 121,277,843 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 8,535 | java | package Interface;
import RenderingEngine.Constructs.BaseObject;
import RenderingEngine.Constructs.EngineObject;
import java.util.ArrayList;
import java.util.List;
import javax.swing.event.TreeSelectionEvent;
import javax.swing.event.TreeSelectionListener;
import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.tree.DefaultTreeModel;
import javax.swing.tree.TreePath;
import javax.swing.tree.TreeSelectionModel;
/**
* ObjectSelectorPanel is a panel for selecting BaseObjects
*
* @author Eero Lempiö [email protected]
*/
public class ObjectSelectorPanel extends javax.swing.JPanel implements ObjectSelectorInterface{
private RendererModel m_model;
private TreeSelectionListener m_selectionListener;
private DefaultMutableTreeNode m_lastNode;
private List<DefaultMutableTreeNode> m_nodes;
private DefaultTreeModel m_sceneModel;
private DefaultMutableTreeNode m_sceneNode;
private DefaultMutableTreeNode m_lightsNode;
private DefaultMutableTreeNode m_objectsNode;
/**
* Creates new form ObjectSelectorPanel
*/
public ObjectSelectorPanel() {
initComponents();
initTable();
}
/**
* Sets the RendererModel of this ObjectSelectorPanel to RendererModel rendererModel
*/
@Override
public void setModel(RendererModel rendererModel) {
m_model = rendererModel;
}
/**
* Sets the displayed active object of this ObjectSelectorPanel to BaseObject baseObject
*/
@Override
public void setActiveObject(BaseObject baseObject) {
jTree1.removeTreeSelectionListener(m_selectionListener);
if(baseObject != null){
DefaultMutableTreeNode activeNode = null;
for(DefaultMutableTreeNode node : m_nodes)
if(node.getUserObject().equals(baseObject)){
activeNode = node;
break;
}
if(activeNode != null)
jTree1.setSelectionPath(new TreePath(m_sceneModel.getPathToRoot(activeNode)));
else{
activeNode = new DefaultMutableTreeNode(baseObject);
if(baseObject instanceof EngineObject){
m_objectsNode.add(activeNode);
m_sceneModel.reload(m_objectsNode);
}
else{
m_lightsNode.add(activeNode);
m_sceneModel.reload(m_lightsNode);
}
m_nodes.add(activeNode);
}
}
else
jTree1.clearSelection();
jTree1.addTreeSelectionListener(m_selectionListener);
}
/**
* Resets this ObjectSelectorPanels displayed itmes to none
*/
@Override
public void reset() {
m_lightsNode.removeAllChildren();
m_sceneModel.reload(m_lightsNode);
m_objectsNode.removeAllChildren();
m_sceneModel.reload(m_objectsNode);
m_nodes = new ArrayList<>();
}
/**
* Removes BaseObject baseObject from diplay
*/
@Override
public void removeObject(BaseObject baseObject) {
jTree1.removeTreeSelectionListener(m_selectionListener);
if(baseObject != null){
jTree1.clearSelection();
DefaultMutableTreeNode activeNode = null;
for(DefaultMutableTreeNode node : m_nodes)
if(node.getUserObject().equals(baseObject)){
activeNode = node;
m_nodes.remove(node);
break;
}
if(activeNode != null)
if(baseObject instanceof EngineObject){
m_objectsNode.remove(activeNode);
m_sceneModel.reload(m_objectsNode);
}
else{
m_lightsNode.remove(activeNode);
m_sceneModel.reload(m_lightsNode);
}
}
jTree1.addTreeSelectionListener(m_selectionListener);
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
SceneObjects = new javax.swing.JLabel();
jPanel1 = new javax.swing.JPanel();
jScrollPane1 = new javax.swing.JScrollPane();
jTree1 = new javax.swing.JTree();
setBackground(new java.awt.Color(114, 114, 114));
setBorder(javax.swing.BorderFactory.createEtchedBorder());
setPreferredSize(new java.awt.Dimension(224, 293));
SceneObjects.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
SceneObjects.setText("Scene Objects");
jPanel1.setBackground(new java.awt.Color(114, 114, 114));
jPanel1.setBorder(javax.swing.BorderFactory.createEtchedBorder());
jTree1.setBackground(new java.awt.Color(114, 114, 114));
javax.swing.tree.DefaultMutableTreeNode treeNode1 = new javax.swing.tree.DefaultMutableTreeNode("root");
jTree1.setModel(new javax.swing.tree.DefaultTreeModel(treeNode1));
jScrollPane1.setViewportView(jTree1);
javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
jPanel1.setLayout(jPanel1Layout);
jPanel1Layout.setHorizontalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jScrollPane1)
);
jPanel1Layout.setVerticalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jScrollPane1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 268, Short.MAX_VALUE)
);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
this.setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addComponent(SceneObjects, javax.swing.GroupLayout.DEFAULT_SIZE, 200, Short.MAX_VALUE)
.addContainerGap())
.addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(SceneObjects)
.addGap(0, 0, 0)
.addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
}// </editor-fold>//GEN-END:initComponents
private void initTable() {
DefaultMutableTreeNode m_sceneNode = new DefaultMutableTreeNode("Scene");
m_lightsNode = new DefaultMutableTreeNode("Lights");
m_sceneNode.add(m_lightsNode);
m_objectsNode = new DefaultMutableTreeNode("Objects");
m_sceneNode.add(m_objectsNode);
m_sceneModel = new DefaultTreeModel(m_sceneNode);
jTree1.setModel(m_sceneModel);
jTree1.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
jTree1.setExpandsSelectedPaths(true);
jTree1.setScrollsOnExpand(true);
m_selectionListener = new TreeSelectionListener(){
@Override
public void valueChanged(TreeSelectionEvent e) {
DefaultMutableTreeNode node = (DefaultMutableTreeNode)jTree1.getLastSelectedPathComponent();
if(m_model != null){
if(node != null && !node.equals(m_sceneNode) && !node.equals(m_lightsNode) && !node.equals(m_objectsNode))
m_model.setactiveObject((BaseObject)node.getUserObject());
else
m_model.setactiveObject(null);
}
}
};
jTree1.addTreeSelectionListener(m_selectionListener);
}
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JLabel SceneObjects;
private javax.swing.JPanel jPanel1;
private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JTree jTree1;
// End of variables declaration//GEN-END:variables
}
| [
"[email protected]"
] | |
b245deac9593f8daa4fa4ad6d53432c6459cdb26 | d6dac5683c12b7abebcdd7938658b71858008bbe | /src/main/java/com/bw/git2/Test2.java | 4af58083bec8ed8d04a8772182489635ac0c2079 | [] | no_license | mener0188/git2 | 1fdf9e0ac985df1cd477983b1992d5cede0899a5 | c26f70d50173ccaecb88ef9d0a1194023c991790 | refs/heads/master | 2020-11-26T21:11:31.783616 | 2020-08-27T01:05:00 | 2020-08-27T01:05:00 | 229,206,095 | 2 | 0 | null | null | null | null | UTF-8 | Java | false | false | 159 | java | package com.bw.git2;
public class Test2 {
public static void main(String[] args) {
//test
System.out.println("---------------------git2");
}
}
| [
"[email protected]"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.