Search in sources :

Example 61 with ISelection

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

the class SrxConfigurationDialog method initListener.

/**
	 * 给增删改三个按钮提示添加事件 ;
	 */
private void initListener() {
    addBtn.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            CreateOrUpdataSRXDialog createDialog = new CreateOrUpdataSRXDialog(getShell(), true);
            int createResult = createDialog.open();
            if (IDialogConstants.OK_ID == createResult) {
                String addedSrxName = createDialog.getCurSrxName();
                // 添加完成该文件后,解析该文件
                boolean openResult = openSrx(ADConstants.configLocation + ADConstants.AD_SRXConfigFolder + File.separator + addedSrxName);
                if (!openResult) {
                    return;
                }
                AddOrEditSrxConfigDialog addDialog = new AddOrEditSrxConfigDialog(getShell(), addedSrxName, handler);
                addDialog.open();
                refreshTable(addedSrxName);
            }
        }
    });
    editBtn.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            editSrx();
        }
    });
    deleteBtn.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            ISelection selection = tableViewer.getSelection();
            if (!selection.isEmpty() && selection != null && selection instanceof StructuredSelection) {
                boolean response = MessageDialog.openConfirm(getShell(), Messages.getString("srx.SrxConfigurationDialog.msgTitle1"), Messages.getString("srx.SrxConfigurationDialog.msg1"));
                if (!response) {
                    return;
                }
                StructuredSelection structSelection = (StructuredSelection) selection;
                @SuppressWarnings("unchecked") Iterator<String[]> it = structSelection.iterator();
                File deleteSrx;
                boolean isTiped = false;
                while (it.hasNext()) {
                    String srxName = it.next()[1];
                    if (isSystemSrx(srxName)) {
                        if (!isTiped) {
                            MessageDialog.openInformation(getShell(), Messages.getString("dialogs.CatalogManagerDialog.msgTitle2"), Messages.getString("srx.SrxConfigurationDialog.msg4"));
                            isTiped = true;
                        }
                        continue;
                    }
                    deleteSrx = new File(ADConstants.configLocation + ADConstants.AD_SRXConfigFolder + File.separator + srxName);
                    if (!deleteSrx.delete()) {
                        MessageDialog.openInformation(getShell(), Messages.getString("srx.SrxConfigurationDialog.msgTitle2"), MessageFormat.format(Messages.getString("srx.SrxConfigurationDialog.msg2"), srxName));
                    }
                }
                refreshTable(null);
            } else {
                MessageDialog.openInformation(getShell(), Messages.getString("srx.SrxConfigurationDialog.msgTitle2"), Messages.getString("srx.SrxConfigurationDialog.msg3"));
            }
        }
    });
}
Also used : SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) SelectionEvent(org.eclipse.swt.events.SelectionEvent) ISelection(org.eclipse.jface.viewers.ISelection) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) Iterator(java.util.Iterator) File(java.io.File)

Example 62 with ISelection

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

the class XmlConvertManagerDialog method initListener.

/**
	 * 给增删改三个按钮添加点击事件 ;
	 */
protected void initListener() {
    addBtn.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            AddOrEditElementOfXmlConvertDialog dialog = new AddOrEditElementOfXmlConvertDialog(getShell(), true, elementsList);
            int result = dialog.open();
            if (result == IDialogConstants.OK_ID) {
                refreshTable(dialog.getCurrentElement());
            }
        }
    });
    editBtn.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            editElement();
        }
    });
    deleteBtn.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            ISelection selection = tableViewer.getSelection();
            if (selection != null && !selection.isEmpty() && selection instanceof IStructuredSelection) {
                if (MessageDialog.openConfirm(getShell(), Messages.getString("dialogs.XmlConvertManagerDialog.msgTitle1"), Messages.getString("dialogs.XmlConvertManagerDialog.msg1"))) {
                    IStructuredSelection structuredSelection = (IStructuredSelection) selection;
                    @SuppressWarnings("unchecked") Iterator<ElementBean> iter = structuredSelection.iterator();
                    ElementBean bean = new ElementBean();
                    while (iter.hasNext()) {
                        bean = iter.next();
                        elementsList.remove(bean);
                    }
                    refreshTable(null);
                }
            } else {
                MessageDialog.openInformation(getShell(), Messages.getString("dialogs.XmlConvertManagerDialog.msgTitle2"), Messages.getString("dialogs.XmlConvertManagerDialog.msg2"));
            }
        }
    });
}
Also used : ElementBean(net.heartsome.cat.ts.ui.advanced.model.ElementBean) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) SelectionEvent(org.eclipse.swt.events.SelectionEvent) ISelection(org.eclipse.jface.viewers.ISelection) Iterator(java.util.Iterator) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection)

Example 63 with ISelection

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

the class XmlConverterConfigurationDialog method initListener.

public void initListener() {
    addBtn.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            AddOrEditXmlConvertConfigDialog dialog = new AddOrEditXmlConvertConfigDialog(getShell(), true);
            int result = dialog.open();
            if (result == IDialogConstants.OK_ID) {
                String curentConvertXMl = dialog.getCurentConverXML();
                refreshTable();
                setTableSelection(curentConvertXMl);
            }
        }
    });
    editBtn.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            editConfigXml();
        }
    });
    deleteBtn.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            ISelection selection = tableViewer.getSelection();
            if (!selection.isEmpty() && selection != null && selection instanceof IStructuredSelection) {
                IStructuredSelection structuredSelection = (IStructuredSelection) selection;
                @SuppressWarnings("unchecked") Iterator<String[]> iter = structuredSelection.iterator();
                while (iter.hasNext()) {
                    String convertXmlName = iter.next()[1];
                    String convertXmlLoaction = root.getLocation().append(ADConstants.AD_xmlConverterConfigFolder).append(convertXmlName).toOSString();
                    File convertXml = new File(convertXmlLoaction);
                    convertXml.delete();
                }
                refreshTable();
            } else {
                MessageDialog.openInformation(getShell(), Messages.getString("dialogs.XmlConverterConfigurationDialog.msgTitle"), Messages.getString("dialogs.XmlConverterConfigurationDialog.msg1"));
            }
        }
    });
    analysisBtn.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            AnalysisXmlConvertConfigDialg dialog = new AnalysisXmlConvertConfigDialg(getShell());
            int result = dialog.open();
            if (result == IDialogConstants.OK_ID) {
                String curentConvertXMl = dialog.getCurentConverXML();
                refreshTable();
                setTableSelection(curentConvertXMl);
            }
        }
    });
}
Also used : SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) SelectionEvent(org.eclipse.swt.events.SelectionEvent) ISelection(org.eclipse.jface.viewers.ISelection) Iterator(java.util.Iterator) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) File(java.io.File)

Example 64 with ISelection

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

the class XmlConverterConfigurationDialog method editConfigXml.

/**
	 * 编辑转换配置XML文件 ;
	 */
public void editConfigXml() {
    ISelection selection = tableViewer.getSelection();
    if (!selection.isEmpty() && selection != null && selection instanceof IStructuredSelection) {
        IStructuredSelection structuredSelection = (IStructuredSelection) selection;
        @SuppressWarnings("unchecked") Iterator<String[]> iter = structuredSelection.iterator();
        String convertXml = iter.next()[1];
        AddOrEditXmlConvertConfigDialog dialog = new AddOrEditXmlConvertConfigDialog(getShell(), false);
        dialog.create();
        String convertXmlLoaction = root.getLocation().append(ADConstants.AD_xmlConverterConfigFolder).append(convertXml).toOSString();
        if (dialog.setInitEditData(convertXmlLoaction)) {
            int result = dialog.open();
            // 如果点击的是确定按钮,那么更新列表
            if (result == IDialogConstants.OK_ID) {
                String curentConvertXMl = dialog.getCurentConverXML();
                refreshTable();
                setTableSelection(curentConvertXMl);
            }
        }
    } else {
        MessageDialog.openInformation(getShell(), Messages.getString("dialogs.XmlConverterConfigurationDialog.msgTitle"), Messages.getString("dialogs.XmlConverterConfigurationDialog.msg2"));
    }
}
Also used : ISelection(org.eclipse.jface.viewers.ISelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection)

Example 65 with ISelection

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

the class SrxMapRulesManageDialog method initListener.

public void initListener() {
    addBtn.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            AddOrEditMapRuleOfSrxDialog dialog = new AddOrEditMapRuleOfSrxDialog(getShell(), true, mapRulesList, handler, srxLocation);
            int result = dialog.open();
            if (result == IDialogConstants.OK_ID) {
                refreshTable(dialog.getCurMapRuleBean());
            }
        }
    });
    editBtn.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            editMapRule();
        }
    });
    deleteBtn.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            ISelection selection = tableViewer.getSelection();
            if (!selection.isEmpty() && selection != null && selection instanceof StructuredSelection) {
                boolean respose = MessageDialog.openConfirm(getShell(), Messages.getString("srx.SrxMapRulesManageDialog.msgTitle"), Messages.getString("srx.SrxMapRulesManageDialog.msg1"));
                if (!respose) {
                    return;
                }
                StructuredSelection structSelection = (StructuredSelection) selection;
                @SuppressWarnings("unchecked") Iterator<MapRuleBean> it = structSelection.iterator();
                while (it.hasNext()) {
                    mapRulesList.remove(it.next());
                }
                refreshTable(null);
            } else {
                MessageDialog.openInformation(getShell(), Messages.getString("srx.SrxMapRulesManageDialog.msgTitle2"), Messages.getString("srx.SrxMapRulesManageDialog.msg2"));
            }
        }
    });
}
Also used : SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) SelectionEvent(org.eclipse.swt.events.SelectionEvent) ISelection(org.eclipse.jface.viewers.ISelection) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) Iterator(java.util.Iterator)

Aggregations

ISelection (org.eclipse.jface.viewers.ISelection)951 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)595 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)173 IWorkbenchWindow (org.eclipse.ui.IWorkbenchWindow)113 ArrayList (java.util.ArrayList)102 IWorkbenchPart (org.eclipse.ui.IWorkbenchPart)101 IResource (org.eclipse.core.resources.IResource)89 ISelectionChangedListener (org.eclipse.jface.viewers.ISelectionChangedListener)88 SelectionChangedEvent (org.eclipse.jface.viewers.SelectionChangedEvent)85 IFile (org.eclipse.core.resources.IFile)84 GridData (org.eclipse.swt.layout.GridData)80 Composite (org.eclipse.swt.widgets.Composite)67 PartInitException (org.eclipse.ui.PartInitException)66 ITextSelection (org.eclipse.jface.text.ITextSelection)65 IEditorPart (org.eclipse.ui.IEditorPart)65 IWorkbenchPage (org.eclipse.ui.IWorkbenchPage)65 ISelectionProvider (org.eclipse.jface.viewers.ISelectionProvider)58 SelectionEvent (org.eclipse.swt.events.SelectionEvent)57 GridLayout (org.eclipse.swt.layout.GridLayout)57 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)52