有没有办法知道所选项目的类型?我想根据项目类型(如J2SE项目)执行一些特定操作.
以下是我发现的唯一方法:
public final class MyAction extends CookieAction {
@Override
public boolean isEnabled() {
if(this.getActivatedNodes() == null || this.getActivatedNodes().length != 1) {
return false;
}
Lookup lookup = this.getActivatedNodes()[0].getLookup();
// gets the selected project
Project currentProject = lookup.lookup(Project.class);
// checks if the selected project is a J2SE Project or a Maven Project
if(currentProject != null && (currentProject.getClass().getSimpleName().equals("J2SEProject")
|| currentProject.getClass().getSimpleName().equals("NbMavenProjectImpl"))) {
return true;
}
return false;
}}
Run Code Online (Sandbox Code Playgroud) 我正试图制作动画,UITextField但我被一个恼人而奇怪的问题所困扰.我的动画有以下顺序:

在第一种状态下,应用程序具有UITextField相机UIButton和取消UIButton后未显示的相机按钮,因为它已被定位在应用程序的限制范围之外.实际上我的应用程序有320的宽度和取消按钮来源是(350,7)

在第二状态中,当用户触摸时UITextField,相机按钮alpha通道被设置为0并且取消按钮的原点被设置为(247,7).

用户触摸键盘的返回按钮或取消按钮后,最终状态与第一状态相同.
在处理期间,UITextField宽度和x轴上的取消按钮原点是动画的.
我的代码是:
- (void)textFieldDidBeginEditing:(UITextField *)textField
{
barcodeSearchButton.userInteractionEnabled = NO;
cancelButton.userInteractionEnabled = NO;
CGFloat cancelButtonXOffset = CGRectGetMaxX(barcodeSearchButton.frame) - cancelButton.frame.size.width;
CGFloat searchFieldWidth = searchField.frame.size.width - cancelButton.frame.size.width + barcodeSearchButton.frame.size.width;
[UIView animateWithDuration:0.3
animations:^{
searchField.frame = CGRectMake(searchField.frame.origin.x, searchField.frame.origin.y, searchFieldWidth, searchField.frame.size.height);
cancelButton.alpha = 1.0;
cancelButton.frame = CGRectMake(cancelButtonXOffset, cancelButton.frame.origin.y, cancelButton.frame.size.width,cancelButton.frame.size.height);
barcodeSearchButton.alpha = 0.0;
}
completion:^(BOOL finished) {
barcodeSearchButton.userInteractionEnabled = NO;
cancelButton.userInteractionEnabled = YES;
}];
}
- (void)textFieldDidEndEditing:(UITextField *)textField
{
barcodeSearchButton.userInteractionEnabled = NO;
cancelButton.userInteractionEnabled …Run Code Online (Sandbox Code Playgroud)