我可以使eclipse SWT UI看起来像Eclipse插件UI吗?

时间:2016-06-27 19:18:21

标签: java eclipse eclipse-plugin swt

我在eclipse中添加了一些功能,就像Eclipse插件

一样

我有一个项目是复选框选择(见图)

    final ListSelectionDialog dialog = new ListSelectionDialog(window.getShell(), list,
            ArrayContentProvider.getInstance(), new LabelProvider(), "");
    dialog.setTitle("Create Events");
    dialog.setHelpAvailable(false);
    dialog.setMessage("Potential events in code:");
    dialog.create();
    dialog.getOkButton().setText("Create");
    dialog.open();

和另一个带有单选按钮的项目(我找不到像ListSelectionDialog这样的单选按钮

public void display(List<String> list){
    Display.getDefault().asyncExec(new Runnable(){
        public void run() {
            Display display = Display.getDefault();
            Shell shell = new Shell(display);
            shell.setLayout(new GridLayout());
            shell.setText("Create Object");
            Label label = new Label(shell, SWT.NULL);
            label.setText("Entry point: ");
            for (String item: list){
                Button btn  = new Button(shell, SWT.RADIO);
                btn.setText(item);                    
            }
            Composite composite = new Composite(shell, SWT.NULL);
            composite.setLayout(new RowLayout());

            Button createButton = new Button(composite, SWT.PUSH);
            createButton.setText("Create");
            Button cancelButton = new Button(composite, SWT.PUSH);
            cancelButton.setText("Cancel");
            shell.setSize(400, 200);
            shell.open ();
            while (!shell.isDisposed ()) {
                if (!display.readAndDispatch ()) display.sleep ();
            }
            shell.dispose ();
                }
        });
}

正如您可以看到基于SWT的项目,看起来不合适并且与Eclipse的UI不一致。 有可能让它看起来像另一个吗?enter image description here

1 个答案:

答案 0 :(得分:1)

使用提供标准外观的JFace // Error: 1062 SQLSTATE: 23000 (ER_DUP_ENTRY) Message: Duplicate entry '%s' for key %d // Error: 1586 SQLSTATE: 23000 (ER_DUP_ENTRY_WITH_KEY_NAME) Message: Duplicate entry '%s' for key '%s' if($mysqli->errno === 1062 || $mysqli->errno === 1586) { if(preg_match("/Duplicate entry '(.*)' for key '(.*)'/", $mysqli->error, $matchArray) === 1) { $duplicatedValue = $matchArray[1]; $uniqueKeyName = $matchArray[2]; if(!($stmt = $mysqli->prepare('SELECT COLUMN_NAME' . ' FROM INFORMATION_SCHEMA.KEY_COLUMN_USAGE' . ' WHERE CONSTRAINT_SCHEMA = ?' . ' AND CONSTRAINT_NAME = ?'))) { die; // Error? Check $mysqli->errno and $mysqli->error; } $schemaName = // Name of the schema (string). if(!$stmt->bind_param('ss', $schemaName, $uniqueKeyName)) { die; // Error? Check $mysqli->errno and $mysqli->error; } if(!$stmt->execute()) { die; // Error? Check $mysqli->errno and $mysqli->error; } $res = $stmt->get_result(); if(!$res) { die; // Error? Check $mysqli->errno and $mysqli->error; } $row = $res->fetch_assoc(); if($row === null) { die; // No results? } $columnName = $row['COLUMN_NAME']; } } 。类似的东西:

Public Sub CommandButton1_Click()
    'DECLARE AND SET VARIABLES
    Dim wbk As Workbook
    Dim Filename As String
    Dim Path As String
    Dim mainwb As Workbook
    Dim ws As Worksheet
     Dim search_result As Range   'range search result
        Dim blank_cell As Long
    Dim wb As Workbook
    Dim rowCount As Long
     Dim add As Range
     Workbooks("abc.xlsm").Activate
       Set wb = ActiveWorkbook
        wb.Sheets("Sheet 1").Activate
        LastRow = ActiveSheet.Range("A" & Rows.Count).End(xlUp).Row
        LastColumn = ActiveSheet.Range("A" & Columns.Count).End(xlUp).Column
    For i = 2 To LastRow
        ActiveSheet.Cells(i, 1).Select
        Filename1 = Selection.Value
        Sheetname1 = ActiveCell.Offset(0, 1).Value
           Workbooks("abc.xlsm").Activate
        input_directory = Sheets("SystemConfiguration").Range("B2").Value & "\"
         Filename = Dir(input_directory & "*.xls")
        Workbooks("abc.xlsm").Activate
        'Do While Len(Filename) > 0  'IF NEXT FILE EXISTS THEN
        Set wbk = Workbooks.Open(input_directory & Filename)
         Set wbk = ActiveWorkbook
         variable = ActiveSheet.Name
         If variable = Sheetname1 & Filename = Filename1 Then
           GoTo PROC
       End If
         ActiveSheet.UsedRange.Rows(1).Copy
         Workbooks("abc.xlsm").Activate
        'ActiveWorkbook.ActiveSheet
         Set wb = ActiveWorkbook
          Set ws = wb.Sheets("Sheet2")
        For Each cell In ws.Columns(3).Cells
            If IsEmpty(cell) = True Then cell.Select: Exit For
        Next cell
     Set add = Selection
     Selection.Offset(0, 2).PasteSpecial Paste:=xlPasteValues, Transpose:=True
     rowCount = Selection.Rows.Count
     Range(add, add.Offset(rowCount - 1, 0)).Value = Filename
     Range(add.Offset(0, 1), add.Offset(rowCount - 1, 1)).Value = variable
         wbk.Close savechanges:=False
         Filename = Dir
    'Loop
    PROC:
     Next i
    End Sub