Search in sources :

Example 41 with Status

use of org.eclipse.core.runtime.Status in project translationstudio8 by heartsome.

the class WorkingSetActionProvider method setWorkingSetFilter.

private void setWorkingSetFilter(IWorkingSet workingSet, boolean firstTime) {
    ResourceWorkingSetFilter workingSetFilter = null;
    ViewerFilter[] filters = viewer.getFilters();
    for (int i = 0; i < filters.length; i++) {
        if (filters[i] instanceof ResourceWorkingSetFilter) {
            workingSetFilter = (ResourceWorkingSetFilter) filters[i];
            break;
        }
    }
    if (workingSetFilter == null) {
        if (firstTime) {
            filterService.addActiveFilterIds(new String[] { WORKING_SET_FILTER_ID });
            filterService.updateViewer();
            setWorkingSetFilter(workingSet, !FIRST_TIME);
            return;
        }
        WorkbenchNavigatorPlugin.log(//$NON-NLS-1$
        "Required filter " + WORKING_SET_FILTER_ID + //$NON-NLS-1$
        " is not present. Working set support will not function correctly.", //$NON-NLS-1$
        new Status(IStatus.ERROR, WorkbenchNavigatorPlugin.PLUGIN_ID, ""));
        return;
    }
    workingSetFilter.setWorkingSet(emptyWorkingSet ? null : workingSet);
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) Status(org.eclipse.core.runtime.Status) ViewerFilter(org.eclipse.jface.viewers.ViewerFilter) ResourceWorkingSetFilter(org.eclipse.ui.ResourceWorkingSetFilter)

Example 42 with Status

use of org.eclipse.core.runtime.Status in project translationstudio8 by heartsome.

the class XLIFFEditorImplWithNatTable method getFilesByFileEditorInput.

/**
	 * 通过 FileEditorInput 得到当前要打开的文件
	 * @param input
	 *            FileEditorInput 对象
	 * @return ;
	 * @throws CoreException
	 */
private List<File> getFilesByFileEditorInput(FileEditorInput input) throws CoreException {
    List<File> files = null;
    IFile file = (IFile) input.getAdapter(IFile.class);
    if (file == null) {
        throw new CoreException(new Status(Status.WARNING, net.heartsome.cat.ts.ui.xliffeditor.nattable.Activator.PLUGIN_ID, Messages.getString("editor.XLIFFEditorImplWithNatTable.msg5")));
    } else {
        if ("xlp".equals(file.getFileExtension()) && ".TEMP".equals(file.getParent().getName())) {
            List<String> multiFiles = new XLFHandler().getMultiFiles(file);
            files = new ArrayList<File>();
            File mergerFile;
            for (String multiFileLC : multiFiles) {
                if (CommonFunction.validXlfExtensionByFileName(multiFileLC)) {
                    mergerFile = new File(multiFileLC);
                    files.add(mergerFile);
                }
            }
        } else {
            files = Arrays.asList(new File(input.getURI()));
        }
    }
    return files;
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) Status(org.eclipse.core.runtime.Status) IFile(org.eclipse.core.resources.IFile) CoreException(org.eclipse.core.runtime.CoreException) IFile(org.eclipse.core.resources.IFile) File(java.io.File) XLFHandler(net.heartsome.cat.ts.core.file.XLFHandler)

Example 43 with Status

use of org.eclipse.core.runtime.Status in project azure-tools-for-java by Microsoft.

the class SignInDialog method createDialogArea.

/**
     * Create contents of the dialog.
     * @param parent
     */
@Override
protected Control createDialogArea(Composite parent) {
    setTitle("Azure Sign In");
    Composite area = (Composite) super.createDialogArea(parent);
    Composite container = new Composite(area, SWT.NONE);
    container.setLayout(new FillLayout(SWT.HORIZONTAL));
    container.setLayoutData(new GridData(GridData.FILL_BOTH));
    Composite composite = new Composite(container, SWT.NONE);
    composite.setLayout(new GridLayout(1, false));
    Group group = new Group(composite, SWT.NONE);
    group.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
    group.setText("Authentication Method");
    group.setLayout(new GridLayout(1, false));
    rbtnInteractive = new Button(group, SWT.RADIO);
    rbtnInteractive.setSelection(true);
    rbtnInteractive.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            enableAutomatedAuthControls(false);
        }
    });
    rbtnInteractive.setText("Interactive");
    Composite compositeInteractive = new Composite(group, SWT.NONE);
    GridData gd_compositeInteractive = new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1);
    gd_compositeInteractive.heightHint = 38;
    gd_compositeInteractive.widthHint = 66;
    compositeInteractive.setLayoutData(gd_compositeInteractive);
    compositeInteractive.setLayout(new GridLayout(1, false));
    lblInteractiveInfo = new Label(compositeInteractive, SWT.WRAP);
    GridData gd_lblInteractiveInfo = new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1);
    gd_lblInteractiveInfo.horizontalIndent = 11;
    lblInteractiveInfo.setLayoutData(gd_lblInteractiveInfo);
    lblInteractiveInfo.setText("You will manually sign in using your Azure credentials as needed.");
    rbtnAutomated = new Button(group, SWT.RADIO);
    rbtnAutomated.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            enableAutomatedAuthControls(true);
        }
    });
    rbtnAutomated.setText("Automated");
    Composite compositeAutomated = new Composite(group, SWT.NONE);
    compositeAutomated.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
    compositeAutomated.setLayout(new GridLayout(2, false));
    lblAutomatedInfo = new Label(compositeAutomated, SWT.WRAP | SWT.HORIZONTAL);
    lblAutomatedInfo.setEnabled(false);
    GridData gd_lblAutomatedInfo = new GridData(SWT.FILL, SWT.CENTER, true, false, 2, 1);
    gd_lblAutomatedInfo.widthHint = 483;
    gd_lblAutomatedInfo.horizontalIndent = 11;
    gd_lblAutomatedInfo.heightHint = 49;
    lblAutomatedInfo.setLayoutData(gd_lblAutomatedInfo);
    lblAutomatedInfo.setText("An authentication file with credentials for an Azure Active Directory service principal will be used for automated sign ins.");
    lblAuthenticationFile = new Label(compositeAutomated, SWT.NONE);
    lblAuthenticationFile.setEnabled(false);
    GridData gd_lblAuthenticationFile = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1);
    gd_lblAuthenticationFile.horizontalIndent = 10;
    lblAuthenticationFile.setLayoutData(gd_lblAuthenticationFile);
    lblAuthenticationFile.setText("Authentication file:");
    new Label(compositeAutomated, SWT.NONE);
    textAuthenticationFilePath = new Text(compositeAutomated, SWT.BORDER | SWT.READ_ONLY);
    textAuthenticationFilePath.setEnabled(false);
    GridData gd_textAuthenticationFilePath = new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1);
    gd_textAuthenticationFilePath.horizontalIndent = 10;
    textAuthenticationFilePath.setLayoutData(gd_textAuthenticationFilePath);
    btnBrowse = new Button(compositeAutomated, SWT.NONE);
    btnBrowse.setEnabled(false);
    btnBrowse.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            doSelectCredFilepath();
        }
    });
    btnBrowse.setText("Browse...");
    new Label(compositeAutomated, SWT.NONE);
    btnCreateAuthenticationFile = new Button(compositeAutomated, SWT.NONE);
    btnCreateAuthenticationFile.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            doCreateServicePrincipal();
        }
    });
    btnCreateAuthenticationFile.setEnabled(false);
    btnCreateAuthenticationFile.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
    btnCreateAuthenticationFile.setText("New...");
    link = new Link(compositeAutomated, SWT.NONE);
    link.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            try {
                PlatformUI.getWorkbench().getBrowserSupport().getExternalBrowser().openURL(new URL("https://go.microsoft.com/fwlink/?linkid=847862"));
            } catch (PartInitException | MalformedURLException ex) {
                LOG.log(new Status(IStatus.ERROR, Activator.PLUGIN_ID, "widgetSelected@SelectionAdapter@link@SignInDialog", ex));
            }
        }
    });
    GridData gd_link = new GridData(SWT.FILL, SWT.FILL, false, false, 2, 1);
    gd_link.widthHint = 312;
    link.setLayoutData(gd_link);
    link.setText("Follow these manual <a>steps</a> if Azure Toolkit fails to create an authentication file programmatically.");
    fileDialog = new FileDialog(btnBrowse.getShell(), SWT.OPEN);
    fileDialog.setText("Select Authentication File");
    fileDialog.setFilterPath(System.getProperty("user.home"));
    fileDialog.setFilterExtensions(new String[] { "*.azureauth", "*.*" });
    return area;
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) Status(org.eclipse.core.runtime.Status) Group(org.eclipse.swt.widgets.Group) Composite(org.eclipse.swt.widgets.Composite) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Label(org.eclipse.swt.widgets.Label) Text(org.eclipse.swt.widgets.Text) FillLayout(org.eclipse.swt.layout.FillLayout) URL(java.net.URL) GridLayout(org.eclipse.swt.layout.GridLayout) Button(org.eclipse.swt.widgets.Button) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) FileDialog(org.eclipse.swt.widgets.FileDialog) Link(org.eclipse.swt.widgets.Link)

Example 44 with Status

use of org.eclipse.core.runtime.Status in project azure-tools-for-java by Microsoft.

the class SubscriptionsDialog method okPressed.

@Override
public void okPressed() {
    TableItem[] tia = table.getItems();
    int chekedCount = 0;
    for (TableItem ti : tia) {
        if (ti.getChecked()) {
            chekedCount++;
        }
    }
    if (chekedCount == 0) {
        this.setErrorMessage("Select at least one subscription");
        return;
    }
    for (int i = 0; i < tia.length; ++i) {
        this.sdl.get(i).setSelected(tia[i].getChecked());
    }
    try {
        subscriptionManager.setSubscriptionDetails(sdl);
    } catch (Exception ex) {
        ex.printStackTrace();
        LOG.log(new Status(IStatus.ERROR, Activator.PLUGIN_ID, "okPressed@SubscriptionDialog", ex));
    }
    super.okPressed();
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) Status(org.eclipse.core.runtime.Status) TableItem(org.eclipse.swt.widgets.TableItem) IOException(java.io.IOException) InvocationTargetException(java.lang.reflect.InvocationTargetException)

Example 45 with Status

use of org.eclipse.core.runtime.Status in project azure-tools-for-java by Microsoft.

the class SubscriptionsDialog method setSubscriptionDetails.

private void setSubscriptionDetails() {
    try {
        sdl = subscriptionManager.getSubscriptionDetails();
        for (SubscriptionDetail sd : sdl) {
            TableItem item = new TableItem(table, SWT.NULL);
            item.setText(new String[] { sd.getSubscriptionName(), sd.getSubscriptionId() });
            item.setChecked(sd.isSelected());
        }
    } catch (IOException ex) {
        ex.printStackTrace();
        LOG.log(new Status(IStatus.ERROR, Activator.PLUGIN_ID, "setSubscriptionDetails@SubscriptionDialog", ex));
    }
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) Status(org.eclipse.core.runtime.Status) TableItem(org.eclipse.swt.widgets.TableItem) SubscriptionDetail(com.microsoft.azuretools.authmanage.models.SubscriptionDetail) IOException(java.io.IOException)

Aggregations

Status (org.eclipse.core.runtime.Status)305 IStatus (org.eclipse.core.runtime.IStatus)282 CoreException (org.eclipse.core.runtime.CoreException)132 IOException (java.io.IOException)66 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)64 InvocationTargetException (java.lang.reflect.InvocationTargetException)40 File (java.io.File)38 ArrayList (java.util.ArrayList)37 IFile (org.eclipse.core.resources.IFile)37 MultiStatus (org.eclipse.core.runtime.MultiStatus)30 IResource (org.eclipse.core.resources.IResource)27 IRunnableWithProgress (org.eclipse.jface.operation.IRunnableWithProgress)26 IProject (org.eclipse.core.resources.IProject)24 IPath (org.eclipse.core.runtime.IPath)24 ITask (com.cubrid.common.core.task.ITask)23 PartInitException (org.eclipse.ui.PartInitException)23 InputStream (java.io.InputStream)18 GridData (org.eclipse.swt.layout.GridData)17 GridLayout (org.eclipse.swt.layout.GridLayout)17 Composite (org.eclipse.swt.widgets.Composite)16