📄 mqueryeditwindow.java
字号:
package net.jumperz.app.MDoorman.windows;
import org.eclipse.swt.graphics.*;
import org.eclipse.swt.widgets.*;
import org.eclipse.swt.*;
import org.eclipse.swt.layout.*;
import org.eclipse.swt.custom.*;
import java.io.*;
import java.util.*;
import net.jumperz.app.MDoorman.*;
import net.jumperz.util.*;
public class MQueryEditWindow
extends MWindow
{
private static final String WINDOW_NAME = "Editing Query";
public static final int WINDOW_STYLE = SWT.CLOSE | SWT.RESIZE | SWT.APPLICATION_MODAL;
private Button okButton, cancelButton;
private StyledText nameText, valueText;
private int action;
private MAbstractQueryWindow queryWindow;
private String name, value;
// --------------------------------------------------------------------------------
public MQueryEditWindow( MAbstractQueryWindow window, String n, String v )
{
super( WINDOW_NAME, new Shell( MDoorman.getInstance().mainShell, WINDOW_STYLE ) );
queryWindow = window;
name = n;
value = v;
nameText.setText( name );
nameText.setFont( doorman.getFont() );
valueText.setText( value );
valueText.setFont( doorman.getFont() );
}
// --------------------------------------------------------------------------------
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, 9 );
d1.top = new FormAttachment( 0, 5 );
Label label1 = new Label( shell, SWT.NONE );
label1.setText( "Name :" );
label1.pack();
label1.setLayoutData( d1 );
FormData d4 = new FormData();
d4.left = new FormAttachment( 0, 9 );
d4.top = new FormAttachment( 40, 8 );
Label label2 = new Label( shell, SWT.NONE );
label2.setText( "Value :" );
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 StyledText( shell, SWT.BORDER | SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL );
FormData d2 = new FormData();
d2.left = new FormAttachment( 0, 55 );
d2.right = new FormAttachment( 100, -5 );
d2.top = new FormAttachment( 0, 5 );
d2.bottom = new FormAttachment( 40, 0 );
nameText.setLayoutData( d2 );
nameText.addListener( SWT.Modify, this );
valueText = new StyledText( shell, SWT.BORDER | SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL );
FormData d3 = new FormData();
d3.left = new FormAttachment( 0, 55 );
d3.right = new FormAttachment( 100, -5 );
d3.top = new FormAttachment( 40, 8 );
d3.bottom = new FormAttachment( 100, -44 );
valueText.setLayoutData( d3 );
valueText.addListener( SWT.Modify, this );
shell.setDefaultButton( okButton );
}
// --------------------------------------------------------------------------------
protected void handleEvent2( Event event )
{
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()
{
valueText.setFocus();
valueText.selectAll();
}
// --------------------------------------------------------------------------------
private void onCancelButtonClick()
{
close();
}
// --------------------------------------------------------------------------------
private void onOkButtonClick()
{
queryWindow.updateQuery( nameText.getText(), valueText.getText() );
close();
}
// --------------------------------------------------------------------------------
protected void onClose2()
{
doorman.optionWindow.updateFilterTable();
doorman.optionWindow.updateGui();
}
// --------------------------------------------------------------------------------
private void onChange()
{
if( nameText.getText().length() > 0 )
{
okButton.setEnabled( true );
}
else
{
okButton.setEnabled( false );
}
}
// --------------------------------------------------------------------------------
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -