Search in sources :

Example 96 with StructuredSelection

use of org.eclipse.jface.viewers.StructuredSelection in project translationstudio8 by heartsome.

the class GotoResourceAction method run.

/**
	 * Collect all resources in the workbench open a dialog asking the user to
	 * select a resource and change the selection in the navigator.
	 */
public void run() {
    GotoResourceDialog dialog = new GotoResourceDialog(shell, ResourcesPlugin.getWorkspace().getRoot(), IResource.FILE | IResource.FOLDER | IResource.PROJECT);
    dialog.open();
    Object[] result = dialog.getResult();
    if (result == null || result.length == 0 || result[0] instanceof IResource == false) {
        return;
    }
    IResource selection = (IResource) result[0];
    viewer.setSelection(new StructuredSelection(selection), true);
}
Also used : StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) IResource(org.eclipse.core.resources.IResource)

Example 97 with StructuredSelection

use of org.eclipse.jface.viewers.StructuredSelection in project translationstudio8 by heartsome.

the class NewTermDbBaseInfoPage method createControl.

/**
	 * Create contents of the wizard.
	 * @param parent
	 */
public void createControl(Composite parent) {
    Composite container = new Composite(parent, SWT.NULL);
    container.setLayout(new GridLayout(1, false));
    setControl(container);
    int labelWidth = 100;
    GridData gdLabel = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1);
    gdLabel.widthHint = labelWidth;
    Group dbGroup1 = new Group(container, SWT.NONE);
    dbGroup1.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
    dbGroup1.setLayout(new GridLayout(2, false));
    dbGroup1.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 4, 1));
    dbGroup1.setText(Messages.getString("wizard.NewTermDbBaseInfoPage.dbGroup1"));
    Label label = new Label(dbGroup1, SWT.RIGHT);
    label.setLayoutData(gdLabel);
    label.setText(Messages.getString("wizard.NewTermDbBaseInfoPage.lblType"));
    dbTypeComboViewer = new ComboViewer(dbGroup1, SWT.READ_ONLY);
    Combo combo = dbTypeComboViewer.getCombo();
    combo.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    // //
    label = new Label(dbGroup1, SWT.RIGHT);
    label.setLayoutData(gdLabel);
    label.setText(Messages.getString("wizard.NewTermDbBaseInfoPage.dbNameText"));
    dbNameText = new Text(dbGroup1, SWT.BORDER);
    dbNameText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    label = new Label(dbGroup1, SWT.RIGHT);
    label.setLayoutData(gdLabel);
    label.setText(Messages.getString("wizard.NewTermDbBaseInfoPage.instanceText"));
    instanceText = new Text(dbGroup1, SWT.BORDER);
    instanceText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    dbTypeComboViewer.setContentProvider(new ArrayContentProvider());
    dbTypeComboViewer.setInput(dbTypeList);
    dbTypeComboViewer.setLabelProvider(new LabelProvider() {

        public String getText(Object element) {
            SystemDBOperator dbOp = (SystemDBOperator) element;
            String dbType = dbOp.getDBConfig().getDefaultType();
            if (dbType.equals(Constants.DBTYPE_MYSQL)) {
                dbType = Constants.DBTYPE_MYSQL_FOR_UI;
            } else if (dbType.equals(Constants.DBTYPE_MSSQL2005)) {
                dbType = Constants.DBTYPE_MSSQL2005_FOR_UI;
            } else if (dbType.equals(Constants.DBTYPE_SQLITE)) {
                dbType = Messages.getString("tb.dbtype.sqlite");
            }
            return dbType;
        }
    });
    dbTypeComboViewer.addSelectionChangedListener(new ISelectionChangedListener() {

        public void selectionChanged(SelectionChangedEvent event) {
            ISelection selection = event.getSelection();
            if (selection != null && selection instanceof IStructuredSelection) {
                IStructuredSelection sel = (IStructuredSelection) selection;
                Object selObj = sel.getFirstElement();
                if (selObj != null && selObj instanceof SystemDBOperator) {
                    SystemDBOperator selDbOp = (SystemDBOperator) selObj;
                    dbTypeChangeEvent(selDbOp);
                }
            }
        }
    });
    Group dbGroup = new Group(container, SWT.NONE);
    dbGroup.setLayout(new GridLayout(5, false));
    dbGroup.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 4, 1));
    dbGroup.setText(Messages.getString("wizard.NewTermDbBaseInfoPage.dbGroup"));
    label = new Label(dbGroup, SWT.RIGHT);
    label.setLayoutData(gdLabel);
    label.setText(Messages.getString("wizard.NewTermDbBaseInfoPage.hostText"));
    hostText = new Text(dbGroup, SWT.BORDER);
    hostText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    label = new Label(dbGroup, SWT.RIGHT);
    label.setLayoutData(gdLabel);
    label.setText(Messages.getString("wizard.NewTermDbBaseInfoPage.portText"));
    portText = new Text(dbGroup, SWT.BORDER);
    new Label(dbGroup, SWT.NONE);
    label = new Label(dbGroup, SWT.RIGHT);
    label.setLayoutData(gdLabel);
    label.setText(Messages.getString("wizard.NewTermDbBaseInfoPage.locationText"));
    locationText = new Text(dbGroup, SWT.BORDER);
    locationText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 3, 1));
    locationText.setEnabled(false);
    borwserBtn = new Button(dbGroup, SWT.NONE);
    borwserBtn.setText(Messages.getString("wizard.NewTermDbBaseInfoPage.borwserBtn"));
    borwserBtn.setEnabled(false);
    borwserBtn.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            DirectoryDialog dlg = new DirectoryDialog(getShell());
            String path = dlg.open();
            if (path != null) {
                locationText.setText(path);
            }
        }
    });
    Group authorityGroup = new Group(container, SWT.NONE);
    authorityGroup.setLayout(new GridLayout(2, false));
    authorityGroup.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 4, 1));
    authorityGroup.setText(Messages.getString("wizard.NewTermDbBaseInfoPage.authorityGroup"));
    label = new Label(authorityGroup, SWT.RIGHT);
    label.setLayoutData(gdLabel);
    label.setText(Messages.getString("wizard.NewTermDbBaseInfoPage.usernameText"));
    usernameText = new Text(authorityGroup, SWT.BORDER);
    usernameText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    label = new Label(authorityGroup, SWT.RIGHT);
    label.setLayoutData(gdLabel);
    label.setText(Messages.getString("wizard.NewTermDbBaseInfoPage.passwordText"));
    passwordText = new Text(authorityGroup, SWT.BORDER | SWT.PASSWORD);
    passwordText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    initDataBindings();
    if (this.dbOp != null) {
        dbTypeComboViewer.setSelection(new StructuredSelection(this.dbOp));
    } else {
        dbTypeComboViewer.setSelection(new StructuredSelection(dbTypeList.get(0)));
    }
    IStatus state = validator();
    if (!state.isOK()) {
        setErrorMessage(state.getMessage());
        setPageComplete(false);
    }
}
Also used : Group(org.eclipse.swt.widgets.Group) IStatus(org.eclipse.core.runtime.IStatus) Composite(org.eclipse.swt.widgets.Composite) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Label(org.eclipse.swt.widgets.Label) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) Combo(org.eclipse.swt.widgets.Combo) Text(org.eclipse.swt.widgets.Text) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) GridLayout(org.eclipse.swt.layout.GridLayout) SystemDBOperator(net.heartsome.cat.database.SystemDBOperator) ComboViewer(org.eclipse.jface.viewers.ComboViewer) Button(org.eclipse.swt.widgets.Button) GridData(org.eclipse.swt.layout.GridData) ArrayContentProvider(org.eclipse.jface.viewers.ArrayContentProvider) ISelection(org.eclipse.jface.viewers.ISelection) SelectionEvent(org.eclipse.swt.events.SelectionEvent) LabelProvider(org.eclipse.jface.viewers.LabelProvider) DirectoryDialog(org.eclipse.swt.widgets.DirectoryDialog)

Example 98 with StructuredSelection

use of org.eclipse.jface.viewers.StructuredSelection in project translationstudio8 by heartsome.

the class TermDbManagerDialog method selectSaveItem.

/**
	 * 选择当前选中的内容 ;
	 */
private void selectSaveItem() {
    if (getCurrDbType() != null) {
        boolean expanded = getTreeViewer().getExpandedState(getCurrDbType());
        if (!expanded) {
            getTreeViewer().setExpandedState(getCurrDbType(), !expanded);
        }
        DatabaseModelBean lastSelectItem = findServerBean(getCurrDbType(), getLastSelectedServer());
        if (lastSelectItem != null) {
            getTreeViewer().setSelection(new StructuredSelection(lastSelectItem), true);
            getTreeViewer().getControl().setFocus();
        } else {
            getTreeViewer().setSelection(new StructuredSelection(getCurrDbType()), true);
            getTreeViewer().getControl().setFocus();
        }
    }
}
Also used : DatabaseModelBean(net.heartsome.cat.common.bean.DatabaseModelBean) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection)

Example 99 with StructuredSelection

use of org.eclipse.jface.viewers.StructuredSelection in project translationstudio8 by heartsome.

the class ExportTmxDialog method loadData.

/**
	 * 加载语言数据 ;
	 */
private void loadData() {
    if (currentDatabase == null) {
        // 清理数据
        hasSelLangListViewer.getList().removeAll();
        srcLangcomboViewer.getCombo().removeAll();
        encodingComboViewer.getCombo().setText("");
        return;
    }
    // 加载所有语言
    hasSelLangListViewer.setInput(currentDatabase.getExistLangs().split(","));
    hasSelLangListViewer.setSelection(new StructuredSelection(currentDatabase.getHasSelectedLangs()));
    // 加载源语言;
    srcLangcomboViewer.setInput(currentDatabase.getCanSelSrcLangs());
    srcLangcomboViewer.setSelection(new StructuredSelection(currentDatabase.getSrcLang()));
    // 加载编码列表,默认为UTF-8
    encodingComboViewer.setSelection(new StructuredSelection("UTF-8"));
}
Also used : IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection)

Example 100 with StructuredSelection

use of org.eclipse.jface.viewers.StructuredSelection in project translationstudio8 by heartsome.

the class RowSelectionPreserver method handleLayerEvent.

/**
	 * On a change in the underlying data:
	 * <ol>
	 * <li>Clears the selection
	 * <li>Re-select the row objects selected earlier.
	 * </ol>
	 */
public void handleLayerEvent(IVisualChangeEvent event) {
    if (ObjectUtils.isEmpty(selectedRowObjects)) {
        return;
    }
    if (event instanceof RowStructuralRefreshEvent || event instanceof RowStructuralChangeEvent || event instanceof SortColumnEvent) {
        selectionLayer.clear();
        selectionProvider.setSelection(new StructuredSelection(getValidSelections()));
    }
}
Also used : SortColumnEvent(net.sourceforge.nattable.sort.event.SortColumnEvent) RowStructuralRefreshEvent(net.sourceforge.nattable.layer.event.RowStructuralRefreshEvent) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) RowStructuralChangeEvent(net.sourceforge.nattable.layer.event.RowStructuralChangeEvent)

Aggregations

StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)181 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)90 ArrayList (java.util.ArrayList)48 ISelection (org.eclipse.jface.viewers.ISelection)37 List (java.util.List)35 TreeViewer (org.eclipse.jface.viewers.TreeViewer)22 IFile (org.eclipse.core.resources.IFile)19 GridData (org.eclipse.swt.layout.GridData)19 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)18 SelectionEvent (org.eclipse.swt.events.SelectionEvent)18 ISelectionChangedListener (org.eclipse.jface.viewers.ISelectionChangedListener)16 Composite (org.eclipse.swt.widgets.Composite)16 SelectionChangedEvent (org.eclipse.jface.viewers.SelectionChangedEvent)15 Label (org.eclipse.swt.widgets.Label)14 Shell (org.eclipse.swt.widgets.Shell)14 IViewPart (org.eclipse.ui.IViewPart)14 IWorkbenchPage (org.eclipse.ui.IWorkbenchPage)14 IWorkbenchWindow (org.eclipse.ui.IWorkbenchWindow)14 IEditorPart (org.eclipse.ui.IEditorPart)13 GridLayout (org.eclipse.swt.layout.GridLayout)12