Search in sources :

Example 1 with License

use of com.android.repository.api.License in project android by JetBrains.

the class LicenseAgreementStep method createCellRenderer.

private ColoredTreeCellRenderer createCellRenderer() {
    return new ColoredTreeCellRenderer() {

        @Override
        public void customizeCellRenderer(@NotNull JTree tree, Object value, boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus) {
            if (row == 0) {
                append("Licenses", SimpleTextAttributes.REGULAR_ATTRIBUTES);
                return;
            }
            DefaultMutableTreeNode node = (DefaultMutableTreeNode) value;
            if (!leaf) {
                License license = (License) node.getUserObject();
                appendLicenseText(license, license.getId());
            } else {
                Change change = (Change) node.getUserObject();
                if (change == null) {
                    return;
                }
                appendLicenseText(change.license, change.toString());
                setIcon(AllIcons.Actions.Download);
            }
        }

        private void appendLicenseText(@Nullable License license, String text) {
            boolean notAccepted = license != null && !myAcceptances.get(license.getId());
            if (notAccepted) {
                append("*", SimpleTextAttributes.ERROR_ATTRIBUTES);
                append(text, SimpleTextAttributes.REGULAR_BOLD_ATTRIBUTES);
            } else {
                append(text, SimpleTextAttributes.REGULAR_ATTRIBUTES);
            }
        }
    };
}
Also used : ColoredTreeCellRenderer(com.intellij.ui.ColoredTreeCellRenderer) DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode) License(com.android.repository.api.License) NotNull(org.jetbrains.annotations.NotNull) Nullable(org.jetbrains.annotations.Nullable)

Example 2 with License

use of com.android.repository.api.License in project android by JetBrains.

the class LicenseAgreementStep method createTreeSelectionListener.

private TreeSelectionListener createTreeSelectionListener() {
    return new TreeSelectionListener() {

        @Override
        public void valueChanged(TreeSelectionEvent e) {
            DefaultMutableTreeNode selected = (DefaultMutableTreeNode) myChangeTree.getLastSelectedPathComponent();
            if (selected != null && selected.isRoot()) {
                return;
            }
            if (selected != null && !selected.isLeaf()) {
                License license = (License) selected.getUserObject();
                myLicenseTextField.setText(license.getValue());
                myCurrentLicense = license.getId();
            } else if (selected != null && !selected.isRoot()) {
                Change change = (Change) selected.getUserObject();
                myLicenseTextField.setText(change.license.getValue());
                myCurrentLicense = change.license.getId();
            }
            if (myAcceptances.get(myCurrentLicense)) {
                myAcceptRadioButton.setSelected(true);
            } else {
                myDeclineRadioButton.setSelected(true);
            }
            myLicenseTextField.setCaretPosition(0);
        }
    };
}
Also used : DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode) License(com.android.repository.api.License) TreeSelectionListener(javax.swing.event.TreeSelectionListener) TreeSelectionEvent(javax.swing.event.TreeSelectionEvent)

Example 3 with License

use of com.android.repository.api.License in project android by JetBrains.

the class AndroidSdkLicenseTemporaryData method getLicense.

public static License getLicense(boolean preview) {
    CommonFactory f = RepoManager.getCommonModule().createLatestFactory();
    License l = f.createLicenseType();
    l.setValue(preview ? HARDCODED_ANDROID_PREVIEW_SDK_LICENSE : HARDCODED_ANDROID_SDK_LICENSE);
    l.setId(preview ? "Android SDK Preview License" : "Android SDK License");
    return l;
}
Also used : CommonFactory(com.android.repository.impl.meta.CommonFactory) License(com.android.repository.api.License)

Aggregations

License (com.android.repository.api.License)3 DefaultMutableTreeNode (javax.swing.tree.DefaultMutableTreeNode)2 CommonFactory (com.android.repository.impl.meta.CommonFactory)1 ColoredTreeCellRenderer (com.intellij.ui.ColoredTreeCellRenderer)1 TreeSelectionEvent (javax.swing.event.TreeSelectionEvent)1 TreeSelectionListener (javax.swing.event.TreeSelectionListener)1 NotNull (org.jetbrains.annotations.NotNull)1 Nullable (org.jetbrains.annotations.Nullable)1