⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mfilterwindow.java

📁 httptunnel.jar httptunnel java 源码
💻 JAVA
字号:
package net.jumperz.app.MDoorman.windows;

import org.eclipse.swt.widgets.*;
import org.eclipse.swt.*;
import org.eclipse.swt.layout.*;

import java.io.*;
import java.util.regex.*;
import java.util.*;

import net.jumperz.app.MDoorman.*;
import net.jumperz.util.*;

public class MFilterWindow
extends MWindow
{
private static final String WINDOW_NAME = "Filter";
public static final int WINDOW_STYLE = SWT.CLOSE | SWT.RESIZE | SWT.APPLICATION_MODAL;

private Button okButton, cancelButton, caseButton;
private Text nameText, patternText;
private Label caseLabel;
private int action;
private MFilter filter;
// --------------------------------------------------------------------------------
public MFilterWindow()
{
super( WINDOW_NAME, new Shell( MDoorman.getInstance().mainShell, WINDOW_STYLE ) );
action = ACTION_ADD;
}
// --------------------------------------------------------------------------------
public MFilterWindow( MFilter filter )
{
super( WINDOW_NAME, new Shell( MDoorman.getInstance().mainShell, WINDOW_STYLE ) );
this.filter = filter;
action = ACTION_EDIT;
nameText.setText( filter.getName() );
patternText.setText( filter.getPattern() );
caseButton.setSelection( filter.isIgnoreCase() );
}
// --------------------------------------------------------------------------------
public int getAction()
{
return action;
}
// --------------------------------------------------------------------------------
public void setAction( int i )
{
action = i;
}
// --------------------------------------------------------------------------------
protected void init2()
{
permanent = false;
windowValue = new int[]{ 200, 300, 100, 500 };
shell.addListener( SWT.Activate, this );

FormData d1 = new FormData();
d1.left = new FormAttachment( 0, LABEL1_LEFT );
d1.top = new FormAttachment( 0, LABEL1_TOP );
Label label1 = new Label( shell, SWT.NONE );
label1.setText( "Name :" );
label1.pack();
label1.setLayoutData( d1 );

FormData d4 = new FormData();
d4.left = new FormAttachment( 0, LABEL2_LEFT );
d4.top = new FormAttachment( 0, LABEL2_TOP );
Label label2 = new Label( shell, SWT.NONE );
label2.setText( "Pattern :" );
label2.pack();
label2.setLayoutData( d4 );

okButton = new Button( shell, SWT.PUSH );
okButton.setLayoutData( buttonFormData1 );
okButton.setText( "&OK" );
okButton.setEnabled( false );
okButton.addListener( SWT.Selection, this );

cancelButton = new Button( shell, SWT.PUSH );
cancelButton.setLayoutData( buttonFormData2 );
cancelButton.setText( "&Cancel" );
cancelButton.addListener( SWT.Selection, this );

nameText = new Text( shell, SWT.BORDER );
FormData d2 = new FormData();
d2.left = new FormAttachment( 0, 85 );
d2.right = new FormAttachment( 100, -50 );
d2.top = new FormAttachment( 0, 20 );
nameText.setLayoutData( d2 );
nameText.addListener( SWT.Modify, this );

patternText = new Text( shell, SWT.BORDER );
FormData d3 = new FormData();
d3.left = new FormAttachment( 0, 85 );
d3.right = new FormAttachment( 100, -30 );
d3.top = new FormAttachment( 0, 50 );
patternText.setLayoutData( d3 );
patternText.addListener( SWT.Modify, this );

caseButton = new Button( shell, SWT.CHECK );
FormData d5 = new FormData();
d5.left = new FormAttachment( 0, 90 );
d5.top = new FormAttachment( 0, 80 );
caseButton.setLayoutData( d5 );

caseLabel = new Label( shell, SWT.NONE );
caseLabel.setText( "Ignore case" );
FormData d6 = new FormData();
d6.left = new FormAttachment( 0, 110 );
d6.top = new FormAttachment( 0, 80 );
caseLabel.setLayoutData( d6 );
caseLabel.addListener( SWT.MouseDown, this );

shell.setDefaultButton( okButton );
}
// --------------------------------------------------------------------------------
protected void handleEvent2( Event event )
{
if( event.widget == caseLabel )
	{
	caseButton.setSelection( !caseButton.getSelection() );
	}
else if( event.type == SWT.Modify )
	{
	onChange();
	}
else if( event.widget == cancelButton )
	{
	onCancelButtonClick();
	}
else if( event.widget == okButton )
	{
	onOkButtonClick();
	}
else if( event.type == SWT.Activate )
	{
	onActivate();
	}
}
// --------------------------------------------------------------------------------
private void onActivate()
{
nameText.setFocus();
}
// --------------------------------------------------------------------------------
private void onCancelButtonClick()
{
close();
}
// --------------------------------------------------------------------------------
private void onOkButtonClick()
{
String pattern = patternText.getText();
try
	{
	Pattern.compile( pattern );
	}
catch( PatternSyntaxException e )
	{
	MDoorman.getInstance().notifyException( e );
	return;
	}

if( action == ACTION_ADD )
	{
	MFilter newFilter = new MFilter( true, nameText.getText(), pattern, caseButton.getSelection() );
	doorman.optionWindow.filterList.add( newFilter );
	}
else if( action == ACTION_EDIT )
	{
	filter.setName( nameText.getText() );
	filter.setPattern( pattern );
	filter.setIgnoreCase( caseButton.getSelection() );
	}
close();
}
// --------------------------------------------------------------------------------
protected void onClose2()
{
doorman.optionWindow.updateFilterTable();
doorman.optionWindow.updateGui();
}
// --------------------------------------------------------------------------------
private void onChange()
{
if( nameText.getText().length() > 0 
 && patternText.getText().length() > 0
  )
	{
	okButton.setEnabled( true );
	}
else
	{
	okButton.setEnabled( false );
	}
}
// --------------------------------------------------------------------------------
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -